From a181ee06e4b52cb35e00ff8c86acff315135faf2 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 22 Apr 2024 23:29:07 +0200 Subject: wallet-core: unify handling of run-until-done, simplify waiter implementation --- packages/taler-wallet-cli/src/index.ts | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) (limited to 'packages/taler-wallet-cli') 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( } } -/** - * Run a function with a local wallet. - * - * Stops the wallet after the function is done. - */ -async function withLocalWallet( - walletCliArgs: WalletCliArgsType, - f: (w: { client: WalletCoreApiClient; ws: Wallet }) => Promise, -): Promise { - 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(); }); -- cgit v1.2.3