diff options
author | Florian Dold <florian@dold.me> | 2024-03-07 17:28:14 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2024-03-07 17:28:42 +0100 |
commit | c22b13eebe0577c2b948a99e42670580d49d60ce (patch) | |
tree | 9497f6edba090d03139490d279f233057a23d69e /packages/taler-wallet-core/src/wallet.ts | |
parent | 284df1fb5d3e255ef802de389e3fd9ba11a3184f (diff) | |
download | wallet-core-c22b13eebe0577c2b948a99e42670580d49d60ce.tar.gz wallet-core-c22b13eebe0577c2b948a99e42670580d49d60ce.tar.bz2 wallet-core-c22b13eebe0577c2b948a99e42670580d49d60ce.zip |
wallet-core: implement and test lost flag for denominations
Diffstat (limited to 'packages/taler-wallet-core/src/wallet.ts')
-rw-r--r-- | packages/taler-wallet-core/src/wallet.ts | 25 |
1 files changed, 25 insertions, 0 deletions
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<Op extends WalletApiOperation>( }); 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); } |