summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Stibane <marc@taler.net>2023-08-08 12:16:54 +0200
committerMarc Stibane <marc@taler.net>2023-08-08 12:16:54 +0200
commit949faafeaefa0ed08545b7315aec6309919594c3 (patch)
treefd205cb045b0e37b58a73c7fad32aff03f0884e0
parent98be8e4302e7d8db8f8ea858a82b25c9e1a3924e (diff)
downloadtaler-ios-949faafeaefa0ed08545b7315aec6309919594c3.tar.gz
taler-ios-949faafeaefa0ed08545b7315aec6309919594c3.tar.bz2
taler-ios-949faafeaefa0ed08545b7315aec6309919594c3.zip
GetScopedCurrencyInfo
-rw-r--r--TalerWallet1/Model/Model+Exchange.swift28
1 files changed, 28 insertions, 0 deletions
diff --git a/TalerWallet1/Model/Model+Exchange.swift b/TalerWallet1/Model/Model+Exchange.swift
index 8446893..434311d 100644
--- 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
+ }
+
}