aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Stibane <marc@taler.net>2023-10-13 19:22:22 +0200
committerMarc Stibane <marc@taler.net>2023-10-13 19:22:22 +0200
commitc6cd080659131d682b26749904afdaca96eb691b (patch)
treeac667f5db8b767a44b853a4c96086c3f7287fba5
parent608250ee9a2126147b9b4c133ac57c1db91a3b94 (diff)
downloadtaler-ios-c6cd080659131d682b26749904afdaca96eb691b.tar.gz
taler-ios-c6cd080659131d682b26749904afdaca96eb691b.tar.bz2
taler-ios-c6cd080659131d682b26749904afdaca96eb691b.zip
updateExchange
-rw-r--r--TalerWallet1/Model/Model+Exchange.swift23
1 files changed, 22 insertions, 1 deletions
diff --git a/TalerWallet1/Model/Model+Exchange.swift b/TalerWallet1/Model/Model+Exchange.swift
index bf4a2ca..7ac8d72 100644
--- a/TalerWallet1/Model/Model+Exchange.swift
+++ b/TalerWallet1/Model/Model+Exchange.swift
@@ -82,10 +82,23 @@ 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) }
+
+ var scopeInfo: ScopeInfo
+
+ struct Args: Encodable {
+ var scopeInfo: ScopeInfo
+ }
+}
+
/// 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" }
+ func operation() -> String { return "addExchange" } // addExchangeEntry
func args() -> Args { return Args(exchangeBaseUrl: exchangeBaseUrl) }
var exchangeBaseUrl: String
@@ -129,6 +142,14 @@ extension WalletModel {
_ = try await sendRequest(request)
}
+ /// ask wallet-core to update an existing exchange by querying it for denominations, fees, and scoped currency info
+ func updateExchange(scopeInfo: ScopeInfo)
+ async throws {
+ let request = UpdateExchange(scopeInfo: scopeInfo)
+ logger.info("updating exchange for: \(scopeInfo.currency, privacy: .public)")
+ _ = try await sendRequest(request)
+ }
+
@MainActor func getCurrencySpecificationM(scope: ScopeInfo)
async throws -> CurrencySpecification { // M for MainActor
let request = GetCurrencySpecification(scope: scope)