From 63aedafd841f3a3d7d3b7974d4e5b8fbd02afd3d Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 5 Mar 2024 10:30:25 +0100 Subject: wallet-core: have balance item even on zero balance Also add a test for this. --- packages/taler-wallet-core/src/balance.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'packages/taler-wallet-core/src/balance.ts') diff --git a/packages/taler-wallet-core/src/balance.ts b/packages/taler-wallet-core/src/balance.ts index 3b53699ac..6dc0783c0 100644 --- a/packages/taler-wallet-core/src/balance.ts +++ b/packages/taler-wallet-core/src/balance.ts @@ -80,7 +80,7 @@ import { getExchangeScopeInfo, getExchangeWireDetailsInTx, } from "./exchanges.js"; -import { InternalWalletState, WalletExecutionContext } from "./wallet.js"; +import { WalletExecutionContext } from "./wallet.js"; /** * Logger. @@ -178,6 +178,10 @@ class BalancesStore { return this.balanceStore[balanceKey]; } + async addZero(currency: string, exchangeBaseUrl: string): Promise { + await this.initBalance(currency, exchangeBaseUrl); + } + async addAvailable( currency: string, exchangeBaseUrl: string, @@ -304,6 +308,7 @@ export async function getBalancesInsideTransaction( await tx.coinAvailability.iter().forEachAsync(async (ca) => { const count = ca.visibleCoinCount ?? 0; + await balanceStore.addZero(ca.currency, ca.exchangeBaseUrl); for (let i = 0; i < count; i++) { await balanceStore.addAvailable( ca.currency, -- cgit v1.2.3