gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated (a8d30ef0f -> 0f3b38745)


From: gnunet
Subject: [taler-wallet-core] branch master updated (a8d30ef0f -> 0f3b38745)
Date: Fri, 31 Mar 2023 19:52:07 +0200

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

sebasjm pushed a change to branch master
in repository wallet-core.

    from a8d30ef0f page = 1
     new b08bb05a4 save wire fee instead of effective amount
     new 0f3b38745 calculate deposit wire transfer

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 packages/taler-util/src/transactions-types.ts      |  4 +-
 packages/taler-wallet-core/src/db.ts               |  4 +-
 packages/taler-wallet-core/src/dbless.ts           |  2 +-
 .../taler-wallet-core/src/operations/deposits.ts   |  3 +-
 packages/taler-wallet-core/src/operations/tip.ts   |  2 +-
 .../src/operations/withdraw.test.ts                |  2 +-
 .../src/wallet/Transaction.tsx                     | 45 ++++++++++++++++------
 7 files changed, 41 insertions(+), 21 deletions(-)

diff --git a/packages/taler-util/src/transactions-types.ts 
b/packages/taler-util/src/transactions-types.ts
index 1d7e6ef30..d3b68b114 100644
--- a/packages/taler-util/src/transactions-types.ts
+++ b/packages/taler-util/src/transactions-types.ts
@@ -586,8 +586,8 @@ export interface TransactionDeposit extends 
TransactionCommon {
     timestampExecuted: TalerProtocolTimestamp;
     // Total amount transfer for this wtid (including fees)
     amountRaw: AmountString;
-    // Total amount received for this wtid (without fees)
-    amountEffective: AmountString;
+    // Wire fee amount for this exchange
+    wireFee: AmountString;
   }>;
 }
 
diff --git a/packages/taler-wallet-core/src/db.ts 
b/packages/taler-wallet-core/src/db.ts
index fb5ea025a..9ee157a2a 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -1680,8 +1680,8 @@ export interface DepositGroupRecord {
       timestampExecuted: TalerProtocolTimestamp;
       // Total amount transfer for this wtid (including fees)
       amountRaw: AmountString;
-      // Total amount received for this wtid (without fees)
-      amountEffective: AmountString;
+      // Wire fee amount for this exchange
+      wireFee: AmountString;
       exchangePub: string;
     };
   };
