commit 949faafeaefa0ed08545b7315aec6309919594c3
parent 98be8e4302e7d8db8f8ea858a82b25c9e1a3924e
Author: Marc Stibane <marc@taler.net>
Date: Tue, 8 Aug 2023 12:16:54 +0200
GetScopedCurrencyInfo
Diffstat:
1 file changed, 28 insertions(+), 0 deletions(-)
diff --git a/TalerWallet1/Model/Model+Exchange.swift b/TalerWallet1/Model/Model+Exchange.swift
@@ -76,6 +76,26 @@ fileprivate struct AddExchange: WalletBackendFormattedRequest {
var exchangeBaseUrl: String
}
}
+
+/// A request to get info about a currency
+struct ScopedCurrencyInfo: Decodable {
+ var decimalSeparator: String
+ var numFractionalDigits: Int // 0 Yen, 2 €,$, 3 arabic
+ var numTinyDigits: Int // SuperScriptDigits
+ var isCurrencyNameLeading: Bool
+}
+
+fileprivate struct GetScopedCurrencyInfo: WalletBackendFormattedRequest {
+ typealias Response = ScopedCurrencyInfo
+ func operation() -> String { return "getScopedCurrencyInfo" }
+ func args() -> Args { return Args(scope: scope) }
+
+ var scope: ScopeInfo
+
+ struct Args: Encodable {
+ var scope: ScopeInfo
+ }
+}
// MARK: -
extension WalletModel {
/// ask wallet-core for its list of known exchanges
@@ -97,4 +117,12 @@ extension WalletModel {
logger.info("adding exchange: \(url, privacy: .public)")
_ = try await sendRequest(request)
}
+
+ @MainActor func getScopedCurrencyInfoM(scope: ScopeInfo)
+ async throws -> ScopedCurrencyInfo { // M for MainActor
+ let request = GetScopedCurrencyInfo(scope: scope)
+ let response = try await sendRequest(request, ASYNCDELAY)
+ return response
+ }
+
}