From c59257b27c5d085231cbb68cb27067c69b6826b9 Mon Sep 17 00:00:00 2001 From: Francisco Gindre Date: Fri, 10 Feb 2023 13:54:12 -0300 Subject: [PATCH] This adopts the `getRecipient()` function of 0.18.1-beta. (#323) It lets the wallet know the recipient addresses of a given transaction set package manager `upToNextMinor` with 0.18.0-beta Update packages Adopt fs_cache_db changes of Zcash SDK. (#322) * Adopt fs_cache_db changes of Zcash SDK. Fixes #306 * Point ZcashLightClientKit to main branch * Fix `fixPendingDbName()` when file already was migrated Adopt Current ZcashLightClientKit commit `cf60f44aa83938432c81361917406483ff42c719` --- wallet/ECC-Wallet.xcodeproj/project.pbxproj | 11 +--------- .../xcshareddata/swiftpm/Package.resolved | 8 +++++++ wallet/wallet/Components/DetailCard.swift | 10 ++++----- .../Environment/CombineSynchronizer.swift | 4 +++- .../Environment/ZECCWalletEnvironment.swift | 21 ------------------- 5 files changed, 17 insertions(+), 37 deletions(-) diff --git a/wallet/ECC-Wallet.xcodeproj/project.pbxproj b/wallet/ECC-Wallet.xcodeproj/project.pbxproj index 16794b4..c4a6e9e 100644 --- a/wallet/ECC-Wallet.xcodeproj/project.pbxproj +++ b/wallet/ECC-Wallet.xcodeproj/project.pbxproj @@ -754,7 +754,6 @@ 0D1250F623B557E40014EE3A = { isa = PBXGroup; children = ( - 34030EE8297A88B300552CAD /* Packages */, 0D12510123B557E40014EE3A /* wallet */, 0D12511823B557E60014EE3A /* walletTests */, 0D12512323B557E60014EE3A /* walletUITests */, @@ -980,14 +979,6 @@ path = Components; sourceTree = ""; }; - 34030EE8297A88B300552CAD /* Packages */ = { - isa = PBXGroup; - children = ( - 0D9F91D7297F2EF70012617D /* ZcashLightClientKit */, - ); - name = Packages; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -2297,7 +2288,7 @@ repositoryURL = "https://github.com/zcash/ZcashLightClientKit"; requirement = { kind = revision; - revision = fad3aae1743467686db8e3a77998baa2ca823fce; + revision = cf60f44aa83938432c81361917406483ff42c719; }; }; /* End XCRemoteSwiftPackageReference section */ diff --git a/wallet/ECC-Wallet.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/wallet/ECC-Wallet.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 2823f75..0dc77e6 100644 --- a/wallet/ECC-Wallet.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/wallet/ECC-Wallet.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -189,6 +189,14 @@ "version" : "0.2.0" } }, + { + "identity" : "zcashlightclientkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/zcash/ZcashLightClientKit", + "state" : { + "revision" : "cf60f44aa83938432c81361917406483ff42c719" + } + }, { "identity" : "zealous-logger", "kind" : "remoteSourceControl", diff --git a/wallet/wallet/Components/DetailCard.swift b/wallet/wallet/Components/DetailCard.swift index 12bad71..4c14fe8 100644 --- a/wallet/wallet/Components/DetailCard.swift +++ b/wallet/wallet/Components/DetailCard.swift @@ -217,13 +217,13 @@ extension Date { extension DetailModel { - init(transaction: ZcashTransaction.Overview, memos: [Memo]) { + init(transaction: ZcashTransaction.Overview, memos: [Memo], recipients: [TransactionRecipient]) { self.date = Date(timeIntervalSince1970: transaction.blockTime ?? 0) self.id = transaction.rawID.toHexStringTxId() self.shielded = true self.status = transaction.isSentTransaction ? .paid(success: (transaction.minedHeight ?? 0) > 0) : .received self.subtitle = transaction.isSentTransaction ? "wallet_history_sent".localized() + " \(self.date.transactionDetail)" : "Received".localized() + " \(self.date.transactionDetail)" - self.zAddress = nil + self.zAddress = recipients.first?.stringEncodedAddress self.amount = transaction.isSentTransaction ? -transaction.value : transaction.value if let memo = memos.first { self.memo = memo.toString() @@ -307,11 +307,11 @@ extension PendingTransactionRecipient { case .address(let recipient): switch recipient { case .sapling(let saplingAddress): - return saplingAddress.stringEncoded.shortAddress + return saplingAddress.stringEncoded case .transparent(let transparentAddress): - return transparentAddress.stringEncoded.shortAddress + return transparentAddress.stringEncoded case .unified(let unified): - return unified.stringEncoded.shortAddress + return unified.stringEncoded } case .internalAccount(let account): return "Funds shielded account \(account)" diff --git a/wallet/wallet/Environment/CombineSynchronizer.swift b/wallet/wallet/Environment/CombineSynchronizer.swift index 83a3b0e..8b209b6 100644 --- a/wallet/wallet/Environment/CombineSynchronizer.swift +++ b/wallet/wallet/Environment/CombineSynchronizer.swift @@ -337,7 +337,9 @@ extension CombineSynchronizer { memos = [] } - return DetailModel(transaction: transaction, memos: memos) + let recipients = self.synchronizer.getRecipients(for: transaction) + + return DetailModel(transaction: transaction, memos: memos, recipients: recipients) } .filter { detailModel in pending.first { (p) -> Bool in p.id == detailModel.id } == nil diff --git a/wallet/wallet/Environment/ZECCWalletEnvironment.swift b/wallet/wallet/Environment/ZECCWalletEnvironment.swift index d8e3842..d06471a 100644 --- a/wallet/wallet/Environment/ZECCWalletEnvironment.swift +++ b/wallet/wallet/Environment/ZECCWalletEnvironment.swift @@ -232,27 +232,6 @@ final class ZECCWalletEnvironment: ObservableObject { case .wipeAttemptWhileProcessing: return WalletError.genericErrorWithMessage(message: synchronizerError.localizedDescription) } - } else if let serviceError = error as? LightWalletServiceError { - switch serviceError { - case .criticalError: - return WalletError.criticalError(error: serviceError) - case .userCancelled: - return WalletError.connectionFailed - case .unknown: - return WalletError.connectionFailed - case .failed: - return WalletError.connectionFailedWithError(error: error) - case .generalError: - return WalletError.connectionFailed - case .invalidBlock: - return WalletError.genericErrorWithError(error: error) - case .sentFailed(let error): - return WalletError.sendFailed(error: error) - case .genericError(error: let error): - return WalletError.genericErrorWithError(error: error) - case .timeOut: - return WalletError.networkTimeout - } } return WalletError.genericErrorWithError(error: error)