Merge pull request #359 from James-Sangalli/fix-prompting-backup-wallet-after-switching-away-from-it

Fix: was prompting to backup new wallets
pull/364/head
James Sangalli 7 years ago committed by GitHub
commit 5fd96a0fc0
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. 5
      Trust/Market/Coordinators/UniversalLinkCoordinator.swift
  5. 3
      Trust/Wallet/Coordinators/WalletCoordinator.swift
  6. 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()

@ -273,8 +273,9 @@ class UniversalLinkCoordinator: Coordinator {
promptBackupWallet()
}
private func promptBackupWallet() {
let coordinator = PromptBackupCoordinator()
private func promptBackupWallet() {
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()

@ -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