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 | 314 |
1 files changed, 157 insertions, 157 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 afeeb2c6b..f0f659aa3 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 @@ -55,7 +55,7 @@ import { KycPendingInfo, KycUserType, PeerPushPaymentIncomingRecord, - PeerPushPaymentIncomingStatus, + PeerPushCreditStatus, PendingTaskType, WithdrawalGroupStatus, WithdrawalRecordType, @@ -99,10 +99,10 @@ export async function preparePeerPushCredit( } const existing = await ws.db - .mktx((x) => [x.contractTerms, x.peerPushPaymentIncoming]) + .mktx((x) => [x.contractTerms, x.peerPushCredit]) .runReadOnly(async (tx) => { const existingPushInc = - await tx.peerPushPaymentIncoming.indexes.byExchangeAndContractPriv.get([ + await tx.peerPushCredit.indexes.byExchangeAndContractPriv.get([ uri.exchangeBaseUrl, uri.contractPriv, ]); @@ -129,12 +129,12 @@ export async function preparePeerPushCredit( amountEffective: existing.existingPushInc.estimatedAmountEffective, amountRaw: existing.existingContractTerms.amount, contractTerms: existing.existingContractTerms, - peerPushPaymentIncomingId: - existing.existingPushInc.peerPushPaymentIncomingId, + peerPushCreditId: + existing.existingPushInc.peerPushCreditId, transactionId: constructTransactionIdentifier({ tag: TransactionType.PeerPushCredit, - peerPushPaymentIncomingId: - existing.existingPushInc.peerPushPaymentIncomingId, + peerPushCreditId: + existing.existingPushInc.peerPushCreditId, }), }; } @@ -172,7 +172,7 @@ export async function preparePeerPushCredit( codecForExchangePurseStatus(), ); - const peerPushPaymentIncomingId = encodeCrock(getRandomBytes(32)); + const peerPushCreditId = encodeCrock(getRandomBytes(32)); const contractTermsHash = ContractTermsUtil.hashContractTerms( dec.contractTerms, @@ -188,17 +188,17 @@ export async function preparePeerPushCredit( ); await ws.db - .mktx((x) => [x.contractTerms, x.peerPushPaymentIncoming]) + .mktx((x) => [x.contractTerms, x.peerPushCredit]) .runReadWrite(async (tx) => { - await tx.peerPushPaymentIncoming.add({ - peerPushPaymentIncomingId, + await tx.peerPushCredit.add({ + peerPushCreditId, contractPriv: contractPriv, exchangeBaseUrl: exchangeBaseUrl, mergePriv: dec.mergePriv, pursePub: pursePub, timestamp: TalerPreciseTimestamp.now(), contractTermsHash, - status: PeerPushPaymentIncomingStatus.DialogProposed, + status: PeerPushCreditStatus.DialogProposed, withdrawalGroupId, currency: Amounts.currencyOf(purseStatus.balance), estimatedAmountEffective: Amounts.stringify( @@ -219,28 +219,28 @@ export async function preparePeerPushCredit( amountEffective: wi.withdrawalAmountEffective, amountRaw: purseStatus.balance, contractTerms: dec.contractTerms, - peerPushPaymentIncomingId, + peerPushCreditId, transactionId: constructTransactionIdentifier({ tag: TransactionType.PeerPushCredit, - peerPushPaymentIncomingId, + peerPushCreditId, }), }; } async function longpollKycStatus( ws: InternalWalletState, - peerPushPaymentIncomingId: string, + peerPushCreditId: string, exchangeUrl: string, kycInfo: KycPendingInfo, userType: KycUserType, ): Promise<TaskRunResult> { const transactionId = constructTransactionIdentifier({ tag: TransactionType.PeerPushCredit, - peerPushPaymentIncomingId, + peerPushCreditId, }); const retryTag = constructTaskIdentifier({ tag: PendingTaskType.PeerPushCredit, - peerPushPaymentIncomingId, + peerPushCreditId, }); runLongpollAsync(ws, retryTag, async (ct) => { @@ -261,24 +261,24 @@ async function longpollKycStatus( kycStatusRes.status === HttpStatusCode.NoContent ) { const transitionInfo = await ws.db - .mktx((x) => [x.peerPushPaymentIncoming]) + .mktx((x) => [x.peerPushCredit]) .runReadWrite(async (tx) => { - const peerInc = await tx.peerPushPaymentIncoming.get( - peerPushPaymentIncomingId, + const peerInc = await tx.peerPushCredit.get( + peerPushCreditId, ); if (!peerInc) { return; } if ( peerInc.status !== - PeerPushPaymentIncomingStatus.PendingMergeKycRequired + PeerPushCreditStatus.PendingMergeKycRequired ) { return; } const oldTxState = computePeerPushCreditTransactionState(peerInc); - peerInc.status = PeerPushPaymentIncomingStatus.PendingMerge; + peerInc.status = PeerPushCreditStatus.PendingMerge; const newTxState = computePeerPushCreditTransactionState(peerInc); - await tx.peerPushPaymentIncoming.put(peerInc); + await tx.peerPushCredit.put(peerInc); return { oldTxState, newTxState }; }); notifyTransition(ws, transactionId, transitionInfo); @@ -304,9 +304,9 @@ async function processPeerPushCreditKycRequired( ): Promise<TaskRunResult> { const transactionId = constructTransactionIdentifier({ tag: TransactionType.PeerPushCredit, - peerPushPaymentIncomingId: peerInc.peerPushPaymentIncomingId, + peerPushCreditId: peerInc.peerPushCreditId, }); - const { peerPushPaymentIncomingId } = peerInc; + const { peerPushCreditId } = peerInc; const userType = "individual"; const url = new URL( @@ -331,10 +331,10 @@ async function processPeerPushCreditKycRequired( const kycStatus = await kycStatusRes.json(); logger.info(`kyc status: ${j2s(kycStatus)}`); const { transitionInfo, result } = await ws.db - .mktx((x) => [x.peerPushPaymentIncoming]) + .mktx((x) => [x.peerPushCredit]) .runReadWrite(async (tx) => { - const peerInc = await tx.peerPushPaymentIncoming.get( - peerPushPaymentIncomingId, + const peerInc = await tx.peerPushCredit.get( + peerPushCreditId, ); if (!peerInc) { return { @@ -348,9 +348,9 @@ async function processPeerPushCreditKycRequired( requirementRow: kycPending.requirement_row, }; peerInc.kycUrl = kycStatus.kyc_url; - peerInc.status = PeerPushPaymentIncomingStatus.PendingMergeKycRequired; + peerInc.status = PeerPushCreditStatus.PendingMergeKycRequired; const newTxState = computePeerPushCreditTransactionState(peerInc); - await tx.peerPushPaymentIncoming.put(peerInc); + await tx.peerPushCredit.put(peerInc); // We'll remove this eventually! New clients should rely on the // kycUrl field of the transaction, not the error code. const res: TaskRunResult = { @@ -379,10 +379,10 @@ async function handlePendingMerge( peerInc: PeerPushPaymentIncomingRecord, contractTerms: PeerContractTerms, ): Promise<TaskRunResult> { - const { peerPushPaymentIncomingId } = peerInc; + const { peerPushCreditId } = peerInc; const transactionId = constructTransactionIdentifier({ tag: TransactionType.PeerPushCredit, - peerPushPaymentIncomingId, + peerPushCreditId, }); const amount = Amounts.parseOrThrow(contractTerms.amount); @@ -460,15 +460,15 @@ async function handlePendingMerge( const txRes = await ws.db .mktx((x) => [ x.contractTerms, - x.peerPushPaymentIncoming, + x.peerPushCredit, x.withdrawalGroups, x.reserves, x.exchanges, x.exchangeDetails, ]) .runReadWrite(async (tx) => { - const peerInc = await tx.peerPushPaymentIncoming.get( - peerPushPaymentIncomingId, + const peerInc = await tx.peerPushCredit.get( + peerPushCreditId, ); if (!peerInc) { return undefined; @@ -476,9 +476,9 @@ async function handlePendingMerge( let withdrawalTransition: TransitionInfo | undefined; const oldTxState = computePeerPushCreditTransactionState(peerInc); switch (peerInc.status) { - case PeerPushPaymentIncomingStatus.PendingMerge: - case PeerPushPaymentIncomingStatus.PendingMergeKycRequired: { - peerInc.status = PeerPushPaymentIncomingStatus.PendingWithdrawing; + case PeerPushCreditStatus.PendingMerge: + case PeerPushCreditStatus.PendingMergeKycRequired: { + peerInc.status = PeerPushCreditStatus.PendingWithdrawing; const wgRes = await internalPerformCreateWithdrawalGroup( ws, tx, @@ -488,7 +488,7 @@ async function handlePendingMerge( break; } } - await tx.peerPushPaymentIncoming.put(peerInc); + await tx.peerPushCredit.put(peerInc); const newTxState = computePeerPushCreditTransactionState(peerInc); return { peerPushCreditTransition: { oldTxState, newTxState }, @@ -514,21 +514,21 @@ async function handlePendingWithdrawing( } const transactionId = constructTransactionIdentifier({ tag: TransactionType.PeerPushCredit, - peerPushPaymentIncomingId: peerInc.peerPushPaymentIncomingId, + peerPushCreditId: peerInc.peerPushCreditId, }); const wgId = peerInc.withdrawalGroupId; let finished: boolean = false; const transitionInfo = await ws.db - .mktx((x) => [x.peerPushPaymentIncoming, x.withdrawalGroups]) + .mktx((x) => [x.peerPushCredit, x.withdrawalGroups]) .runReadWrite(async (tx) => { - const ppi = await tx.peerPushPaymentIncoming.get( - peerInc.peerPushPaymentIncomingId, + const ppi = await tx.peerPushCredit.get( + peerInc.peerPushCreditId, ); if (!ppi) { finished = true; return; } - if (ppi.status !== PeerPushPaymentIncomingStatus.PendingWithdrawing) { + if (ppi.status !== PeerPushCreditStatus.PendingWithdrawing) { finished = true; return; } @@ -539,13 +539,13 @@ async function handlePendingWithdrawing( return undefined; } switch (wg.status) { - case WithdrawalGroupStatus.Finished: + case WithdrawalGroupStatus.Done: finished = true; - ppi.status = PeerPushPaymentIncomingStatus.Done; + ppi.status = PeerPushCreditStatus.Done; break; // FIXME: Also handle other final states! } - await tx.peerPushPaymentIncoming.put(ppi); + await tx.peerPushCredit.put(ppi); const newTxState = computePeerPushCreditTransactionState(ppi); return { oldTxState, @@ -563,14 +563,14 @@ async function handlePendingWithdrawing( export async function processPeerPushCredit( ws: InternalWalletState, - peerPushPaymentIncomingId: string, + peerPushCreditId: string, ): Promise<TaskRunResult> { let peerInc: PeerPushPaymentIncomingRecord | undefined; let contractTerms: PeerContractTerms | undefined; await ws.db - .mktx((x) => [x.contractTerms, x.peerPushPaymentIncoming]) + .mktx((x) => [x.contractTerms, x.peerPushCredit]) .runReadWrite(async (tx) => { - peerInc = await tx.peerPushPaymentIncoming.get(peerPushPaymentIncomingId); + peerInc = await tx.peerPushCredit.get(peerPushCreditId); if (!peerInc) { return; } @@ -578,35 +578,35 @@ export async function processPeerPushCredit( if (ctRec) { contractTerms = ctRec.contractTermsRaw; } - await tx.peerPushPaymentIncoming.put(peerInc); + await tx.peerPushCredit.put(peerInc); }); checkDbInvariant(!!contractTerms); if (!peerInc) { throw Error( - `can't accept unknown incoming p2p push payment (${peerPushPaymentIncomingId})`, + `can't accept unknown incoming p2p push payment (${peerPushCreditId})`, ); } switch (peerInc.status) { - case PeerPushPaymentIncomingStatus.PendingMergeKycRequired: { + case PeerPushCreditStatus.PendingMergeKycRequired: { if (!peerInc.kycInfo) { throw Error("invalid state, kycInfo required"); } return await longpollKycStatus( ws, - peerPushPaymentIncomingId, + peerPushCreditId, peerInc.exchangeBaseUrl, peerInc.kycInfo, "individual", ); } - case PeerPushPaymentIncomingStatus.PendingMerge: + case PeerPushCreditStatus.PendingMerge: return handlePendingMerge(ws, peerInc, contractTerms); - case PeerPushPaymentIncomingStatus.PendingWithdrawing: + case PeerPushCreditStatus.PendingWithdrawing: return handlePendingWithdrawing(ws, peerInc); default: @@ -619,9 +619,9 @@ export async function confirmPeerPushCredit( req: ConfirmPeerPushCreditRequest, ): Promise<AcceptPeerPushPaymentResponse> { let peerInc: PeerPushPaymentIncomingRecord | undefined; - let peerPushPaymentIncomingId: string; - if (req.peerPushPaymentIncomingId) { - peerPushPaymentIncomingId = req.peerPushPaymentIncomingId; + let peerPushCreditId: string; + if (req.peerPushCreditId) { + peerPushCreditId = req.peerPushCreditId; } else if (req.transactionId) { const parsedTx = parseTransactionIdentifier(req.transactionId); if (!parsedTx) { @@ -630,29 +630,29 @@ export async function confirmPeerPushCredit( if (parsedTx.tag !== TransactionType.PeerPushCredit) { throw Error("invalid transaction ID type"); } - peerPushPaymentIncomingId = parsedTx.peerPushPaymentIncomingId; + peerPushCreditId = parsedTx.peerPushCreditId; } else { throw Error( - "no transaction ID (or deprecated peerPushPaymentIncomingId) provided", + "no transaction ID (or deprecated peerPushCreditId) provided", ); } await ws.db - .mktx((x) => [x.contractTerms, x.peerPushPaymentIncoming]) + .mktx((x) => [x.contractTerms, x.peerPushCredit]) .runReadWrite(async (tx) => { - peerInc = await tx.peerPushPaymentIncoming.get(peerPushPaymentIncomingId); + peerInc = await tx.peerPushCredit.get(peerPushCreditId); if (!peerInc) { return; } - if (peerInc.status === PeerPushPaymentIncomingStatus.DialogProposed) { - peerInc.status = PeerPushPaymentIncomingStatus.PendingMerge; + if (peerInc.status === PeerPushCreditStatus.DialogProposed) { + peerInc.status = PeerPushCreditStatus.PendingMerge; } - await tx.peerPushPaymentIncoming.put(peerInc); + await tx.peerPushCredit.put(peerInc); }); if (!peerInc) { throw Error( - `can't accept unknown incoming p2p push payment (${req.peerPushPaymentIncomingId})`, + `can't accept unknown incoming p2p push payment (${req.peerPushCreditId})`, ); } @@ -660,7 +660,7 @@ export async function confirmPeerPushCredit( const transactionId = constructTransactionIdentifier({ tag: TransactionType.PeerPushCredit, - peerPushPaymentIncomingId, + peerPushCreditId, }); return { @@ -670,48 +670,48 @@ export async function confirmPeerPushCredit( export async function suspendPeerPushCreditTransaction( ws: InternalWalletState, - peerPushPaymentIncomingId: string, + peerPushCreditId: string, ) { const taskId = constructTaskIdentifier({ tag: PendingTaskType.PeerPushCredit, - peerPushPaymentIncomingId, + peerPushCreditId, }); const transactionId = constructTransactionIdentifier({ tag: TransactionType.PeerPushCredit, - peerPushPaymentIncomingId, + peerPushCreditId, }); stopLongpolling(ws, taskId); const transitionInfo = await ws.db - .mktx((x) => [x.peerPushPaymentIncoming]) + .mktx((x) => [x.peerPushCredit]) .runReadWrite(async (tx) => { - const pushCreditRec = await tx.peerPushPaymentIncoming.get( - peerPushPaymentIncomingId, + const pushCreditRec = await tx.peerPushCredit.get( + peerPushCreditId, ); if (!pushCreditRec) { - logger.warn(`peer push credit ${peerPushPaymentIncomingId} not found`); + logger.warn(`peer push credit ${peerPushCreditId} not found`); return; } - let newStatus: PeerPushPaymentIncomingStatus | undefined = undefined; + let newStatus: PeerPushCreditStatus | undefined = undefined; switch (pushCreditRec.status) { - case PeerPushPaymentIncomingStatus.DialogProposed: - case PeerPushPaymentIncomingStatus.Done: - case PeerPushPaymentIncomingStatus.SuspendedMerge: - case PeerPushPaymentIncomingStatus.SuspendedMergeKycRequired: - case PeerPushPaymentIncomingStatus.SuspendedWithdrawing: + case PeerPushCreditStatus.DialogProposed: + case PeerPushCreditStatus.Done: + case PeerPushCreditStatus.SuspendedMerge: + case PeerPushCreditStatus.SuspendedMergeKycRequired: + case PeerPushCreditStatus.SuspendedWithdrawing: break; - case PeerPushPaymentIncomingStatus.PendingMergeKycRequired: - newStatus = PeerPushPaymentIncomingStatus.SuspendedMergeKycRequired; + case PeerPushCreditStatus.PendingMergeKycRequired: + newStatus = PeerPushCreditStatus.SuspendedMergeKycRequired; break; - case PeerPushPaymentIncomingStatus.PendingMerge: - newStatus = PeerPushPaymentIncomingStatus.SuspendedMerge; + case PeerPushCreditStatus.PendingMerge: + newStatus = PeerPushCreditStatus.SuspendedMerge; break; - case PeerPushPaymentIncomingStatus.PendingWithdrawing: + case PeerPushCreditStatus.PendingWithdrawing: // FIXME: Suspend internal withdrawal transaction! - newStatus = PeerPushPaymentIncomingStatus.SuspendedWithdrawing; + newStatus = PeerPushCreditStatus.SuspendedWithdrawing; break; - case PeerPushPaymentIncomingStatus.Aborted: + case PeerPushCreditStatus.Aborted: break; - case PeerPushPaymentIncomingStatus.Failed: + case PeerPushCreditStatus.Failed: break; default: assertUnreachable(pushCreditRec.status); @@ -720,7 +720,7 @@ export async function suspendPeerPushCreditTransaction( const oldTxState = computePeerPushCreditTransactionState(pushCreditRec); pushCreditRec.status = newStatus; const newTxState = computePeerPushCreditTransactionState(pushCreditRec); - await tx.peerPushPaymentIncoming.put(pushCreditRec); + await tx.peerPushCredit.put(pushCreditRec); return { oldTxState, newTxState, @@ -733,51 +733,51 @@ export async function suspendPeerPushCreditTransaction( export async function abortPeerPushCreditTransaction( ws: InternalWalletState, - peerPushPaymentIncomingId: string, + peerPushCreditId: string, ) { const taskId = constructTaskIdentifier({ tag: PendingTaskType.PeerPushCredit, - peerPushPaymentIncomingId, + peerPushCreditId, }); const transactionId = constructTransactionIdentifier({ tag: TransactionType.PeerPushCredit, - peerPushPaymentIncomingId, + peerPushCreditId, }); stopLongpolling(ws, taskId); const transitionInfo = await ws.db - .mktx((x) => [x.peerPushPaymentIncoming]) + .mktx((x) => [x.peerPushCredit]) .runReadWrite(async (tx) => { - const pushCreditRec = await tx.peerPushPaymentIncoming.get( - peerPushPaymentIncomingId, + const pushCreditRec = await tx.peerPushCredit.get( + peerPushCreditId, ); if (!pushCreditRec) { - logger.warn(`peer push credit ${peerPushPaymentIncomingId} not found`); + logger.warn(`peer push credit ${peerPushCreditId} not found`); return; } - let newStatus: PeerPushPaymentIncomingStatus | undefined = undefined; + let newStatus: PeerPushCreditStatus | undefined = undefined; switch (pushCreditRec.status) { - case PeerPushPaymentIncomingStatus.DialogProposed: - newStatus = PeerPushPaymentIncomingStatus.Aborted; + case PeerPushCreditStatus.DialogProposed: + newStatus = PeerPushCreditStatus.Aborted; break; - case PeerPushPaymentIncomingStatus.Done: + case PeerPushCreditStatus.Done: break; - case PeerPushPaymentIncomingStatus.SuspendedMerge: - case PeerPushPaymentIncomingStatus.SuspendedMergeKycRequired: - case PeerPushPaymentIncomingStatus.SuspendedWithdrawing: - newStatus = PeerPushPaymentIncomingStatus.Aborted; + case PeerPushCreditStatus.SuspendedMerge: + case PeerPushCreditStatus.SuspendedMergeKycRequired: + case PeerPushCreditStatus.SuspendedWithdrawing: + newStatus = PeerPushCreditStatus.Aborted; break; - case PeerPushPaymentIncomingStatus.PendingMergeKycRequired: - newStatus = PeerPushPaymentIncomingStatus.Aborted; + case PeerPushCreditStatus.PendingMergeKycRequired: + newStatus = PeerPushCreditStatus.Aborted; break; - case PeerPushPaymentIncomingStatus.PendingMerge: - newStatus = PeerPushPaymentIncomingStatus.Aborted; + case PeerPushCreditStatus.PendingMerge: + newStatus = PeerPushCreditStatus.Aborted; break; - case PeerPushPaymentIncomingStatus.PendingWithdrawing: - newStatus = PeerPushPaymentIncomingStatus.Aborted; + case PeerPushCreditStatus.PendingWithdrawing: + newStatus = PeerPushCreditStatus.Aborted; break; - case PeerPushPaymentIncomingStatus.Aborted: + case PeerPushCreditStatus.Aborted: break; - case PeerPushPaymentIncomingStatus.Failed: + case PeerPushCreditStatus.Failed: break; default: assertUnreachable(pushCreditRec.status); @@ -786,7 +786,7 @@ export async function abortPeerPushCreditTransaction( const oldTxState = computePeerPushCreditTransactionState(pushCreditRec); pushCreditRec.status = newStatus; const newTxState = computePeerPushCreditTransactionState(pushCreditRec); - await tx.peerPushPaymentIncoming.put(pushCreditRec); + await tx.peerPushCredit.put(pushCreditRec); return { oldTxState, newTxState, @@ -799,7 +799,7 @@ export async function abortPeerPushCreditTransaction( export async function failPeerPushCreditTransaction( ws: InternalWalletState, - peerPushPaymentIncomingId: string, + peerPushCreditId: string, ) { // We don't have any "aborting" states! throw Error("can't run cancel-aborting on peer-push-credit transaction"); @@ -807,47 +807,47 @@ export async function failPeerPushCreditTransaction( export async function resumePeerPushCreditTransaction( ws: InternalWalletState, - peerPushPaymentIncomingId: string, + peerPushCreditId: string, ) { const taskId = constructTaskIdentifier({ tag: PendingTaskType.PeerPushCredit, - peerPushPaymentIncomingId, + peerPushCreditId, }); const transactionId = constructTransactionIdentifier({ tag: TransactionType.PeerPushCredit, - peerPushPaymentIncomingId, + peerPushCreditId, }); stopLongpolling(ws, taskId); const transitionInfo = await ws.db - .mktx((x) => [x.peerPushPaymentIncoming]) + .mktx((x) => [x.peerPushCredit]) .runReadWrite(async (tx) => { - const pushCreditRec = await tx.peerPushPaymentIncoming.get( - peerPushPaymentIncomingId, + const pushCreditRec = await tx.peerPushCredit.get( + peerPushCreditId, ); if (!pushCreditRec) { - logger.warn(`peer push credit ${peerPushPaymentIncomingId} not found`); + logger.warn(`peer push credit ${peerPushCreditId} not found`); return; } - let newStatus: PeerPushPaymentIncomingStatus | undefined = undefined; + let newStatus: PeerPushCreditStatus | undefined = undefined; switch (pushCreditRec.status) { - case PeerPushPaymentIncomingStatus.DialogProposed: - case PeerPushPaymentIncomingStatus.Done: - case PeerPushPaymentIncomingStatus.PendingMergeKycRequired: - case PeerPushPaymentIncomingStatus.PendingMerge: - case PeerPushPaymentIncomingStatus.PendingWithdrawing: - case PeerPushPaymentIncomingStatus.SuspendedMerge: - newStatus = PeerPushPaymentIncomingStatus.PendingMerge; + case PeerPushCreditStatus.DialogProposed: + case PeerPushCreditStatus.Done: + case PeerPushCreditStatus.PendingMergeKycRequired: + case PeerPushCreditStatus.PendingMerge: + case PeerPushCreditStatus.PendingWithdrawing: + case PeerPushCreditStatus.SuspendedMerge: + newStatus = PeerPushCreditStatus.PendingMerge; break; - case PeerPushPaymentIncomingStatus.SuspendedMergeKycRequired: - newStatus = PeerPushPaymentIncomingStatus.PendingMergeKycRequired; + case PeerPushCreditStatus.SuspendedMergeKycRequired: + newStatus = PeerPushCreditStatus.PendingMergeKycRequired; break; - case PeerPushPaymentIncomingStatus.SuspendedWithdrawing: + case PeerPushCreditStatus.SuspendedWithdrawing: // FIXME: resume underlying "internal-withdrawal" transaction. - newStatus = PeerPushPaymentIncomingStatus.PendingWithdrawing; + newStatus = PeerPushCreditStatus.PendingWithdrawing; break; - case PeerPushPaymentIncomingStatus.Aborted: + case PeerPushCreditStatus.Aborted: break; - case PeerPushPaymentIncomingStatus.Failed: + case PeerPushCreditStatus.Failed: break; default: assertUnreachable(pushCreditRec.status); @@ -856,7 +856,7 @@ export async function resumePeerPushCreditTransaction( const oldTxState = computePeerPushCreditTransactionState(pushCreditRec); pushCreditRec.status = newStatus; const newTxState = computePeerPushCreditTransactionState(pushCreditRec); - await tx.peerPushPaymentIncoming.put(pushCreditRec); + await tx.peerPushCredit.put(pushCreditRec); return { oldTxState, newTxState, @@ -872,50 +872,50 @@ export function computePeerPushCreditTransactionState( pushCreditRecord: PeerPushPaymentIncomingRecord, ): TransactionState { switch (pushCreditRecord.status) { - case PeerPushPaymentIncomingStatus.DialogProposed: + case PeerPushCreditStatus.DialogProposed: return { major: TransactionMajorState.Dialog, minor: TransactionMinorState.Proposed, }; - case PeerPushPaymentIncomingStatus.PendingMerge: + case PeerPushCreditStatus.PendingMerge: return { major: TransactionMajorState.Pending, minor: TransactionMinorState.Merge, }; - case PeerPushPaymentIncomingStatus.Done: + case PeerPushCreditStatus.Done: return { major: TransactionMajorState.Done, }; - case PeerPushPaymentIncomingStatus.PendingMergeKycRequired: + case PeerPushCreditStatus.PendingMergeKycRequired: return { major: TransactionMajorState.Pending, minor: TransactionMinorState.KycRequired, }; - case PeerPushPaymentIncomingStatus.PendingWithdrawing: + case PeerPushCreditStatus.PendingWithdrawing: return { major: TransactionMajorState.Pending, minor: TransactionMinorState.Withdraw, }; - case PeerPushPaymentIncomingStatus.SuspendedMerge: + case PeerPushCreditStatus.SuspendedMerge: return { major: TransactionMajorState.Suspended, minor: TransactionMinorState.Merge, }; - case PeerPushPaymentIncomingStatus.SuspendedMergeKycRequired: + case PeerPushCreditStatus.SuspendedMergeKycRequired: return { major: TransactionMajorState.Suspended, minor: TransactionMinorState.MergeKycRequired, }; - case PeerPushPaymentIncomingStatus.SuspendedWithdrawing: + case PeerPushCreditStatus.SuspendedWithdrawing: return { major: TransactionMajorState.Suspended, minor: TransactionMinorState.Withdraw, }; - case PeerPushPaymentIncomingStatus.Aborted: + case PeerPushCreditStatus.Aborted: return { major: TransactionMajorState.Aborted, }; - case PeerPushPaymentIncomingStatus.Failed: + case PeerPushCreditStatus.Failed: return { major: TransactionMajorState.Failed, }; @@ -928,25 +928,25 @@ export function computePeerPushCreditTransactionActions( pushCreditRecord: PeerPushPaymentIncomingRecord, ): TransactionAction[] { switch (pushCreditRecord.status) { - case PeerPushPaymentIncomingStatus.DialogProposed: + case PeerPushCreditStatus.DialogProposed: return [TransactionAction.Delete]; - case PeerPushPaymentIncomingStatus.PendingMerge: + case PeerPushCreditStatus.PendingMerge: return [TransactionAction.Abort, TransactionAction.Suspend]; - case PeerPushPaymentIncomingStatus.Done: + case PeerPushCreditStatus.Done: return [TransactionAction.Delete]; - case PeerPushPaymentIncomingStatus.PendingMergeKycRequired: + case PeerPushCreditStatus.PendingMergeKycRequired: return [TransactionAction.Abort, TransactionAction.Suspend]; - case PeerPushPaymentIncomingStatus.PendingWithdrawing: + case PeerPushCreditStatus.PendingWithdrawing: return [TransactionAction.Suspend, TransactionAction.Fail]; - case PeerPushPaymentIncomingStatus.SuspendedMerge: + case PeerPushCreditStatus.SuspendedMerge: return [TransactionAction.Resume, TransactionAction.Abort]; - case PeerPushPaymentIncomingStatus.SuspendedMergeKycRequired: + case PeerPushCreditStatus.SuspendedMergeKycRequired: return [TransactionAction.Resume, TransactionAction.Abort]; - case PeerPushPaymentIncomingStatus.SuspendedWithdrawing: + case PeerPushCreditStatus.SuspendedWithdrawing: return [TransactionAction.Resume, TransactionAction.Fail]; - case PeerPushPaymentIncomingStatus.Aborted: + case PeerPushCreditStatus.Aborted: return [TransactionAction.Delete]; - case PeerPushPaymentIncomingStatus.Failed: + case PeerPushCreditStatus.Failed: return [TransactionAction.Delete]; default: assertUnreachable(pushCreditRecord.status); |