taler-ios

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

commit 3e2da084e65b6ee5b121d0915609418d91f8f4cc
parent 0ebc3a84249e00a44d9fe4cdc4cc836211e83cf0
Author: Marc Stibane <marc@taler.net>
Date:   Fri, 20 Oct 2023 08:43:15 +0200

cleanup

Diffstat:
MTalerWallet.xcodeproj/project.pbxproj | 2+-
MTalerWallet1/Backend/WalletBackendRequest.swift | 138+++++++++++++++++++++++--------------------------------------------------------
MTalerWallet1/Model/Model+Balances.swift | 4++--
MTalerWallet1/Model/Model+Exchange.swift | 29++++++++++++++---------------
MTalerWallet1/Model/Model+P2P.swift | 38+++++++++++++++++++-------------------
MTalerWallet1/Model/Model+Payment.swift | 12++++++------
MTalerWallet1/Model/Model+Pending.swift | 2+-
MTalerWallet1/Model/Model+Settings.swift | 33+++++++++++++++------------------
MTalerWallet1/Model/Model+Transactions.swift | 26+++++++++++++-------------
MTalerWallet1/Model/Model+Withdraw.swift | 24++++++++++++------------
MTalerWallet1/Model/WalletModel.swift | 10+++++-----
MTalerWallet1/Views/Balances/BalancesListView.swift | 2+-
MTalerWallet1/Views/Balances/BalancesSectionView.swift | 10+++++-----
13 files changed, 134 insertions(+), 196 deletions(-)

