taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 09bae316456f49c6bac2aca6185483e1e7ab2d5a
parent 311ca8cb7ba7cafa8f9baeb904775d6f1392935f
Author: Florian Dold <florian@dold.me>
Date:   Tue, 22 Oct 2024 15:06:59 +0200

wallet-core,harness: docs, test getWithdrawalDetailsForAmount on zero input

Diffstat:
Mpackages/taler-harness/src/integrationtests/test-withdrawal-manual.ts | 25++++++++++++++++++++++---
Mpackages/taler-util/src/types-taler-wallet.ts | 35++++++++++++++++++++---------------
Mpackages/taler-wallet-core/src/pay-peer-push-debit.ts | 2+-
3 files changed, 43 insertions(+), 19 deletions(-)

diff --git a/packages/taler-harness/src/integrationtests/test-withdrawal-manual.ts b/packages/taler-harness/src/integrationtests/test-withdrawal-manual.ts @@ -19,15 +19,15 @@ */ import { AbsoluteTime, - TalerCorebankApiClient, + AmountString, Logger, + ScopeType, WireGatewayApiClient, j2s, - AmountString, } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; -import { GlobalTestState } from "../harness/harness.js"; import { createSimpleTestkudosEnvironmentV3 } from "../harness/environments.js"; +import { GlobalTestState } from "../harness/harness.js"; const logger = new Logger("test-withdrawal-manual.ts"); @@ -50,6 +50,25 @@ export async function runWithdrawalManualTest(t: GlobalTestState) { const tStart = AbsoluteTime.now(); + // Test some getWithdrawalDetailsForAmount requests + { + // Zero should be acceptable + const det = await walletClient.call( + WalletApiOperation.GetWithdrawalDetailsForAmount, + { + amount: "TESTKUDOS:0", + restrictScope: { + type: ScopeType.Exchange, + currency: "TESTKUDOS", + url: exchange.baseUrl, + }, + }, + ); + t.assertAmountEquals(det.amountEffective, "TESTKUDOS:0"); + t.assertAmountEquals(det.amountRaw, "TESTKUDOS:0"); + t.assertDeepEqual(det.numCoins, 0); + } + logger.info("starting AcceptManualWithdrawal request"); // We expect this to return immediately. diff --git a/packages/taler-util/src/types-taler-wallet.ts b/packages/taler-util/src/types-taler-wallet.ts @@ -1503,14 +1503,6 @@ export interface WithdrawalDetailsForAmount { exchangeBaseUrl: string; /** - * Did the user accept the current version of the exchange's - * terms of service? - * - * @deprecated the client should query the exchange entry instead - */ - tosAccepted: boolean; - - /** * Amount that the user will transfer to the exchange. */ amountRaw: AmountString; @@ -1528,13 +1520,6 @@ export interface WithdrawalDetailsForAmount { numCoins: number; /** - * Ways to pay the exchange. - * - * @deprecated in favor of withdrawalAccountsList - */ - paytoUris: string[]; - - /** * Ways to pay the exchange, including accounts that require currency conversion. */ withdrawalAccountsList: WithdrawalExchangeAccountDetails[]; @@ -1563,6 +1548,21 @@ export interface WithdrawalDetailsForAmount { * Withdrawals over that amount will be denied. */ kycHardLimit?: AmountString; + + /** + * Ways to pay the exchange. + * + * @deprecated in favor of withdrawalAccountsList + */ + paytoUris: string[]; + + /** + * Did the user accept the current version of the exchange's + * terms of service? + * + * @deprecated the client should query the exchange entry instead + */ + tosAccepted: boolean; } export interface DenomSelItem { @@ -1846,6 +1846,11 @@ export const codecForAcceptManualWithdrawalRequest = export interface GetWithdrawalDetailsForAmountRequest { exchangeBaseUrl?: string; + /** + * Specify currency scope for the withdrawal. + * + * May only be used when exchangeBaseUrl is not specified. + */ restrictScope?: ScopeInfo; amount: AmountString; diff --git a/packages/taler-wallet-core/src/pay-peer-push-debit.ts b/packages/taler-wallet-core/src/pay-peer-push-debit.ts @@ -472,7 +472,7 @@ async function internalCheckPeerPushDebit( } const coinSelRes = await selectPeerCoins(wex, { instructedAmount, - restrictScope, + restrictScope: req.restrictScope, feesCoveredByCounterparty: false, }); let coins: SelectedProspectiveCoin[] | undefined = undefined;