gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated: check if threshold is number


From: gnunet
Subject: [taler-wallet-core] branch master updated: check if threshold is number or amount and default to 0
Date: Sat, 11 Mar 2023 22:31:08 +0100

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

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

The following commit(s) were added to refs/heads/master by this push:
     new 77c71a4c2 check if threshold is number or amount and default to 0
77c71a4c2 is described below

commit 77c71a4c2d4d202f82a33bd44f5a099f82249482
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Sat Mar 11 18:30:44 2023 -0300

    check if threshold is number or amount and default to 0
---
 packages/demobank-ui/src/hooks/access.ts | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/packages/demobank-ui/src/hooks/access.ts 
b/packages/demobank-ui/src/hooks/access.ts
index 750b95fa0..ee8566efe 100644
--- a/packages/demobank-ui/src/hooks/access.ts
+++ b/packages/demobank-ui/src/hooks/access.ts
@@ -183,18 +183,26 @@ export function useAccountDetails(
 
   //FIXME: remove optional when libeufin sandbox has implemented the feature
   if (data && typeof data.data.debitThreshold === "undefined") {
-    data.data.debitThreshold = "100";
+    data.data.debitThreshold = "0";
   }
   //FIXME: sandbox server should return amount string
   if (data) {
-    const d = structuredClone(data);
+    const isAmount = Amounts.parse(data.data.debitThreshold);
+    if (isAmount) {
+      //server response with correct format
+      return data;
+    }
     const { currency } = Amounts.parseOrThrow(data.data.balance.amount);
-    d.data.debitThreshold = Amounts.stringify({
+    const clone = structuredClone(data);
+
+    const theNumber = Number.parseInt(data.data.debitThreshold, 10);
+    const value = Number.isNaN(theNumber) ? 0 : theNumber;
+    clone.data.debitThreshold = Amounts.stringify({
       currency,
-      value: Number.parseInt(d.data.debitThreshold, 10),
+      value: value,
       fraction: 0,
     });
-    return d;
+    return clone;
   }
   if (error) return error.info;
   return { loading: true };

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