diff options
author | Florian Dold <florian@dold.me> | 2023-06-30 16:14:58 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-06-30 16:14:58 +0200 |
commit | d4ee96138774e8bc469f172bbb6276af89d6f240 (patch) | |
tree | eda5bc6833306727f711cc5aedd5f307fa8b1f67 /packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts | |
parent | 7523ffa9105f71a6a4c201d3ee46dbfccc929cea (diff) |
wallet-core: rename OperationAttempt->TaskRun, do not allow task result values anymore
Diffstat (limited to 'packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts b/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts index 9ae94fff8..c853bc0ef 100644 --- a/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts +++ b/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts @@ -61,8 +61,8 @@ import { PendingTaskType } from "../pending-types.js"; import { assertUnreachable } from "../util/assertUnreachable.js"; import { checkLogicInvariant } from "../util/invariants.js"; import { - OperationAttemptResult, - OperationAttemptResultType, + TaskRunResult, + TaskRunResultType, constructTaskIdentifier, runLongpollAsync, spendCoins, @@ -110,12 +110,12 @@ async function handlePurseCreationConflict( ws: InternalWalletState, peerPushInitiation: PeerPushPaymentInitiationRecord, resp: HttpResponse, -): Promise<OperationAttemptResult> { +): Promise<TaskRunResult> { const pursePub = peerPushInitiation.pursePub; const errResp = await readTalerErrorResponse(resp); if (errResp.code !== TalerErrorCode.EXCHANGE_GENERIC_INSUFFICIENT_FUNDS) { await failPeerPushDebitTransaction(ws, pursePub); - return OperationAttemptResult.finishedEmpty(); + return TaskRunResult.finished(); } // FIXME: Properly parse! @@ -176,13 +176,13 @@ async function handlePurseCreationConflict( } await tx.peerPushPaymentInitiations.put(myPpi); }); - return OperationAttemptResult.finishedEmpty(); + return TaskRunResult.finished(); } async function processPeerPushDebitCreateReserve( ws: InternalWalletState, peerPushInitiation: PeerPushPaymentInitiationRecord, -): Promise<OperationAttemptResult> { +): Promise<TaskRunResult> { logger.info("processing peer-push-debit pending(create-reserve)"); const pursePub = peerPushInitiation.pursePub; const purseExpiration = peerPushInitiation.purseExpiration; @@ -264,7 +264,7 @@ async function processPeerPushDebitCreateReserve( case HttpStatusCode.Forbidden: { // FIXME: Store this error! await failPeerPushDebitTransaction(ws, pursePub); - return OperationAttemptResult.finishedEmpty(); + return TaskRunResult.finished(); } case HttpStatusCode.Conflict: { // Handle double-spending @@ -273,7 +273,7 @@ async function processPeerPushDebitCreateReserve( default: { const errResp = await readTalerErrorResponse(httpResp); return { - type: OperationAttemptResultType.Error, + type: TaskRunResultType.Error, errorDetail: errResp, }; } @@ -289,13 +289,13 @@ async function processPeerPushDebitCreateReserve( stTo: PeerPushPaymentInitiationStatus.PendingReady, }); - return OperationAttemptResult.finishedEmpty(); + return TaskRunResult.finished(); } async function processPeerPushDebitAbortingDeletePurse( ws: InternalWalletState, peerPushInitiation: PeerPushPaymentInitiationRecord, -): Promise<OperationAttemptResult> { +): Promise<TaskRunResult> { const { pursePub, pursePriv } = peerPushInitiation; const transactionId = constructTransactionIdentifier({ tag: TransactionType.PeerPushDebit, @@ -364,7 +364,7 @@ async function processPeerPushDebitAbortingDeletePurse( }); notifyTransition(ws, transactionId, transitionInfo); - return OperationAttemptResult.pendingEmpty(); + return TaskRunResult.pending(); } interface SimpleTransition { @@ -406,7 +406,7 @@ async function transitionPeerPushDebitTransaction( async function processPeerPushDebitAbortingRefresh( ws: InternalWalletState, peerPushInitiation: PeerPushPaymentInitiationRecord, -): Promise<OperationAttemptResult> { +): Promise<TaskRunResult> { const pursePub = peerPushInitiation.pursePub; const abortRefreshGroupId = peerPushInitiation.abortRefreshGroupId; checkLogicInvariant(!!abortRefreshGroupId); @@ -448,7 +448,7 @@ async function processPeerPushDebitAbortingRefresh( }); notifyTransition(ws, transactionId, transitionInfo); // FIXME: Shouldn't this be finished in some cases?! - return OperationAttemptResult.pendingEmpty(); + return TaskRunResult.pending(); } /** @@ -457,7 +457,7 @@ async function processPeerPushDebitAbortingRefresh( async function processPeerPushDebitReady( ws: InternalWalletState, peerPushInitiation: PeerPushPaymentInitiationRecord, -): Promise<OperationAttemptResult> { +): Promise<TaskRunResult> { logger.info("processing peer-push-debit pending(ready)"); const pursePub = peerPushInitiation.pursePub; const retryTag = constructTaskIdentifier({ @@ -520,14 +520,14 @@ async function processPeerPushDebitReady( "returning early from peer-push-debit for long-polling in background", ); return { - type: OperationAttemptResultType.Longpoll, + type: TaskRunResultType.Longpoll, }; } export async function processPeerPushDebit( ws: InternalWalletState, pursePub: string, -): Promise<OperationAttemptResult> { +): Promise<TaskRunResult> { const peerPushInitiation = await ws.db .mktx((x) => [x.peerPushPaymentInitiations]) .runReadOnly(async (tx) => { @@ -546,7 +546,7 @@ export async function processPeerPushDebit( if (ws.activeLongpoll[retryTag]) { logger.info("peer-push-debit task already in long-polling, returning!"); return { - type: OperationAttemptResultType.Longpoll, + type: TaskRunResultType.Longpoll, }; } @@ -567,10 +567,7 @@ export async function processPeerPushDebit( } } - return { - type: OperationAttemptResultType.Finished, - result: undefined, - }; + return TaskRunResult.finished(); } /** |