From d4ee96138774e8bc469f172bbb6276af89d6f240 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Fri, 30 Jun 2023 16:14:58 +0200 Subject: wallet-core: rename OperationAttempt->TaskRun, do not allow task result values anymore --- .../src/operations/pay-peer-pull-debit.ts | 30 +++++++++------------- 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts') diff --git a/packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts b/packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts index 9d8fabfb2..1aa332439 100644 --- a/packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts +++ b/packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts @@ -62,8 +62,8 @@ import { import { assertUnreachable } from "../util/assertUnreachable.js"; import { checkLogicInvariant } from "../util/invariants.js"; import { - OperationAttemptResult, - OperationAttemptResultType, + TaskRunResult, + TaskRunResultType, TaskIdentifiers, constructTaskIdentifier, runTaskWithErrorReporting, @@ -89,12 +89,12 @@ async function handlePurseCreationConflict( ws: InternalWalletState, peerPullInc: PeerPullPaymentIncomingRecord, resp: HttpResponse, -): Promise { +): Promise { const pursePub = peerPullInc.pursePub; const errResp = await readTalerErrorResponse(resp); if (errResp.code !== TalerErrorCode.EXCHANGE_GENERIC_INSUFFICIENT_FUNDS) { await failPeerPullDebitTransaction(ws, pursePub); - return OperationAttemptResult.finishedEmpty(); + return TaskRunResult.finished(); } // FIXME: Properly parse! @@ -167,13 +167,13 @@ async function handlePurseCreationConflict( } await tx.peerPullPaymentIncoming.put(myPpi); }); - return OperationAttemptResult.finishedEmpty(); + return TaskRunResult.finished(); } async function processPeerPullDebitPendingDeposit( ws: InternalWalletState, peerPullInc: PeerPullPaymentIncomingRecord, -): Promise { +): Promise { const peerPullPaymentIncomingId = peerPullInc.peerPullPaymentIncomingId; const pursePub = peerPullInc.pursePub; @@ -299,21 +299,18 @@ async function processPeerPullDebitPendingDeposit( default: { const errResp = await readTalerErrorResponse(httpResp); return { - type: OperationAttemptResultType.Error, + type: TaskRunResultType.Error, errorDetail: errResp, }; } } - return { - type: OperationAttemptResultType.Finished, - result: undefined, - }; + return TaskRunResult.finished(); } async function processPeerPullDebitAbortingRefresh( ws: InternalWalletState, peerPullInc: PeerPullPaymentIncomingRecord, -): Promise { +): Promise { const peerPullPaymentIncomingId = peerPullInc.peerPullPaymentIncomingId; const abortRefreshGroupId = peerPullInc.abortRefreshGroupId; checkLogicInvariant(!!abortRefreshGroupId); @@ -357,13 +354,13 @@ async function processPeerPullDebitAbortingRefresh( }); notifyTransition(ws, transactionId, transitionInfo); // FIXME: Shouldn't this be finished in some cases?! - return OperationAttemptResult.pendingEmpty(); + return TaskRunResult.pending(); } export async function processPeerPullDebit( ws: InternalWalletState, peerPullPaymentIncomingId: string, -): Promise { +): Promise { const peerPullInc = await ws.db .mktx((x) => [x.peerPullPaymentIncoming]) .runReadOnly(async (tx) => { @@ -379,10 +376,7 @@ export async function processPeerPullDebit( case PeerPullDebitRecordStatus.AbortingRefresh: return await processPeerPullDebitAbortingRefresh(ws, peerPullInc); } - return { - type: OperationAttemptResultType.Finished, - result: undefined, - }; + return TaskRunResult.finished(); } export async function confirmPeerPullDebit( -- cgit v1.2.3