diff options
author | Sebastian <sebasjm@gmail.com> | 2024-05-30 13:16:15 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-06-06 13:03:13 -0300 |
commit | 60a4640a35be584ee004de5e362f21ed03fa239e (patch) | |
tree | 1df828dd3c5f5898434efb5df301d4f116196581 /packages/taler-wallet-webextension/src/cta/Withdraw | |
parent | 920595aa3864615c07aba0ecfc233acf05f3e3e6 (diff) | |
download | wallet-core-60a4640a35be584ee004de5e362f21ed03fa239e.tar.xz |
working #8882
Diffstat (limited to 'packages/taler-wallet-webextension/src/cta/Withdraw')
-rw-r--r-- | packages/taler-wallet-webextension/src/cta/Withdraw/state.ts | 33 | ||||
-rw-r--r-- | packages/taler-wallet-webextension/src/cta/Withdraw/test.ts | 5 |
2 files changed, 17 insertions, 21 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts index 90ad65d6e..da3b1eeb2 100644 --- a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts +++ b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts @@ -213,10 +213,7 @@ export function useComponentStateFromURI({ const uriInfo = await api.wallet.call( WalletApiOperation.PrepareBankIntegratedWithdrawal, - { - talerWithdrawUri, - selectedExchange: updatedExchangeByUser, - }, + { talerWithdrawUri }, ); const { amount, @@ -225,12 +222,12 @@ export function useComponentStateFromURI({ confirmTransferUrl, status, } = uriInfo.info; - const txInfo = - uriInfo.transactionId === undefined - ? undefined - : await api.wallet.call(WalletApiOperation.GetTransactionById, { - transactionId: uriInfo.transactionId, - }); + const txInfo = await api.wallet.call( + WalletApiOperation.GetTransactionById, + { + transactionId: uriInfo.transactionId, + }, + ); return { talerWithdrawUri, status, @@ -292,9 +289,6 @@ export function useComponentStateFromURI({ transactionId: string; confirmTransferUrl: string | undefined; }> { - if (!txId) { - throw Error("can't confirm transaction"); - } const res = await api.wallet.call(WalletApiOperation.ConfirmWithdrawal, { exchangeBaseUrl: exchange, amount, @@ -370,15 +364,16 @@ function exchangeSelectionState( onExchangeUpdated(current); } }, [current]); - - const safeAmount = !infoAmount ? Amounts.zeroOfCurrency(currency) : infoAmount - const [choosenAmount, setChoosenAmount] = useState(safeAmount) + + const safeAmount = !infoAmount + ? Amounts.zeroOfCurrency(currency) + : infoAmount; + const [choosenAmount, setChoosenAmount] = useState(safeAmount); if (selectedExchange.status !== "ready") { return selectedExchange; } - return useCallback((): | State.Success | State.LoadingUriError @@ -520,8 +515,8 @@ function exchangeSelectionState( amount: { value: choosenAmount, onInput: pushAlertOnError(async (v) => { - setChoosenAmount(v) - }) + setChoosenAmount(v); + }), }, talerWithdrawUri, ageRestriction, diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts b/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts index 785fab996..5bbf5f6c8 100644 --- a/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts +++ b/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts @@ -26,6 +26,7 @@ import { ExchangeListItem, ExchangeTosStatus, ScopeType, + TransactionIdStr, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { expect } from "chai"; @@ -111,7 +112,7 @@ describe("Withdraw CTA states", () => { WalletApiOperation.PrepareBankIntegratedWithdrawal, undefined, { - transactionId: "123", + transactionId: "123" as TransactionIdStr, info: { status: "pending", operationId: "123", @@ -153,7 +154,7 @@ describe("Withdraw CTA states", () => { WalletApiOperation.PrepareBankIntegratedWithdrawal, undefined, { - transactionId: "123", + transactionId: "123" as TransactionIdStr, info: { status: "pending", operationId: "123", |