diff options
Diffstat (limited to 'packages/taler-wallet-core/src/operations/recoup.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/recoup.ts | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/packages/taler-wallet-core/src/operations/recoup.ts b/packages/taler-wallet-core/src/operations/recoup.ts index 782e98d1c..0ae873125 100644 --- a/packages/taler-wallet-core/src/operations/recoup.ts +++ b/packages/taler-wallet-core/src/operations/recoup.ts @@ -30,6 +30,7 @@ import { Logger, RefreshReason, TalerPreciseTimestamp, + TransactionType, URL, codecForRecoupConfirmation, codecForReserveStatus, @@ -52,9 +53,15 @@ import { import { InternalWalletState } from "../internal-wallet-state.js"; import { checkDbInvariant } from "../util/invariants.js"; import { GetReadWriteAccess } from "../util/query.js"; -import { TaskRunResult } from "./common.js"; +import { + TaskRunResult, + TransactionContext, + constructTaskIdentifier, +} from "./common.js"; import { createRefreshGroup } from "./refresh.js"; import { internalCreateWithdrawalGroup } from "./withdraw.js"; +import { constructTransactionIdentifier } from "./transactions.js"; +import { PendingTaskType } from "../pending-types.js"; const logger = new Logger("operations/recoup.ts"); @@ -394,12 +401,16 @@ export async function processRecoupGroup( } rg2.timestampFinished = timestampPreciseToDb(TalerPreciseTimestamp.now()); if (rg2.scheduleRefreshCoins.length > 0) { - const refreshGroupId = await createRefreshGroup( + await createRefreshGroup( ws, tx, Amounts.currencyOf(rg2.scheduleRefreshCoins[0].amount), rg2.scheduleRefreshCoins, RefreshReason.Recoup, + constructTransactionIdentifier({ + tag: TransactionType.Recoup, + recoupGroupId: rg2.recoupGroupId, + }), ); } await tx.recoupGroups.put(rg2); @@ -407,6 +418,40 @@ export async function processRecoupGroup( return TaskRunResult.finished(); } +export class RewardTransactionContext implements TransactionContext { + abortTransaction(): Promise<void> { + throw new Error("Method not implemented."); + } + suspendTransaction(): Promise<void> { + throw new Error("Method not implemented."); + } + resumeTransaction(): Promise<void> { + throw new Error("Method not implemented."); + } + failTransaction(): Promise<void> { + throw new Error("Method not implemented."); + } + deleteTransaction(): Promise<void> { + throw new Error("Method not implemented."); + } + public transactionId: string; + public retryTag: string; + + constructor( + public ws: InternalWalletState, + private recoupGroupId: string, + ) { + this.transactionId = constructTransactionIdentifier({ + tag: TransactionType.Recoup, + recoupGroupId, + }); + this.retryTag = constructTaskIdentifier({ + tag: PendingTaskType.Recoup, + recoupGroupId, + }); + } +} + export async function createRecoupGroup( ws: InternalWalletState, tx: GetReadWriteAccess<{ |