Merge pull request #3967 from oa-s/#3966

Remove `nativeCryptoCurrencyPrices ` dependency from `TokensCoordinator` #3966
pull/3969/head
Crypto Pank 3 years ago committed by GitHub
commit f4c85585a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      AlphaWallet/InCoordinator.swift
  2. 15
      AlphaWallet/Sell/ViewControllers/EnterSellTokensCardPriceQuantityViewController.swift
  3. 3
      AlphaWallet/Tokens/Collectibles/Coordinators/TokensCardCollectionCoordinator.swift
  4. 5
      AlphaWallet/Tokens/Coordinators/SingleChainTokenCoordinator.swift
  5. 6
      AlphaWallet/Tokens/Coordinators/TokensCoordinator.swift
  6. 5
      AlphaWallet/Transactions/Coordinators/TokensCardCoordinator.swift
  7. 1
      AlphaWalletTests/Coordinators/TokensCoordinatorTests.swift
  8. 2
      AlphaWalletTests/Settings/ConfigTests.swift

@ -411,7 +411,6 @@ class InCoordinator: NSObject, Coordinator {
keystore: keystore,
config: config,
tokenCollection: tokenCollection,
nativeCryptoCurrencyPrices: nativeCryptoCurrencyPrices,
assetDefinitionStore: assetDefinitionStore,
eventsDataStore: eventsDataStore,
promptBackupCoordinator: promptBackupCoordinator,

@ -24,7 +24,6 @@ class EnterSellTokensCardPriceQuantityViewController: UIViewController, TokenVer
private let tokenRowView: TokenRowView & UIView
private let buttonsBar = ButtonsBar(configuration: .primary(buttons: 1))
private var viewModel: EnterSellTokensCardPriceQuantityViewControllerViewModel
private let ethPrice: Subscribable<Double>
private var totalEthCost: Ether {
if let ethCostPerToken = Ether(string: pricePerTokenField.ethCost) {
let quantity = Int(quantityStepper.value)
@ -54,20 +53,20 @@ class EnterSellTokensCardPriceQuantityViewController: UIViewController, TokenVer
lazy var pricePerTokenField = AmountTextField(tokenObject: viewModel.ethToken)
let paymentFlow: PaymentFlow
weak var delegate: EnterSellTokensCardPriceQuantityViewControllerDelegate?
private let walletSession: WalletSession
// swiftlint:disable function_body_length
init(
analyticsCoordinator: AnalyticsCoordinator,
storage: TokensDataStore,
paymentFlow: PaymentFlow,
cryptoPrice: Subscribable<Double>,
viewModel: EnterSellTokensCardPriceQuantityViewControllerViewModel,
assetDefinitionStore: AssetDefinitionStore
assetDefinitionStore: AssetDefinitionStore,
walletSession: WalletSession
) {
self.analyticsCoordinator = analyticsCoordinator
self.storage = storage
self.paymentFlow = paymentFlow
self.ethPrice = cryptoPrice
self.walletSession = walletSession
self.viewModel = viewModel
self.assetDefinitionStore = assetDefinitionStore
@ -98,9 +97,9 @@ class EnterSellTokensCardPriceQuantityViewController: UIViewController, TokenVer
dollarCostLabelLabel.translatesAutoresizingMaskIntoConstraints = false
dollarCostLabel.translatesAutoresizingMaskIntoConstraints = false
pricePerTokenField.translatesAutoresizingMaskIntoConstraints = false
cryptoPrice.subscribe { [weak self] value in
if let value = value {
self?.pricePerTokenField.cryptoToDollarRate = NSDecimalNumber(value: value)
walletSession.balanceCoordinator.subscribableEthBalanceViewModel.subscribe { [weak self] value in
if let value = value?.ticker.flatMap({ NSDecimalNumber(value: $0.price_usd) }) {
self?.pricePerTokenField.cryptoToDollarRate = value
}
}
pricePerTokenField.delegate = self

@ -28,7 +28,6 @@ class TokensCardCollectionCoordinator: NSObject, Coordinator {
private let session: WalletSession
private let tokensStorage: TokensDataStore
private (set) var ethPrice: Subscribable<Double>
private let assetDefinitionStore: AssetDefinitionStore
private let eventsDataStore: EventsDataStoreProtocol
private let transactionsStorage: TransactionsStorage
@ -44,7 +43,6 @@ class TokensCardCollectionCoordinator: NSObject, Coordinator {
navigationController: UINavigationController,
keystore: Keystore,
tokensStorage: TokensDataStore,
ethPrice: Subscribable<Double>,
token: TokenObject,
assetDefinitionStore: AssetDefinitionStore,
eventsDataStore: EventsDataStoreProtocol,
@ -58,7 +56,6 @@ class TokensCardCollectionCoordinator: NSObject, Coordinator {
self.keystore = keystore
self.navigationController = navigationController
self.tokensStorage = tokensStorage
self.ethPrice = ethPrice
self.token = token
self.assetDefinitionStore = assetDefinitionStore
self.eventsDataStore = eventsDataStore

@ -29,7 +29,6 @@ protocol SingleChainTokenCoordinatorDelegate: CanOpenURL, SendTransactionDelegat
class SingleChainTokenCoordinator: Coordinator {
private let keystore: Keystore
private let storage: TokensDataStore
private let ethPrice: Subscribable<Double>
private let assetDefinitionStore: AssetDefinitionStore
private let eventsDataStore: EventsDataStoreProtocol
private let analyticsCoordinator: AnalyticsCoordinator
@ -54,7 +53,6 @@ class SingleChainTokenCoordinator: Coordinator {
session: WalletSession,
keystore: Keystore,
tokensStorage: TokensDataStore,
ethPrice: Subscribable<Double>,
assetDefinitionStore: AssetDefinitionStore,
eventsDataStore: EventsDataStoreProtocol,
analyticsCoordinator: AnalyticsCoordinator,
@ -69,7 +67,6 @@ class SingleChainTokenCoordinator: Coordinator {
self.session = session
self.keystore = keystore
self.storage = tokensStorage
self.ethPrice = ethPrice
self.assetDefinitionStore = assetDefinitionStore
self.eventsDataStore = eventsDataStore
self.analyticsCoordinator = analyticsCoordinator
@ -427,7 +424,6 @@ class SingleChainTokenCoordinator: Coordinator {
navigationController: navigationController,
keystore: keystore,
tokensStorage: storage,
ethPrice: ethPrice,
token: token,
assetDefinitionStore: assetDefinitionStore,
eventsDataStore: eventsDataStore,
@ -453,7 +449,6 @@ class SingleChainTokenCoordinator: Coordinator {
navigationController: navigationController,
keystore: keystore,
tokensStorage: storage,
ethPrice: ethPrice,
token: token,
assetDefinitionStore: assetDefinitionStore,
eventsDataStore: eventsDataStore,

@ -28,7 +28,6 @@ class TokensCoordinator: Coordinator {
private let keystore: Keystore
private let config: Config
private let tokenCollection: TokenCollection
private let nativeCryptoCurrencyPrices: ServerDictionary<Subscribable<Double>>
private let assetDefinitionStore: AssetDefinitionStore
private let eventsDataStore: EventsDataStoreProtocol
private let promptBackupCoordinator: PromptBackupCoordinator
@ -101,7 +100,6 @@ class TokensCoordinator: Coordinator {
keystore: Keystore,
config: Config,
tokenCollection: TokenCollection,
nativeCryptoCurrencyPrices: ServerDictionary<Subscribable<Double>>,
assetDefinitionStore: AssetDefinitionStore,
eventsDataStore: EventsDataStoreProtocol,
promptBackupCoordinator: PromptBackupCoordinator,
@ -120,7 +118,6 @@ class TokensCoordinator: Coordinator {
self.keystore = keystore
self.config = config
self.tokenCollection = tokenCollection
self.nativeCryptoCurrencyPrices = nativeCryptoCurrencyPrices
self.assetDefinitionStore = assetDefinitionStore
self.eventsDataStore = eventsDataStore
self.promptBackupCoordinator = promptBackupCoordinator
@ -179,9 +176,8 @@ class TokensCoordinator: Coordinator {
for each in tokenCollection.tokenDataStores {
let server = each.server
let session = sessions[server]
let price = nativeCryptoCurrencyPrices[server]
let transactionsStorage = transactionsStorages[server]
let coordinator = SingleChainTokenCoordinator(session: session, keystore: keystore, tokensStorage: each, ethPrice: price, assetDefinitionStore: assetDefinitionStore, eventsDataStore: eventsDataStore, analyticsCoordinator: analyticsCoordinator, withAutoDetectTransactedTokensQueue: autoDetectTransactedTokensQueue, withAutoDetectTokensQueue: autoDetectTokensQueue, tokenActionsProvider: tokenActionsService, transactionsStorage: transactionsStorage, coinTickersFetcher: coinTickersFetcher, activitiesService: activitiesService, alertService: alertService)
let coordinator = SingleChainTokenCoordinator(session: session, keystore: keystore, tokensStorage: each, assetDefinitionStore: assetDefinitionStore, eventsDataStore: eventsDataStore, analyticsCoordinator: analyticsCoordinator, withAutoDetectTransactedTokensQueue: autoDetectTransactedTokensQueue, withAutoDetectTokensQueue: autoDetectTokensQueue, tokenActionsProvider: tokenActionsService, transactionsStorage: transactionsStorage, coinTickersFetcher: coinTickersFetcher, activitiesService: activitiesService, alertService: alertService)
coordinator.delegate = self
addCoordinator(coordinator)
}

@ -29,7 +29,6 @@ class TokensCardCoordinator: NSObject, Coordinator {
private let session: WalletSession
private let tokensDataStore: TokensDataStore
private let ethPrice: Subscribable<Double>
private let assetDefinitionStore: AssetDefinitionStore
private let eventsDataStore: EventsDataStoreProtocol
private weak var transferTokensViewController: TransferTokensCardViaWalletAddressViewController?
@ -44,7 +43,6 @@ class TokensCardCoordinator: NSObject, Coordinator {
navigationController: UINavigationController,
keystore: Keystore,
tokensStorage: TokensDataStore,
ethPrice: Subscribable<Double>,
token: TokenObject,
assetDefinitionStore: AssetDefinitionStore,
eventsDataStore: EventsDataStoreProtocol,
@ -56,7 +54,6 @@ class TokensCardCoordinator: NSObject, Coordinator {
self.keystore = keystore
self.navigationController = navigationController
self.tokensDataStore = tokensStorage
self.ethPrice = ethPrice
self.token = token
self.assetDefinitionStore = assetDefinitionStore
self.eventsDataStore = eventsDataStore
@ -233,7 +230,7 @@ class TokensCardCoordinator: NSObject, Coordinator {
private func makeEnterSellTokensCardPriceQuantityViewController(token: TokenObject, for tokenHolder: TokenHolder, paymentFlow: PaymentFlow) -> EnterSellTokensCardPriceQuantityViewController {
let viewModel = EnterSellTokensCardPriceQuantityViewControllerViewModel(token: token, tokenHolder: tokenHolder, server: session.server, assetDefinitionStore: assetDefinitionStore)
let controller = EnterSellTokensCardPriceQuantityViewController(analyticsCoordinator: analyticsCoordinator, storage: tokensDataStore, paymentFlow: paymentFlow, cryptoPrice: ethPrice, viewModel: viewModel, assetDefinitionStore: assetDefinitionStore)
let controller = EnterSellTokensCardPriceQuantityViewController(analyticsCoordinator: analyticsCoordinator, storage: tokensDataStore, paymentFlow: paymentFlow, viewModel: viewModel, assetDefinitionStore: assetDefinitionStore, walletSession: session)
controller.configure()
controller.delegate = self
return controller

@ -34,7 +34,6 @@ class TokensCoordinatorTests: XCTestCase {
keystore: FakeKeystore(),
config: config,
tokenCollection: .init(filterTokensCoordinator: FilterTokensCoordinator(assetDefinitionStore: assetDefinitionStore, tokenActionsService: tokenActionsService, coinTickersFetcher: FakeCoinTickersFetcher()), tokenDataStores: []),
nativeCryptoCurrencyPrices: .init(),
assetDefinitionStore: AssetDefinitionStore(),
eventsDataStore: FakeEventsDataStore(),
promptBackupCoordinator: PromptBackupCoordinator(keystore: FakeKeystore(), wallet: .make(), config: config, analyticsCoordinator: FakeAnalyticsService()),

@ -38,7 +38,6 @@ class ConfigTests: XCTestCase {
keystore: FakeKeystore(),
config: config,
tokenCollection: .init(filterTokensCoordinator: FilterTokensCoordinator(assetDefinitionStore: assetDefinitionStore, tokenActionsService: tokenActionsService, coinTickersFetcher: FakeCoinTickersFetcher()), tokenDataStores: []),
nativeCryptoCurrencyPrices: .init(),
assetDefinitionStore: AssetDefinitionStore(),
eventsDataStore: FakeEventsDataStore(),
promptBackupCoordinator: PromptBackupCoordinator(keystore: FakeKeystore(), wallet: .make(), config: config, analyticsCoordinator: FakeAnalyticsService()),
@ -64,7 +63,6 @@ class ConfigTests: XCTestCase {
keystore: FakeKeystore(),
config: config,
tokenCollection: .init(filterTokensCoordinator: FilterTokensCoordinator(assetDefinitionStore: assetDefinitionStore, tokenActionsService: tokenActionsService, coinTickersFetcher: FakeCoinTickersFetcher()), tokenDataStores: []),
nativeCryptoCurrencyPrices: .init(),
assetDefinitionStore: AssetDefinitionStore(),
eventsDataStore: FakeEventsDataStore(),
promptBackupCoordinator: PromptBackupCoordinator(keystore: FakeKeystore(), wallet: .make(), config: config, analyticsCoordinator: FakeAnalyticsService()),

Loading…
Cancel
Save