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: fix/deduplicate


From: gnunet
Subject: [taler-wallet-core] branch master updated: wallet-core: fix/deduplicate funding payto URI generation for withdrawals
Date: Fri, 07 Oct 2022 14:45:28 +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 f479ca013 wallet-core: fix/deduplicate funding payto URI generation 
for withdrawals
f479ca013 is described below

commit f479ca01390483a8744207bd9b64ea3b7322231c
Author: Florian Dold <florian@dold.me>
AuthorDate: Fri Oct 7 14:45:25 2022 +0200

    wallet-core: fix/deduplicate funding payto URI generation for withdrawals
---
 .../src/operations/transactions.ts                 | 39 ++++++++++++++--------
 .../taler-wallet-core/src/operations/withdraw.ts   | 22 +++++++++---
 2 files changed, 42 insertions(+), 19 deletions(-)

diff --git a/packages/taler-wallet-core/src/operations/transactions.ts 
b/packages/taler-wallet-core/src/operations/transactions.ts
index be1233d2c..555ba0d8d 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -58,7 +58,10 @@ import { processPurchasePay } from "./pay.js";
 import { processRefreshGroup } from "./refresh.js";
 import { applyRefundFromPurchaseId } from "./refund.js";
 import { processTip } from "./tip.js";
-import { processWithdrawalGroup } from "./withdraw.js";
+import {
+  augmentPaytoUrisForWithdrawal,
+  processWithdrawalGroup,
+} from "./withdraw.js";
 
 const logger = new Logger("taler-wallet-core:transactions.ts");
 
@@ -473,31 +476,39 @@ function buildTransactionForBankIntegratedWithdraw(
 }
 
 function buildTransactionForManualWithdraw(
-  wsr: WithdrawalGroupRecord,
+  withdrawalGroup: WithdrawalGroupRecord,
   exchangeDetails: ExchangeDetailsRecord,
   ort?: OperationRetryRecord,
 ): Transaction {
-  if (wsr.wgInfo.withdrawalType !== WithdrawalRecordType.BankManual)
+  if (withdrawalGroup.wgInfo.withdrawalType !== 
WithdrawalRecordType.BankManual)
     throw Error("");
 
+  const plainPaytoUris =
+    exchangeDetails.wireInfo?.accounts.map((x) => x.payto_uri) ?? [];
+
+  const exchangePaytoUris = augmentPaytoUrisForWithdrawal(
+    plainPaytoUris,
+    withdrawalGroup.reservePub,
+    withdrawalGroup.instructedAmount,
+  );
+
   return {
     type: TransactionType.Withdrawal,
-    amountEffective: Amounts.stringify(wsr.denomsSel.totalCoinValue),
-    amountRaw: Amounts.stringify(wsr.rawWithdrawalAmount),
+    amountEffective: Amounts.stringify(
+      withdrawalGroup.denomsSel.totalCoinValue,
+    ),
+    amountRaw: Amounts.stringify(withdrawalGroup.rawWithdrawalAmount),
     withdrawalDetails: {
       type: WithdrawalType.ManualTransfer,
-      reservePub: wsr.reservePub,
-      exchangePaytoUris:
-        exchangeDetails.wireInfo?.accounts.map((x) =>
-          addPaytoQueryParams(x.payto_uri, { subject: wsr.reservePub }),
-        ) ?? [],
+      reservePub: withdrawalGroup.reservePub,
+      exchangePaytoUris,
     },
-    exchangeBaseUrl: wsr.exchangeBaseUrl,
-    pending: !wsr.timestampFinish,
-    timestamp: wsr.timestampStart,
+    exchangeBaseUrl: withdrawalGroup.exchangeBaseUrl,
+    pending: !withdrawalGroup.timestampFinish,
+    timestamp: withdrawalGroup.timestampStart,
     transactionId: makeEventId(
       TransactionType.Withdrawal,
-      wsr.withdrawalGroupId,
+      withdrawalGroup.withdrawalGroupId,
     ),
     frozen: false,
     ...(ort?.lastError ? { error: ort.lastError } : {}),
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts 
b/packages/taler-wallet-core/src/operations/withdraw.ts
index d768bbeb2..fb5e2c70a 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -1483,6 +1483,19 @@ export async function getFundingPaytoUrisTx(
     .runReadWrite((tx) => getFundingPaytoUris(tx, withdrawalGroupId));
 }
 
+export function augmentPaytoUrisForWithdrawal(
+  plainPaytoUris: string[],
+  reservePub: string,
+  instructedAmount: AmountJson,
+): string[] {
+  return plainPaytoUris.map((x) =>
+    addPaytoQueryParams(x, {
+      amount: Amounts.stringify(instructedAmount),
+      message: `Taler Withdrawal ${reservePub}`,
+    }),
+  );
+}
+
 /**
  * Get payto URIs that can be used to fund a withdrawal operation.
  */
@@ -1512,11 +1525,10 @@ export async function getFundingPaytoUris(
     );
     return [];
   }
-  return plainPaytoUris.map((x) =>
-    addPaytoQueryParams(x, {
-      amount: Amounts.stringify(withdrawalGroup.instructedAmount),
-      message: `Taler Withdrawal ${withdrawalGroup.reservePub}`,
-    }),
+  return augmentPaytoUrisForWithdrawal(
+    plainPaytoUris,
+    withdrawalGroup.reservePub,
+    withdrawalGroup.instructedAmount,
   );
 }
 

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