gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated: fix withdraw-exchange redirec


From: gnunet
Subject: [taler-wallet-core] branch master updated: fix withdraw-exchange redirect when there is not amount
Date: Wed, 13 Dec 2023 19:15:45 +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 cd1201ef6 fix withdraw-exchange redirect when there is not amount
cd1201ef6 is described below

commit cd1201ef6c737b007adf1c3c572b41d793f2296b
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Wed Dec 13 15:15:37 2023 -0300

    fix withdraw-exchange redirect when there is not amount
---
 .../src/wallet/Application.tsx                     |  6 ++--
 packages/web-util/src/utils/http-impl.browser.ts   | 32 ++++++++++++----------
 packages/web-util/src/utils/http-impl.sw.ts        | 28 ++++++++++---------
 3 files changed, 34 insertions(+), 32 deletions(-)

diff --git a/packages/taler-wallet-webextension/src/wallet/Application.tsx 
b/packages/taler-wallet-webextension/src/wallet/Application.tsx
index 7bd4195ee..df0e968b9 100644
--- a/packages/taler-wallet-webextension/src/wallet/Application.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/Application.tsx
@@ -404,10 +404,8 @@ export function Application(): VNode {
             }) => (
               <CallToActionTemplate title={i18n.str`Digital cash withdrawal`}>
                 <WithdrawPageFromParams
-                  onAmountChanged={async (e) => {
-                    const page = `${Pages.ctaWithdrawManual({
-                      amount,
-                    })}?talerUri=${encodeURIComponent(talerUri)}`;
+                  onAmountChanged={async (newamount) => {
+                    const page = `${Pages.ctaWithdrawManual({ amount: 
newamount })}?talerUri=${encodeURIComponent(talerUri)}`;
                     redirectTo(page);
                   }}
                   talerExchangeWithdrawUri={talerUri}
diff --git a/packages/web-util/src/utils/http-impl.browser.ts 
b/packages/web-util/src/utils/http-impl.browser.ts
index db789a536..974a7d1b8 100644
--- a/packages/web-util/src/utils/http-impl.browser.ts
+++ b/packages/web-util/src/utils/http-impl.browser.ts
@@ -140,22 +140,24 @@ export class BrowserHttpLib implements HttpRequestLibrary 
{
             const td = new TextDecoder();
             return td.decode(myRequest.response);
           };
+          let responseJson: unknown = undefined;
           const makeJson = async (): Promise<any> => {
-            let responseJson;
-            try {
-              const td = new TextDecoder();
-              const responseString = td.decode(myRequest.response);
-              responseJson = JSON.parse(responseString);
-            } catch (e) {
-              throw TalerError.fromDetail(
-                TalerErrorCode.WALLET_RECEIVED_MALFORMED_RESPONSE,
-                {
-                  requestUrl,
-                  requestMethod,
-                  httpStatusCode: myRequest.status,
-                },
-                "Invalid JSON from HTTP response",
-              );
+            if (responseJson === undefined) {
+              try {
+                const td = new TextDecoder();
+                const responseString = td.decode(myRequest.response);
+                responseJson = JSON.parse(responseString);
+              } catch (e) {
+                throw TalerError.fromDetail(
+                  TalerErrorCode.WALLET_RECEIVED_MALFORMED_RESPONSE,
+                  {
+                    requestUrl,
+                    requestMethod,
+                    httpStatusCode: myRequest.status,
+                  },
+                  "Invalid JSON from HTTP response",
+                );
+              }
             }
             if (responseJson === null || typeof responseJson !== "object") {
               throw TalerError.fromDetail(
diff --git a/packages/web-util/src/utils/http-impl.sw.ts 
b/packages/web-util/src/utils/http-impl.sw.ts
index aab88021f..295681b53 100644
--- a/packages/web-util/src/utils/http-impl.sw.ts
+++ b/packages/web-util/src/utils/http-impl.sw.ts
@@ -176,20 +176,22 @@ function makeJsonHandler(
   requestUrl: string,
   requestMethod: string,
 ) {
+  let responseJson: unknown = undefined;
   return async function getJsonFromResponse(): Promise<any> {
-    let responseJson;
-    try {
-      responseJson = await response.json();
-    } catch (e) {
-      throw TalerError.fromDetail(
-        TalerErrorCode.WALLET_RECEIVED_MALFORMED_RESPONSE,
-        {
-          requestUrl,
-          requestMethod,
-          httpStatusCode: response.status,
-        },
-        "Invalid JSON from HTTP response",
-      );
+    if (responseJson === undefined) {
+      try {
+        responseJson = await response.json();
+      } catch (e) {
+        throw TalerError.fromDetail(
+          TalerErrorCode.WALLET_RECEIVED_MALFORMED_RESPONSE,
+          {
+            requestUrl,
+            requestMethod,
+            httpStatusCode: response.status,
+          },
+          "Invalid JSON from HTTP response",
+        );
+      }
     }
     if (responseJson === null || typeof responseJson !== "object") {
       throw TalerError.fromDetail(

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