diff options
Diffstat (limited to 'packages/taler-wallet-core/src/wallet.ts')
-rw-r--r-- | packages/taler-wallet-core/src/wallet.ts | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index 223272745..d8361c6e4 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -71,7 +71,6 @@ import { WalletCoreVersion, WalletNotification, WalletRunConfig, - WithdrawalDetailsForAmount, checkDbInvariant, codecForAbortTransaction, codecForAcceptBankIntegratedWithdrawalRequest, @@ -291,7 +290,7 @@ import { import { acceptWithdrawalFromUri, createManualWithdrawal, - getExchangeWithdrawalInfo, + getWithdrawalDetailsForAmount, getWithdrawalDetailsForUri, } from "./withdraw.js"; @@ -668,6 +667,7 @@ export interface PendingOperationsResponse { */ async function dispatchRequestInternal<Op extends WalletApiOperation>( wex: WalletExecutionContext, + cts: CancellationToken.Source, operation: WalletApiOperation, payload: unknown, ): Promise<WalletCoreResponseType<typeof operation>> { @@ -893,27 +893,7 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>( case WalletApiOperation.GetWithdrawalDetailsForAmount: { const req = codecForGetWithdrawalDetailsForAmountRequest().decode(payload); - const wi = await getExchangeWithdrawalInfo( - wex, - req.exchangeBaseUrl, - Amounts.parseOrThrow(req.amount), - req.restrictAge, - ); - let numCoins = 0; - for (const x of wi.selectedDenoms.selectedDenoms) { - numCoins += x.count; - } - const resp: WithdrawalDetailsForAmount = { - amountRaw: req.amount, - amountEffective: Amounts.stringify(wi.selectedDenoms.totalCoinValue), - paytoUris: wi.exchangePaytoUris, - tosAccepted: wi.termsOfServiceAccepted, - ageRestrictionOptions: wi.ageRestrictionOptions, - withdrawalAccountsList: wi.exchangeCreditAccountDetails, - numCoins, - // FIXME: Once we have proper scope info support, return correct info here. - scopeInfo: wi.scopeInfo, - }; + const resp = await getWithdrawalDetailsForAmount(wex, cts, req); return resp; } case WalletApiOperation.GetBalances: { @@ -1522,6 +1502,8 @@ async function handleCoreApiRequest( let wex: WalletExecutionContext; let oc: ObservabilityContext; + const cts = CancellationToken.create(); + if (ws.initCalled && ws.config.testing.emitObservabilityEvents) { oc = { observe(evt) { @@ -1534,12 +1516,12 @@ async function handleCoreApiRequest( }, }; - wex = getObservedWalletExecutionContext(ws, CancellationToken.CONTINUE, oc); + wex = getObservedWalletExecutionContext(ws, cts.token, oc); } else { oc = { observe(evt) {}, }; - wex = getNormalWalletExecutionContext(ws, CancellationToken.CONTINUE, oc); + wex = getNormalWalletExecutionContext(ws, cts.token, oc); } try { @@ -1550,6 +1532,7 @@ async function handleCoreApiRequest( }); const result = await dispatchRequestInternal( wex, + cts, operation as any, payload, ); @@ -1772,6 +1755,8 @@ export class InternalWalletState { devExperimentState: DevExperimentState = {}; + clientCancellationMap: Map<string, CancellationToken.Source> = new Map(); + initWithConfig(newConfig: WalletRunConfig): void { this._config = newConfig; |