gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated: wallet-core: implement listEx


From: gnunet
Subject: [taler-wallet-core] branch master updated: wallet-core: implement listExchangesForScopedCurrency
Date: Tue, 17 Oct 2023 20:43:12 +0200

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

dold pushed a commit to branch master
in repository wallet-core.

The following commit(s) were added to refs/heads/master by this push:
     new 39ba26c76 wallet-core: implement listExchangesForScopedCurrency
39ba26c76 is described below

commit 39ba26c7623a380c15bf183d25ec8f1fd60b65b6
Author: Florian Dold <florian@dold.me>
AuthorDate: Tue Oct 17 20:43:03 2023 +0200

    wallet-core: implement listExchangesForScopedCurrency
---
 packages/taler-util/src/wallet-types.ts            | 28 ++++++++++++++++++----
 packages/taler-wallet-core/src/wallet-api-types.ts | 14 +++++++++++
 packages/taler-wallet-core/src/wallet.ts           | 21 ++++++++++++++++
 3 files changed, 58 insertions(+), 5 deletions(-)

diff --git a/packages/taler-util/src/wallet-types.ts 
b/packages/taler-util/src/wallet-types.ts
index 49dae9bd4..de9948ea6 100644
--- a/packages/taler-util/src/wallet-types.ts
+++ b/packages/taler-util/src/wallet-types.ts
@@ -426,6 +426,16 @@ export const codecForGetCurrencyInfoRequest =
       .property("scope", codecForScopeInfo())
       .build("GetCurrencySpecificationRequest");
 
+export interface ListExchangesForScopedCurrencyRequest {
+  scope: ScopeInfo;
+}
+
+export const codecForListExchangesForScopedCurrencyRequest =
+  (): Codec<ListExchangesForScopedCurrencyRequest> =>
+    buildCodecForObject<ListExchangesForScopedCurrencyRequest>()
+      .property("scope", codecForScopeInfo())
+      .build("ListExchangesForScopedCurrencyRequest");
+
 export interface GetCurrencySpecificationResponse {
   currencySpecification: CurrencySpecification;
 }
@@ -547,11 +557,11 @@ export interface CoinDumpJson {
     withdrawal_reserve_pub: string | undefined;
     coin_status: CoinStatus;
     spend_allocation:
-    | {
-      id: string;
-      amount: string;
-    }
-    | undefined;
+      | {
+          id: string;
+          amount: string;
+        }
+      | undefined;
     /**
      * Information about the age restriction
      */
@@ -1045,6 +1055,10 @@ export interface DepositInfo {
   ageCommitmentProof?: AgeCommitmentProof;
 }
 
+export interface ExchangesShortListResponse {
+  exchanges: ShortExchangeListItem[];
+}
+
 export interface ExchangesListResponse {
   exchanges: ExchangeListItem[];
 }
@@ -1282,6 +1296,10 @@ export interface OperationErrorInfo {
   error: TalerErrorDetail;
 }
 
+export interface ShortExchangeListItem {
+  exchangeBaseUrl: string;
+}
+
 // FIXME: This should probably include some error status.
 export interface ExchangeListItem {
   exchangeBaseUrl: string;
diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts 
b/packages/taler-wallet-core/src/wallet-api-types.ts
index a8de9ac03..b974aa4bb 100644
--- a/packages/taler-wallet-core/src/wallet-api-types.ts
+++ b/packages/taler-wallet-core/src/wallet-api-types.ts
@@ -55,6 +55,7 @@ import {
   DeleteTransactionRequest,
   ExchangeDetailedResponse,
   ExchangesListResponse,
+  ExchangesShortListResponse,
   FailTransactionRequest,
   ForceRefreshRequest,
   ForgetKnownBankAccountsRequest,
@@ -77,6 +78,7 @@ import {
   InitiatePeerPushDebitResponse,
   IntegrationTestArgs,
   KnownBankAccounts,
+  ListExchangesForScopedCurrencyRequest,
   ListKnownBankAccountsRequest,
   ManualWithdrawalDetails,
   PrepareDepositRequest,
@@ -225,6 +227,7 @@ export enum WalletApiOperation {
   RecoverStoredBackup = "recoverStoredBackup",
   UpdateExchangeEntry = "updateExchangeEntry",
   TestingWaitTasksProcessed = "testingWaitTasksProcessed",
+  ListExchangesForScopedCurrency = "listExchangesForScopedCurrency",
 }
 
 // group: Initialization
@@ -556,6 +559,16 @@ export type ListExchangesOp = {
   response: ExchangesListResponse;
 };
 
+/**
+ * List exchanges that are available for withdrawing a particular
+ * scoped currency.
+ */
+export type ListExchangesForScopedCurrencyOp = {
+  op: WalletApiOperation.ListExchangesForScopedCurrency;
+  request: ListExchangesForScopedCurrencyRequest;
+  response: ExchangesShortListResponse;
+};
+
 /**
  * Add / force-update an exchange.
  */
@@ -1105,6 +1118,7 @@ export type WalletOperations = {
   [WalletApiOperation.AcceptBankIntegratedWithdrawal]: 
AcceptBankIntegratedWithdrawalOp;
   [WalletApiOperation.AcceptManualWithdrawal]: AcceptManualWithdrawalOp;
   [WalletApiOperation.ListExchanges]: ListExchangesOp;
+  [WalletApiOperation.ListExchangesForScopedCurrency]: 
ListExchangesForScopedCurrencyOp;
   [WalletApiOperation.AddExchange]: AddExchangeOp;
   [WalletApiOperation.ListKnownBankAccounts]: ListKnownBankAccountsOp;
   [WalletApiOperation.AddKnownBankAccounts]: AddKnownBankAccountsOp;
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);

-- 
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]