taler-typescript-core

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

commit d04f9051f73b06b1234301283e8a85dc96fcbff6
parent a3d238ae00b02d1ce6250f80aa90c0cac7ddcc89
Author: Florian Dold <dold@taler.net>
Date:   Wed, 25 Nov 2026 19:34:26 +0100

wallet web UI: use withdrawal exchange candidates in the exchange picker

Diffstat:
Mpackages/wallet-webui/src/routes/App.tsx | 34+++++++++++-----------------------
Mpackages/wallet-webui/src/testing/demo-wallet.ts | 24++++++++++++++++--------
2 files changed, 27 insertions(+), 31 deletions(-)

diff --git a/packages/wallet-webui/src/routes/App.tsx b/packages/wallet-webui/src/routes/App.tsx @@ -2789,9 +2789,9 @@ function WithdrawalRoute( : demo ? "/withdraw?kind=demo" : "/withdraw"; - const defaults = useWalletQuery( + const candidates = useWalletQuery( connection, - WalletApiOperation.GetDefaultExchanges, + WalletApiOperation.ListWithdrawalExchangeCandidates, {}, ); const allExchanges = useWalletQuery( @@ -2822,26 +2822,14 @@ function WithdrawalRoute( ageRestrictionOptions: exchange.ageRestrictionOptions, })); } else { - providers = defaults.data?.defaultExchanges.flatMap((exchange) => { - const parsed = TalerUris.parse(exchange.talerUri); - if ( - Result.isError(parsed) || - parsed.value.type !== TalerUriAction.WithdrawExchange - ) - return []; - const exchangeBaseUrl = parsed.value.exchangeBaseUrl; - const managedExchange = allExchanges.data?.exchanges.find( - (candidate) => candidate.exchangeBaseUrl === exchangeBaseUrl, - ); - return [ - { - exchangeBaseUrl, - currency: exchange.currency, - commonAmounts: exchange.currencySpec.common_amounts ?? [], - ageRestrictionOptions: managedExchange?.ageRestrictionOptions, - }, - ]; - }); + providers = candidates.data?.candidates.map((exchange) => ({ + exchangeBaseUrl: exchange.exchangeBaseUrl, + currency: exchange.currency, + commonAmounts: exchange.currencySpec.common_amounts ?? [], + ageRestrictionOptions: allExchanges.data?.exchanges.find( + (entry) => entry.exchangeBaseUrl === exchange.exchangeBaseUrl, + )?.ageRestrictionOptions, + })); if ( providers && requestedExchange && @@ -3012,7 +3000,7 @@ function WithdrawalRoute( /> ); } - const query = demo ? demoExchanges : defaults; + const query = demo ? demoExchanges : candidates; const providerLoading = directedByExchangeUri ? allExchanges.isLoading : query.isLoading || (!demo && allExchanges.isLoading); diff --git a/packages/wallet-webui/src/testing/demo-wallet.ts b/packages/wallet-webui/src/testing/demo-wallet.ts @@ -2,6 +2,8 @@ import { ConfirmPayResultType, observedTransaction, ExchangeEntryStatus, + ExchangeEntrySource, + ExchangeRecommendationReason, ExchangeTosStatus, ExchangeUpdateStatus, NotificationType, @@ -22,6 +24,7 @@ import { stringifyYaml, stringifyScopeInfo, type AmountString, + type ListWithdrawalExchangeCandidatesResponse, type ScopeInfo, type Transaction, type TransactionIdStr, @@ -944,22 +947,27 @@ export class DemoWalletConnection implements WalletConnection { } case WalletApiOperation.ListExchanges: return { exchanges: structuredClone(this.state.exchanges) } as never; - case WalletApiOperation.GetDefaultExchanges: - return { - defaultExchanges: [ + case WalletApiOperation.ListWithdrawalExchangeCandidates: + return ({ + candidates: [ { + exchangeBaseUrl, + exchangeEntryStatus: ExchangeEntryStatus.Used, + exchangeUpdateStatus: ExchangeUpdateStatus.Ready, + source: ExchangeEntrySource.Builtin, + recommendationReasons: [ExchangeRecommendationReason.Preset], talerUri: "taler://withdraw-exchange/exchange.demo.invalid/", currency: "CHF", currencySpec: { name: /* Translators: Text for a fictional demo or developer screen preview; not a live wallet action or real merchant data. */ i18n.str`Swiss franc`, - numFractionalInputDigits: 2, - numFractionalNormalDigits: 2, - numFractionalTrailingZeroDigits: 2, - altUnitNames: {}, + num_fractional_input_digits: 2, + num_fractional_normal_digits: 2, + num_fractional_trailing_zero_digits: 2, + alt_unit_names: { 0: "CHF" }, }, }, ], - } as never; + } satisfies ListWithdrawalExchangeCandidatesResponse) as never; case WalletApiOperation.GetExchangeEntryByUrl: return structuredClone( this.state.exchanges.find(