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-credit.ts | |
parent | 7523ffa9105f71a6a4c201d3ee46dbfccc929cea (diff) | |
download | wallet-core-d4ee96138774e8bc469f172bbb6276af89d6f240.tar.xz |
wallet-core: rename OperationAttempt->TaskRun, do not allow task result values anymore
Diffstat (limited to 'packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts b/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts index 3e5750af7..e76b934fa 100644 --- a/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts +++ b/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts @@ -62,8 +62,8 @@ import { import { assertUnreachable } from "../util/assertUnreachable.js"; import { checkDbInvariant } from "../util/invariants.js"; import { - OperationAttemptResult, - OperationAttemptResultType, + TaskRunResult, + TaskRunResultType, constructTaskIdentifier, runLongpollAsync, } from "./common.js"; @@ -233,7 +233,7 @@ async function longpollKycStatus( exchangeUrl: string, kycInfo: KycPendingInfo, userType: KycUserType, -): Promise<OperationAttemptResult> { +): Promise<TaskRunResult> { const transactionId = constructTransactionIdentifier({ tag: TransactionType.PeerPushCredit, peerPushPaymentIncomingId, @@ -293,7 +293,7 @@ async function longpollKycStatus( } }); return { - type: OperationAttemptResultType.Longpoll, + type: TaskRunResultType.Longpoll, }; } @@ -301,7 +301,7 @@ async function processPeerPushCreditKycRequired( ws: InternalWalletState, peerInc: PeerPushPaymentIncomingRecord, kycPending: WalletKycUuid, -): Promise<OperationAttemptResult> { +): Promise<TaskRunResult> { const transactionId = constructTransactionIdentifier({ tag: TransactionType.PeerPushCredit, peerPushPaymentIncomingId: peerInc.peerPushPaymentIncomingId, @@ -326,10 +326,7 @@ async function processPeerPushCreditKycRequired( kycStatusRes.status === HttpStatusCode.NoContent ) { logger.warn("kyc requested, but already fulfilled"); - return { - type: OperationAttemptResultType.Finished, - result: undefined, - }; + return TaskRunResult.finished(); } else if (kycStatusRes.status === HttpStatusCode.Accepted) { const kycStatus = await kycStatusRes.json(); logger.info(`kyc status: ${j2s(kycStatus)}`); @@ -342,7 +339,7 @@ async function processPeerPushCreditKycRequired( if (!peerInc) { return { transitionInfo: undefined, - result: OperationAttemptResult.finishedEmpty(), + result: TaskRunResult.finished(), }; } const oldTxState = computePeerPushCreditTransactionState(peerInc); @@ -356,8 +353,8 @@ async function processPeerPushCreditKycRequired( await tx.peerPushPaymentIncoming.put(peerInc); // We'll remove this eventually! New clients should rely on the // kycUrl field of the transaction, not the error code. - const res: OperationAttemptResult = { - type: OperationAttemptResultType.Error, + const res: TaskRunResult = { + type: TaskRunResultType.Error, errorDetail: makeErrorDetail( TalerErrorCode.WALLET_WITHDRAWAL_KYC_REQUIRED, { @@ -381,7 +378,7 @@ async function handlePendingMerge( ws: InternalWalletState, peerInc: PeerPushPaymentIncomingRecord, contractTerms: PeerContractTerms, -): Promise<OperationAttemptResult> { +): Promise<TaskRunResult> { const { peerPushPaymentIncomingId } = peerInc; const transactionId = constructTransactionIdentifier({ tag: TransactionType.PeerPushCredit, @@ -506,16 +503,13 @@ async function handlePendingMerge( ); notifyTransition(ws, transactionId, txRes?.peerPushCreditTransition); - return { - type: OperationAttemptResultType.Finished, - result: undefined, - }; + return TaskRunResult.finished(); } async function handlePendingWithdrawing( ws: InternalWalletState, peerInc: PeerPushPaymentIncomingRecord, -): Promise<OperationAttemptResult> { +): Promise<TaskRunResult> { if (!peerInc.withdrawalGroupId) { throw Error("invalid db state (withdrawing, but no withdrawal group ID"); } @@ -561,17 +555,17 @@ async function handlePendingWithdrawing( }); notifyTransition(ws, transactionId, transitionInfo); if (finished) { - return OperationAttemptResult.finishedEmpty(); + return TaskRunResult.finished(); } else { // FIXME: Return indicator that we depend on the other operation! - return OperationAttemptResult.pendingEmpty(); + return TaskRunResult.pending(); } } export async function processPeerPushCredit( ws: InternalWalletState, peerPushPaymentIncomingId: string, -): Promise<OperationAttemptResult> { +): Promise<TaskRunResult> { let peerInc: PeerPushPaymentIncomingRecord | undefined; let contractTerms: PeerContractTerms | undefined; await ws.db @@ -617,7 +611,7 @@ export async function processPeerPushCredit( return handlePendingWithdrawing(ws, peerInc); default: - return OperationAttemptResult.finishedEmpty(); + return TaskRunResult.finished(); } } |