diff options
Diffstat (limited to 'packages/taler-wallet-webextension/src/cta')
3 files changed, 10 insertions, 16 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/Pay.tsx b/packages/taler-wallet-webextension/src/cta/Pay.tsx index 9b7f7862f..3e9e34fe6 100644 --- a/packages/taler-wallet-webextension/src/cta/Pay.tsx +++ b/packages/taler-wallet-webextension/src/cta/Pay.tsx @@ -29,7 +29,6 @@ import { AmountJson, Amounts, ConfirmPayResult, - ConfirmPayResultDone, ConfirmPayResultType, ContractTerms, NotificationType, @@ -60,11 +59,7 @@ import { WarningBox, } from "../components/styled/index.js"; import { useTranslationContext } from "../context/translation.js"; -import { - HookError, - useAsyncAsHook, - useAsyncAsHook2, -} from "../hooks/useAsyncAsHook.js"; +import { HookError, useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; import { ButtonHandler } from "../mui/handlers.js"; import * as wxApi from "../wxApi.js"; @@ -112,7 +107,7 @@ export function useComponentState( ); const [payErrMsg, setPayErrMsg] = useState<TalerError | undefined>(undefined); - const hook = useAsyncAsHook2(async () => { + const hook = useAsyncAsHook(async () => { if (!talerPayUri) throw Error("ERROR_NO-URI-FOR-PAYMENT"); const payStatus = await api.preparePay(talerPayUri); const balance = await api.getBalance(); diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw.test.ts b/packages/taler-wallet-webextension/src/cta/Withdraw.test.ts index 0301e321c..7f05870c1 100644 --- a/packages/taler-wallet-webextension/src/cta/Withdraw.test.ts +++ b/packages/taler-wallet-webextension/src/cta/Withdraw.test.ts @@ -58,7 +58,10 @@ describe("Withdraw CTA states", () => { const { status, hook } = getLastResultOrThrow() expect(status).equals('loading-uri') - expect(hook).deep.equals({ "hasError": true, "operational": false, "message": "ERROR_NO-URI-FOR-WITHDRAWAL" }); + if (!hook) expect.fail(); + if (!hook.hasError) expect.fail(); + if (hook.operational) expect.fail(); + expect(hook.message).eq("ERROR_NO-URI-FOR-WITHDRAWAL"); } await assertNoPendingUpdate() diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw.tsx b/packages/taler-wallet-webextension/src/cta/Withdraw.tsx index 56c64a6d7..3346512f7 100644 --- a/packages/taler-wallet-webextension/src/cta/Withdraw.tsx +++ b/packages/taler-wallet-webextension/src/cta/Withdraw.tsx @@ -40,11 +40,7 @@ import { WalletAction, } from "../components/styled/index.js"; import { useTranslationContext } from "../context/translation.js"; -import { - HookError, - useAsyncAsHook, - useAsyncAsHook2, -} from "../hooks/useAsyncAsHook.js"; +import { HookError, useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; import { buildTermsOfServiceState } from "../utils/index.js"; import { ButtonHandler, SelectFieldHandler } from "../mui/handlers.js"; import * as wxApi from "../wxApi.js"; @@ -103,7 +99,7 @@ export function useComponentState( /** * Ask the wallet about the withdraw URI */ - const uriInfoHook = useAsyncAsHook2(async () => { + const uriInfoHook = useAsyncAsHook(async () => { if (!talerWithdrawUri) throw Error("ERROR_NO-URI-FOR-WITHDRAWAL"); const uriInfo = await api.getWithdrawalDetailsForUri({ @@ -151,7 +147,7 @@ export function useComponentState( /** * For the exchange selected, bring the status of the terms of service */ - const terms = useAsyncAsHook2(async () => { + const terms = useAsyncAsHook(async () => { if (!thisExchange) return false; const exchangeTos = await api.getExchangeTos(thisExchange, ["text/xml"]); @@ -165,7 +161,7 @@ export function useComponentState( * With the exchange and amount, ask the wallet the information * about the withdrawal */ - const info = useAsyncAsHook2(async () => { + const info = useAsyncAsHook(async () => { if (!thisExchange || !amount) return false; const info = await api.getExchangeWithdrawalInfo({ |