diff options
Diffstat (limited to 'packages/taler-wallet-core/src')
-rw-r--r-- | packages/taler-wallet-core/src/shepherd.ts | 85 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/wallet-api-types.ts | 13 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/wallet.ts | 15 |
3 files changed, 112 insertions, 1 deletions
diff --git a/packages/taler-wallet-core/src/shepherd.ts b/packages/taler-wallet-core/src/shepherd.ts index e6ea412e3..8fdf2b66b 100644 --- a/packages/taler-wallet-core/src/shepherd.ts +++ b/packages/taler-wallet-core/src/shepherd.ts @@ -843,6 +843,91 @@ async function makeExchangeRetryNotification( return notif; } +export function listTaskForTransactionId(transactionId: string): TaskIdStr[] { + const tid = parseTransactionIdentifier(transactionId); + if (!tid) { + throw Error("invalid task ID"); + } + switch (tid.tag) { + case TransactionType.Deposit: + return [ + constructTaskIdentifier({ + tag: PendingTaskType.Deposit, + depositGroupId: tid.depositGroupId, + }), + ]; + case TransactionType.InternalWithdrawal: + return [ + constructTaskIdentifier({ + tag: PendingTaskType.Withdraw, + withdrawalGroupId: tid.withdrawalGroupId, + }), + ]; + case TransactionType.Payment: + return [ + constructTaskIdentifier({ + tag: PendingTaskType.Purchase, + proposalId: tid.proposalId, + }), + ]; + case TransactionType.PeerPullCredit: + return [ + constructTaskIdentifier({ + tag: PendingTaskType.PeerPullCredit, + pursePub: tid.pursePub, + }), + ]; + case TransactionType.PeerPullDebit: + return [ + constructTaskIdentifier({ + tag: PendingTaskType.PeerPullDebit, + peerPullDebitId: tid.peerPullDebitId, + }), + ]; + case TransactionType.PeerPushCredit: + return [ + constructTaskIdentifier({ + tag: PendingTaskType.PeerPullCredit, + pursePub: tid.peerPushCreditId, + }), + ]; + case TransactionType.PeerPushDebit: + return [ + constructTaskIdentifier({ + tag: PendingTaskType.PeerPullCredit, + pursePub: tid.pursePub, + }), + ]; + case TransactionType.Recoup: + return [ + constructTaskIdentifier({ + tag: PendingTaskType.Recoup, + recoupGroupId: tid.recoupGroupId, + }), + ]; + case TransactionType.Refresh: + return [ + constructTaskIdentifier({ + tag: PendingTaskType.Refresh, + refreshGroupId: tid.refreshGroupId, + }), + ]; + case TransactionType.Refund: + return []; + case TransactionType.Reward: + return []; + case TransactionType.Withdrawal: + return [ + constructTaskIdentifier({ + tag: PendingTaskType.Withdraw, + withdrawalGroupId: tid.withdrawalGroupId, + }), + ]; + default: + assertUnreachable(tid); + } +} + /** * Convert the task ID for a task that processes a transaction int * the ID for the transaction. diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts b/packages/taler-wallet-core/src/wallet-api-types.ts index cf8f93ed1..5e2d83a33 100644 --- a/packages/taler-wallet-core/src/wallet-api-types.ts +++ b/packages/taler-wallet-core/src/wallet-api-types.ts @@ -116,6 +116,8 @@ import { StoredBackupList, TestPayArgs, TestPayResult, + TestingListTasksForTransactionRequest, + TestingListTasksForTransactionsResponse, TestingSetTimetravelRequest, TestingWaitTransactionRequest, Transaction, @@ -250,6 +252,7 @@ export enum WalletApiOperation { AddGlobalCurrencyAuditor = "addGlobalCurrencyAuditor", RemoveGlobalCurrencyAuditor = "removeGlobalCurrencyAuditor", ListAssociatedRefreshes = "listAssociatedRefreshes", + TestingListTaskForTransaction = "testingListTasksForTransaction", } // group: Initialization @@ -1114,6 +1117,15 @@ export type TestingSetTimetravelOp = { }; /** + * Add an offset to the wallet's internal time. + */ +export type TestingListTasksForTransactionOp = { + op: WalletApiOperation.TestingListTaskForTransaction; + request: TestingListTasksForTransactionRequest; + response: TestingListTasksForTransactionsResponse; +}; + +/** * Wait until all transactions are in a final state. */ export type TestingWaitTransactionsFinalOp = { @@ -1263,6 +1275,7 @@ export type WalletOperations = { [WalletApiOperation.AddGlobalCurrencyExchange]: AddGlobalCurrencyExchangeOp; [WalletApiOperation.RemoveGlobalCurrencyExchange]: RemoveGlobalCurrencyExchangeOp; [WalletApiOperation.ListAssociatedRefreshes]: ListAssociatedRefreshesOp; + [WalletApiOperation.TestingListTaskForTransaction]: TestingListTasksForTransactionOp; }; export type WalletCoreRequestType< diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index ea3c4bb83..14f4c85c3 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -55,6 +55,7 @@ import { TalerErrorCode, TalerProtocolTimestamp, TalerUriAction, + TestingListTasksForTransactionsResponse, TestingWaitTransactionRequest, TimerAPI, TimerGroup, @@ -121,6 +122,7 @@ import { codecForStartRefundQueryRequest, codecForSuspendTransaction, codecForTestPayArgs, + codecForTestingListTasksForTransactionRequest, codecForTestingSetTimetravelRequest, codecForTransactionByIdRequest, codecForTransactionsRequest, @@ -233,7 +235,11 @@ import { } from "./pay-peer-push-debit.js"; import { DbAccess } from "./query.js"; import { forceRefresh } from "./refresh.js"; -import { TaskScheduler, TaskSchedulerImpl } from "./shepherd.js"; +import { + TaskScheduler, + TaskSchedulerImpl, + listTaskForTransactionId, +} from "./shepherd.js"; import { runIntegrationTest, runIntegrationTest2, @@ -717,6 +723,13 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>( await withdrawTestBalance(wex, req); return {}; } + case WalletApiOperation.TestingListTaskForTransaction: { + const req = + codecForTestingListTasksForTransactionRequest().decode(payload); + return { + taskIdList: listTaskForTransactionId(req.transactionId), + } satisfies TestingListTasksForTransactionsResponse; + } case WalletApiOperation.RunIntegrationTest: { const req = codecForIntegrationTestArgs().decode(payload); await runIntegrationTest(wex, req); |