From c22b13eebe0577c2b948a99e42670580d49d60ce Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 7 Mar 2024 17:28:14 +0100 Subject: wallet-core: implement and test lost flag for denominations --- packages/taler-wallet-core/src/wallet.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'packages/taler-wallet-core/src/wallet.ts') diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index 8c9eee009..46f58ec81 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -57,6 +57,7 @@ import { TalerErrorCode, TalerProtocolTimestamp, TalerUriAction, + TestingGetDenomStatsResponse, TestingListTasksForTransactionsResponse, TestingWaitTransactionRequest, TimerAPI, @@ -126,6 +127,7 @@ import { codecForStartRefundQueryRequest, codecForSuspendTransaction, codecForTestPayArgs, + codecForTestingGetDenomStatsRequest, codecForTestingListTasksForTransactionRequest, codecForTestingSetTimetravelRequest, codecForTransactionByIdRequest, @@ -799,6 +801,29 @@ async function dispatchRequestInternal( }); return {}; } + case WalletApiOperation.TestingGetDenomStats: { + const req = codecForTestingGetDenomStatsRequest().decode(payload); + const denomStats: TestingGetDenomStatsResponse = { + numKnown: 0, + numLost: 0, + numOffered: 0, + }; + await wex.db.runReadOnlyTx(["denominations"], async (tx) => { + const denoms = await tx.denominations.indexes.byExchangeBaseUrl.getAll( + req.exchangeBaseUrl, + ); + for (const d of denoms) { + denomStats.numKnown++; + if (d.isOffered) { + denomStats.numOffered++; + } + if (d.isLost) { + denomStats.numLost++; + } + } + }); + return denomStats; + } case WalletApiOperation.ListExchanges: { return await listExchanges(wex); } -- cgit v1.2.3