diff options
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(); } } |