taler-typescript-core

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

commit 56031c345a5fe5d1acae032115ded6e5599fb64e
parent 87a47c3d0f19f5e8a012416eaf4f3001573da146
Author: Florian Dold <florian@dold.me>
Date:   Mon,  2 Mar 2026 19:11:58 +0100

wallet-core: draft getDefaultExchanges

Diffstat:
Mpackages/taler-util/src/types-taler-wallet.ts | 19+++++++++++++++++++
Mpackages/taler-wallet-core/src/wallet-api-types.ts | 12++++++++++++
Mpackages/taler-wallet-core/src/wallet.ts | 30++++++++++++++++++++++++++++++
3 files changed, 61 insertions(+), 0 deletions(-)

diff --git a/packages/taler-util/src/types-taler-wallet.ts b/packages/taler-util/src/types-taler-wallet.ts @@ -4719,3 +4719,22 @@ export interface FlightRecordEntry { export enum FlightRecordEvent { MeltGone = "melt-gone", } + +export interface GetDefaultExchangesResponse { + defaultExchanges: { + /** + * A taler://withdraw-exchange URI for the + * exchange. + */ + talerUri: string; + /** + * Currency spec for the currency offered + * by the exchange. + */ + currencySpec: CurrencySpecification; + /** + * Countries supported by the exchange as ISO 3166-1 alpha-2 codes. + */ + countries: string[]; + }[]; +} diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts b/packages/taler-wallet-core/src/wallet-api-types.ts @@ -97,6 +97,7 @@ import { GetChoicesForPaymentResult, GetCurrencySpecificationRequest, GetCurrencySpecificationResponse, + GetDefaultExchangesResponse, GetDepositWireTypesForCurrencyRequest, GetDepositWireTypesForCurrencyResponse, GetDepositWireTypesRequest, @@ -323,6 +324,7 @@ export enum WalletApiOperation { GetBankingChoicesForPayto = "getBankingChoicesForPayto", ConvertIbanAccountFieldToPayto = "convertIbanAccountFieldToPayto", ConvertIbanPaytoToAccountField = "convertIbanPaytoToAccountField", + GetDefaultExchanges = "getDefaultExchanges", // Tokens and token families ListDiscounts = "listDiscounts", @@ -1069,6 +1071,15 @@ export type GetExchangeDetailedInfoOp = { /** * Get the current terms of a service of an exchange. */ +export type GetDefaultExchangesOp = { + op: WalletApiOperation.GetDefaultExchanges; + request: EmptyObject; + response: GetDefaultExchangesResponse; +}; + +/** + * Get the current terms of a service of an exchange. + */ export type GetExchangeEntryByUrlOp = { op: WalletApiOperation.GetExchangeEntryByUrl; request: GetExchangeEntryByUrlRequest; @@ -1816,6 +1827,7 @@ export type WalletOperations = { [WalletApiOperation.GetDiagnostics]: TestingGetDiagnosticsOp; [WalletApiOperation.TestingGetPerformanceStats]: GetPerformanceStatsOp; [WalletApiOperation.TestingGetFlightRecords]: TestingGetFlightRecordsOp; + [WalletApiOperation.GetDefaultExchanges]: GetDefaultExchangesOp; }; export type WalletCoreRequestType< diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts @@ -84,6 +84,7 @@ import { GetChoicesForPaymentResult, GetCurrencySpecificationRequest, GetCurrencySpecificationResponse, + GetDefaultExchangesResponse, GetDepositWireTypesForCurrencyRequest, GetDepositWireTypesForCurrencyResponse, GetDepositWireTypesRequest, @@ -2051,6 +2052,31 @@ export async function handleGetFlightRecords( return { flightRecords: wex.ws.flightRecords }; } +export async function handleGetDefaultExchanges( + wex: WalletExecutionContext, + _req: EmptyObject, +): Promise<GetDefaultExchangesResponse> { + return { + defaultExchanges: [ + { + talerUri: "taler://withdraw-exchange/exchange.taler-ops.ch/", + currencySpec: { + name: "Swiss francs", + common_amounts: ["CHF:5", "CHF:10", "CHF:25", "CHF:50"], + num_fractional_input_digits: 2, + num_fractional_normal_digits: 2, + num_fractional_trailing_zero_digits: 2, + alt_unit_names: { + "0": "Fr.", + "-2": "Rp.", + }, + }, + countries: ["CH"], + }, + ], + }; +} + export async function handleGetDiagnostics( wex: WalletExecutionContext, req: EmptyObject, @@ -2113,6 +2139,10 @@ interface HandlerWithValidator<Tag extends WalletApiOperation> { } const handlers: { [T in WalletApiOperation]: HandlerWithValidator<T> } = { + [WalletApiOperation.GetDefaultExchanges]: { + codec: codecForEmptyObject(), + handler: handleGetDefaultExchanges, + }, [WalletApiOperation.TestingGetFlightRecords]: { codec: codecForEmptyObject(), handler: handleGetFlightRecords,