Skip to content

Commit

Permalink
Issues/180 (trustwallet#201)
Browse files Browse the repository at this point in the history
* Add pair to send view controller.

* Add TokensDataStore dependansy to the view controllers.

* Show actual price of the toke.

* Update condition for section update.

* Send proper amount in tokens to the transaction.

* Reset field value on pair change.

* Update of the appearence.

* Update of the footer view

* Update of the section.

* Clear code from section variable.

* Hide section footer and fiat button if we do not have price.

* Update prices on transaction view controller.

* Fix for Unit tests.

* Update of the send view controller.

* Fix test that should be off.
  • Loading branch information
OlegGordiichuk authored and Michael Scoff committed Jan 9, 2018
1 parent 06ed371 commit 2769013
Show file tree
Hide file tree
Showing 12 changed files with 208 additions and 50 deletions.
14 changes: 7 additions & 7 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ PODS:
- Result (~> 3.0)
- KeychainSwift (10.0.0)
- Kingfisher (4.6.1)
- Lokalise (0.8.0)
- Lokalise (0.8.1)
- MBProgressHUD (1.1.0)
- Moya (10.0.1):
- Moya/Core (= 10.0.1)
Expand All @@ -34,12 +34,12 @@ PODS:
- RealmSwift (3.0.2):
- Realm (= 3.0.2)
- Result (3.2.4)
- secp256k1_ios (0.0.7)
- secp256k1_ios (0.0.9)
- SeedStackViewController (0.4.0)
- SipHash (1.2.0)
- SSKeychain (1.4.1)
- StatefulViewController (3.0)
- SwiftLint (0.24.0)
- SwiftLint (0.24.1)
- TrustKeystore (0.0.4):
- CryptoSwift
- secp256k1_ios (~> 0.0.7)
Expand Down Expand Up @@ -83,7 +83,7 @@ EXTERNAL SOURCES:

CHECKOUT OPTIONS:
CryptoSwift:
:commit: 289ef07b2f386d91a25b9393a96b0c3daa1d9114
:commit: 46cfb548f83b89a13ce99f452223933c31fac5ba
:git: https://github.com/krzyzanowskim/CryptoSwift
JSONRPCKit:
:commit: 50d19a4f7ec593ac5e07cffa1e11c17f1fbe347d
Expand All @@ -106,7 +106,7 @@ SPEC CHECKSUMS:
JSONRPCKit: 22132c575ba2dc6f2f4ae72fda4943a63efca686
KeychainSwift: f9f7910449a0c0fd2cabc889121530dd2c477c33
Kingfisher: 1f9157d9c02b380cbd0b7cc890161195164eb634
Lokalise: 9547ef438a2d25cfba0b4c02201d3c39b3db35fb
Lokalise: d81f4ccce8cd2c1589bf73bb39fab7781d4f7cbc
MBProgressHUD: e7baa36a220447d8aeb12769bf0585582f3866d9
Moya: 9e621707ff754eeb51ff3ec51a3d54e517c0733a
QRCodeReaderViewController: e8f27d035b3e72b1d4b1c61ff66458287e3be0ff
Expand All @@ -115,12 +115,12 @@ SPEC CHECKSUMS:
Realm: 6f23fd1f178a09342eac21bfa7c2bf4312a7a180
RealmSwift: 695393add1b8f9d5fa75dd16e6355cf3935f71e2
Result: d2d07204ce72856f1fd9130bbe42c35a7b0fea10
secp256k1_ios: 12a9bddc3d7aa723efbb32b42413f041b11a7765
secp256k1_ios: 1abf641309cd2b1ec1c5f4ca76be50623cbd57bc
SeedStackViewController: 45e88ca1493a610e74d661d3feced7098f72dbd3
SipHash: c6e9e43e9c531b5bc6602545130c26194a6d31ce
SSKeychain: 55cc80f66f5c73da827e3077f02e43528897db41
StatefulViewController: 4803bf900d44de26074344998e10e041113b5931
SwiftLint: a014c92b4664e8b13f380f8640a51bb1733778ba
SwiftLint: 2e4b89feed5909c42c3735bbd6745f4345c4b772
TrustKeystore: 2c62775c98df86b7e2ef78c059581a4e8c98a054
VENTouchLock: 20d378b9c6173e2c054448aeb3fb2f40822a9f3f

Expand Down
19 changes: 12 additions & 7 deletions Trust/InCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,13 @@ class InCoordinator: Coordinator {
account: account,
config: config
)

MigrationInitializer(account: account, chainID: config.chainID).perform()

let tokensStorage = TokensDataStore(
session: session,
configuration: RealmConfiguration.configuration(for: session.account, chainID: session.config.chainID)
)

let transactionsStorage = TransactionsStorage(
configuration: RealmConfiguration.configuration(for: account, chainID: session.config.chainID)
Expand All @@ -76,7 +82,8 @@ class InCoordinator: Coordinator {
let transactionCoordinator = TransactionCoordinator(
session: session,
storage: transactionsStorage,
keystore: keystore
keystore: keystore,
tokensStorage: tokensStorage
)
transactionCoordinator.rootViewController.tabBarItem = UITabBarItem(title: NSLocalizedString("transactions.tabbar.item.title", value: "Transactions", comment: ""), image: R.image.feed(), selectedImage: nil)
transactionCoordinator.delegate = self
Expand Down Expand Up @@ -107,10 +114,6 @@ class InCoordinator: Coordinator {
}

if inCoordinatorViewModel.tokensAvailable {
let tokensStorage = TokensDataStore(
session: session,
configuration: RealmConfiguration.configuration(for: session.account, chainID: session.config.chainID)
)
let tokenCoordinator = TokensCoordinator(
session: session,
keystore: keystore,
Expand Down Expand Up @@ -184,14 +187,16 @@ class InCoordinator: Coordinator {
func showPaymentFlow(for type: PaymentFlow) {
guard let transactionCoordinator = transactionCoordinator else { return }
let session = transactionCoordinator.session
let tokenStorage = transactionCoordinator.tokensStorage

switch session.account.type {
case .real(let account):
let coordinator = PaymentCoordinator(
flow: type,
session: session,
account: account,
keystore: keystore
keystore: keystore,
storage: tokenStorage,
account: account
)
coordinator.delegate = self
navigationController.present(coordinator.navigationController, animated: true, completion: nil)
Expand Down
6 changes: 5 additions & 1 deletion Trust/Transactions/Coordinators/TransactionCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,22 @@ class TransactionCoordinator: Coordinator {
weak var delegate: TransactionCoordinatorDelegate?

let session: WalletSession
let tokensStorage: TokensDataStore
let navigationController: UINavigationController
var coordinators: [Coordinator] = []

init(
session: WalletSession,
navigationController: UINavigationController = NavigationController(),
storage: TransactionsStorage,
keystore: Keystore
keystore: Keystore,
tokensStorage: TokensDataStore
) {
self.session = session
self.keystore = keystore
self.navigationController = navigationController
self.storage = storage
self.tokensStorage = tokensStorage

NotificationCenter.default.addObserver(self, selector: #selector(didEnterForeground), name: .UIApplicationWillEnterForeground, object: nil)
}
Expand All @@ -56,6 +59,7 @@ class TransactionCoordinator: Coordinator {
account: account,
dataCoordinator: dataCoordinator,
session: session,
tokensStorage: tokensStorage,
viewModel: viewModel
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class TransactionsViewController: UIViewController {

var viewModel: TransactionsViewModel

let tokensStorage: TokensDataStore
let account: Wallet

let tableView = UITableView(frame: .zero, style: .plain)
let refreshControl = UIRefreshControl()

Expand All @@ -44,15 +46,17 @@ class TransactionsViewController: UIViewController {
account: Wallet,
dataCoordinator: TransactionDataCoordinator,
session: WalletSession,
tokensStorage: TokensDataStore,
viewModel: TransactionsViewModel = TransactionsViewModel(transactions: [])
) {
self.account = account
self.dataCoordinator = dataCoordinator
self.session = session
self.viewModel = viewModel

self.tokensStorage = tokensStorage
super.init(nibName: nil, bundle: nil)


tokensStorage.updatePrices()
view.backgroundColor = viewModel.backgroundColor
tableView.translatesAutoresizingMaskIntoConstraints = false
tableView.delegate = self
Expand Down
12 changes: 8 additions & 4 deletions Trust/Transfer/Coordinators/PaymentCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class PaymentCoordinator: Coordinator {
var coordinators: [Coordinator] = []
let navigationController: UINavigationController
let keystore: Keystore
let storage: TokensDataStore
let account: Account

lazy var transferType: TransferType = {
Expand All @@ -32,15 +33,17 @@ class PaymentCoordinator: Coordinator {
navigationController: UINavigationController = UINavigationController(),
flow: PaymentFlow,
session: WalletSession,
account: Account,
keystore: Keystore
keystore: Keystore,
storage: TokensDataStore,
account: Account
) {
self.navigationController = navigationController
self.navigationController.modalPresentationStyle = .formSheet
self.session = session
self.account = account
self.flow = flow
self.keystore = keystore
self.storage = storage
}

func start() {
Expand All @@ -50,8 +53,9 @@ class PaymentCoordinator: Coordinator {
transferType: type,
navigationController: navigationController,
session: session,
account: account,
keystore: keystore
keystore: keystore,
storage: storage,
account: account
)
coordinator.delegate = self
coordinator.start()
Expand Down
8 changes: 6 additions & 2 deletions Trust/Transfer/Coordinators/SendCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class SendCoordinator: Coordinator {
let account: Account
let navigationController: UINavigationController
let keystore: Keystore
let storage: TokensDataStore
var coordinators: [Coordinator] = []
weak var delegate: SendCoordinatorDelegate?
lazy var sendViewController: SendViewController = {
Expand All @@ -26,15 +27,17 @@ class SendCoordinator: Coordinator {
transferType: TransferType,
navigationController: UINavigationController = UINavigationController(),
session: WalletSession,
account: Account,
keystore: Keystore
keystore: Keystore,
storage: TokensDataStore,
account: Account
) {
self.transferType = transferType
self.navigationController = navigationController
self.navigationController.modalPresentationStyle = .formSheet
self.session = session
self.account = account
self.keystore = keystore
self.storage = storage
}

func start() {
Expand All @@ -44,6 +47,7 @@ class SendCoordinator: Coordinator {
func makeSendViewController() -> SendViewController {
let controller = SendViewController(
session: session,
storage: storage,
account: account,
transferType: transferType
)
Expand Down
10 changes: 10 additions & 0 deletions Trust/Transfer/Types/TransferType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,14 @@ extension TransferType {
case .exchange: return "--"
}
}

func contract() -> String {
switch self {
case .ether:
return "0x"
case .token(let token):
return token.contract
case .exchange: return "--"
}
}
}
Loading

0 comments on commit 2769013

Please sign in to comment.