Merge branch 'master' into remove-one-more-notifications-button-in-settings

pull/360/head
James Sangalli 7 years ago committed by GitHub
commit d785252551
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      Trust/Accounts/Coordinators/AccountsCoordinator.swift
  2. 8
      Trust/Export/Coordinators/PromptBackupCoordinator.swift
  3. 6
      Trust/InCoordinator.swift
  4. 6
      Trust/Market/Coordinators/UniversalLinkCoordinator.swift
  5. 9
      Trust/Market/ViewModels/ImportTicketViewControllerViewModel.swift
  6. 3
      Trust/Wallet/Coordinators/WalletCoordinator.swift
  7. 2
      Trust/Wallet/Types/WalletEntryPoint.swift

@ -69,7 +69,7 @@ class AccountsCoordinator: Coordinator {
func importOrCreateWallet(entryPoint: WalletEntryPoint) {
let coordinator = WalletCoordinator(keystore: keystore)
if entryPoint == .createInstantWallet {
if case let .createInstantWallet = entryPoint {
coordinator.navigationController = navigationController
}
coordinator.delegate = self

@ -7,9 +7,15 @@ protocol PromptBackupCoordinatorDelegate: class {
func didFinish(in coordinator: PromptBackupCoordinator)
}
///We allow user to switch wallets, so it's important to know which wallet we are prompting for. It might not be the current wallet
class PromptBackupCoordinator: Coordinator {
var coordinators: [Coordinator] = []
weak var delegate: PromptBackupCoordinatorDelegate?
var walletAddress: String
init(walletAddress: String) {
self.walletAddress = walletAddress
}
func start() {
let keystore = try! EtherKeystore()
@ -19,7 +25,7 @@ class PromptBackupCoordinator: Coordinator {
}
let coordinator = WalletCoordinator(keystore: keystore)
coordinator.delegate = self
let proceed = coordinator.start(.backupWallet)
let proceed = coordinator.start(.backupWallet(address: walletAddress))
guard proceed else {
finish()
return

@ -220,13 +220,13 @@ class InCoordinator: Coordinator {
if let balance = BigInt(eth.value) {
self?.ethBalance.value = BigInt(eth.value)
guard !(balance.isZero) else { return }
self?.promptBackupWallet()
self?.promptBackupWallet(withAddress: account.address.description)
}
}
}
private func promptBackupWallet() {
let coordinator = PromptBackupCoordinator()
private func promptBackupWallet(withAddress address: String) {
let coordinator = PromptBackupCoordinator(walletAddress: address)
addCoordinator(coordinator)
coordinator.delegate = self
coordinator.start()

@ -18,6 +18,7 @@ class UniversalLinkCoordinator: Coordinator {
var importTicketViewController: ImportTicketViewController?
var ethPrice: Subscribable<Double>?
var ethBalance: Subscribable<BigInt>?
var hasCompleted = false
func start()
{
@ -246,6 +247,7 @@ class UniversalLinkCoordinator: Coordinator {
}
private func updateImportTicketController(with state: ImportTicketViewControllerViewModel.State, ticketHolder: TicketHolder? = nil, ethCost: String? = nil, dollarCost: String? = nil) {
guard !hasCompleted else { return }
if let vc = importTicketViewController, var viewModel = vc.viewModel {
viewModel.state = state
if let ticketHolder = ticketHolder {
@ -259,6 +261,7 @@ class UniversalLinkCoordinator: Coordinator {
}
vc.configure(viewModel: viewModel)
}
hasCompleted = state.hasCompleted
}
private func promptImportUniversalLink(ticketHolder: TicketHolder, ethCost: String, dollarCost: String? = nil) {
@ -271,7 +274,8 @@ class UniversalLinkCoordinator: Coordinator {
}
private func promptBackupWallet() {
let coordinator = PromptBackupCoordinator()
guard let keystore = try? EtherKeystore(), let address = keystore.recentlyUsedWallet?.address.eip55String else { return }
let coordinator = PromptBackupCoordinator(walletAddress: address)
addCoordinator(coordinator)
coordinator.delegate = self
coordinator.start()

@ -9,6 +9,15 @@ struct ImportTicketViewControllerViewModel {
case processing
case succeeded
case failed(errorMessage: String)
var hasCompleted: Bool {
switch self {
case .succeeded, .failed:
return true
case .validating, .processing, .promptImport:
return false
}
}
}
var state: State
var ticketHolder: TicketHolder?

@ -43,8 +43,9 @@ class WalletCoordinator: Coordinator {
case .createInstantWallet:
createInstantWallet()
return false
case .backupWallet:
case .backupWallet(let address):
if let type = keystore.recentlyUsedWallet?.type, case let .real(account) = type {
guard address == account.address.eip55String else { return false }
guard !Config().isWalletAddressAlreadyPromptedForBackUp(address: account.address.eip55String) else { return false }
Config().addToWalletAddressesAlreadyPromptedForBackup(address: account.address.eip55String)
pushBackup(for: account)

@ -6,5 +6,5 @@ enum WalletEntryPoint {
case welcome
case createInstantWallet
case importWallet
case backupWallet
case backupWallet(address: String)
}

Loading…
Cancel
Save