diff --git a/packages/taler-wallet-core/src/dbless.ts 
b/packages/taler-wallet-core/src/dbless.ts
index 99596edd8..fe5eb6e3f 100644
--- a/packages/taler-wallet-core/src/dbless.ts
+++ b/packages/taler-wallet-core/src/dbless.ts
@@ -62,10 +62,10 @@ import {
 import {
   getBankStatusUrl,
   getBankWithdrawalInfo,
-  isWithdrawableDenom,
 } from "./operations/withdraw.js";
 import { ExchangeInfo } from "./operations/exchanges.js";
 import { assembleRefreshRevealRequest } from "./operations/refresh.js";
+import { isWithdrawableDenom } from "./index.js";
 
 const logger = new Logger("dbless.ts");
 
diff --git a/packages/taler-wallet-core/src/operations/deposits.ts 
b/packages/taler-wallet-core/src/operations/deposits.ts
index 64217acab..47efbb213 100644
--- a/packages/taler-wallet-core/src/operations/deposits.ts
+++ b/packages/taler-wallet-core/src/operations/deposits.ts
@@ -234,12 +234,11 @@ export async function processDepositGroup(
         );
         const raw = Amounts.parseOrThrow(track.coin_contribution);
         const wireFee = Amounts.parseOrThrow(fee.wireFee);
-        const effective = Amounts.sub(raw, wireFee).amount;
 
         newWiredTransaction = {
           value: {
             amountRaw: Amounts.stringify(raw),
-            amountEffective: Amounts.stringify(effective),
+            wireFee: Amounts.stringify(wireFee),
             exchangePub: track.exchange_pub,
             timestampExecuted: track.execution_time,
             wireTransferId: track.wtid,
diff --git a/packages/taler-wallet-core/src/operations/tip.ts 
b/packages/taler-wallet-core/src/operations/tip.ts
index 28c3cda52..b37288079 100644
--- a/packages/taler-wallet-core/src/operations/tip.ts
+++ b/packages/taler-wallet-core/src/operations/tip.ts
@@ -61,9 +61,9 @@ import { updateExchangeFromUrl } from "./exchanges.js";
 import {
   getCandidateWithdrawalDenoms,
   getExchangeWithdrawalInfo,
-  selectWithdrawalDenominations,
   updateWithdrawalDenoms,
 } from "./withdraw.js";
+import { selectWithdrawalDenominations } from "../util/coinSelection.js";
 
 const logger = new Logger("operations/tip.ts");
 
diff --git a/packages/taler-wallet-core/src/operations/withdraw.test.ts 
b/packages/taler-wallet-core/src/operations/withdraw.test.ts
index c77f75b9d..5a557b5de 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.test.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.test.ts
@@ -17,7 +17,7 @@
 import { Amounts, DenomKeyType } from "@gnu-taler/taler-util";
 import test from "ava";
 import { DenominationRecord, DenominationVerificationStatus } from "../db.js";
-import { selectWithdrawalDenominations } from "./withdraw.js";
+import { selectWithdrawalDenominations } from "../util/coinSelection.js";
 
 test("withdrawal selection bug repro", (t) => {
   const amount = {
diff --git a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx 
b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx
index d95b10297..58e50e7b6 100644
--- a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx
@@ -1571,6 +1571,38 @@ function RefundDetails({ amount }: { amount: 
AmountWithFee }): VNode {
   );
 }
 
+type AmountAmountByWireTransferByWire = {
+  id: string;
+  amount: string;
+}[];
+
+function calculateAmountByWireTransfer(
+  state: TransactionDeposit["trackingState"],
+): AmountAmountByWireTransferByWire {
+  const allTracking = Object.values(state ?? {});
+
+  //group tracking by wtid, sum amounts
+  const trackByWtid = allTracking.reduce((prev, cur) => {
+    const fee = Amounts.parseOrThrow(cur.wireFee);
+    const raw = Amounts.parseOrThrow(cur.amountRaw);
+    const total = !prev[cur.wireTransferId]
+      ? raw
+      : Amounts.add(prev[cur.wireTransferId].total, raw).amount;
+
+    prev[cur.wireTransferId] = {
+      total,
+      fee,
+    };
+    return prev;
+  }, {} as Record<string, { total: AmountJson; fee: AmountJson }>);
+
+  //remove wire fee from total amount
+  return Object.entries(trackByWtid).map(([id, info]) => ({
+    id,
+    amount: Amounts.stringify(Amounts.sub(info.total, info.fee).amount),
+  }));
+}
+
 function TrackingDepositDetails({
   trackingState,
 }: {
@@ -1578,18 +1610,7 @@ function TrackingDepositDetails({
 }): VNode {
   const { i18n } = useTranslationContext();
 
-  const trackByWtid = Object.values(trackingState ?? {}).reduce((prev, cur) => 
{
-    const am = Amounts.parseOrThrow(cur.amountEffective);
-    const sum = !prev[cur.wireTransferId]
-      ? am
-      : Amounts.add(prev[cur.wireTransferId], am).amount;
-    prev[cur.wireTransferId] = sum;
-    return prev;
-  }, {} as Record<string, AmountJson>);
-  const wireTransfers = Object.entries(trackByWtid).map(([id, amountJson]) => 
({
-    id,
-    amount: Amounts.stringify(amountJson),
-  }));
+  const wireTransfers = calculateAmountByWireTransfer(trackingState);
 
   return (
     <PurchaseDetailsTable>

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