From efbde0e16033542ae104f5365be5cee6e65ef7b0 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Wed, 29 Mar 2023 00:06:24 -0300
Subject: handle kyc error on invoice and transfer

---
 .../src/wallet/DeveloperPage.tsx                    | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

(limited to 'packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx')

diff --git a/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx b/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx
index 2db2041d4..339e69213 100644
--- a/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx
@@ -140,12 +140,19 @@ export function View({
     });
   }
   const api = useBackendContext();
+
   const fileRef = useRef<HTMLInputElement>(null);
   async function onImportDatabase(str: string): Promise<void> {
     return api.wallet.call(WalletApiOperation.ImportDb, {
       dump: JSON.parse(str),
     });
   }
+
+  const hook = useAsyncAsHook(() =>
+    api.wallet.call(WalletApiOperation.ListExchanges, {}),
+  );
+  const exchangeList = hook && !hook.hasError ? hook.response.exchanges : [];
+
   const currencies: { [ex: string]: string } = {};
   const money_by_exchange = coins.reduce(
     (prev, cur) => {
@@ -171,7 +178,6 @@ export function View({
       [exchange_name: string]: CalculatedCoinfInfo[];
     },
   );
-  const exchanges = Object.keys(money_by_exchange);
 
   const [tagName, setTagName] = useState("");
   const [logLevel, setLogLevel] = useState("info");
@@ -324,27 +330,28 @@ export function View({
             variant="contained"
             onClick={async () => {
               const result = await Promise.all(
-                exchanges.map(async (ex) => {
+                exchangeList.map(async (exchange) => {
+                  const url = exchange.exchangeBaseUrl;
                   const oldKeys = JSON.stringify(
-                    await (await fetch(`${ex}keys`)).json(),
+                    await (await fetch(`${url}keys`)).json(),
                   );
                   const oldWire = JSON.stringify(
-                    await (await fetch(`${ex}wire`)).json(),
+                    await (await fetch(`${url}wire`)).json(),
                   );
                   const newKeys = JSON.stringify(
                     await (
-                      await fetch(`${ex}keys`, { cache: "no-cache" })
+                      await fetch(`${url}keys`, { cache: "no-cache" })
                     ).json(),
                   );
                   const newWire = JSON.stringify(
                     await (
-                      await fetch(`${ex}wire`, { cache: "no-cache" })
+                      await fetch(`${url}wire`, { cache: "no-cache" })
                     ).json(),
                   );
                   return oldKeys !== newKeys || newWire !== oldWire;
                 }),
               );
-              const ex = exchanges.filter((e, i) => result[i]);
+              const ex = exchangeList.filter((e, i) => result[i]);
               if (!ex.length) {
                 alert("no exchange was outdated");
               } else {
-- 
cgit v1.2.3