diff --git a/TalerWallet.xcodeproj/project.pbxproj b/TalerWallet.xcodeproj/project.pbxproj @@ -794,7 +794,7 @@ D14AFD1E24D232B300C51073 /* Products */ = { isa = PBXGroup; children = ( - 4E3EAE892A990778009F1BE8 /* GNU_Taler.app */, + 4E3EAE892A990778009F1BE8 /* GNU_Taler.app */, D14AFD1D24D232B300C51073 /* Taler_Wallet.app */, D14AFD3324D232B500C51073 /* TalerTests.xctest */, D14AFD3E24D232B500C51073 /* TalerUITests.xctest */, diff --git a/TalerWallet1/Backend/WalletBackendRequest.swift b/TalerWallet1/Backend/WalletBackendRequest.swift @@ -111,12 +111,15 @@ struct OrderShortInfo: Codable { // MARK: - /// A request to process a refund. struct WalletBackendApplyRefundRequest: WalletBackendFormattedRequest { + func operation() -> String { "applyRefund" } + func args() -> Args { Args(talerRefundUri: talerRefundUri) } + var talerRefundUri: String - + struct Args: Encodable { var talerRefundUri: String } - + struct Response: Decodable { var contractTermsHash: String var amountEffectivePaid: Amount @@ -125,38 +128,27 @@ struct WalletBackendApplyRefundRequest: WalletBackendFormattedRequest { var pendingAtExchange: Bool var info: OrderShortInfo } - - func operation() -> String { - return "applyRefund" - } - - func args() -> Args { - return Args(talerRefundUri: talerRefundUri) - } } /// A request to force update an exchange. struct WalletBackendForceUpdateRequest: WalletBackendFormattedRequest { + func operation() -> String { "addRequest" } + func args() -> Args { Args(exchangeBaseUrl: exchangeBaseUrl) } + var exchangeBaseUrl: String - struct Args: Encodable { var exchangeBaseUrl: String } - + struct Response: Decodable {} - - func operation() -> String { - return "addRequest" - } - - func args() -> Args { - return Args(exchangeBaseUrl: exchangeBaseUrl) - } } /// A request to deposit funds. struct WalletBackendCreateDepositGroupRequest: WalletBackendFormattedRequest { + func operation() -> String { "createDepositGroup" } + func args() -> Args { Args(depositPayToUri: depositePayToUri, amount: amount) } + var depositePayToUri: String var amount: Amount @@ -168,52 +160,32 @@ struct WalletBackendCreateDepositGroupRequest: WalletBackendFormattedRequest { struct Response: Decodable { var depositGroupId: String } - - func operation() -> String { - return "createDepositGroup" - } - - func args() -> Args { - return Args(depositPayToUri: depositePayToUri, amount: amount) - } } /// A request to get information about a payment request. struct WalletBackendPreparePayRequest: WalletBackendFormattedRequest { + func operation() -> String { "preparePay" } + func args() -> Args { Args(talerPayUri: talerPayUri) } var talerPayUri: String - + struct Args: Encodable { var talerPayUri: String } - + struct Response: Decodable {} - - func operation() -> String { - return "preparePay" - } - - func args() -> Args { - return Args(talerPayUri: talerPayUri) - } } /// A request to confirm a payment. struct WalletBackendConfirmPayRequest: WalletBackendFormattedRequest { + func operation() -> String { "confirmPay" } + func args() -> Args { Args(proposalId: proposalId) } var proposalId: String - + struct Args: Encodable { var proposalId: String } - + struct Response: Decodable {} - - func operation() -> String { - return "confirmPay" - } - - func args() -> Args { - return Args(proposalId: proposalId) - } } // MARK: - @@ -229,8 +201,8 @@ struct PrepareRewardResponse: Decodable { /// A request to prepare a reward. struct PrepareRewardRequest: WalletBackendFormattedRequest { typealias Response = PrepareRewardResponse - func operation() -> String { return "prepareReward" } - func args() -> Args { return Args(talerRewardUri: talerRewardUri) } + func operation() -> String { "prepareReward" } + func args() -> Args { Args(talerRewardUri: talerRewardUri) } var talerRewardUri: String struct Args: Encodable { @@ -241,8 +213,8 @@ struct PrepareRewardRequest: WalletBackendFormattedRequest { /// A request to accept a reward. struct AcceptRewardRequest: WalletBackendFormattedRequest { struct Response: Decodable {} - func operation() -> String { return "acceptReward" } - func args() -> Args { return Args(walletRewardId: walletRewardId) } + func operation() -> String { "acceptReward" } + func args() -> Args { Args(walletRewardId: walletRewardId) } var walletRewardId: String struct Args: Encodable { @@ -252,21 +224,16 @@ struct AcceptRewardRequest: WalletBackendFormattedRequest { // MARK: - /// A request to abort a failed payment. struct WalletBackendAbortFailedPaymentRequest: WalletBackendFormattedRequest { + func operation() -> String { "abortFailedPayWithRefund" } + func args() -> Args { Args(proposalId: proposalId) } + var proposalId: String - struct Args: Encodable { var proposalId: String } struct Response: Decodable {} - func operation() -> String { - return "abortFailedPayWithRefund" - } - - func args() -> Args { - return Args(proposalId: proposalId) - } } // MARK: - struct IntegrationTestArgs: Codable { @@ -280,19 +247,13 @@ struct IntegrationTestArgs: Codable { /// A request to run a basic integration test. struct WalletBackendRunIntegrationTestRequest: WalletBackendFormattedRequest { + func operation() -> String { "runIntegrationTest" } + func args() -> Args { integrationTestArgs } var integrationTestArgs: IntegrationTestArgs typealias Args = IntegrationTestArgs struct Response: Decodable {} - - func operation() -> String { - return "runIntegrationTest" - } - - func args() -> Args { - return integrationTestArgs - } } struct TestPayArgs: Codable { @@ -304,19 +265,13 @@ struct TestPayArgs: Codable { /// A request to make a test payment. struct WalletBackendTestPayRequest: WalletBackendFormattedRequest { + func operation() -> String { "testPay" } + func args() -> Args { testPayArgs } + var testPayArgs: TestPayArgs - typealias Args = TestPayArgs struct Response: Decodable {} - - func operation() -> String { - return "testPay" - } - - func args() -> Args { - return testPayArgs - } } struct Coin: Codable { @@ -333,25 +288,22 @@ struct Coin: Codable { /// A request to dump all coins to JSON. struct WalletBackendDumpCoinsRequest: WalletBackendFormattedRequest { - struct Args: Encodable { - - } - + func operation() -> String { "dumpCoins" } + func args() -> Args { Args() } + struct Args: Encodable { } + struct Response: Decodable { var coins: [Coin] } - func operation() -> String { - return "dumpCoins" - } - - func args() -> Args { - return Args() - } } /// A request to suspend or unsuspend a coin. struct WalletBackendSuspendCoinRequest: WalletBackendFormattedRequest { + struct Response: Decodable {} + func operation() -> String { "setCoinSuspended" } + func args() -> Args { Args(coinPub: coinPub, suspended: suspended) } + var coinPub: String var suspended: Bool @@ -359,16 +311,6 @@ struct WalletBackendSuspendCoinRequest: WalletBackendFormattedRequest { var coinPub: String var suspended: Bool } - - struct Response: Decodable {} - - func operation() -> String { - return "setCoinSuspended" - } - - func args() -> Args { - return Args(coinPub: coinPub, suspended: suspended) - } } diff --git a/TalerWallet1/Model/Model+Balances.swift b/TalerWallet1/Model/Model+Balances.swift @@ -31,8 +31,8 @@ struct Balance: Decodable, Hashable, Sendable { // MARK: - /// A request to get the balances held in the wallet. fileprivate struct Balances: WalletBackendFormattedRequest { - func operation() -> String { return "getBalances" } - func args() -> Args { return Args() } + func operation() -> String { "getBalances" } + func args() -> Args { Args() } struct Args: Encodable {} // no arguments needed diff --git a/TalerWallet1/Model/Model+Exchange.swift b/TalerWallet1/Model/Model+Exchange.swift @@ -7,6 +7,10 @@ import taler_swift import SymLog fileprivate let ASYNCDELAY: UInt = 0 //set e.g to 6 or 9 seconds for debugging +struct ExchangeError: Codable, Hashable { + var error: HTTPError +} + enum ExchangeEntryStatus: String, Codable { case preset case ephemeral @@ -43,9 +47,7 @@ struct Exchange: Codable, Hashable, Identifiable { var ageRestrictionOptions: [Int] var lastUpdateErrorInfo: ExchangeError? - var id: String { - exchangeBaseUrl - } + var id: String { exchangeBaseUrl } var name: String? { if let url = URL(string: exchangeBaseUrl) { if let host = url.host { @@ -56,9 +58,6 @@ struct Exchange: Codable, Hashable, Identifiable { } } -struct ExchangeError: Codable, Hashable { - var error: HTTPError -} struct ExchangeListItem: Codable, Hashable { var exchangeBaseUrl: String var currency: String @@ -79,8 +78,8 @@ struct ExchangeListItem: Codable, Hashable { // MARK: - /// A request to list exchanges. fileprivate struct ListExchanges: WalletBackendFormattedRequest { - func operation() -> String { return "listExchanges" } - func args() -> Args { return Args() } + func operation() -> String { "listExchanges" } + func args() -> Args { Args() } struct Args: Encodable {} // no arguments needed @@ -92,8 +91,8 @@ fileprivate struct ListExchanges: WalletBackendFormattedRequest { /// A request to update a single exchange. fileprivate struct UpdateExchange: WalletBackendFormattedRequest { struct Response: Decodable {} // no result - getting no error back means success - func operation() -> String { return "updateExchangeEntry" } - func args() -> Args { return Args(scopeInfo: scopeInfo) } + func operation() -> String { "updateExchangeEntry" } + func args() -> Args { Args(scopeInfo: scopeInfo) } var scopeInfo: ScopeInfo @@ -105,8 +104,8 @@ fileprivate struct UpdateExchange: WalletBackendFormattedRequest { /// A request to add an exchange. fileprivate struct AddExchange: WalletBackendFormattedRequest { struct Response: Decodable {} // no result - getting no error back means success - func operation() -> String { return "addExchange" } // addExchangeEntry - func args() -> Args { return Args(exchangeBaseUrl: exchangeBaseUrl) } + func operation() -> String { "addExchange" } // addExchangeEntry + func args() -> Args { Args(exchangeBaseUrl: exchangeBaseUrl) } var exchangeBaseUrl: String @@ -117,9 +116,9 @@ fileprivate struct AddExchange: WalletBackendFormattedRequest { /// A request to get info about a currency fileprivate struct GetCurrencySpecification: WalletBackendFormattedRequest { - typealias Response = CurrencySpecification - func operation() -> String { return "getCurrencySpecification" } - func args() -> Args { return Args(scope: scope) } + typealias Response = CurrencySpecification2 + func operation() -> String { "getCurrencySpecification" } + func args() -> Args { Args(scope: scope) } var scope: ScopeInfo diff --git a/TalerWallet1/Model/Model+P2P.swift b/TalerWallet1/Model/Model+P2P.swift @@ -22,8 +22,8 @@ struct AmountResponse: Codable { } fileprivate struct GetMaxPeerPushAmount: WalletBackendFormattedRequest { typealias Response = AmountResponse - func operation() -> String { return "GetMaxPeerPushAmount" } - func args() -> Args { return Args(currency: currency) } + func operation() -> String { "GetMaxPeerPushAmount" } + func args() -> Args { Args(currency: currency) } var currency: String struct Args: Encodable { @@ -48,8 +48,8 @@ struct CheckPeerPushDebitResponse: Codable { } fileprivate struct CheckPeerPushDebit: WalletBackendFormattedRequest { typealias Response = CheckPeerPushDebitResponse - func operation() -> String { return "checkPeerPushDebit" } - func args() -> Args { return Args(amount: amount) } + func operation() -> String { "checkPeerPushDebit" } + func args() -> Args { Args(amount: amount) } var amount: Amount struct Args: Encodable { @@ -77,9 +77,9 @@ struct InitiatePeerPushDebitResponse: Codable { } fileprivate struct InitiatePeerPushDebit: WalletBackendFormattedRequest { typealias Response = InitiatePeerPushDebitResponse - func operation() -> String { return "initiatePeerPushDebit" } - func args() -> Args { return Args(exchangeBaseUrl: exchangeBaseUrl, - partialContractTerms: partialContractTerms) } + func operation() -> String { "initiatePeerPushDebit" } + func args() -> Args { Args(exchangeBaseUrl: exchangeBaseUrl, + partialContractTerms: partialContractTerms) } var exchangeBaseUrl: String? var partialContractTerms: PeerContractTerms @@ -109,8 +109,8 @@ struct CheckPeerPullCreditResponse: Codable { } fileprivate struct CheckPeerPullCredit: WalletBackendFormattedRequest { typealias Response = CheckPeerPullCreditResponse - func operation() -> String { return "checkPeerPullCredit" } - func args() -> Args { return Args(exchangeBaseUrl: exchangeBaseUrl, scopeInfo: scopeInfo, amount: amount) } + func operation() -> String { "checkPeerPullCredit" } + func args() -> Args { Args(exchangeBaseUrl: exchangeBaseUrl, scopeInfo: scopeInfo, amount: amount) } var exchangeBaseUrl: String? var scopeInfo: ScopeInfo? @@ -138,8 +138,8 @@ struct InitiatePeerPullCreditResponse: Codable { } fileprivate struct InitiatePeerPullCredit: WalletBackendFormattedRequest { typealias Response = InitiatePeerPullCreditResponse - func operation() -> String { return "initiatePeerPullCredit" } - func args() -> Args { return Args(exchangeBaseUrl: exchangeBaseUrl, + func operation() -> String { "initiatePeerPullCredit" } + func args() -> Args { Args(exchangeBaseUrl: exchangeBaseUrl, partialContractTerms: partialContractTerms) } var exchangeBaseUrl: String? @@ -170,8 +170,8 @@ struct PreparePeerPushCreditResponse: Codable { } fileprivate struct PreparePeerPushCredit: WalletBackendFormattedRequest { typealias Response = PreparePeerPushCreditResponse - func operation() -> String { return "preparePeerPushCredit" } - func args() -> Args { return Args(talerUri: talerUri) } + func operation() -> String { "preparePeerPushCredit" } + func args() -> Args { Args(talerUri: talerUri) } var talerUri: String struct Args: Encodable { @@ -191,8 +191,8 @@ extension WalletModel { /// Accept an incoming peer push payment fileprivate struct AcceptPeerPushCredit: WalletBackendFormattedRequest { struct Response: Decodable {} // no result - getting no error back means success - func operation() -> String { return "confirmPeerPushCredit" } // should be "acceptPeerPushCredit" - func args() -> Args { return Args(transactionId: transactionId) } + func operation() -> String { "confirmPeerPushCredit" } // should be "acceptPeerPushCredit" + func args() -> Args { Args(transactionId: transactionId) } var transactionId: String struct Args: Encodable { @@ -219,8 +219,8 @@ struct PreparePeerPullDebitResponse: Codable { } fileprivate struct PreparePeerPullDebit: WalletBackendFormattedRequest { typealias Response = PreparePeerPullDebitResponse - func operation() -> String { return "preparePeerPullDebit" } - func args() -> Args { return Args(talerUri: talerUri) } + func operation() -> String { "preparePeerPullDebit" } + func args() -> Args { Args(talerUri: talerUri) } var talerUri: String struct Args: Encodable { @@ -240,8 +240,8 @@ extension WalletModel { /// Confirm incoming peer push request(invoice) and pay fileprivate struct ConfirmPeerPullDebit: WalletBackendFormattedRequest { struct Response: Decodable {} // no result - getting no error back means success - func operation() -> String { return "confirmPeerPullDebit" } - func args() -> Args { return Args(transactionId: transactionId) } + func operation() -> String { "confirmPeerPullDebit" } + func args() -> Args { Args(transactionId: transactionId) } var transactionId: String struct Args: Encodable { diff --git a/TalerWallet1/Model/Model+Payment.swift b/TalerWallet1/Model/Model+Payment.swift @@ -139,8 +139,8 @@ struct PreparePayResult: Codable { /// A request to get an exchange's payment contract terms. fileprivate struct PreparePayForUri: WalletBackendFormattedRequest { typealias Response = PreparePayResult - func operation() -> String { return "preparePayForUri" } - func args() -> Args { return Args(talerPayUri: talerPayUri) } + func operation() -> String { "preparePayForUri" } + func args() -> Args { Args(talerPayUri: talerPayUri) } var talerPayUri: String struct Args: Encodable { @@ -150,8 +150,8 @@ fileprivate struct PreparePayForUri: WalletBackendFormattedRequest { /// A request to get an exchange's payment contract terms. fileprivate struct PreparePayForTemplate: WalletBackendFormattedRequest { typealias Response = PreparePayResult - func operation() -> String { return "preparePayForTemplate" } - func args() -> Args { return Args(talerPayTemplateUri: talerPayTemplateUri) } + func operation() -> String { "preparePayForTemplate" } + func args() -> Args { Args(talerPayTemplateUri: talerPayTemplateUri) } var talerPayTemplateUri: String struct Args: Encodable { @@ -168,8 +168,8 @@ struct ConfirmPayResult: Decodable { /// A request to get an exchange's payment details. fileprivate struct confirmPayForUri: WalletBackendFormattedRequest { typealias Response = ConfirmPayResult - func operation() -> String { return "confirmPay" } - func args() -> Args { return Args(transactionId: transactionId) } + func operation() -> String { "confirmPay" } + func args() -> Args { Args(transactionId: transactionId) } var transactionId: String struct Args: Encodable { diff --git a/TalerWallet1/Model/Model+Pending.swift b/TalerWallet1/Model/Model+Pending.swift @@ -11,7 +11,7 @@ fileprivate let ASYNCDELAY: UInt = 0 //set e.g to 6 or 9 seconds for debugging // MARK: - /// A request to list the backend's currently pending operations. fileprivate struct GetPendingOperations: WalletBackendFormattedRequest { - func operation() -> String { return "getPendingOperations" } + func operation() -> String { "getPendingOperations" } func args() -> Args { Args() } struct Args: Encodable {} diff --git a/TalerWallet1/Model/Model+Settings.swift b/TalerWallet1/Model/Model+Settings.swift @@ -13,13 +13,12 @@ fileprivate let MERCHANTAUTHTOKEN = "secret-token:sandbox" /// A request to add a test balance to the wallet. fileprivate struct WithdrawTestBalanceRequest: WalletBackendFormattedRequest { struct Response: Decodable {} // no result - getting no error back means success - func operation() -> String { return "withdrawTestBalance" } - func args() -> Args { - return Args(amount: amount, -// bankBaseUrl: bankBaseUrl, - corebankApiBaseUrl: corebankApiBaseUrl, - exchangeBaseUrl: exchangeBaseUrl) - } + func operation() -> String { "withdrawTestBalance" } + func args() -> Args { Args(amount: amount, +// bankBaseUrl: bankBaseUrl, + corebankApiBaseUrl: corebankApiBaseUrl, + exchangeBaseUrl: exchangeBaseUrl) + } var amount: Amount // var bankBaseUrl: String @@ -48,17 +47,15 @@ extension WalletModel { /// A request to add a test balance to the wallet. fileprivate struct RunIntegrationTest: WalletBackendFormattedRequest { struct Response: Decodable {} // no result - getting no error back means success - func operation() -> String { return newVersion ? "runIntegrationTestV2" : "runIntegrationTest" } - func args() -> Args { - return Args(exchangeBaseUrl: exchangeBaseUrl, -// bankBaseUrl: bankBaseUrl, - corebankApiBaseUrl: corebankApiBaseUrl, - merchantBaseUrl: merchantBaseUrl, - merchantAuthToken: merchantAuthToken, - amountToWithdraw: amountToWithdraw, - amountToSpend: amountToSpend - ) - } + func operation() -> String { newVersion ? "runIntegrationTestV2" : "runIntegrationTest" } + func args() -> Args { Args(exchangeBaseUrl: exchangeBaseUrl, +// bankBaseUrl: bankBaseUrl, + corebankApiBaseUrl: corebankApiBaseUrl, + merchantBaseUrl: merchantBaseUrl, + merchantAuthToken: merchantAuthToken, + amountToWithdraw: amountToWithdraw, + amountToSpend: amountToSpend) + } let newVersion: Bool diff --git a/TalerWallet1/Model/Model+Transactions.swift b/TalerWallet1/Model/Model+Transactions.swift @@ -35,9 +35,9 @@ extension WalletModel { // MARK: - /// A request to get the transactions in the wallet's history. fileprivate struct GetTransactions: WalletBackendFormattedRequest { - func operation() -> String { return "getTransactions" } -// func operation() -> String { return "testingGetSampleTransactions" } - func args() -> Args { return Args(currency: currency, search: search, sort: sort) } + func operation() -> String { "getTransactions" } +// func operation() -> String { "testingGetSampleTransactions" } + func args() -> Args { Args(currency: currency, search: search, sort: sort) } var currency: String? var search: String? @@ -55,8 +55,8 @@ fileprivate struct GetTransactions: WalletBackendFormattedRequest { /// A request to abort a wallet transaction by ID. struct AbortTransaction: WalletBackendFormattedRequest { struct Response: Decodable {} // no result - getting no error back means success - func operation() -> String { return "abortTransaction" } - func args() -> Args { return Args(transactionId: transactionId) } + func operation() -> String { "abortTransaction" } + func args() -> Args { Args(transactionId: transactionId) } var transactionId: String struct Args: Encodable { @@ -66,8 +66,8 @@ struct AbortTransaction: WalletBackendFormattedRequest { /// A request to delete a wallet transaction by ID. struct DeleteTransaction: WalletBackendFormattedRequest { struct Response: Decodable {} // no result - getting no error back means success - func operation() -> String { return "deleteTransaction" } - func args() -> Args { return Args(transactionId: transactionId) } + func operation() -> String { "deleteTransaction" } + func args() -> Args { Args(transactionId: transactionId) } var transactionId: String struct Args: Encodable { @@ -77,8 +77,8 @@ struct DeleteTransaction: WalletBackendFormattedRequest { /// A request to delete a wallet transaction by ID. struct FailTransaction: WalletBackendFormattedRequest { struct Response: Decodable {} // no result - getting no error back means success - func operation() -> String { return "failTransaction" } - func args() -> Args { return Args(transactionId: transactionId) } + func operation() -> String { "failTransaction" } + func args() -> Args { Args(transactionId: transactionId) } var transactionId: String struct Args: Encodable { @@ -88,8 +88,8 @@ struct FailTransaction: WalletBackendFormattedRequest { /// A request to suspend a wallet transaction by ID. struct SuspendTransaction: WalletBackendFormattedRequest { struct Response: Decodable {} // no result - getting no error back means success - func operation() -> String { return "suspendTransaction" } - func args() -> Args { return Args(transactionId: transactionId) } + func operation() -> String { "suspendTransaction" } + func args() -> Args { Args(transactionId: transactionId) } var transactionId: String struct Args: Encodable { @@ -99,8 +99,8 @@ struct SuspendTransaction: WalletBackendFormattedRequest { /// A request to suspend a wallet transaction by ID. struct ResumeTransaction: WalletBackendFormattedRequest { struct Response: Decodable {} // no result - getting no error back means success - func operation() -> String { return "resumeTransaction" } - func args() -> Args { return Args(transactionId: transactionId) } + func operation() -> String { "resumeTransaction" } + func args() -> Args { Args(transactionId: transactionId) } var transactionId: String struct Args: Encodable { diff --git a/TalerWallet1/Model/Model+Withdraw.swift b/TalerWallet1/Model/Model+Withdraw.swift @@ -17,8 +17,8 @@ struct WithdrawUriInfoResponse: Decodable { /// A request to get an exchange's withdrawal details. fileprivate struct GetWithdrawalDetailsForURI: WalletBackendFormattedRequest { typealias Response = WithdrawUriInfoResponse - func operation() -> String { return "getWithdrawalDetailsForUri" } - func args() -> Args { return Args(talerWithdrawUri: talerWithdrawUri) } + func operation() -> String { "getWithdrawalDetailsForUri" } + func args() -> Args { Args(talerWithdrawUri: talerWithdrawUri) } var talerWithdrawUri: String struct Args: Encodable { @@ -38,8 +38,8 @@ struct WithdrawalAmountDetails: Decodable { /// A request to get an exchange's withdrawal details. fileprivate struct GetWithdrawalDetailsForAmount: WalletBackendFormattedRequest { typealias Response = WithdrawalAmountDetails - func operation() -> String { return "getWithdrawalDetailsForAmount" } - func args() -> Args { return Args(exchangeBaseUrl: exchangeBaseUrl, amount: amount) } + func operation() -> String { "getWithdrawalDetailsForAmount" } + func args() -> Args { Args(exchangeBaseUrl: exchangeBaseUrl, amount: amount) } var exchangeBaseUrl: String var amount: Amount @@ -69,8 +69,8 @@ struct ExchangeTermsOfService: Decodable { /// A request to query an exchange's terms of service. fileprivate struct GetExchangeTermsOfService: WalletBackendFormattedRequest { typealias Response = ExchangeTermsOfService - func operation() -> String { return "getExchangeTos" } - func args() -> Args { return Args(exchangeBaseUrl: exchangeBaseUrl, acceptedFormat: acceptedFormat) } + func operation() -> String { "getExchangeTos" } + func args() -> Args { Args(exchangeBaseUrl: exchangeBaseUrl, acceptedFormat: acceptedFormat) } var exchangeBaseUrl: String var acceptedFormat: [String]? @@ -82,8 +82,8 @@ fileprivate struct GetExchangeTermsOfService: WalletBackendFormattedRequest { /// A request to mark an exchange's terms of service as accepted. fileprivate struct SetExchangeTOSAccepted: WalletBackendFormattedRequest { struct Response: Decodable {} // no result - getting no error back means success - func operation() -> String { return "setExchangeTosAccepted" } - func args() -> Args { return Args(exchangeBaseUrl: exchangeBaseUrl, etag: etag) } + func operation() -> String { "setExchangeTosAccepted" } + func args() -> Args { Args(exchangeBaseUrl: exchangeBaseUrl, etag: etag) } var exchangeBaseUrl: String var etag: String @@ -102,8 +102,8 @@ struct AcceptWithdrawalResponse: Decodable { /// A request to accept a bank-integrated withdrawl. fileprivate struct AcceptBankIntegratedWithdrawal: WalletBackendFormattedRequest { typealias Response = AcceptWithdrawalResponse - func operation() -> String { return "acceptBankIntegratedWithdrawal" } - func args() -> Args { return Args(talerWithdrawUri: talerWithdrawUri, exchangeBaseUrl: exchangeBaseUrl) } + func operation() -> String { "acceptBankIntegratedWithdrawal" } + func args() -> Args { Args(talerWithdrawUri: talerWithdrawUri, exchangeBaseUrl: exchangeBaseUrl) } var talerWithdrawUri: String var exchangeBaseUrl: String @@ -122,8 +122,8 @@ struct AcceptManualWithdrawalResult: Decodable { /// A request to accept a manual withdrawl. fileprivate struct AcceptManualWithdrawal: WalletBackendFormattedRequest { typealias Response = AcceptManualWithdrawalResult - func operation() -> String { return "acceptManualWithdrawal" } - func args() -> Args { return Args(exchangeBaseUrl: exchangeBaseUrl, amount: amount, restrictAge: restrictAge) } + func operation() -> String { "acceptManualWithdrawal" } + func args() -> Args { Args(exchangeBaseUrl: exchangeBaseUrl, amount: amount, restrictAge: restrictAge) } var exchangeBaseUrl: String var amount: Amount diff --git a/TalerWallet1/Model/WalletModel.swift b/TalerWallet1/Model/WalletModel.swift @@ -68,8 +68,8 @@ class WalletModel: ObservableObject { /// A request to get a wallet transaction by ID. fileprivate struct GetTransactionById: WalletBackendFormattedRequest { typealias Response = Transaction - func operation() -> String { return "getTransactionById" } - func args() -> Args { return Args(transactionId: transactionId) } + func operation() -> String { "getTransactionById" } + func args() -> Args { Args(transactionId: transactionId) } var transactionId: String @@ -90,7 +90,7 @@ struct VersionInfo: Decodable { // MARK: - /// A request to initialize Wallet-core fileprivate struct InitRequest: WalletBackendFormattedRequest { - func operation() -> String { return "init" } + func operation() -> String { "init" } func args() -> Args { return Args(persistentStoragePath: persistentStoragePath, // cryptoWorkerType: "sync", @@ -158,8 +158,8 @@ extension WalletModel { // MARK: - /// A request to initialize Wallet-core fileprivate struct ResetRequest: WalletBackendFormattedRequest { - func operation() -> String { return "reset" } - func args() -> Args { return Args() } + func operation() -> String { "reset" } + func args() -> Args { Args() } struct Args: Encodable {} // no arguments needed struct Response: Decodable {} diff --git a/TalerWallet1/Views/Balances/BalancesListView.swift b/TalerWallet1/Views/Balances/BalancesListView.swift @@ -146,7 +146,7 @@ extension BalancesListView { WalletEmptyView(stack: stack.push("isEmpty")) } else { List(balances, id: \.self) { balance in - BalancesSectionView(stack: stack.push("\(balance.available.currencyStr)"), + BalancesSectionView(stack: stack.push("\(balance.scopeInfo.currency)"), balance: balance, sectionCount: count, centsToTransfer: $centsToTransfer, diff --git a/TalerWallet1/Views/Balances/BalancesSectionView.swift b/TalerWallet1/Views/Balances/BalancesSectionView.swift @@ -39,21 +39,21 @@ struct BalancesSectionView { @State private var shownSectionID = UUID() // guaranteed to be different the first time func reloadCompleted(_ stack: CallStack) async -> () { - let currency = balance.available.currencyStr + let currency = balance.scopeInfo.currency transactions = await model.transactionsT(stack.push(), currency: currency) completedTransactions = WalletModel.completedTransactions(transactions) // sectionID = UUID() } func reloadPending(_ stack: CallStack) async -> () { - let currency = balance.available.currencyStr + let currency = balance.scopeInfo.currency transactions = await model.transactionsT(stack.push(), currency: currency) pendingTransactions = WalletModel.pendingTransactions(transactions) // sectionID = UUID() } func reloadUncompleted(_ stack: CallStack) async -> () { - let currency = balance.available.currencyStr + let currency = balance.scopeInfo.currency transactions = await model.transactionsT(stack.push(), currency: currency) uncompletedTransactions = WalletModel.uncompletedTransactions(transactions) // sectionID = UUID() @@ -66,7 +66,7 @@ extension BalancesSectionView: View { let _ = Self._printChanges() let _ = symLog.vlog() // just to get the # to compare it with .onAppear & onDisappear #endif - let currency = balance.available.currencyStr + let currency = balance.scopeInfo.currency Section { if "KUDOS" == currency && !balance.available.isZero { @@ -244,7 +244,7 @@ fileprivate struct BalancesNavigationLinksView: View { } var body: some View { - let currency = balance.available.currencyStr + let currency = balance.scopeInfo.currency HStack(spacing: 0) { NavigationLink(destination: LazyView { SendAmount(stack: stack.push(),