gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated (dbbe1b0a -> 9f60e3d7)


From: gnunet
Subject: [taler-wallet-core] branch master updated (dbbe1b0a -> 9f60e3d7)
Date: Wed, 01 Dec 2021 18:07:58 +0100

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

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

    from dbbe1b0a fix recoup error handling
     new 2dc876d6 taler-util: amount currency normalization
     new 9f60e3d7 wallet: use correct denoms as refresh targets

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/amounts.ts                    | 16 +++++++++++-----
 packages/taler-wallet-core/src/operations/pay.ts      |  6 ++++--
 packages/taler-wallet-core/src/operations/withdraw.ts |  7 ++++---
 3 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/packages/taler-util/src/amounts.ts 
b/packages/taler-util/src/amounts.ts
index 41fd14be..25b3a2c8 100644
--- a/packages/taler-util/src/amounts.ts
+++ b/packages/taler-util/src/amounts.ts
@@ -151,7 +151,7 @@ export class Amounts {
     }
     let fraction = first.fraction % amountFractionalBase;
     for (const x of rest) {
-      if (x.currency !== currency) {
+      if (x.currency.toUpperCase() !== currency.toUpperCase()) {
         throw Error(`Mismatched currency: ${x.currency} and ${currency}`);
       }
 
@@ -187,7 +187,7 @@ export class Amounts {
     let fraction = a.fraction;
 
     for (const b of rest) {
-      if (b.currency !== currency) {
+      if (b.currency.toUpperCase() !== a.currency.toUpperCase()) {
         throw Error(`Mismatched currency: ${b.currency} and ${currency}`);
       }
       if (fraction < b.fraction) {
@@ -299,7 +299,7 @@ export class Amounts {
       return undefined;
     }
     return {
-      currency: res[1],
+      currency: res[1].toUpperCase(),
       fraction: Math.round(amountFractionalBase * Number.parseFloat(tail)),
       value,
     };
@@ -403,11 +403,17 @@ export class Amounts {
    */
   static stringify(a: AmountLike): string {
     a = Amounts.jsonifyAmount(a);
-    const s = this.stringifyValue(a)
+    const s = this.stringifyValue(a);
 
     return `${a.currency}:${s}`;
   }
 
+  static isSameCurrency(a1: AmountLike, a2: AmountLike): boolean {
+    const x1 = this.jsonifyAmount(a1);
+    const x2 = this.jsonifyAmount(a2);
+    return x1.currency.toUpperCase() === x2.currency.toUpperCase();
+  }
+
   static stringifyValue(a: AmountJson, minFractional: number = 0): string {
     const av = a.value + Math.floor(a.fraction / amountFractionalBase);
     const af = a.fraction % amountFractionalBase;
@@ -424,6 +430,6 @@ export class Amounts {
         n = (n * 10) % amountFractionalBase;
       }
     }
-    return s
+    return s;
   }
 }
diff --git a/packages/taler-wallet-core/src/operations/pay.ts 
b/packages/taler-wallet-core/src/operations/pay.ts
index 73fc6537..5aa23496 100644
--- a/packages/taler-wallet-core/src/operations/pay.ts
+++ b/packages/taler-wallet-core/src/operations/pay.ts
@@ -162,8 +162,10 @@ export async function getTotalPaymentCost(
           );
         }
         const allDenoms = await tx.denominations.indexes.byExchangeBaseUrl
-          .iter()
-          .toArray();
+          .iter(coin.exchangeBaseUrl)
+          .filter((x) =>
+            Amounts.isSameCurrency(x.value, pcs.coinContributions[i]),
+          );
         const amountLeft = Amounts.sub(denom.value, pcs.coinContributions[i])
           .amount;
         const refreshCost = getTotalRefreshCost(allDenoms, denom, amountLeft);
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts 
b/packages/taler-wallet-core/src/operations/withdraw.ts
index 8c9178f5..ebab5468 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -219,7 +219,7 @@ export function selectWithdrawalDenominations(
   for (const d of denoms) {
     let count = 0;
     const cost = Amounts.add(d.value, d.feeWithdraw).amount;
-    for (; ;) {
+    for (;;) {
       if (Amounts.cmp(remaining, cost) < 0) {
         break;
       }
@@ -773,7 +773,8 @@ export async function updateWithdrawalDenoms(
         denom.verificationStatus === DenominationVerificationStatus.Unverified
       ) {
         logger.trace(
-          `Validating denomination (${current + 1}/${denominations.length
+          `Validating denomination (${current + 1}/${
+            denominations.length
           }) signature of ${denom.denomPubHash}`,
         );
         const valid = await ws.cryptoApi.isValidDenom(
@@ -1023,7 +1024,7 @@ export async function getExchangeWithdrawalInfo(
     ) {
       console.warn(
         `wallet's support for exchange protocol version 
${WALLET_EXCHANGE_PROTOCOL_VERSION} might be outdated ` +
-        `(exchange has ${exchangeDetails.protocolVersion}), checking for 
updates`,
+          `(exchange has ${exchangeDetails.protocolVersion}), checking for 
updates`,
       );
     }
   }

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