From 3f2db7707fdf4eb4c1dfdb527d5726dd1694e126 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 25 Oct 2022 12:23:08 -0300 Subject: using new wallet api (typed interface) --- .../src/wallet/AddAccount/state.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'packages/taler-wallet-webextension/src/wallet/AddAccount/state.ts') diff --git a/packages/taler-wallet-webextension/src/wallet/AddAccount/state.ts b/packages/taler-wallet-webextension/src/wallet/AddAccount/state.ts index f14c4c1bb..a9e8dfb30 100644 --- a/packages/taler-wallet-webextension/src/wallet/AddAccount/state.ts +++ b/packages/taler-wallet-webextension/src/wallet/AddAccount/state.ts @@ -15,19 +15,17 @@ */ import { parsePaytoUri, stringifyPaytoUri } from "@gnu-taler/taler-util"; +import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { useState } from "preact/hooks"; import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js"; -import * as wxApi from "../../wxApi.js"; +import { wxApi } from "../../wxApi.js"; import { Props, State } from "./index.js"; export function useComponentState( { currency, onAccountAdded, onCancel }: Props, api: typeof wxApi, ): State { - const hook = useAsyncAsHook(async () => { - const { accounts } = await api.listKnownBankAccounts(currency); - return { accounts }; - }); + const hook = useAsyncAsHook(() => api.wallet.call(WalletApiOperation.ListKnownBankAccounts, { currency })); const [payto, setPayto] = useState(""); const [alias, setAlias] = useState(""); @@ -61,7 +59,10 @@ export function useComponentState( async function addAccount(): Promise { if (!uri || found) return; - await api.addKnownBankAccounts(uri, currency, alias); + const normalizedPayto = stringifyPaytoUri(uri); + await api.wallet.call(WalletApiOperation.AddKnownBankAccounts, { + alias, currency, payto: normalizedPayto + }); onAccountAdded(payto); } @@ -69,10 +70,10 @@ export function useComponentState( payto === "" ? undefined : !uri - ? "the uri is not ok" - : found - ? "that account is already present" - : undefined; + ? "the uri is not ok" + : found + ? "that account is already present" + : undefined; const unableToAdd = !type || !alias || paytoUriError; -- cgit v1.2.3