summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/cta
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-10-14 18:40:04 +0200
committerFlorian Dold <florian@dold.me>2022-10-14 18:48:03 +0200
commit6acddd6d70abc568e4b3740f56662691278aa645 (patch)
tree2733a5669090e54a864ad7c1052ef21fffc5aa06 /packages/taler-wallet-webextension/src/cta
parentda9ec5eb16298d8ca5690800eca1c15f5a6cfaa5 (diff)
downloadwallet-core-6acddd6d70abc568e4b3740f56662691278aa645.tar.gz
wallet-core-6acddd6d70abc568e4b3740f56662691278aa645.tar.bz2
wallet-core-6acddd6d70abc568e4b3740f56662691278aa645.zip
wallet-core: get rid of duplicated withdrawal info API
Diffstat (limited to 'packages/taler-wallet-webextension/src/cta')
-rw-r--r--packages/taler-wallet-webextension/src/cta/Withdraw/state.ts11
-rw-r--r--packages/taler-wallet-webextension/src/cta/Withdraw/test.ts41
2 files changed, 16 insertions, 36 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts
index c2b9e375f..53bac579e 100644
--- a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts
+++ b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts
@@ -182,16 +182,15 @@ function exchangeSelectionState(
* about the withdrawal
*/
const amountHook = useAsyncAsHook(async () => {
- const info = await api.getExchangeWithdrawalInfo({
+ const info = await api.getWithdrawalDetailsForAmount({
exchangeBaseUrl: currentExchange.exchangeBaseUrl,
- amount: chosenAmount,
- tosAcceptedFormat: ["text/xml"],
- ageRestricted,
+ amount: Amounts.stringify(chosenAmount),
+ restrictAge: ageRestricted,
});
const withdrawAmount = {
- raw: Amounts.parseOrThrow(info.withdrawalAmountRaw),
- effective: Amounts.parseOrThrow(info.withdrawalAmountEffective),
+ raw: Amounts.parseOrThrow(info.amountRaw),
+ effective: Amounts.parseOrThrow(info.amountEffective),
};
return {
diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts b/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts
index f3598b557..d86771208 100644
--- a/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts
+++ b/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts
@@ -22,14 +22,11 @@
import {
Amounts,
ExchangeFullDetails,
- ExchangeListItem,
GetExchangeTosResult,
} from "@gnu-taler/taler-util";
-import { ExchangeWithdrawDetails } from "@gnu-taler/taler-wallet-core";
import { expect } from "chai";
import { mountHook } from "../../test-utils.js";
import { useComponentStateFromURI } from "./state.js";
-import * as wxApi from "../../wxApi.js";
const exchanges: ExchangeFullDetails[] = [
{
@@ -162,20 +159,11 @@ describe("Withdraw CTA states", () => {
},
{
listExchanges: async () => ({ exchanges }),
- getWithdrawalDetailsForUri: async ({
- talerWithdrawUri,
- }: any): Promise<ExchangeWithdrawDetails> =>
- ({
- amount: "ARS:2",
- possibleExchanges: exchanges,
- defaultExchangeBaseUrl: exchanges[0].exchangeBaseUrl,
- } as Partial<ExchangeWithdrawDetails> as ExchangeWithdrawDetails),
- getExchangeWithdrawalInfo:
- async (): Promise<ExchangeWithdrawDetails> =>
- ({
- withdrawalAmountRaw: "ARS:2",
- withdrawalAmountEffective: "ARS:2",
- } as any),
+ getWithdrawalDetailsForUri: async ({ talerWithdrawUri }: any) => ({
+ amount: "ARS:2",
+ possibleExchanges: exchanges,
+ defaultExchangeBaseUrl: exchanges[0].exchangeBaseUrl,
+ }),
getExchangeTos: async (): Promise<GetExchangeTosResult> => ({
contentType: "text",
content: "just accept",
@@ -255,19 +243,12 @@ describe("Withdraw CTA states", () => {
},
},
{
- listExchanges: async () => listExchangesResponse,
- getWithdrawalDetailsForUri: async ({ talerWithdrawUri }: any) =>
- ({
- amount: "ARS:2",
- possibleExchanges: exchanges,
- defaultExchangeBaseUrl: exchanges[0].exchangeBaseUrl,
- } as Partial<ExchangeWithdrawDetails> as ExchangeWithdrawDetails),
- getExchangeWithdrawalInfo:
- async (): Promise<ExchangeWithdrawDetails> =>
- ({
- withdrawalAmountRaw: "ARS:2",
- withdrawalAmountEffective: "ARS:2",
- } as any),
+ listExchanges: async () => ({ exchanges }),
+ getWithdrawalDetailsForUri: async ({ talerWithdrawUri }: any) => ({
+ amount: "ARS:2",
+ possibleExchanges: exchanges,
+ defaultExchangeBaseUrl: exchanges[0].exchangeBaseUrl,
+ }),
getExchangeTos: async (): Promise<GetExchangeTosResult> => ({
contentType: "text",
content: "just accept",