taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 5af31804c98c53691fd03dc0083f10d694cfeb75
parent 7480e7870ce486b670f3e2ff6b3363563cec9fa5
Author: Florian Dold <florian@dold.me>
Date:   Thu, 29 Feb 2024 23:50:30 +0100

fix condition

Diffstat:
Mpackages/taler-wallet-cli/src/index.ts | 2+-
Mpackages/taler-wallet-core/src/wallet.ts | 68++++++++++++++++++++++++++++++++++++++------------------------------
2 files changed, 39 insertions(+), 31 deletions(-)

diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts @@ -273,7 +273,7 @@ async function createLocalWallet( applyVerbose(walletCliArgs.wallet.verbose); const res = { wallet: wh.wallet, getStats: wh.getDbStats }; - if (!noInit) { + if (noInit) { return res; } try { diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts @@ -172,7 +172,6 @@ import { CoinSourceType, ConfigRecordKey, DenominationRecord, - OperationRetryRecord, WalletDbReadOnlyTransaction, WalletStoresV1, clearDatabase, @@ -181,7 +180,6 @@ import { openStoredBackupsDatabase, openTalerDatabase, timestampAbsoluteFromDb, - timestampPreciseFromDb, timestampProtocolToDb, } from "./db.js"; import { @@ -519,9 +517,9 @@ async function dumpCoins(wex: WalletExecutionContext): Promise<CoinDumpJson> { ageCommitmentProof: c.ageCommitmentProof, spend_allocation: c.spendAllocation ? { - amount: c.spendAllocation.amount, - id: c.spendAllocation.id, - } + amount: c.spendAllocation.amount, + id: c.spendAllocation.id, + } : undefined, }); } @@ -989,31 +987,41 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>( return {}; } case WalletApiOperation.GetActiveTasks: { - const allTasksId = wex.taskScheduler.getActiveTasks() + const allTasksId = wex.taskScheduler.getActiveTasks(); + + const tasksInfo = await Promise.all( + allTasksId.map(async (id) => { + return await wex.ws.db.runReadOnlyTx( + ["operationRetries"], + async (tx) => { + return tx.operationRetries.get(id); + }, + ); + }), + ); - const tasksInfo = await Promise.all(allTasksId.map(async (id) => { - return await wex.ws.db.runReadOnlyTx( - ["operationRetries"], - async (tx) => { - return tx.operationRetries.get(id); - }, - ) - })) - - const tasks = allTasksId - .map((taskId, i): ActiveTask => { - const transaction = convertTaskToTransactionId(taskId); - const d = tasksInfo[i] - - const firstTry = !d?undefined:timestampAbsoluteFromDb(d.retryInfo.firstTry) - const nextTry = !d?undefined:timestampAbsoluteFromDb(d.retryInfo.nextRetry) - const counter = d?.retryInfo.retryCounter - const lastError = d?.lastError - - return { - id: taskId, counter, firstTry, nextTry, lastError, transaction - } - }) + const tasks = allTasksId.map((taskId, i): ActiveTask => { + const transaction = convertTaskToTransactionId(taskId); + const d = tasksInfo[i]; + + const firstTry = !d + ? undefined + : timestampAbsoluteFromDb(d.retryInfo.firstTry); + const nextTry = !d + ? undefined + : timestampAbsoluteFromDb(d.retryInfo.nextRetry); + const counter = d?.retryInfo.retryCounter; + const lastError = d?.lastError; + + return { + id: taskId, + counter, + firstTry, + nextTry, + lastError, + transaction, + }; + }); return { tasks }; } case WalletApiOperation.FailTransaction: { @@ -1491,7 +1499,7 @@ async function handleCoreApiRequest( wex = getObservedWalletExecutionContext(ws, CancellationToken.CONTINUE, oc); } else { oc = { - observe(evt) { }, + observe(evt) {}, }; wex = getNormalWalletExecutionContext(ws, CancellationToken.CONTINUE, oc); }