taler-typescript-core

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

commit c445a377255402431deeca43a10603bc1bac6e60
parent aaa11fabdacd0763c15b6a415f05e79cd4baba6e
Author: Florian Dold <dold@taler.net>
Date:   Wed, 22 Jul 2026 10:44:00 +0200

wallet: accept setWalletRunConfig as the first request

The operation is the primary name for the handler that initializes the wallet,
but the guards in front of the dispatcher only let its initWallet alias
through.

Diffstat:
Mpackages/taler-wallet-core/src/requests.ts | 14+++++++++++++-
Mpackages/taler-wallet-core/src/wallet.ts | 7+++++--
2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/packages/taler-wallet-core/src/requests.ts b/packages/taler-wallet-core/src/requests.ts @@ -2668,6 +2668,18 @@ const handlers: { [T in WalletApiOperation]: HandlerWithValidator<T> } = { }; /** + * Check whether an operation may be run before the wallet is initialized. + * + * Both operations run the same handler, either of them initializes the wallet. + */ +export function isWalletInitOperation(operation: string): boolean { + return ( + operation === WalletApiOperation.InitWallet || + operation === WalletApiOperation.SetWalletRunConfig + ); +} + +/** * Implementation of the "wallet-core" API. */ export async function dispatchRequestInternal( @@ -2675,7 +2687,7 @@ export async function dispatchRequestInternal( operation: WalletApiOperation, payload: unknown, ): Promise<WalletCoreResponseType<typeof operation>> { - if (!wex.ws.initCalled && operation !== WalletApiOperation.InitWallet) { + if (!wex.ws.initCalled && !isWalletInitOperation(operation)) { throw Error( `wallet must be initialized before running operation ${operation}`, ); diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts @@ -85,7 +85,10 @@ import { } from "./observable-wrappers.js"; import { ProgressContext } from "./progress.js"; import { TransactionAbortedError } from "./query.js"; -import { dispatchRequestInternal } from "./requests.js"; +import { + dispatchRequestInternal, + isWalletInitOperation, +} from "./requests.js"; import { TaskScheduler, TaskSchedulerImpl } from "./shepherd.js"; import { rematerializeTransactions } from "./transactions.js"; import { @@ -452,7 +455,7 @@ async function dispatchWalletCoreApiRequest( id: string, payload: unknown, ): Promise<CoreApiResponse> { - if (operation !== WalletApiOperation.InitWallet) { + if (!isWalletInitOperation(operation)) { if (!ws.initCalled) { throw Error("init must be called first"); }