taler-ios

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

commit a4069f8e5d21184172daa774f528334d5798fcd6
parent 744d32a9de9da0ec89a9e5ef93d2963b7f4a8a2f
Author: Marc Stibane <marc@taler.net>
Date:   Mon, 20 Feb 2023 15:11:30 +0100

Constants, cleanup

Diffstat:
MTalerWallet.xcodeproj/project.pbxproj | 4++++
ATalerWallet1/Helper/PublicConstants.swift | 24++++++++++++++++++++++++
MTalerWallet1/Model/ExchangeTestModel.swift | 24++++++++++++------------
MTalerWallet1/Views/Pending/PendingModel.swift | 4++--
MTalerWallet1/Views/Transactions/TransactionsModel.swift | 8--------
MTalerWallet1/Views/Withdraw/WithdrawURIView.swift | 2+-
6 files changed, 43 insertions(+), 23 deletions(-)

diff --git a/TalerWallet.xcodeproj/project.pbxproj b/TalerWallet.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 4EA1ABBE29A3833A008821EA /* PublicConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EA1ABBD29A3833A008821EA /* PublicConstants.swift */; }; 4EB094D629896CD20043A8A1 /* TalerWalletTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB094D429896CD20043A8A1 /* TalerWalletTests.swift */; }; 4EB094D729896CD20043A8A1 /* WalletBackendTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB094D529896CD20043A8A1 /* WalletBackendTests.swift */; }; 4EB094DC29896D030043A8A1 /* TalerWalletUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB094D929896D030043A8A1 /* TalerWalletUITestsLaunchTests.swift */; }; @@ -97,6 +98,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 4EA1ABBD29A3833A008821EA /* PublicConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublicConstants.swift; sourceTree = "<group>"; }; 4EB094D429896CD20043A8A1 /* TalerWalletTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TalerWalletTests.swift; sourceTree = "<group>"; }; 4EB094D529896CD20043A8A1 /* WalletBackendTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WalletBackendTests.swift; sourceTree = "<group>"; }; 4EB094D929896D030043A8A1 /* TalerWalletUITestsLaunchTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TalerWalletUITestsLaunchTests.swift; sourceTree = "<group>"; }; @@ -234,6 +236,7 @@ 4EB095062989CB7C0043A8A1 /* TalerDater.swift */, 4EB095072989CB7C0043A8A1 /* TalerStrings.swift */, 4EB095082989CB7C0043A8A1 /* View+dismissTop.swift */, + 4EA1ABBD29A3833A008821EA /* PublicConstants.swift */, ); path = Helper; sourceTree = "<group>"; @@ -588,6 +591,7 @@ 4EB095562989CBFE0043A8A1 /* TransactionsListView.swift in Sources */, 4EB0951F2989CBCB0043A8A1 /* WalletBackendRequest.swift in Sources */, 4EB095572989CBFE0043A8A1 /* TransactionRow.swift in Sources */, + 4EA1ABBE29A3833A008821EA /* PublicConstants.swift in Sources */, 4EB0956B2989CBFE0043A8A1 /* TextFieldAlert.swift in Sources */, 4EB0956C2989CBFE0043A8A1 /* AmountView.swift in Sources */, 4EB095592989CBFE0043A8A1 /* TransactionsModel.swift in Sources */, diff --git a/TalerWallet1/Helper/PublicConstants.swift b/TalerWallet1/Helper/PublicConstants.swift @@ -0,0 +1,24 @@ +/* + * This file is part of GNU Taler + * (C) 2022 Taler Systems S.A. + * + * GNU Taler is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 3, or (at your option) any later version. + * + * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +import Foundation + +public let EXCHANGEBASEURL = "exchangeBaseUrl" + +public let WITHDRAWAL = "withdrawal" +public let PAYMENT = "payment" +public let REFUND = "refund" +public let TIP = "tip" +public let REFRESH = "refresh" diff --git a/TalerWallet1/Model/ExchangeTestModel.swift b/TalerWallet1/Model/ExchangeTestModel.swift @@ -18,11 +18,11 @@ import taler_swift import SymLog fileprivate let ASYNCDELAY: UInt = 0 //set e.g to 6 or 9 seconds for debugging -fileprivate let EXCHANGEBASEURL = "https://exchange.demo.taler.net/" -fileprivate let BANKBASEURL = "https://bank.demo.taler.net/" -fileprivate let BANKACCESSAPIBASEURL = "https://bank.demo.taler.net/demobanks/default/access-api/" -fileprivate let MERCHANTBASEURL = "https://backend.demo.taler.net/" -fileprivate let MERCHANTAUTHTOKEN = "secret-token:sandbox" +fileprivate let DEMO_EXCHANGEBASEURL = "https://exchange.demo.taler.net/" +fileprivate let DEMO_BANKBASEURL = "https://bank.demo.taler.net/" +fileprivate let DEMO_BANKAPIBASEURL = "https://bank.demo.taler.net/demobanks/default/access-api/" +fileprivate let DEMO_MERCHANTBASEURL = "https://backend.demo.taler.net/" +fileprivate let DEMO_MERCHANTAUTHTOKEN = "secret-token:sandbox" // MARK: - class ExchangeTestModel: WalletModel { @@ -33,9 +33,9 @@ extension ExchangeTestModel { do { let amount = Amount(currency: "KUDOS", integer: 11, fraction: 0) let request = WalletBackendWithdrawTestBalance(amount: amount, - bankBaseUrl: BANKBASEURL, - exchangeBaseUrl: EXCHANGEBASEURL, - bankAccessApiBaseUrl: BANKACCESSAPIBASEURL) + bankBaseUrl: DEMO_BANKBASEURL, + exchangeBaseUrl: DEMO_EXCHANGEBASEURL, + bankAccessApiBaseUrl: DEMO_BANKAPIBASEURL) let response = try await sendRequest(request, ASYNCDELAY) symLog?.log("received: \(response)") } catch { @@ -49,10 +49,10 @@ extension ExchangeTestModel { let amountS = Amount(currency: "KUDOS", integer: 1, fraction: 0) let request = WalletBackendRunIntegration(amountToWithdraw: amountW, amountToSpend: amountS, - bankBaseUrl: BANKACCESSAPIBASEURL, - exchangeBaseUrl: EXCHANGEBASEURL, - merchantBaseUrl: MERCHANTBASEURL, - merchantAuthToken: MERCHANTAUTHTOKEN) + bankBaseUrl: DEMO_BANKAPIBASEURL, + exchangeBaseUrl: DEMO_EXCHANGEBASEURL, + merchantBaseUrl: DEMO_MERCHANTBASEURL, + merchantAuthToken: DEMO_MERCHANTAUTHTOKEN) let response = try await sendRequest(request, ASYNCDELAY) symLog?.log("received: \(response)") } catch { diff --git a/TalerWallet1/Views/Pending/PendingModel.swift b/TalerWallet1/Views/Pending/PendingModel.swift @@ -56,7 +56,7 @@ struct PendingOperation: Codable, Hashable { } //let pending1 = ["type": "exchange-update", -// "exchangeBaseUrl": "https://exchange.demo.taler.net/", +// EXCHANGEBASEURL: "https://exchange.demo.taler.net/", // "id": "exchange-update:https://exchange.demo.taler.net/", // "timestampDue": ["t_ms": 1669931055000], // "isDue": false, @@ -64,7 +64,7 @@ struct PendingOperation: Codable, Hashable { // "givesLifeness": false] as [String : Any] // //let pending2 = ["type": "exchange-check-refresh", -// "exchangeBaseUrl": "https://exchange.demo.taler.net/", +// EXCHANGEBASEURL: "https://exchange.demo.taler.net/", // "id": "exchange-update:https://exchange.demo.taler.net/", // "timestampDue": ["t_ms": 1670013862000], // "isDue": false, diff --git a/TalerWallet1/Views/Transactions/TransactionsModel.swift b/TalerWallet1/Views/Transactions/TransactionsModel.swift @@ -22,14 +22,6 @@ fileprivate let ASYNCDELAY: UInt = 0 //set e.g to 6 or 9 seconds for debugging class TransactionsModel: WalletModel { @Published var transactions: [Transaction]? // update view } -//extension Transaction { -// func exchangeBaseUrl() -> String { -// switch detail { -// case .withdrawal(let transactionWithdrawal): -// return transactionWithdrawal.exchangeBaseUrl -// } -// } -//} // MARK: - /// A request to get the transactions in the wallet's history. diff --git a/TalerWallet1/Views/Withdraw/WithdrawURIView.swift b/TalerWallet1/Views/Withdraw/WithdrawURIView.swift @@ -66,7 +66,7 @@ struct WithdrawURIView: View { symLog.log(".task") detailsForUri = try await viewModel.loadWithdrawalDetailsForURI(url.absoluteString) let baseURL = detailsForUri!.defaultExchangeBaseUrl - symLog.log("amount: \(detailsForUri!.amount), baseURL: \(baseURL)") + symLog.log("amount: \(detailsForUri!.amount), baseURL: \(String(describing: baseURL))") // TODO: let user choose exchange from array detailsForAmount = try await viewModel.loadWithdrawalDetailsForAmount(detailsForUri!) symLog.log("raw: \(detailsForAmount!.amountRaw), effective: \(detailsForAmount!.amountEffective)")