[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.
- [taler-taler-ios] branch master updated (adfc919 -> a0c6bdb), gnunet, 2023/10/21
- [taler-taler-ios] 10/11: Use CurrencyFormatter for Balance, gnunet, 2023/10/21
- [taler-taler-ios] 11/11: Minimalistic, gnunet, 2023/10/21
- [taler-taler-ios] 06/11: listExchangesForScopedCurrency,
gnunet <=
- [taler-taler-ios] 04/11: cleanup, gnunet, 2023/10/21
- [taler-taler-ios] 01/11: CurrencySpecification, gnunet, 2023/10/21
- [taler-taler-ios] 03/11: ExchangeListItem, gnunet, 2023/10/21
- [taler-taler-ios] 05/11: getCurrencyInfo(scope), gnunet, 2023/10/21
- [taler-taler-ios] 02/11: HTTPError, gnunet, 2023/10/21
- [taler-taler-ios] 09/11: Call AboutView, gnunet, 2023/10/21
- [taler-taler-ios] 08/11: AboutView, gnunet, 2023/10/21
- [taler-taler-ios] 07/11: cache currency infos, gnunet, 2023/10/21