diff options
author | Florian Dold <florian@dold.me> | 2024-04-22 23:29:07 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2024-04-22 23:29:07 +0200 |
commit | a181ee06e4b52cb35e00ff8c86acff315135faf2 (patch) | |
tree | 9961ae277d861f93818c253e3992ad25128f6377 /packages/taler-wallet-cli | |
parent | e944c27e43474e8db464fbc593607e4e9d89576d (diff) | |
download | wallet-core-a181ee06e4b52cb35e00ff8c86acff315135faf2.tar.xz |
wallet-core: unify handling of run-until-done, simplify waiter implementation
Diffstat (limited to 'packages/taler-wallet-cli')
-rw-r--r-- | packages/taler-wallet-cli/src/index.ts | 31 |
1 files changed, 3 insertions, 28 deletions
diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts index 8c4760223..f0ff02903 100644 --- a/packages/taler-wallet-cli/src/index.ts +++ b/packages/taler-wallet-cli/src/index.ts @@ -358,25 +358,6 @@ async function withWallet<T>( } } -/** - * Run a function with a local wallet. - * - * Stops the wallet after the function is done. - */ -async function withLocalWallet<T>( - walletCliArgs: WalletCliArgsType, - f: (w: { client: WalletCoreApiClient; ws: Wallet }) => Promise<T>, -): Promise<T> { - const wh = await createLocalWallet(walletCliArgs, (notif) => { - writeObservabilityLog(notif); - }); - const w = wh.wallet; - const res = await f({ client: w.client, ws: w }); - logger.info("Work done, stopping wallet."); - w.stop(); - return res; -} - walletCli .subcommand("balance", "balance", { help: "Show wallet balance." }) .flag("json", ["--json"], { @@ -584,12 +565,8 @@ walletCli help: "Run until no more work is left.", }) .action(async (args) => { - await withLocalWallet(args, async (wallet) => { - logger.info("running until pending operations are finished"); - await wallet.ws.runTaskLoop({ - stopWhenDone: true, - }); - wallet.ws.stop(); + await withWallet(args, async (ctx) => { + await ctx.client.call(WalletApiOperation.TestingWaitTasksDone, {}); }); }); @@ -1330,9 +1307,7 @@ advancedCli exchangeBaseUrl: "http://localhost:8081/", merchantBaseUrl: "http://localhost:8083/", }); - await wallet.runTaskLoop({ - stopWhenDone: true, - }); + await wallet.client.call(WalletApiOperation.TestingWaitTasksDone, {}); wallet.stop(); }); |