From ef636c022bb6f8017ef237a5e6468f5c449665ad Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 14 Jun 2021 19:37:35 +0200 Subject: implement force-retrying transactions --- .../src/operations/transactions.ts | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'packages/taler-wallet-core/src/operations') diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts index 3d9f1be41..1b2c8477f 100644 --- a/packages/taler-wallet-core/src/operations/transactions.ts +++ b/packages/taler-wallet-core/src/operations/transactions.ts @@ -38,6 +38,11 @@ import { } from "@gnu-taler/taler-util"; import { getFundingPaytoUris } from "./reserves.js"; import { getExchangeDetails } from "./exchanges.js"; +import { processWithdrawGroup } from "./withdraw.js"; +import { processPurchasePay } from "./pay.js"; +import { processDepositGroup } from "./deposits.js"; +import { processTip } from "./tip.js"; +import { processRefreshGroup } from "./refresh.js"; /** * Create an event ID from the type and the primary key for the event. @@ -398,6 +403,46 @@ export enum TombstoneTag { DeleteRefund = "delete-refund", } +/** + * Immediately retry the underlying operation + * of a transaction. + */ +export async function retryTransaction( + ws: InternalWalletState, + transactionId: string, +): Promise { + const [type, ...rest] = transactionId.split(":"); + + switch (type) { + case TransactionType.Deposit: + const depositGroupId = rest[0]; + processDepositGroup(ws, depositGroupId, true); + break; + case TransactionType.Withdrawal: { + const withdrawalGroupId = rest[0]; + await processWithdrawGroup(ws, withdrawalGroupId, true); + break; + } + case TransactionType.Payment: { + const proposalId = rest[0] + await processPurchasePay(ws, proposalId, true); + break; + } + case TransactionType.Tip: { + const walletTipId = rest[0]; + await processTip(ws, walletTipId, true); + break; + } + case TransactionType.Refresh: { + const refreshGroupId = rest[0]; + await processRefreshGroup(ws, refreshGroupId, true); + break; + } + default: + break; + } +} + /** * Permanently delete a transaction based on the transaction ID. */ -- cgit v1.2.3