diff --git a/Kukai Mobile.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Kukai Mobile.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 4e5f67a9..7a06fd62 100644 --- a/Kukai Mobile.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Kukai Mobile.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -70,7 +70,7 @@ "location" : "https://github.com/kukai-wallet/kukai-core-swift", "state" : { "branch" : "develop", - "revision" : "d4c59332acc9d6d32ae45e5d4cbf441a0e9e1b46" + "revision" : "20c37e6e9344500c64d550a644b29c1b2185af87" } }, { diff --git a/Kukai Mobile/Modules/Account/AccountViewModel.swift b/Kukai Mobile/Modules/Account/AccountViewModel.swift index e717b1a3..35ef6f59 100644 --- a/Kukai Mobile/Modules/Account/AccountViewModel.swift +++ b/Kukai Mobile/Modules/Account/AccountViewModel.swift @@ -207,6 +207,7 @@ class AccountViewModel: ViewModel, UITableViewDiffableDataSourceHandler { } let metadata = DependencyManager.shared.selectedWalletMetadata + let parentMetadata = metadata?.isChild == true ? DependencyManager.shared.walletList.parentMetadata(forChildAddress: metadata?.address ?? "") : nil let isTestnet = DependencyManager.shared.currentNetworkType == .testnet var snapshot = NSDiffableDataSourceSnapshot() var data: [AnyHashable] = [] @@ -224,7 +225,7 @@ class AccountViewModel: ViewModel, UITableViewDiffableDataSourceHandler { data = handleRefreshForNewUser(startingData: data, metadata: metadata) } else { - data = handleRefreshForRegularUser(startingData: data, metadata: metadata, selectedAddress: selectedAddress) + data = handleRefreshForRegularUser(startingData: data, metadata: metadata, parentMetadata: parentMetadata, selectedAddress: selectedAddress) } } else { @@ -261,10 +262,10 @@ class AccountViewModel: ViewModel, UITableViewDiffableDataSourceHandler { return (xtzBalance == .zero() && tokenCount == 0) } - private func handleRefreshForRegularUser(startingData: [AnyHashable], metadata: WalletMetadata?, selectedAddress: String) -> [AnyHashable] { + private func handleRefreshForRegularUser(startingData: [AnyHashable], metadata: WalletMetadata?, parentMetadata: WalletMetadata?, selectedAddress: String) -> [AnyHashable] { var data = startingData - if metadata?.backedUp == false { + if metadata?.backedUp == false && (parentMetadata == nil || parentMetadata?.backedUp != true) { data.append(BackupCellData()) } diff --git a/Kukai Mobile/Modules/Home/AccountsViewModel.swift b/Kukai Mobile/Modules/Home/AccountsViewModel.swift index 50451aa9..8b3298b1 100644 --- a/Kukai Mobile/Modules/Home/AccountsViewModel.swift +++ b/Kukai Mobile/Modules/Home/AccountsViewModel.swift @@ -339,7 +339,7 @@ class AccountsViewModel: ViewModel, UITableViewDiffableDataSourceHandler { let addAccount = UIAction(title: "Add Account", image: UIImage(named: "AddNewAccount")) { [weak self] action in vc.showLoadingView() - AddAccountViewModel.addAccount(forMetadata: walletMetadata, hdWalletIndex: hdWalletIndex) { [weak self] errorTitle, errorMessage in + AddAccountViewModel.addAccount(forMetadata: walletMetadata, hdWalletIndex: hdWalletIndex, forceMainnet: false) { [weak self] errorTitle, errorMessage in vc.hideLoadingView() if let title = errorTitle, let message = errorMessage { vc.windowError(withTitle: title, description: message) diff --git a/Kukai Mobile/Modules/Home/AddAccountViewController.swift b/Kukai Mobile/Modules/Home/AddAccountViewController.swift index 48ff6b62..2fdf14ca 100644 --- a/Kukai Mobile/Modules/Home/AddAccountViewController.swift +++ b/Kukai Mobile/Modules/Home/AddAccountViewController.swift @@ -75,7 +75,7 @@ extension AddAccountViewController: UITableViewDelegate { tableView.selectRow(at: indexPath, animated: true, scrollPosition: .none) self.showLoadingView() - AddAccountViewModel.addAccount(forMetadata: metadata, hdWalletIndex: indexPath.section) { [weak self] errorTitle, errorMessage in + AddAccountViewModel.addAccount(forMetadata: metadata, hdWalletIndex: indexPath.section, forceMainnet: false) { [weak self] errorTitle, errorMessage in self?.hideLoadingView() if let title = errorTitle, let message = errorMessage { diff --git a/Kukai Mobile/Modules/Home/AddAccountViewModel.swift b/Kukai Mobile/Modules/Home/AddAccountViewModel.swift index 603d48fe..a5eb1f58 100644 --- a/Kukai Mobile/Modules/Home/AddAccountViewModel.swift +++ b/Kukai Mobile/Modules/Home/AddAccountViewModel.swift @@ -89,7 +89,7 @@ class AddAccountViewModel: ViewModel, UITableViewDiffableDataSourceHandler { return dataSource?.itemIdentifier(for: indexPath) as? WalletMetadata } - public static func isPreviousAccountUsed(forAddress address: String, completion: @escaping ((Bool) -> Void)) { + public static func isPreviousAccountUsed(forAddress address: String, forceMainnet: Bool, completion: @escaping ((Bool) -> Void)) { var metadataToCheck = DependencyManager.shared.walletList.metadata(forAddress: address) if (metadataToCheck?.children.count ?? 0) > 0, let last = metadataToCheck?.children.last { metadataToCheck = last @@ -100,12 +100,12 @@ class AddAccountViewModel: ViewModel, UITableViewDiffableDataSourceHandler { return } - WalletManagementService.isUsedAccount(address: meta.address, completion: completion) + WalletManagementService.isUsedAccount(address: meta.address, forceMainnet: forceMainnet, completion: completion) } - public static func addAccount(forMetadata walletMetadata: WalletMetadata, hdWalletIndex: Int, completion: @escaping ((String?, String?) -> Void)) { + public static func addAccount(forMetadata walletMetadata: WalletMetadata, hdWalletIndex: Int, forceMainnet: Bool, completion: @escaping ((String?, String?) -> Void)) { - AddAccountViewModel.isPreviousAccountUsed(forAddress: walletMetadata.address, completion: { isUsed in + AddAccountViewModel.isPreviousAccountUsed(forAddress: walletMetadata.address, forceMainnet: forceMainnet, completion: { isUsed in guard isUsed else { completion("error-previous-account-title".localized(), "error-previous-account-empty".localized()) return diff --git a/Kukai Mobile/Modules/RecoveryPhrase/VerifyRecoveryPhraseViewController.swift b/Kukai Mobile/Modules/RecoveryPhrase/VerifyRecoveryPhraseViewController.swift index 762901e4..1289fe60 100644 --- a/Kukai Mobile/Modules/RecoveryPhrase/VerifyRecoveryPhraseViewController.swift +++ b/Kukai Mobile/Modules/RecoveryPhrase/VerifyRecoveryPhraseViewController.swift @@ -297,11 +297,17 @@ class VerifyRecoveryPhraseViewController: UIViewController { private func compareIndexesAndNavigate() { if realWordIndexes.contains(selectedIndexes) { + guard let address = (sideMenuOption_address ?? DependencyManager.shared.selectedWalletAddress) else { return } + // Check if we are backing up from a child wallet, if so, switch out to its parent var metadata = DependencyManager.shared.walletList.metadata(forAddress: address) + if metadata?.isChild == true { + let parent = DependencyManager.shared.walletList.parentMetadata(forChildAddress: metadata?.address ?? "") + metadata = parent + } metadata?.backedUp = true guard let meta = metadata else { @@ -309,11 +315,11 @@ class VerifyRecoveryPhraseViewController: UIViewController { } let walletCache = WalletCacheService() - let _ = DependencyManager.shared.walletList.update(address: address, with: meta) + let _ = DependencyManager.shared.walletList.update(address: meta.address, with: meta) // load meta address so we pick up parent let _ = walletCache.encryptAndWriteMetadataToDisk(DependencyManager.shared.walletList) DependencyManager.shared.walletList = walletCache.readMetadataFromDiskAndDecrypt() - DependencyManager.shared.selectedWalletMetadata = DependencyManager.shared.walletList.metadata(forAddress: address) + DependencyManager.shared.selectedWalletMetadata = DependencyManager.shared.walletList.metadata(forAddress: address) // make sure we don't use meta address so we reload the child self.navigate() } diff --git a/Kukai Mobile/Modules/Send/Base.lproj/Send.storyboard b/Kukai Mobile/Modules/Send/Base.lproj/Send.storyboard index 95f7f33c..a2ea4769 100644 --- a/Kukai Mobile/Modules/Send/Base.lproj/Send.storyboard +++ b/Kukai Mobile/Modules/Send/Base.lproj/Send.storyboard @@ -1,9 +1,9 @@ - + - + @@ -575,7 +575,7 @@ -