summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/wallet.ts
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-02-28 22:41:41 -0300
committerSebastian <sebasjm@gmail.com>2024-02-28 22:41:41 -0300
commit74b9ee559fc57f48a591140eb342cc8e2bbd3dd3 (patch)
treec26fb1cf465edc41ba625ce790eed2c71f308f77 /packages/taler-wallet-core/src/wallet.ts
parent83c5a50f6c95a9ddde0db6ae1eeb6039550375e5 (diff)
downloadwallet-core-74b9ee559fc57f48a591140eb342cc8e2bbd3dd3.tar.gz
wallet-core-74b9ee559fc57f48a591140eb342cc8e2bbd3dd3.tar.bz2
wallet-core-74b9ee559fc57f48a591140eb342cc8e2bbd3dd3.zip
get activity
Diffstat (limited to 'packages/taler-wallet-core/src/wallet.ts')
-rw-r--r--packages/taler-wallet-core/src/wallet.ts41
1 files changed, 37 insertions, 4 deletions
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts
index 14f4c85c3..2757f7fec 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -24,6 +24,7 @@
*/
import { IDBFactory } from "@gnu-taler/idb-bridge";
import {
+ ActiveTask,
AmountString,
Amounts,
AsyncCondition,
@@ -168,6 +169,7 @@ import {
CoinSourceType,
ConfigRecordKey,
DenominationRecord,
+ OperationRetryRecord,
WalletDbReadOnlyTransaction,
WalletStoresV1,
clearDatabase,
@@ -175,6 +177,8 @@ import {
importDb,
openStoredBackupsDatabase,
openTalerDatabase,
+ timestampAbsoluteFromDb,
+ timestampPreciseFromDb,
timestampProtocolToDb,
} from "./db.js";
import {
@@ -238,6 +242,7 @@ import { forceRefresh } from "./refresh.js";
import {
TaskScheduler,
TaskSchedulerImpl,
+ convertTaskToTransactionId,
listTaskForTransactionId,
} from "./shepherd.js";
import {
@@ -513,9 +518,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,
});
}
@@ -968,6 +973,34 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
await suspendTransaction(wex, req.transactionId);
return {};
}
+ case WalletApiOperation.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 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: {
const req = codecForFailTransactionRequest().decode(payload);
await failTransaction(wex, req.transactionId);
@@ -1438,7 +1471,7 @@ async function handleCoreApiRequest(
wex = getObservedWalletExecutionContext(ws, CancellationToken.CONTINUE, oc);
} else {
oc = {
- observe(evt) {},
+ observe(evt) { },
};
wex = getNormalWalletExecutionContext(ws, CancellationToken.CONTINUE, oc);
}