Correcting style

pull/2/head
Michael Scoff 7 years ago
parent 09d4deb6d5
commit 82b4ac8aee
  1. 15
      Trust/Browser/ViewControllers/BrowserViewController.swift
  2. 1
      Trust/Exchange/Coordinators/ExchangeCoordinator.swift
  3. 1
      Trust/Transactions/Coordinators/TransactionDataCoordinator.swift
  4. 2
      Trust/Transactions/ViewControllers/TransactionsViewController.swift
  5. 2
      Trust/Transfer/Types/TransferType.swift
  6. 2
      Trust/Transfer/ViewControllers/ConfirmPaymentViewController.swift
  7. 26
      Trust/Transfer/ViewControllers/SendViewController.swift
  8. 2
      Trust/Transfer/ViewModels/SendViewModel.swift
  9. 2
      Trust/Wallet/ViewControllers/PassphraseViewController.swift

@ -86,12 +86,12 @@ class BrowserViewController: UIViewController {
"""
let web3 = new Web3(new Web3.providers.HttpProvider("\(session.config.rpcURL.absoluteString)"));
web3.eth.defaultAccount = "\(session.account.address.address)"
web3.eth.accounts = function(message, callback) {
console.log("account asked for!!!")
return ["\(session.account.address.address)"]
}
var callback_;
web3.eth.sendTransaction = function(message, callback) {
console.log(message);
@ -100,18 +100,17 @@ class BrowserViewController: UIViewController {
callback_ = callback;
}
"""
// web3.eth.sign = function(message, callback){
// console.log("hooooray");
// runCommand("sign", {"message": message})
// }
// web3.eth.signTransaction = function(tx, callback) {
// console.log("testing");
// runCommand("signTransaction", tx)
// }
let userScript = WKUserScript(source: js, injectionTime: .atDocumentStart, forMainFrameOnly: false)
config.userContentController.add(self, name: "sendTransaction")
config.userContentController.add(self, name: "command")
@ -146,7 +145,7 @@ class BrowserViewController: UIViewController {
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func notifyFinish(transaction: SentTransaction) {
let evString = "callback_(null, \(transaction.id))"
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
@ -166,11 +165,11 @@ extension BrowserViewController: WKScriptMessageHandler {
if message.name == "sendTransaction" {
guard let body = message.body as? [String: AnyObject],
let jsonString = body.jsonString else { return }
let command = try! decoder.decode(DappCommand.self, from: jsonString.data(using: .utf8)!)
let action = DappAction.fromCommand(command)
delegate?.didCall(action: action)
return
}

@ -69,4 +69,3 @@ class ExchangeCoordinator: Coordinator {
// navigationController.displaySuccess(title: "Exchanged completed. Transaction ID: (\(transaction.id)")
// }
//}

@ -84,7 +84,6 @@ class TransactionDataCoordinator {
func fetchPendingTransactions() {
// TODO: Handle pending transactions
}
@objc func fetchPending() {

@ -55,7 +55,7 @@ class TransactionsViewController: UIViewController {
self.viewModel = viewModel
self.tokensStorage = tokensStorage
super.init(nibName: nil, bundle: nil)
tokensStorage.updatePrices()
view.backgroundColor = viewModel.backgroundColor
tableView.translatesAutoresizingMaskIntoConstraints = false

@ -19,7 +19,7 @@ extension TransferType {
case .exchange: return "--"
}
}
func contract() -> String {
switch self {
case .ether:

@ -53,7 +53,7 @@ class ConfirmPaymentViewController: UIViewController {
self.displayError(error: error)
}
}
configurator.configurationUpdate.subscribe { [weak self] configurator in
configurator.configurationUpdate.subscribe { [weak self] _ in
guard let `self` = self else { return }
self.reloadView()
}

@ -30,16 +30,16 @@ class SendViewController: FormViewController {
static let address = "address"
static let amount = "amount"
}
struct Pair {
let left: String
let right: String
func swapPair() -> Pair {
return Pair(left: right, right: left)
}
}
var pairValue = 0.0
let session: WalletSession
let account: Account
@ -55,7 +55,7 @@ class SendViewController: FormViewController {
private var gasPrice: BigInt?
private var data = Data()
lazy var currentPair: Pair = {
return Pair(left: viewModel.symbol, right: Config().currency.rawValue)
}()
@ -72,10 +72,10 @@ class SendViewController: FormViewController {
self.storage = storage
super.init(nibName: nil, bundle: nil)
storage.updatePrices()
getGasPrice()
title = viewModel.title
view.backgroundColor = viewModel.backgroundColor
@ -104,17 +104,17 @@ class SendViewController: FormViewController {
maxButton.translatesAutoresizingMaskIntoConstraints = false
maxButton.setTitle(NSLocalizedString("send.max.button.title", value: "Max", comment: ""), for: .normal)
maxButton.addTarget(self, action: #selector(useMaxAmount), for: .touchUpInside)
let fiatButton = Button(size: .normal, style: .borderless)
fiatButton.translatesAutoresizingMaskIntoConstraints = false
fiatButton.setTitle(currentPair.right, for: .normal)
fiatButton.addTarget(self, action: #selector(fiatAction), for: .touchUpInside)
fiatButton.isHidden = isFiatViewHidden()
let amountRightView = UIStackView(arrangedSubviews: [
fiatButton,
])
amountRightView.translatesAutoresizingMaskIntoConstraints = false
amountRightView.distribution = .equalSpacing
amountRightView.spacing = 1
@ -230,7 +230,7 @@ class SendViewController: FormViewController {
amountRow?.value = value
amountRow?.reload()
}
@objc func fiatAction(sender: UIButton) {
let swappedPair = currentPair.swapPair()
//New pair for future calculation we should swap pair each time we press fiat button.
@ -255,7 +255,7 @@ class SendViewController: FormViewController {
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func updatePriceSection() {
//We use this section update to prevent update of the all section including cells.
UIView.setAnimationsEnabled(false)
@ -267,7 +267,7 @@ class SendViewController: FormViewController {
tableView.endUpdates()
UIView.setAnimationsEnabled(true)
}
private func updatePairPrice(with amount: Double) {
guard let rates = storage.tickers, let currentTokenInfo = rates[viewModel.contract], let price = Double(currentTokenInfo.price) else {
return
@ -279,7 +279,7 @@ class SendViewController: FormViewController {
}
self.updatePriceSection()
}
private func isFiatViewHidden() -> Bool {
guard let rates = storage.tickers, let currentTokenInfo = rates[viewModel.contract], let _ = Double(currentTokenInfo.price) else {
return true

@ -23,7 +23,7 @@ struct SendViewModel {
var symbol: String {
return transferType.symbol(server: config.server)
}
var contract: String {
return transferType.contract()
}

@ -7,7 +7,7 @@ class PassphraseViewController: UIViewController {
let passphraseView = PassphraseView(frame: .zero)
let viewModel = PassphraseViewModel()
init(words: [String]) {
super.init(nibName: nil, bundle: nil)

Loading…
Cancel
Save