Refactor: Make analyticsCoordinator non-optional

pull/2573/head
Hwee-Boon Yar 4 years ago
parent 6ca01f4854
commit b12b3848fb
  1. 4
      AlphaWallet/Accounts/Coordinators/AccountsCoordinator.swift
  2. 4
      AlphaWallet/Browser/Coordinators/DappBrowserCoordinator.swift
  3. 12
      AlphaWallet/Browser/Coordinators/ScanQRCodeCoordinator.swift
  4. 4
      AlphaWallet/Export/Coordinators/BackupCoordinator.swift
  5. 4
      AlphaWallet/Export/Coordinators/PromptBackupCoordinator.swift
  6. 10
      AlphaWallet/InCoordinator.swift
  7. 6
      AlphaWallet/KeyManagement/EtherKeystore.swift
  8. 4
      AlphaWallet/KeyManagement/LegacyFileBasedKeystore.swift
  9. 9
      AlphaWallet/Redeem/Helpers/SignatureHelper.swift
  10. 6
      AlphaWallet/Redeem/ViewControllers/TokenCardRedemptionViewController.swift
  11. 4
      AlphaWallet/Settings/Coordinators/SettingsCoordinator.swift
  12. 4
      AlphaWallet/Settings/ViewControllers/SettingsViewController.swift
  13. 4
      AlphaWallet/Tokens/Coordinators/AddHideTokensCoordinator.swift
  14. 4
      AlphaWallet/Tokens/Coordinators/ClaimPaidOrderCoordinator.swift
  15. 4
      AlphaWallet/Tokens/Coordinators/NewTokenCoordinator.swift
  16. 4
      AlphaWallet/Tokens/Coordinators/SingleChainTokenCoordinator.swift
  17. 4
      AlphaWallet/Tokens/Coordinators/TokensCoordinator.swift
  18. 6
      AlphaWallet/Tokens/ViewControllers/TokenViewController.swift
  19. 20
      AlphaWallet/Tokens/Views/TokenInstanceWebView.swift
  20. 6
      AlphaWallet/Transactions/Coordinators/TokensCardCoordinator.swift
  21. 4
      AlphaWallet/Transfer/Coordinators/PaymentCoordinator.swift
  22. 4
      AlphaWallet/Transfer/Coordinators/SendCoordinator.swift
  23. 14
      AlphaWallet/Transfer/Coordinators/TransactionConfirmationCoordinator.swift
  24. 4
      AlphaWallet/Transfer/Coordinators/TransferNFTCoordinator.swift
  25. 4
      AlphaWallet/Wallet/Coordinators/BackupSeedPhraseCoordinator.swift
  26. 8
      AlphaWallet/Wallet/Coordinators/InitialWalletCreationCoordinator.swift
  27. 4
      AlphaWallet/Wallet/Coordinators/WalletCoordinator.swift
  28. 4
      AlphaWallet/Wallet/ViewControllers/CreateInitialWalletViewController.swift
  29. 4
      AlphaWallet/Wallet/ViewControllers/ImportWalletViewController.swift
  30. 4
      AlphaWallet/Wallet/ViewControllers/VerifySeedPhraseViewController.swift
  31. 6
      AlphaWallet/WalletConnect/Controllers/TransactionConfirmationCoordinatorBridgeToPromise.swift
  32. 4
      AlphaWallet/WalletConnect/Coordinator/WalletConnectCoordinator.swift
  33. 4
      AlphaWalletTests/Coordinators/BackupCoordinatorTests.swift
  34. 12
      AlphaWalletTests/Coordinators/InCoordinatorTests.swift
  35. 2
      AlphaWalletTests/Coordinators/InitialWalletCreationCoordinatorTests.swift
  36. 4
      AlphaWalletTests/Coordinators/SendCoordinatorTests.swift
  37. 4
      AlphaWalletTests/Coordinators/TokensCoordinatorTests.swift
  38. 6
      AlphaWalletTests/Coordinators/WalletCoordinatorTests.swift
  39. 4
      AlphaWalletTests/EtherClient/EtherKeystoreTests.swift
  40. 2
      AlphaWalletTests/Factories/FakeEtherKeystore.swift
  41. 2
      AlphaWalletTests/Market/OrderSigningTests.swift
  42. 2
      AlphaWalletTests/Settings/ConfigTests.swift
  43. 6
      AlphaWalletTests/Settings/Coordinators/SettingsCoordinatorTests.swift
  44. 4
      AlphaWalletTests/ViewControllers/PaymentCoordinatorTests.swift

