taler-ios

iOS apps for GNU Taler (wallet)
Log | Files | Refs | README | LICENSE

commit bf9bfba90aed389a0ff802b861a3c0dc5882518b
parent 949faafeaefa0ed08545b7315aec6309919594c3
Author: Marc Stibane <marc@taler.net>
Date:   Tue,  8 Aug 2023 12:18:26 +0200

Wallet changes + bugfixes

Diffstat:
MTalerWallet1/Backend/WalletBackendRequest.swift | 13+++++++------
MTalerWallet1/Backend/WalletCore.swift | 2+-
MTalerWallet1/Model/WalletModel.swift | 2+-
MTalerWallet1/Views/Exchange/ManualWithdraw.swift | 2+-
4 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/TalerWallet1/Backend/WalletBackendRequest.swift b/TalerWallet1/Backend/WalletBackendRequest.swift @@ -28,18 +28,19 @@ struct ScopeInfo: Codable, Hashable { enum ScopeInfoType: String, Codable { case global case exchange + case auditor } var type: ScopeInfoType - var exchangeBaseUrl: String? // only for "exchange" + var url: String? // only for "exchange" var currency: String public static func == (lhs: ScopeInfo, rhs: ScopeInfo) -> Bool { - if let lhsBaseURL = lhs.exchangeBaseUrl { - if let rhsBaseURL = rhs.exchangeBaseUrl { + if let lhsBaseURL = lhs.url { + if let rhsBaseURL = rhs.url { if lhsBaseURL != rhsBaseURL { return false } // different exchanges // else fall thru and check type & currency } else { return false } // left but not right - } else if rhs.exchangeBaseUrl != nil { + } else if rhs.url != nil { return false // right but not left } return lhs.type == rhs.type && @@ -47,8 +48,8 @@ struct ScopeInfo: Codable, Hashable { } public func hash(into hasher: inout Hasher) { hasher.combine(type) - if let baseURL = exchangeBaseUrl { - hasher.combine(baseURL) + if let url { + hasher.combine(url) } hasher.combine(currency) } diff --git a/TalerWallet1/Backend/WalletCore.swift b/TalerWallet1/Backend/WalletCore.swift @@ -186,7 +186,7 @@ extension WalletCore { do { let decoded = try JSONDecoder().decode(TransactionTransition.self, from: jsonData) if decoded.newTxState != decoded.oldTxState { - let components = decoded.transactionId.components(separatedBy: [":"]) + let components = decoded.transactionId.components(separatedBy: ":") if components.count >= 3 { // txn:$txtype:$uid if let type = TransactionType(rawValue: components[1]) { guard type != .refresh else { return } diff --git a/TalerWallet1/Model/WalletModel.swift b/TalerWallet1/Model/WalletModel.swift @@ -69,7 +69,7 @@ fileprivate struct GetTransactionById: WalletBackendFormattedRequest { // MARK: - /// The info returned from Wallet-core init struct VersionInfo: Decodable { - var hash: String + var hash: String? var version: String var exchange: String var merchant: String diff --git a/TalerWallet1/Views/Exchange/ManualWithdraw.swift b/TalerWallet1/Views/Exchange/ManualWithdraw.swift @@ -25,7 +25,7 @@ struct ManualWithdraw: View { let _ = Self._printChanges() let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear #endif - let currency = exchange.currency! + let currency = exchange.currency ?? String(localized: "Unknown", comment: "unknown currency") let navTitle = String(localized: "Withdraw \(currency)") let currencyField = CurrencyField(value: $centsToTransfer, currency: currency) // becomeFirstResponder // let agePicker = AgePicker(ageMenuList: $ageMenuList, selectedAge: $selectedAge)