commit c6cd080659131d682b26749904afdaca96eb691b
parent 608250ee9a2126147b9b4c133ac57c1db91a3b94
Author: Marc Stibane <marc@taler.net>
Date: Fri, 13 Oct 2023 19:22:22 +0200
updateExchange
Diffstat:
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git 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)