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: only specify tra


From: gnunet
Subject: [taler-wallet-core] branch master updated: wallet-core: only specify transfer amount for currency conversion withdrawals
Date: Tue, 28 Nov 2023 19:17:37 +0100

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 27578b074 wallet-core: only specify transfer amount for currency 
conversion withdrawals
27578b074 is described below

commit 27578b07404370351b5b511b3d3af0e8b2c77223
Author: Florian Dold <florian@dold.me>
AuthorDate: Tue Nov 28 19:17:38 2023 +0100

    wallet-core: only specify transfer amount for currency conversion 
withdrawals
---
 .../src/integrationtests/test-withdrawal-conversion.ts | 15 +++++++--------
 packages/taler-util/src/wallet-types.ts                | 18 +++++++++++++++++-
 packages/taler-wallet-core/src/operations/withdraw.ts  |  5 ++++-
 packages/taler-wallet-core/src/wallet.ts               |  8 ++++++++
 4 files changed, 36 insertions(+), 10 deletions(-)

diff --git 
a/packages/taler-harness/src/integrationtests/test-withdrawal-conversion.ts 
b/packages/taler-harness/src/integrationtests/test-withdrawal-conversion.ts
index 08ae38bf2..69c6427ca 100644
--- a/packages/taler-harness/src/integrationtests/test-withdrawal-conversion.ts
+++ b/packages/taler-harness/src/integrationtests/test-withdrawal-conversion.ts
@@ -196,10 +196,9 @@ export async function runWithdrawalConversionTest(t: 
GlobalTestState) {
 
   console.log(`withdrawal details: ${j2s(infoRes)}`);
 
-  t.assertAmountEquals(
-    infoRes.withdrawalAccountList[0].transferAmount,
-    "FOO:123",
-  );
+  const checkTransferAmount = infoRes.withdrawalAccountList[0].transferAmount;
+  t.assertTrue(checkTransferAmount != null);
+  t.assertAmountEquals(checkTransferAmount, "FOO:123");
 
   const tStart = AbsoluteTime.now();
 
@@ -217,10 +216,10 @@ export async function runWithdrawalConversionTest(t: 
GlobalTestState) {
   logger.info("AcceptManualWithdrawal finished");
   logger.info(`result: ${j2s(wres)}`);
 
-  t.assertAmountEquals(
-    wres.withdrawalAccountsList[0].transferAmount,
-    "FOO:123",
-  );
+  const acceptedTransferAmount = wres.withdrawalAccountsList[0].transferAmount;
+  t.assertTrue(acceptedTransferAmount != null);
+
+  t.assertAmountEquals(acceptedTransferAmount, "FOO:123");
 
   const txInfo = await walletClient.call(
     WalletApiOperation.GetTransactionById,
diff --git a/packages/taler-util/src/wallet-types.ts 
b/packages/taler-util/src/wallet-types.ts
index 022f42f13..c67c59646 100644
--- a/packages/taler-util/src/wallet-types.ts
+++ b/packages/taler-util/src/wallet-types.ts
@@ -1395,6 +1395,8 @@ export const codecForExchangesListResponse = (): 
Codec<ExchangesListResponse> =>
 export interface AcceptManualWithdrawalResult {
   /**
    * Payto URIs that can be used to fund the withdrawal.
+   *
+   * @deprecated in favor of withdrawalAccountsList
    */
   exchangePaytoUris: string[];
 
@@ -1449,6 +1451,11 @@ export interface ManualWithdrawalDetails {
    * the array of ages.
    */
   ageRestrictionOptions?: number[];
+
+  /**
+   * Scope info of the currency withdrawn.
+   */
+  scopeInfo: ScopeInfo;
 }
 
 /**
@@ -2779,8 +2786,17 @@ export interface WithdrawalExchangeAccountDetails {
    * amount for withdrawal.
    *
    * Redundant with the amount in paytoUri, just included to avoid parsing.
+   *
+   * Only included if this account does a currency conversion.
+   */
+  transferAmount?: AmountString;
+
+  /**
+   * Currency specification for the external currency.
+   *
+   * Only included if this account requires a currency conversion.
    */
-  transferAmount: AmountString;
+  currencySpecification?: CurrencySpecification;
 
   /**
    * Further restrictions for sending money to the
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts 
b/packages/taler-wallet-core/src/operations/withdraw.ts
index c7a44bf0f..9c798e813 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -2589,7 +2589,7 @@ async function fetchWithdrawalAccountInfo(
   const withdrawalAccounts: WithdrawalExchangeAccountDetails[] = [];
   for (let acct of exchangeDetails.wireInfo.accounts) {
     let paytoUri: string;
-    let transferAmount: AmountString;
+    let transferAmount: AmountString | undefined = undefined;
     if (acct.conversion_url != null) {
       const reqUrl = new URL("cashin-rate", acct.conversion_url);
       reqUrl.searchParams.set(
@@ -2622,6 +2622,9 @@ async function fetchWithdrawalAccountInfo(
       transferAmount,
       creditRestrictions: acct.credit_restrictions,
     };
+    if (transferAmount != null) {
+      acctInfo.transferAmount = transferAmount;
+    }
     withdrawalAccounts.push(acctInfo);
   }
   return withdrawalAccounts;
diff --git a/packages/taler-wallet-core/src/wallet.ts 
b/packages/taler-wallet-core/src/wallet.ts
index 6b9e960ce..507d72cce 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -52,6 +52,7 @@ import {
   NotificationType,
   RecoverStoredBackupRequest,
   RefreshReason,
+  ScopeType,
   StoredBackupList,
   TalerError,
   TalerErrorCode,
@@ -1209,6 +1210,7 @@ async function dispatchRequestInternal<Op extends 
WalletApiOperation>(
       for (const x of wi.selectedDenoms.selectedDenoms) {
         numCoins += x.count;
       }
+      const amt = Amounts.parseOrThrow(req.amount);
       const resp: ManualWithdrawalDetails = {
         amountRaw: req.amount,
         amountEffective: Amounts.stringify(wi.selectedDenoms.totalCoinValue),
@@ -1217,6 +1219,12 @@ async function dispatchRequestInternal<Op extends 
WalletApiOperation>(
         ageRestrictionOptions: wi.ageRestrictionOptions,
         withdrawalAccountList: wi.exchangeCreditAccountDetails,
         numCoins,
+        // FIXME: Once we have proper scope info support, return correct info 
here.
+        scopeInfo: {
+          type: ScopeType.Exchange,
+          currency: amt.currency,
+          url: req.exchangeBaseUrl,
+        },
       };
       return resp;
     }

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