diff options
author | Florian Dold <florian@dold.me> | 2022-10-14 18:40:04 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-10-14 18:48:03 +0200 |
commit | 6acddd6d70abc568e4b3740f56662691278aa645 (patch) | |
tree | 2733a5669090e54a864ad7c1052ef21fffc5aa06 /packages/taler-wallet-webextension | |
parent | da9ec5eb16298d8ca5690800eca1c15f5a6cfaa5 (diff) |
wallet-core: get rid of duplicated withdrawal info API
Diffstat (limited to 'packages/taler-wallet-webextension')
3 files changed, 23 insertions, 45 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", diff --git a/packages/taler-wallet-webextension/src/wxApi.ts b/packages/taler-wallet-webextension/src/wxApi.ts index e0a1ee238..17083cb5b 100644 --- a/packages/taler-wallet-webextension/src/wxApi.ts +++ b/packages/taler-wallet-webextension/src/wxApi.ts @@ -51,8 +51,8 @@ import { ExchangesListResponse, ForgetKnownBankAccountsRequest, GetExchangeTosResult, - GetExchangeWithdrawalInfo, GetFeeForDepositRequest, + GetWithdrawalDetailsForAmountRequest, GetWithdrawalDetailsForUriRequest, InitiatePeerPullPaymentRequest, InitiatePeerPullPaymentResponse, @@ -60,6 +60,7 @@ import { InitiatePeerPushPaymentResponse, KnownBankAccounts, Logger, + ManualWithdrawalDetails, NotificationType, PaytoUri, PrepareDepositRequest, @@ -81,7 +82,6 @@ import { import { AddBackupProviderRequest, BackupInfo, - ExchangeWithdrawDetails, PendingOperationsResponse, RemoveBackupProviderRequest, TalerError, @@ -459,14 +459,12 @@ export function getWithdrawalDetailsForUri( return callBackend("getWithdrawalDetailsForUri", req); } -/** - * Get diagnostics information - */ -export function getExchangeWithdrawalInfo( - req: GetExchangeWithdrawalInfo, -): Promise<ExchangeWithdrawDetails> { - return callBackend("getExchangeWithdrawalInfo", req); +export function getWithdrawalDetailsForAmount( + req: GetWithdrawalDetailsForAmountRequest, +): Promise<ManualWithdrawalDetails> { + return callBackend("getWithdrawalDetailsForAmount", req); } + export function getExchangeTos( exchangeBaseUrl: string, acceptedFormat: string[], |