@ -17,7 +17,7 @@ class AccountsCoordinator: Coordinator {
private let balanceCoordinator = GetNativeCryptoCurrencyBalanceCoordinator(forServer: .main)
private let keystore: Keystore
private let promptBackupCoordinator: PromptBackupCoordinator
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
let navigationController: UINavigationController
var coordinators: [Coordinator] = []
@ -39,7 +39,7 @@ class AccountsCoordinator: Coordinator {
navigationController: UINavigationController,
keystore: Keystore,
promptBackupCoordinator: PromptBackupCoordinator,
analyticsCoordinator: AnalyticsCoordinator?
analyticsCoordinator: AnalyticsCoordinator
) {
self.config = config
self.navigationController = navigationController

@ -22,7 +22,7 @@ final class DappBrowserCoordinator: NSObject, Coordinator {
private let sessions: ServerDictionary<WalletSession>
private let keystore: Keystore
private let config: Config
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
private var browserNavBar: DappBrowserNavigationBar? {
return navigationController.navigationBar as? DappBrowserNavigationBar
}
@ -111,7 +111,7 @@ final class DappBrowserCoordinator: NSObject, Coordinator {
sharedRealm: Realm,
browserOnly: Bool,
nativeCryptoCurrencyPrices: ServerDictionary<Subscribable<Double>>,
analyticsCoordinator: AnalyticsCoordinator?
analyticsCoordinator: AnalyticsCoordinator
) {
self.navigationController = UINavigationController(navigationBarClass: DappBrowserNavigationBar.self, toolbarClass: nil)
self.sessions = sessions

@ -11,7 +11,7 @@ protocol ScanQRCodeCoordinatorDelegate: class {
}
final class ScanQRCodeCoordinator: NSObject, Coordinator {
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
private lazy var navigationController = UINavigationController(rootViewController: qrcodeController)
private lazy var reader = QRCodeReader(metadataObjectTypes: [AVMetadataObject.ObjectType.qr])
private lazy var qrcodeController: QRCodeReaderViewController = {
@ -45,21 +45,21 @@ final class ScanQRCodeCoordinator: NSObject, Coordinator {
var coordinators: [Coordinator] = []
weak var delegate: ScanQRCodeCoordinatorDelegate?
init(analyticsCoordinator: AnalyticsCoordinator?, navigationController: UINavigationController, account: Wallet?) {
init(analyticsCoordinator: AnalyticsCoordinator, navigationController: UINavigationController, account: Wallet?) {
self.analyticsCoordinator = analyticsCoordinator
self.account = account
self.parentNavigationController = navigationController
}
func start(fromSource source: Analytics.ScanQRCodeSource) {
analyticsCoordinator?.log(navigation: Analytics.Navigation.scanQrCode, properties: [Analytics.Properties.source.rawValue: source.rawValue])
analyticsCoordinator.log(navigation: Analytics.Navigation.scanQrCode, properties: [Analytics.Properties.source.rawValue: source.rawValue])
navigationController.makePresentationFullScreenForiOS13Migration()
parentNavigationController.present(navigationController, animated: true)
}
@objc private func dismiss() {
stopScannerAndDismiss {
self.analyticsCoordinator?.log(action: Analytics.Action.cancelScanQrCode)
self.analyticsCoordinator.log(action: Analytics.Action.cancelScanQrCode)
self.delegate?.didCancel(in: self)
}
}
@ -102,7 +102,7 @@ extension ScanQRCodeCoordinator: QRCodeReaderDelegate {
func readerDidCancel(_ reader: QRCodeReaderViewController!) {
stopScannerAndDismiss {
self.analyticsCoordinator?.log(action: Analytics.Action.cancelScanQrCode)
self.analyticsCoordinator.log(action: Analytics.Action.cancelScanQrCode)
self.delegate?.didCancel(in: self)
}
}
@ -110,7 +110,7 @@ extension ScanQRCodeCoordinator: QRCodeReaderDelegate {
func reader(_ reader: QRCodeReaderViewController!, didScanResult result: String!) {
let resultType = convertToAnalyticsResultType(value: result)
stopScannerAndDismiss {
self.analyticsCoordinator?.log(action: Analytics.Action.completeScanQrCode, properties: [Analytics.Properties.resultType.rawValue: resultType.rawValue])
self.analyticsCoordinator.log(action: Analytics.Action.completeScanQrCode, properties: [Analytics.Properties.resultType.rawValue: resultType.rawValue])
self.delegate?.didScan(result: result, in: self)
}
}

@ -12,13 +12,13 @@ protocol BackupCoordinatorDelegate: class {
class BackupCoordinator: Coordinator {
private let keystore: Keystore
private let account: AlphaWallet.Address
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
let navigationController: UINavigationController
weak var delegate: BackupCoordinatorDelegate?
var coordinators: [Coordinator] = []
init(navigationController: UINavigationController, keystore: Keystore, account: AlphaWallet.Address, analyticsCoordinator: AnalyticsCoordinator?) {
init(navigationController: UINavigationController, keystore: Keystore, account: AlphaWallet.Address, analyticsCoordinator: AnalyticsCoordinator) {
self.navigationController = navigationController
self.keystore = keystore
self.account = account

@ -26,7 +26,7 @@ class PromptBackupCoordinator: Coordinator {
private let keystore: Keystore
private let wallet: Wallet
private let config: Config
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
//TODO this should be the total of mainnets instead of just Ethereum mainnet
private var nativeCryptoCurrencyDollarValueInUsd: Double = 0
@ -36,7 +36,7 @@ class PromptBackupCoordinator: Coordinator {
weak var prominentPromptDelegate: PromptBackupCoordinatorProminentPromptDelegate?
weak var subtlePromptDelegate: PromptBackupCoordinatorSubtlePromptDelegate?
init(keystore: Keystore, wallet: Wallet, config: Config, analyticsCoordinator: AnalyticsCoordinator?) {
init(keystore: Keystore, wallet: Wallet, config: Config, analyticsCoordinator: AnalyticsCoordinator) {
self.keystore = keystore
self.wallet = wallet
self.config = config

@ -46,7 +46,7 @@ class InCoordinator: NSObject, Coordinator {
private let appTracker: AppTracker
private var transactionsStorages = ServerDictionary<TransactionsStorage>()
private var walletSessions = ServerDictionary<WalletSession>()
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
private var callForAssetAttributeCoordinators = ServerDictionary<CallForAssetAttributeCoordinator>() {
didSet {
XMLHandler.callForAssetAttributeCoordinators = callForAssetAttributeCoordinators
@ -134,7 +134,7 @@ class InCoordinator: NSObject, Coordinator {
assetDefinitionStore: AssetDefinitionStore,
config: Config,
appTracker: AppTracker = AppTracker(),
analyticsCoordinator: AnalyticsCoordinator?,
analyticsCoordinator: AnalyticsCoordinator,
urlSchemeCoordinator: UrlSchemeCoordinatorType
) {
self.navigationController = navigationController
@ -424,7 +424,7 @@ class InCoordinator: NSObject, Coordinator {
return coordinator
}
private func createBrowserCoordinator(sessions: ServerDictionary<WalletSession>, browserOnly: Bool, analyticsCoordinator: AnalyticsCoordinator?) -> DappBrowserCoordinator {
private func createBrowserCoordinator(sessions: ServerDictionary<WalletSession>, browserOnly: Bool, analyticsCoordinator: AnalyticsCoordinator) -> DappBrowserCoordinator {
let realm = self.realm(forAccount: wallet)
let coordinator = DappBrowserCoordinator(sessions: sessions, keystore: keystore, config: config, sharedRealm: realm, browserOnly: browserOnly, nativeCryptoCurrencyPrices: nativeCryptoCurrencyPrices, analyticsCoordinator: analyticsCoordinator)
coordinator.delegate = self
@ -816,7 +816,7 @@ private extension TransactionType {
extension InCoordinator: TokensCoordinatorDelegate {
func didTapSwap(forTransactionType transactionType: TransactionType, service: SwapTokenURLProviderType, in coordinator: TokensCoordinator) {
analyticsCoordinator?.log(navigation: Analytics.Navigation.tokenSwap, properties: [Analytics.Properties.name.rawValue: service.analyticsName])
analyticsCoordinator.log(navigation: Analytics.Navigation.tokenSwap, properties: [Analytics.Properties.name.rawValue: service.analyticsName])
guard let token = transactionType.swapServiceInputToken, let url = service.url(token: token) else { return }
if let server = service.rpcServer {
@ -983,6 +983,6 @@ extension InCoordinator: ClaimOrderCoordinatorDelegate {
extension InCoordinator {
private func logEnabledChains() {
let list = config.enabledServers.map(\.chainID).sorted()
analyticsCoordinator?.setUser(property: Analytics.UserProperties.enabledChains, value: list)
analyticsCoordinator.setUser(property: Analytics.UserProperties.enabledChains, value: list)
}
}

@ -105,7 +105,7 @@ open class EtherKeystore: Keystore {
}
}
var analyticsCoordinator: AnalyticsCoordinator?
private var analyticsCoordinator: AnalyticsCoordinator
//i.e if passcode is enabled. Face ID/Touch ID wouldn't work without passcode being enabled and we can't write to the keychain or generate a key in secure enclave when passcode is disabled
var isUserPresenceCheckPossible: Bool {
@ -157,10 +157,10 @@ open class EtherKeystore: Keystore {
//TODO improve
static var currentWallet: Wallet {
//Better crash now instead of populating callers with optionals
(try! EtherKeystore(analyticsCoordinator: nil)).currentWallet
(try! EtherKeystore(analyticsCoordinator: NoOpAnalyticsService())).currentWallet
}
init(keychain: KeychainSwift = KeychainSwift(keyPrefix: Constants.keychainKeyPrefix), userDefaults: UserDefaults = .standard, analyticsCoordinator: AnalyticsCoordinator?) throws {
init(keychain: KeychainSwift = KeychainSwift(keyPrefix: Constants.keychainKeyPrefix), userDefaults: UserDefaults = .standard, analyticsCoordinator: AnalyticsCoordinator) throws {
if !UIApplication.shared.isProtectedDataAvailable {
throw EtherKeystoreError.protectionDisabled
}

@ -15,11 +15,11 @@ class LegacyFileBasedKeystore {
private let keychain: KeychainSwift
private let datadir = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
private let keyStore: KeyStore
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
let keystoreDirectory: URL
public init(keychain: KeychainSwift = KeychainSwift(keyPrefix: Constants.keychainKeyPrefix), keyStoreSubfolder: String = "/keystore", analyticsCoordinator: AnalyticsCoordinator?) throws {
public init(keychain: KeychainSwift = KeychainSwift(keyPrefix: Constants.keychainKeyPrefix), keyStoreSubfolder: String = "/keystore", analyticsCoordinator: AnalyticsCoordinator) throws {
if !UIApplication.shared.isProtectedDataAvailable {
throw FileBasedKeystoreError.protectionDisabled
}

@ -10,8 +10,9 @@ import Foundation
import BigInt
class SignatureHelper {
class func signatureAsHex(for message: String, account: AlphaWallet.Address) throws -> String? {
let keystore = try EtherKeystore(analyticsCoordinator: nil)
//TODO better to pass in keystore instead of analyticsCoordinator
class func signatureAsHex(for message: String, account: AlphaWallet.Address, analyticsCoordinator: AnalyticsCoordinator) throws -> String? {
let keystore = try EtherKeystore(analyticsCoordinator: analyticsCoordinator)
let signature = keystore.signMessageData(message.data(using: String.Encoding.utf8), for: account)
let signatureHex = try? signature.dematerialize().hex(options: .upperCase)
guard let data = signatureHex else {
@ -20,8 +21,8 @@ class SignatureHelper {
return data
}
class func signatureAsDecimal(for message: String, account: AlphaWallet.Address) throws -> String? {
guard let signatureHex = try signatureAsHex(for: message, account: account) else { return nil }
class func signatureAsDecimal(for message: String, account: AlphaWallet.Address, analyticsCoordinator: AnalyticsCoordinator) throws -> String? {
guard let signatureHex = try signatureAsHex(for: message, account: account, analyticsCoordinator: analyticsCoordinator) else { return nil }
guard let signatureDecimalString = BigInt(signatureHex, radix: 16)?.description else { return nil }
return signatureDecimalString
}

@ -20,6 +20,7 @@ class TokenCardRedemptionViewController: UIViewController, TokenVerifiableStatus
private var timer: Timer!
private var session: WalletSession
private let token: TokenObject
private let analyticsCoordinator: AnalyticsCoordinator
var contract: AlphaWallet.Address {
return token.contractAddress
@ -30,11 +31,12 @@ class TokenCardRedemptionViewController: UIViewController, TokenVerifiableStatus
let assetDefinitionStore: AssetDefinitionStore
weak var delegate: TokenCardRedemptionViewControllerDelegate?
init(session: WalletSession, token: TokenObject, viewModel: TokenCardRedemptionViewModel, assetDefinitionStore: AssetDefinitionStore) {
init(session: WalletSession, token: TokenObject, viewModel: TokenCardRedemptionViewModel, assetDefinitionStore: AssetDefinitionStore, analyticsCoordinator: AnalyticsCoordinator) {
self.session = session
self.token = token
self.viewModel = viewModel
self.assetDefinitionStore = assetDefinitionStore
self.analyticsCoordinator = analyticsCoordinator
let tokenType = OpenSeaBackedNonFungibleTokenHandling(token: token, assetDefinitionStore: assetDefinitionStore, tokenViewType: .viewIconified)
switch tokenType {
@ -115,7 +117,7 @@ class TokenCardRedemptionViewController: UIViewController, TokenVerifiableStatus
switch session.account.type {
case .real(let account):
do {
guard let decimalSignature = try SignatureHelper.signatureAsDecimal(for: redeemData.message, account: account) else { break }
guard let decimalSignature = try SignatureHelper.signatureAsDecimal(for: redeemData.message, account: account, analyticsCoordinator: analyticsCoordinator) else { break }
let qrCodeInfo = redeemData.qrCode + decimalSignature
imageView.image = qrCodeInfo.toQRCode()
} catch {

@ -25,7 +25,7 @@ class SettingsCoordinator: Coordinator {
private var config: Config
private let sessions: ServerDictionary<WalletSession>
private let promptBackupCoordinator: PromptBackupCoordinator
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
private var account: Wallet {
return sessions.anyValue.account
@ -55,7 +55,7 @@ class SettingsCoordinator: Coordinator {
config: Config,
sessions: ServerDictionary<WalletSession>,
promptBackupCoordinator: PromptBackupCoordinator,
analyticsCoordinator: AnalyticsCoordinator?
analyticsCoordinator: AnalyticsCoordinator
) {
self.navigationController = navigationController
self.navigationController.modalPresentationStyle = .formSheet

@ -17,7 +17,7 @@ class SettingsViewController: UIViewController {
private let config: Config
private let keystore: Keystore
private let account: Wallet
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
private let promptBackupWalletViewHolder = UIView()
private let tableView: UITableView = {
let tableView = UITableView(frame: .zero, style: .plain)
@ -57,7 +57,7 @@ class SettingsViewController: UIViewController {
view = tableView
}
init(config: Config, keystore: Keystore, account: Wallet, analyticsCoordinator: AnalyticsCoordinator?) {
init(config: Config, keystore: Keystore, account: Wallet, analyticsCoordinator: AnalyticsCoordinator) {
self.config = config
self.keystore = keystore
self.account = account

@ -12,7 +12,7 @@ protocol AddHideTokensCoordinatorDelegate: class {
}
class AddHideTokensCoordinator: Coordinator {
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
private let navigationController: UINavigationController
private var viewModel: AddHideTokensViewModel
private lazy var viewController: AddHideTokensViewController = .init(
@ -30,7 +30,7 @@ class AddHideTokensCoordinator: Coordinator {
var coordinators: [Coordinator] = []
weak var delegate: AddHideTokensCoordinatorDelegate?
init(tokens: [TokenObject], assetDefinitionStore: AssetDefinitionStore, filterTokensCoordinator: FilterTokensCoordinator, tickers: [RPCServer: [AlphaWallet.Address: CoinTicker]], sessions: ServerDictionary<WalletSession>, analyticsCoordinator: AnalyticsCoordinator?, navigationController: UINavigationController, tokenCollection: TokenCollection, config: Config, singleChainTokenCoordinators: [SingleChainTokenCoordinator]) {
init(tokens: [TokenObject], assetDefinitionStore: AssetDefinitionStore, filterTokensCoordinator: FilterTokensCoordinator, tickers: [RPCServer: [AlphaWallet.Address: CoinTicker]], sessions: ServerDictionary<WalletSession>, analyticsCoordinator: AnalyticsCoordinator, navigationController: UINavigationController, tokenCollection: TokenCollection, config: Config, singleChainTokenCoordinators: [SingleChainTokenCoordinator]) {
self.config = config
self.filterTokensCoordinator = filterTokensCoordinator
self.sessions = sessions

@ -21,7 +21,7 @@ class ClaimPaidOrderCoordinator: Coordinator {
private let tokenObject: TokenObject
private let signedOrder: SignedOrder
private let ethPrice: Subscribable<Double>
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
private var numberOfTokens: UInt {
if let tokenIds = signedOrder.order.tokenIds, !tokenIds.isEmpty {
@ -36,7 +36,7 @@ class ClaimPaidOrderCoordinator: Coordinator {
var coordinators: [Coordinator] = []
weak var delegate: ClaimOrderCoordinatorDelegate?
init(navigationController: UINavigationController, keystore: Keystore, session: WalletSession, tokenObject: TokenObject, signedOrder: SignedOrder, ethPrice: Subscribable<Double>, analyticsCoordinator: AnalyticsCoordinator?) {
init(navigationController: UINavigationController, keystore: Keystore, session: WalletSession, tokenObject: TokenObject, signedOrder: SignedOrder, ethPrice: Subscribable<Double>, analyticsCoordinator: AnalyticsCoordinator) {
self.navigationController = navigationController
self.keystore = keystore
self.session = session

@ -33,7 +33,7 @@ class NewTokenCoordinator: Coordinator {
private let singleChainTokenCoordinators: [SingleChainTokenCoordinator]
private let config: Config
private let tokenCollection: TokenCollection
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
private let navigationController: UINavigationController
private lazy var viewController: NewTokenViewController = .init(server: serverToAddCustomTokenOn, initialState: initialState)
private let initialState: NewTokenInitialState
@ -41,7 +41,7 @@ class NewTokenCoordinator: Coordinator {
var coordinators: [Coordinator] = []
weak var delegate: NewTokenCoordinatorDelegate?
init(analyticsCoordinator: AnalyticsCoordinator?, navigationController: UINavigationController, tokenCollection: TokenCollection, config: Config, singleChainTokenCoordinators: [SingleChainTokenCoordinator], initialState: NewTokenInitialState = .empty, sessions: ServerDictionary<WalletSession>) {
init(analyticsCoordinator: AnalyticsCoordinator, navigationController: UINavigationController, tokenCollection: TokenCollection, config: Config, singleChainTokenCoordinators: [SingleChainTokenCoordinator], initialState: NewTokenInitialState = .empty, sessions: ServerDictionary<WalletSession>) {
self.config = config
self.analyticsCoordinator = analyticsCoordinator
self.navigationController = navigationController

@ -41,7 +41,7 @@ class SingleChainTokenCoordinator: Coordinator {
private let cryptoPrice: Subscribable<Double>
private let assetDefinitionStore: AssetDefinitionStore
private let eventsDataStore: EventsDataStoreProtocol
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
private let autoDetectTransactedTokensQueue: OperationQueue
private let autoDetectTokensQueue: OperationQueue
private var isAutoDetectingTransactedTokens = false
@ -58,7 +58,7 @@ class SingleChainTokenCoordinator: Coordinator {
ethPrice: Subscribable<Double>,
assetDefinitionStore: AssetDefinitionStore,
eventsDataStore: EventsDataStoreProtocol,
analyticsCoordinator: AnalyticsCoordinator?,
analyticsCoordinator: AnalyticsCoordinator,
withAutoDetectTransactedTokensQueue autoDetectTransactedTokensQueue: OperationQueue,
withAutoDetectTokensQueue autoDetectTokensQueue: OperationQueue,
swapTokenActionsService: SwapTokenActionsService

@ -26,7 +26,7 @@ class TokensCoordinator: Coordinator {
private let eventsDataStore: EventsDataStoreProtocol
private let promptBackupCoordinator: PromptBackupCoordinator
private let filterTokensCoordinator: FilterTokensCoordinator
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
private let swapTokenService: SwapTokenServiceType
private var serverToAddCustomTokenOn: RPCServerOrAuto = .auto {
didSet {
@ -91,7 +91,7 @@ class TokensCoordinator: Coordinator {
eventsDataStore: EventsDataStoreProtocol,
promptBackupCoordinator: PromptBackupCoordinator,
filterTokensCoordinator: FilterTokensCoordinator,
analyticsCoordinator: AnalyticsCoordinator?,
analyticsCoordinator: AnalyticsCoordinator,
swapTokenService: SwapTokenServiceType,
walletConnectCoordinator: WalletConnectCoordinator
) {

@ -28,7 +28,7 @@ class TokenViewController: UIViewController {
private let tokensDataStore: TokensDataStore
private let assetDefinitionStore: AssetDefinitionStore
private let transactionType: TransactionType
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
private let tableView = UITableView(frame: .zero, style: .plain)
private let buttonsBar = ButtonsBar(configuration: .combined(buttons: 2))
private lazy var tokenScriptFileStatusHandler = XMLHandler(token: token, assetDefinitionStore: assetDefinitionStore)
@ -36,7 +36,7 @@ class TokenViewController: UIViewController {
weak var delegate: TokenViewControllerDelegate?
init(session: WalletSession, tokensDataStore: TokensDataStore, assetDefinition: AssetDefinitionStore, transactionType: TransactionType, analyticsCoordinator: AnalyticsCoordinator?, token: TokenObject) {
init(session: WalletSession, tokensDataStore: TokensDataStore, assetDefinition: AssetDefinitionStore, transactionType: TransactionType, analyticsCoordinator: AnalyticsCoordinator, token: TokenObject) {
self.token = token
self.session = session
self.tokensDataStore = tokensDataStore
@ -236,7 +236,7 @@ class TokenViewController: UIViewController {
//TODO log
return
}
analyticsCoordinator?.log(navigation: Analytics.Navigation.onRamp, properties: [Analytics.Properties.name.rawValue: "Ramp"])
analyticsCoordinator.log(navigation: Analytics.Navigation.onRamp, properties: [Analytics.Properties.name.rawValue: "Ramp"])
delegate?.shouldOpen(url: url, onServer: .xDai, forTransactionType: transactionType, inViewController: self)
}
break

@ -485,7 +485,7 @@ extension TokenInstanceWebView {
//TODO pass in keystore
let coordinator = SignMessageCoordinator(
navigationController: navigationController,
keystore: try! EtherKeystore(analyticsCoordinator: nil),
keystore: try! EtherKeystore(analyticsCoordinator: NoOpAnalyticsService()),
account: account
)
coordinator.didComplete = { [weak self] result in
@ -578,3 +578,21 @@ extension String {
return hashValue
}
}
//TODO to remove this.
//TODO Do not use this unless it's absolutely necessary e.g. it requires a big re-architecting of code
class NoOpAnalyticsService: AnalyticsServiceType {
func log(action: AnalyticsAction, properties: [String : AnalyticsEventPropertyValue]?) { }
func applicationDidBecomeActive() { }
func application(continue userActivity: NSUserActivity) { }
func application(open url: URL, sourceApplication: String?, annotation: Any) { }
func application(open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) { }
func application(didReceiveRemoteNotification userInfo: [AnyHashable : Any]) { }
func add(pushDeviceToken token: Data) { }
func log(navigation: AnalyticsNavigation, properties: [String : AnalyticsEventPropertyValue]?) {}
func setUser(property: AnalyticsUserProperty, value: AnalyticsEventPropertyValue) { }
func incrementUser(property: AnalyticsUserProperty, by value: Int) { }
func incrementUser(property: AnalyticsUserProperty, by value: Double) { }
init() {}
}

@ -31,7 +31,7 @@ class TokensCardCoordinator: NSObject, Coordinator {
private let assetDefinitionStore: AssetDefinitionStore
private let eventsDataStore: EventsDataStoreProtocol
private weak var transferTokensViewController: TransferTokensCardViaWalletAddressViewController?
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
weak var delegate: TokensCardCoordinatorDelegate?
let navigationController: UINavigationController
@ -52,7 +52,7 @@ class TokensCardCoordinator: NSObject, Coordinator {
token: TokenObject,
assetDefinitionStore: AssetDefinitionStore,
eventsDataStore: EventsDataStoreProtocol,
analyticsCoordinator: AnalyticsCoordinator?
analyticsCoordinator: AnalyticsCoordinator
) {
self.session = session
self.keystore = keystore
@ -264,7 +264,7 @@ class TokensCardCoordinator: NSObject, Coordinator {
private func makeTokenCardRedemptionViewController(token: TokenObject, for tokenHolder: TokenHolder) -> TokenCardRedemptionViewController {
let viewModel = TokenCardRedemptionViewModel(token: token, tokenHolder: tokenHolder)
let controller = TokenCardRedemptionViewController(session: session, token: token, viewModel: viewModel, assetDefinitionStore: assetDefinitionStore)
let controller = TokenCardRedemptionViewController(session: session, token: token, viewModel: viewModel, assetDefinitionStore: assetDefinitionStore, analyticsCoordinator: analyticsCoordinator)
controller.configure()
controller.delegate = self
return controller

@ -16,7 +16,7 @@ class PaymentCoordinator: Coordinator {
private let ethPrice: Subscribable<Double>
private let tokenHolders: [TokenHolder]!
private let assetDefinitionStore: AssetDefinitionStore
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
weak var delegate: PaymentCoordinatorDelegate?
var coordinators: [Coordinator] = []
@ -31,7 +31,7 @@ class PaymentCoordinator: Coordinator {
ethPrice: Subscribable<Double>,
tokenHolders: [TokenHolder] = [],
assetDefinitionStore: AssetDefinitionStore,
analyticsCoordinator: AnalyticsCoordinator?
analyticsCoordinator: AnalyticsCoordinator
) {
self.navigationController = navigationController
self.session = session

@ -20,7 +20,7 @@ class SendCoordinator: Coordinator {
private let ethPrice: Subscribable<Double>
private let tokenHolders: [TokenHolder]!
private let assetDefinitionStore: AssetDefinitionStore
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
private var transactionConfirmationResult: TransactionConfirmationResult = .noData
lazy var sendViewController: SendViewController = {
@ -41,7 +41,7 @@ class SendCoordinator: Coordinator {
ethPrice: Subscribable<Double>,
tokenHolders: [TokenHolder] = [],
assetDefinitionStore: AssetDefinitionStore,
analyticsCoordinator: AnalyticsCoordinator?
analyticsCoordinator: AnalyticsCoordinator
) {
self.transactionType = transactionType
self.navigationController = navigationController

@ -71,7 +71,7 @@ class TransactionConfirmationCoordinator: Coordinator {
}()
private weak var configureTransactionViewController: ConfigureTransactionViewController?
private let configurator: TransactionConfigurator
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
lazy var navigationController: UINavigationController = {
let controller = UINavigationController(rootViewController: confirmationViewController)
controller.modalPresentationStyle = .overFullScreen
@ -83,7 +83,7 @@ class TransactionConfirmationCoordinator: Coordinator {
var coordinators: [Coordinator] = []
weak var delegate: TransactionConfirmationCoordinatorDelegate?
init(navigationController: UINavigationController, session: WalletSession, transaction: UnconfirmedTransaction, configuration: TransactionConfirmationConfiguration, analyticsCoordinator: AnalyticsCoordinator?) {
init(navigationController: UINavigationController, session: WalletSession, transaction: UnconfirmedTransaction, configuration: TransactionConfirmationConfiguration, analyticsCoordinator: AnalyticsCoordinator) {
configurator = TransactionConfigurator(session: session, transaction: transaction)
self.configuration = configuration
self.analyticsCoordinator = analyticsCoordinator
@ -96,7 +96,7 @@ class TransactionConfirmationCoordinator: Coordinator {
configurator.start()
confirmationViewController.reloadView()
analyticsCoordinator?.log(navigation: Analytics.Navigation.actionSheetForTransactionConfirmation, properties: [Analytics.Properties.source.rawValue: source.rawValue])
analyticsCoordinator.log(navigation: Analytics.Navigation.actionSheetForTransactionConfirmation, properties: [Analytics.Properties.source.rawValue: source.rawValue])
}
func close(completion: @escaping () -> Void) {
@ -122,7 +122,7 @@ class TransactionConfirmationCoordinator: Coordinator {
extension TransactionConfirmationCoordinator: TransactionConfirmationViewControllerDelegate {
func didClose(in controller: TransactionConfirmationViewController) {
analyticsCoordinator?.log(action: Analytics.Action.cancelsTransactionInActionSheet)
analyticsCoordinator.log(action: Analytics.Action.cancelsTransactionInActionSheet)
navigationController.dismiss(animated: false) { [weak self] in
guard let strongSelf = self, let delegate = strongSelf.delegate else { return }
delegate.didClose(in: strongSelf)
@ -180,15 +180,15 @@ extension TransactionConfirmationCoordinator: TransactionConfirmationViewControl
transactionType = .unknown
}
analyticsCoordinator?.log(action: Analytics.Action.confirmsTransactionInActionSheet, properties: [
analyticsCoordinator.log(action: Analytics.Action.confirmsTransactionInActionSheet, properties: [
Analytics.Properties.speedType.rawValue: speedType.rawValue,
Analytics.Properties.chain.rawValue: configurator.session.server.chainID,
Analytics.Properties.transactionType.rawValue: transactionType.rawValue,
])
if configurator.session.server.isTestnet {
analyticsCoordinator?.incrementUser(property: Analytics.UserProperties.testnetTransactionCount, by: 1)
analyticsCoordinator.incrementUser(property: Analytics.UserProperties.testnetTransactionCount, by: 1)
} else {
analyticsCoordinator?.incrementUser(property: Analytics.UserProperties.transactionCount, by: 1)
analyticsCoordinator.incrementUser(property: Analytics.UserProperties.transactionCount, by: 1)
}
}

@ -17,11 +17,11 @@ class TransferNFTCoordinator: Coordinator {
private let keystore: Keystore
private let session: WalletSession
private let ethPrice: Subscribable<Double>
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
var coordinators: [Coordinator] = []
weak var delegate: TransferNFTCoordinatorDelegate?
init(navigationController: UINavigationController, transactionType: TransactionType, tokenHolder: TokenHolder, recipient: AlphaWallet.Address, keystore: Keystore, session: WalletSession, ethPrice: Subscribable<Double>, analyticsCoordinator: AnalyticsCoordinator?) {
init(navigationController: UINavigationController, transactionType: TransactionType, tokenHolder: TokenHolder, recipient: AlphaWallet.Address, keystore: Keystore, session: WalletSession, ethPrice: Subscribable<Double>, analyticsCoordinator: AnalyticsCoordinator) {
self.navigationController = navigationController
self.transactionType = transactionType
self.tokenHolder = tokenHolder

@ -23,7 +23,7 @@ class BackupSeedPhraseCoordinator: Coordinator {
return createVerifySeedPhraseViewController()
}()
private let account: AlphaWallet.Address
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
private let keystore: Keystore
private var _context: LAContext?
private var context: LAContext {
@ -49,7 +49,7 @@ class BackupSeedPhraseCoordinator: Coordinator {
var coordinators: [Coordinator] = []
weak var delegate: BackupSeedPhraseCoordinatorDelegate?
init(navigationController: UINavigationController = UINavigationController(), keystore: Keystore, account: AlphaWallet.Address, analyticsCoordinator: AnalyticsCoordinator?) {
init(navigationController: UINavigationController = UINavigationController(), keystore: Keystore, account: AlphaWallet.Address, analyticsCoordinator: AnalyticsCoordinator) {
self.navigationController = navigationController
self.keystore = keystore
self.account = account

@ -9,9 +9,9 @@ protocol InitialWalletCreationCoordinatorDelegate: class {
}
class InitialWalletCreationCoordinator: Coordinator {
private let keystore: Keystore
private let keystore: Keystore
private let config: Config
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
let navigationController: UINavigationController
var coordinators: [Coordinator] = []
@ -21,7 +21,7 @@ class InitialWalletCreationCoordinator: Coordinator {
config: Config,
navigationController: UINavigationController,
keystore: Keystore,
analyticsCoordinator: AnalyticsCoordinator?
analyticsCoordinator: AnalyticsCoordinator
) {
self.config = config
self.navigationController = navigationController
@ -37,7 +37,7 @@ class InitialWalletCreationCoordinator: Coordinator {
coordinator.start(.addInitialWallet)
addCoordinator(coordinator)
}
}
}
extension InitialWalletCreationCoordinator: WalletCoordinatorDelegate {

@ -12,7 +12,7 @@ class WalletCoordinator: Coordinator {
private let config: Config
private var keystore: Keystore
private weak var importWalletViewController: ImportWalletViewController?
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
var navigationController: UINavigationController
weak var delegate: WalletCoordinatorDelegate?
@ -22,7 +22,7 @@ class WalletCoordinator: Coordinator {
config: Config,
navigationController: UINavigationController = UINavigationController(),
keystore: Keystore,
analyticsCoordinator: AnalyticsCoordinator?
analyticsCoordinator: AnalyticsCoordinator
) {
self.config = config
self.navigationController = navigationController

@ -11,7 +11,7 @@ protocol CreateInitialWalletViewControllerDelegate: class {
class CreateInitialWalletViewController: UIViewController {
private let keystore: Keystore
private var viewModel = CreateInitialViewModel()
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
private let roundedBackground = RoundedBackground()
private let subtitleLabel = UILabel()
private let imageView = UIImageView()
@ -37,7 +37,7 @@ class CreateInitialWalletViewController: UIViewController {
weak var delegate: CreateInitialWalletViewControllerDelegate?
init(keystore: Keystore, analyticsCoordinator: AnalyticsCoordinator?) {
init(keystore: Keystore, analyticsCoordinator: AnalyticsCoordinator) {
self.keystore = keystore
self.analyticsCoordinator = analyticsCoordinator
super.init(nibName: nil, bundle: nil)

@ -20,7 +20,7 @@ class ImportWalletViewController: UIViewController {
private static let mnemonicSuggestionsBarHeight: CGFloat = ScreenChecker().isNarrowScreen ? 40 : 60
private let keystore: Keystore
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
private let viewModel = ImportWalletViewModel()
//We don't actually use the rounded corner here, but it's a useful "content" view here
private let roundedBackground = RoundedBackground()
@ -176,7 +176,7 @@ class ImportWalletViewController: UIViewController {
weak var delegate: ImportWalletViewControllerDelegate?
init(keystore: Keystore, analyticsCoordinator: AnalyticsCoordinator?) {
init(keystore: Keystore, analyticsCoordinator: AnalyticsCoordinator) {
self.keystore = keystore
self.analyticsCoordinator = analyticsCoordinator

@ -33,7 +33,7 @@ class VerifySeedPhraseViewController: UIViewController {
private var viewModel: VerifySeedPhraseViewModel
private let keystore: Keystore
private let account: AlphaWallet.Address
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
private let roundedBackground = RoundedBackground()
private let subtitleLabel = UILabel()
private let seedPhraseTextView = UITextView()
@ -98,7 +98,7 @@ class VerifySeedPhraseViewController: UIViewController {
weak var delegate: VerifySeedPhraseViewControllerDelegate?
init(keystore: Keystore, account: AlphaWallet.Address, analyticsCoordinator: AnalyticsCoordinator?) {
init(keystore: Keystore, account: AlphaWallet.Address, analyticsCoordinator: AnalyticsCoordinator) {
self.keystore = keystore
self.account = account
self.analyticsCoordinator = analyticsCoordinator

@ -10,14 +10,14 @@ import PromiseKit
import Result
private class TransactionConfirmationCoordinatorBridgeToPromise {
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
private let navigationController: UINavigationController
private let session: WalletSession
private let coordinator: Coordinator
private let (promise, seal) = Promise<ConfirmResult>.pending()
private var retainCycle: TransactionConfirmationCoordinatorBridgeToPromise?
init(_ navigationController: UINavigationController, session: WalletSession, coordinator: Coordinator, analyticsCoordinator: AnalyticsCoordinator?) {
init(_ navigationController: UINavigationController, session: WalletSession, coordinator: Coordinator, analyticsCoordinator: AnalyticsCoordinator) {
self.navigationController = navigationController
self.session = session
self.coordinator = coordinator
@ -93,7 +93,7 @@ extension UIViewController {
extension TransactionConfirmationCoordinator {
//session contains account already
static func promise(_ navigationController: UINavigationController, session: WalletSession, coordinator: Coordinator, account: AlphaWallet.Address, transaction: UnconfirmedTransaction, configuration: TransactionConfirmationConfiguration, analyticsCoordinator: AnalyticsCoordinator?, source: Analytics.TransactionConfirmationSource) -> Promise<ConfirmResult> {
static func promise(_ navigationController: UINavigationController, session: WalletSession, coordinator: Coordinator, account: AlphaWallet.Address, transaction: UnconfirmedTransaction, configuration: TransactionConfirmationConfiguration, analyticsCoordinator: AnalyticsCoordinator, source: Analytics.TransactionConfirmationSource) -> Promise<ConfirmResult> {
let bridge = TransactionConfirmationCoordinatorBridgeToPromise(navigationController, session: session, coordinator: coordinator, analyticsCoordinator: analyticsCoordinator)
return bridge.promise(account: account, transaction: transaction, configuration: configuration, source: source)
}

@ -34,7 +34,7 @@ class WalletConnectCoordinator: NSObject, Coordinator {
private let keystore: Keystore
private let sessions: ServerDictionary<WalletSession>
private let analyticsCoordinator: AnalyticsCoordinator?
private let analyticsCoordinator: AnalyticsCoordinator
private let config: Config
private let nativeCryptoCurrencyPrices: ServerDictionary<Subscribable<Double>>
private weak var notificationAlertController: UIViewController?
@ -43,7 +43,7 @@ class WalletConnectCoordinator: NSObject, Coordinator {
}
private weak var sessionsViewController: WalletConnectSessionsViewController?
init(keystore: Keystore, sessions: ServerDictionary<WalletSession>, navigationController: UINavigationController, analyticsCoordinator: AnalyticsCoordinator?, config: Config, nativeCryptoCurrencyPrices: ServerDictionary<Subscribable<Double>>) {
init(keystore: Keystore, sessions: ServerDictionary<WalletSession>, navigationController: UINavigationController, analyticsCoordinator: AnalyticsCoordinator, config: Config, nativeCryptoCurrencyPrices: ServerDictionary<Subscribable<Double>>) {
self.config = config
self.sessions = sessions
self.keystore = keystore

@ -9,7 +9,7 @@ class BackupCoordinatorTests: XCTestCase {
navigationController: FakeNavigationController(),
keystore: FakeKeystore(assumeAllWalletsType: .hdWallet),
account: .make(),
analyticsCoordinator: nil
analyticsCoordinator: FakeAnalyticsService()
)
coordinator.start()
@ -21,7 +21,7 @@ class BackupCoordinatorTests: XCTestCase {
navigationController: FakeNavigationController(),
keystore: FakeKeystore(assumeAllWalletsType: .keyStoreWallet),
account: .make(),
analyticsCoordinator: nil
analyticsCoordinator: FakeAnalyticsService()
)
coordinator.start()

@ -31,7 +31,7 @@ class InCoordinatorTests: XCTestCase {
keystore: FakeKeystore(wallets: [wallet]),
assetDefinitionStore: AssetDefinitionStore(),
config: config,
analyticsCoordinator: nil,
analyticsCoordinator: FakeAnalyticsService(),
urlSchemeCoordinator: FakeUrlSchemeCoordinator.make()
)
@ -64,7 +64,7 @@ class InCoordinatorTests: XCTestCase {
keystore: keystore,
assetDefinitionStore: AssetDefinitionStore(),
config: .make(),
analyticsCoordinator: nil,
analyticsCoordinator: FakeAnalyticsService(),
urlSchemeCoordinator: FakeUrlSchemeCoordinator.make()
)
@ -85,7 +85,7 @@ class InCoordinatorTests: XCTestCase {
keystore: FakeKeystore(wallets: [wallet]),
assetDefinitionStore: AssetDefinitionStore(),
config: .make(),
analyticsCoordinator: nil,
analyticsCoordinator: FakeAnalyticsService(),
urlSchemeCoordinator: FakeUrlSchemeCoordinator.make()
)
coordinator.showTabBar(for: .make())
@ -104,7 +104,7 @@ class InCoordinatorTests: XCTestCase {
keystore: FakeKeystore(wallets: [wallet]),
assetDefinitionStore: AssetDefinitionStore(),
config: .make(),
analyticsCoordinator: nil,
analyticsCoordinator: FakeAnalyticsService(),
urlSchemeCoordinator: FakeUrlSchemeCoordinator.make()
)
coordinator.showTabBar(for: .make())
@ -122,7 +122,7 @@ class InCoordinatorTests: XCTestCase {
keystore: FakeKeystore(),
assetDefinitionStore: AssetDefinitionStore(),
config: .make(),
analyticsCoordinator: nil,
analyticsCoordinator: FakeAnalyticsService(),
urlSchemeCoordinator: FakeUrlSchemeCoordinator.make()
)
coordinator.showTabBar(for: .make())
@ -161,7 +161,7 @@ class InCoordinatorTests: XCTestCase {
keystore: keystore,
assetDefinitionStore: AssetDefinitionStore(),
config: .make(),
analyticsCoordinator: nil,
analyticsCoordinator: FakeAnalyticsService(),
urlSchemeCoordinator: FakeUrlSchemeCoordinator.make()
)
coordinator.showTabBar(for: wallet)

@ -10,7 +10,7 @@ class InitialWalletCreationCoordinatorTests: XCTestCase {
config: .make(),
navigationController: FakeNavigationController(),
keystore: FakeKeystore(),
analyticsCoordinator: nil
analyticsCoordinator: FakeAnalyticsService()
)
coordinator.start()

@ -16,7 +16,7 @@ class SendCoordinatorTests: XCTestCase {
account: .make(),
ethPrice: Subscribable<Double>(nil),
assetDefinitionStore: AssetDefinitionStore(),
analyticsCoordinator: nil
analyticsCoordinator: FakeAnalyticsService()
)
coordinator.start()
@ -35,7 +35,7 @@ class SendCoordinatorTests: XCTestCase {
account: .make(),
ethPrice: Subscribable<Double>(nil),
assetDefinitionStore: AssetDefinitionStore(),
analyticsCoordinator: nil
analyticsCoordinator: FakeAnalyticsService()
)
coordinator.start()

@ -33,9 +33,9 @@ class TokensCoordinatorTests: XCTestCase {
nativeCryptoCurrencyPrices: .init(),
assetDefinitionStore: AssetDefinitionStore(),
eventsDataStore: FakeEventsDataStore(),
promptBackupCoordinator: PromptBackupCoordinator(keystore: FakeKeystore(), wallet: .make(), config: config, analyticsCoordinator: nil),
promptBackupCoordinator: PromptBackupCoordinator(keystore: FakeKeystore(), wallet: .make(), config: config, analyticsCoordinator: FakeAnalyticsService()),
filterTokensCoordinator: FilterTokensCoordinator(assetDefinitionStore: assetDefinitionStore, swapTokenService: swapTokenService),
analyticsCoordinator: nil,
analyticsCoordinator: FakeAnalyticsService(),
swapTokenService: swapTokenService,
walletConnectCoordinator: .fake()
)

@ -10,7 +10,7 @@ class WalletCoordinatorTests: XCTestCase {
config: .make(),
navigationController: FakeNavigationController(),
keystore: FakeKeystore(),
analyticsCoordinator: nil
analyticsCoordinator: FakeAnalyticsService()
)
coordinator.start(.importWallet)
@ -24,7 +24,7 @@ class WalletCoordinatorTests: XCTestCase {
config: .make(),
navigationController: FakeNavigationController(),
keystore: FakeEtherKeystore(),
analyticsCoordinator: nil
analyticsCoordinator: FakeAnalyticsService()
)
coordinator.delegate = delegate
@ -36,7 +36,7 @@ class WalletCoordinatorTests: XCTestCase {
config: .make(),
navigationController: FakeNavigationController(),
keystore: FakeKeystore(),
analyticsCoordinator: nil
analyticsCoordinator: FakeAnalyticsService()
)
coordinator.start(.addInitialWallet)

@ -24,7 +24,7 @@ class EtherKeystoreTests: XCTestCase {
}
func testEmptyPassword() {
let keystore = try! LegacyFileBasedKeystore(analyticsCoordinator: nil)
let keystore = try! LegacyFileBasedKeystore(analyticsCoordinator: FakeAnalyticsService())
let password = keystore.getPassword(for: .make())
XCTAssertNil(password)
}
@ -140,7 +140,7 @@ class EtherKeystoreTests: XCTestCase {
func testConvertPrivateKeyToKeyStore() {
let passphrase = "MyHardPassword!"
let keystore = FakeEtherKeystore()
let result = (try! LegacyFileBasedKeystore(analyticsCoordinator: nil)).convertPrivateKeyToKeystoreFile(privateKey: Data(hexString: TestKeyStore.testPrivateKey)!, passphrase: passphrase)
let result = (try! LegacyFileBasedKeystore(analyticsCoordinator: FakeAnalyticsService())).convertPrivateKeyToKeystoreFile(privateKey: Data(hexString: TestKeyStore.testPrivateKey)!, passphrase: passphrase)
let dict = try! result.dematerialize()
keystore.importWallet(type: .keystore(string: dict.jsonString!, password: passphrase)) { result in
let wallet = try! result.dematerialize()

@ -7,6 +7,6 @@ import KeychainSwift
class FakeEtherKeystore: EtherKeystore {
convenience init() {
let uniqueString = NSUUID().uuidString
try! self.init(keychain: KeychainSwift(keyPrefix: "fake" + uniqueString), userDefaults: UserDefaults.test, analyticsCoordinator: nil)
try! self.init(keychain: KeychainSwift(keyPrefix: "fake" + uniqueString), userDefaults: UserDefaults.test, analyticsCoordinator: FakeAnalyticsService())
}
}

@ -6,7 +6,7 @@ import BigInt
class OrderSigningTests: XCTestCase {
func testSigningOrders() {
let keystore = try! EtherKeystore(analyticsCoordinator: nil)
let keystore = try! EtherKeystore(analyticsCoordinator: FakeAnalyticsService())
let contractAddress = AlphaWallet.Address(string: "0xacDe9017473D7dC82ACFd0da601E4de291a7d6b0")!
let account = try! keystore.createAccount().dematerialize()
var testOrdersList = [Order]()

@ -10,7 +10,7 @@ extension WalletConnectCoordinator {
var sessions = ServerDictionary<WalletSession>()
let session = WalletSession.make()
sessions[session.server] = session
return .init(keystore: keystore, sessions: sessions, navigationController: .init(), analyticsCoordinator: nil, config: .make(), nativeCryptoCurrencyPrices: .init())
return .init(keystore: keystore, sessions: sessions, navigationController: .init(), analyticsCoordinator: FakeAnalyticsService(), config: .make(), nativeCryptoCurrencyPrices: .init())
}
}

@ -23,14 +23,14 @@ class SettingsCoordinatorTests: XCTestCase {
}
let storage = FakeTransactionsStorage()
let promptBackupCoordinator = PromptBackupCoordinator(keystore: FakeKeystore(), wallet: .make(), config: .make(), analyticsCoordinator: nil)
let promptBackupCoordinator = PromptBackupCoordinator(keystore: FakeKeystore(), wallet: .make(), config: .make(), analyticsCoordinator: FakeAnalyticsService())
let coordinator = SettingsCoordinator(
navigationController: FakeNavigationController(),
keystore: FakeEtherKeystore(),
config: .make(),
sessions: .init(),
promptBackupCoordinator: promptBackupCoordinator,
analyticsCoordinator: nil
analyticsCoordinator: FakeAnalyticsService()
)
let delegate = Delegate()
coordinator.delegate = delegate
@ -43,7 +43,7 @@ class SettingsCoordinatorTests: XCTestCase {
navigationController: FakeNavigationController(),
keystore: FakeEtherKeystore(),
promptBackupCoordinator: promptBackupCoordinator,
analyticsCoordinator: nil
analyticsCoordinator: FakeAnalyticsService()
)
XCTAssertFalse(delegate.deleteDelegateMethodCalled)

@ -15,7 +15,7 @@ class PaymentCoordinatorTests: XCTestCase {
storage: FakeTokensDataStore(),
ethPrice: Subscribable<Double>(nil),
assetDefinitionStore: AssetDefinitionStore(),
analyticsCoordinator: nil
analyticsCoordinator: FakeAnalyticsService()
)
coordinator.start()
@ -32,7 +32,7 @@ class PaymentCoordinatorTests: XCTestCase {
storage: FakeTokensDataStore(),
ethPrice: Subscribable<Double>(nil),
assetDefinitionStore: AssetDefinitionStore(),
analyticsCoordinator: nil
analyticsCoordinator: FakeAnalyticsService()
)
coordinator.start()

Loading…
Cancel
Save