gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated: webex: load deposit wire meth


From: gnunet
Subject: [taler-wallet-core] branch master updated: webex: load deposit wire methods from wallet core
Date: Sat, 07 Sep 2024 12:44:20 +0200

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

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

The following commit(s) were added to refs/heads/master by this push:
     new f9502ad5a webex: load deposit wire methods from wallet core
f9502ad5a is described below

commit f9502ad5a529e7b5d011dd0cc948473c25c3aff5
Author: Iván Ávalos <avalos@disroot.org>
AuthorDate: Sat Sep 7 12:44:17 2024 +0200

    webex: load deposit wire methods from wallet core
---
 .../src/wallet/ManageAccount/state.ts              | 57 +++++++++++++++++-----
 1 file changed, 44 insertions(+), 13 deletions(-)

diff --git 
a/packages/taler-wallet-webextension/src/wallet/ManageAccount/state.ts 
b/packages/taler-wallet-webextension/src/wallet/ManageAccount/state.ts
index 09abf92ac..72727ec64 100644
--- a/packages/taler-wallet-webextension/src/wallet/ManageAccount/state.ts
+++ b/packages/taler-wallet-webextension/src/wallet/ManageAccount/state.ts
@@ -26,7 +26,6 @@ import { useBackendContext } from "../../context/backend.js";
 import { useTranslationContext } from "@gnu-taler/web-util/browser";
 import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
 import { AccountByType, Props, State } from "./index.js";
-import { useSettings } from "../../hooks/useSettings.js";
 
 export function useComponentState({
   scope,
@@ -36,28 +35,22 @@ export function useComponentState({
   const api = useBackendContext();
   const { pushAlertOnError } = useAlertContext();
   const { i18n } = useTranslationContext();
+
   const hook = useAsyncAsHook(() =>
     api.wallet.call(WalletApiOperation.ListKnownBankAccounts, { currency: 
scope.currency }),
   );
-  const accountType: Record<string, string> = {
-    iban: "IBAN",
-  };
-  const [settings] = useSettings();
-  if (settings.extendedAccountTypes) {
-    accountType["bitcoin"] = "Bitcoin";
-    accountType["x-taler-bank"] = "Taler Bank";
-  }
 
-  const [payto, setPayto] = useState("");
-  const [alias, setAlias] = useState("");
-  const [type, setType] = useState("iban");
+  const hook2 = useAsyncAsHook(() =>
+    api.wallet.call(WalletApiOperation.GetDepositWireTypesForCurrency, { 
currency: scope.currency, scopeInfo: scope }),
+  );
 
-  if (!hook) {
+  if (!hook || !hook2) {
     return {
       status: "loading",
       error: undefined,
     };
   }
+
   if (hook.hasError) {
     return {
       status: "error",
@@ -68,6 +61,44 @@ export function useComponentState({
     };
   }
 
+  if (hook2.hasError) {
+    return {
+      status: "error",
+      error: alertFromError(
+        i18n,
+        i18n.str`Could not load supported wire methods`,
+        hook2),
+    };
+  }
+
+  if (hook2.response.wireTypes.length === 0) {
+    return {
+      status: "error",
+      error: {
+        type: "error",
+        message: i18n.str`No wire methods supported for this currency`,
+        description: i18n.str``,
+        cause: new Error("something"),
+        context: {},
+      },
+    };
+  }
+
+  const [payto, setPayto] = useState("");
+  const [alias, setAlias] = useState("");
+  const [type, setType] = useState(hook2.response.wireTypes[0]);
+
+  const accountType: Record<string, string> = {};
+  hook2.response.wireTypes.forEach(t => {
+    if (t === "iban") {
+      accountType[t] = "IBAN"
+    } else if (t === "x-taler-bank") {
+      accountType[t] = "x-taler-bank"
+    } else if (t === "bitcoin") {
+      accountType[t] = "Bitcoin"
+    }
+  });
+
   const uri = parsePaytoUri(payto);
   const found =
     hook.response.accounts.findIndex(

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