gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-ios] 06/11: listExchangesForScopedCurrency


From: gnunet
Subject: [taler-taler-ios] 06/11: listExchangesForScopedCurrency
Date: Sat, 21 Oct 2023 21:10:04 +0200

This is an automated email from the git hooks/post-receive script.

marc-stibane pushed a commit to branch master
in repository taler-ios.

commit fa93599052d1eb19046a3a3952636b83eaaaa0e9
Author: Marc Stibane <marc@taler.net>
AuthorDate: Fri Oct 20 08:51:58 2023 +0200

    listExchangesForScopedCurrency
---
 TalerWallet1/Model/Model+Exchange.swift | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/TalerWallet1/Model/Model+Exchange.swift 
b/TalerWallet1/Model/Model+Exchange.swift
index 0622245..524f462 100644
--- a/TalerWallet1/Model/Model+Exchange.swift
+++ b/TalerWallet1/Model/Model+Exchange.swift
@@ -75,7 +75,27 @@ struct ExchangeListItem: Codable, Hashable {
         hasher.combine(paytoUris)
     }
 }
+
+struct ExchangeUrlItem: Codable, Hashable, Identifiable {
+    var exchangeBaseUrl: String
+    var id: String { exchangeBaseUrl }
+}
 // MARK: -
+/// A request to list exchanges names for a currency
+fileprivate struct ListExchangesForScopedCurrency: 
WalletBackendFormattedRequest {
+    func operation() -> String { "listExchangesForScopedCurrency" }
+    func args() -> Args { Args(scope: scope) }
+
+    var scope: ScopeInfo
+
+    struct Args: Encodable {
+        var scope: ScopeInfo
+    }
+    struct Response: Decodable, Sendable {
+        var exchanges: [ExchangeUrlItem]              // list of Exchange names
+    }
+}
+
 /// A request to list exchanges.
 fileprivate struct ListExchanges: WalletBackendFormattedRequest {
     func operation() -> String { "listExchanges" }
@@ -128,6 +148,18 @@ fileprivate struct GetCurrencySpecification: 
WalletBackendFormattedRequest {
 }
 // MARK: -
 extension WalletModel {
+    /// ask wallet-core for its list of known exchanges
+    @MainActor func listExchangesForScopedCurrencyM(scope: ScopeInfo)
+      async -> [ExchangeUrlItem] {            // M for MainActor
+        do {
+            let request = ListExchangesForScopedCurrency(scope: scope)
+            let response = try await sendRequest(request, ASYNCDELAY)
+            return response.exchanges
+        } catch {
+            return []               // empty, but not nil
+        }
+    }
+
     /// ask wallet-core for its list of known exchanges
     @MainActor func listExchangesM()
       async -> [Exchange] {   // M for MainActor

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]