summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/wallet.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-10-17 20:43:03 +0200
committerFlorian Dold <florian@dold.me>2023-10-17 20:43:09 +0200
commit39ba26c7623a380c15bf183d25ec8f1fd60b65b6 (patch)
treeb77c3881d2bad24b397ff599bf329d23c789bb38 /packages/taler-wallet-core/src/wallet.ts
parent503cbfbb95828677b83212816951eb501de2a8fe (diff)
downloadwallet-core-39ba26c7623a380c15bf183d25ec8f1fd60b65b6.tar.gz
wallet-core-39ba26c7623a380c15bf183d25ec8f1fd60b65b6.tar.bz2
wallet-core-39ba26c7623a380c15bf183d25ec8f1fd60b65b6.zip
wallet-core: implement listExchangesForScopedCurrency
Diffstat (limited to 'packages/taler-wallet-core/src/wallet.ts')
-rw-r--r--packages/taler-wallet-core/src/wallet.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts
index 06d9bb9e8..6600aa799 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -129,6 +129,9 @@ import {
setDangerousTimetravel,
TestingWaitTransactionRequest,
codecForUpdateExchangeEntryRequest,
+ codecForListExchangesForScopedCurrencyRequest,
+ ListExchangesForScopedCurrencyRequest,
+ ExchangesShortListResponse,
} from "@gnu-taler/taler-util";
import type { HttpRequestLibrary } from "@gnu-taler/taler-util/http";
import { readSuccessResponseJsonOrThrow } from "@gnu-taler/taler-util/http";
@@ -1132,6 +1135,24 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
case WalletApiOperation.ListExchanges: {
return await getExchanges(ws);
}
+ case WalletApiOperation.ListExchangesForScopedCurrency: {
+ const req =
+ codecForListExchangesForScopedCurrencyRequest().decode(payload);
+ const exchangesResp = await getExchanges(ws);
+ const result: ExchangesShortListResponse = {
+ exchanges: [],
+ };
+ // Right now we only filter on the currency, as wallet-core doesn't
+ // fully support scoped currencies yet.
+ for (const exch of exchangesResp.exchanges) {
+ if (exch.currency === req.scope.currency) {
+ result.exchanges.push({
+ exchangeBaseUrl: exch.exchangeBaseUrl,
+ });
+ }
+ }
+ return result;
+ }
case WalletApiOperation.GetExchangeDetailedInfo: {
const req = codecForAddExchangeRequest().decode(payload);
return await getExchangeDetailedInfo(ws, req.exchangeBaseUrl);