diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts index 82ad54a20..0e35fe27c 100644 --- a/packages/taler-wallet-core/src/db.ts +++ b/packages/taler-wallet-core/src/db.ts @@ -1839,9 +1839,12 @@ export enum PeerPullPaymentInitiationStatus { PendingReady = 11 /* ACTIVE_START + 1 */, PendingMergeKycRequired = 12 /* ACTIVE_START + 2 */, PendingWithdrawing = 13, + SuspendedCreatePurse = 30, SuspendedReady = 31, - SuspendedWithdrawing = 32, + SuspendedMergeKycRequired = 32, + SuspendedWithdrawing = 33, + DonePurseDeposited = 50 /* DORMANT_START */, } @@ -1898,14 +1901,20 @@ export interface PeerPullPaymentInitiationRecord { } export enum PeerPushPaymentIncomingStatus { - Proposed = 30 /* USER_ATTENTION_START */, - Accepted = 10 /* ACTIVE_START */, + PendingMerge = 10 /* ACTIVE_START */, MergeKycRequired = 11 /* ACTIVE_START + 1 */, /** * Merge was successful and withdrawal group has been created, now * everything is in the hand of the withdrawal group. */ - Withdrawing = 12, + PendingWithdrawing = 12, + + SuspendedMerge = 20, + SuspendedMergeKycRequired = 21, + SuspendedWithdrawing = 22, + + DialogProposed = 30 /* USER_ATTENTION_START */, + Done = 50 /* DORMANT_START */, } @@ -1956,10 +1965,14 @@ export interface PeerPushPaymentIncomingRecord { kycInfo?: KycPendingInfo; } -export enum PeerPullPaymentIncomingStatus { - Proposed = 30 /* USER_ATTENTION_START */, - Accepted = 10 /* ACTIVE_START */, - Paid = 50 /* DORMANT_START */, +export enum PeerPullDebitRecordStatus { + PendingDeposit = 10 /* ACTIVE_START */, + + SuspendedDeposit = 11, + + DialogProposed = 30 /* USER_ATTENTION_START */, + + DonePaid = 50 /* DORMANT_START */, } export interface PeerPullPaymentCoinSelection { @@ -1995,7 +2008,7 @@ export interface PeerPullPaymentIncomingRecord { /** * Status of the peer push payment incoming initiation. */ - status: PeerPullPaymentIncomingStatus; + status: PeerPullDebitRecordStatus; /** * Estimated total cost when the record was created. diff --git a/packages/taler-wallet-core/src/operations/pay-peer.ts b/packages/taler-wallet-core/src/operations/pay-peer.ts index f464948f8..fb1260e3c 100644 --- a/packages/taler-wallet-core/src/operations/pay-peer.ts +++ b/packages/taler-wallet-core/src/operations/pay-peer.ts @@ -84,7 +84,7 @@ import { SpendCoinDetails } from "../crypto/cryptoImplementation.js"; import { DenominationRecord, PeerPullPaymentIncomingRecord, - PeerPullPaymentIncomingStatus, + PeerPullDebitRecordStatus, PeerPullPaymentInitiationRecord, PeerPullPaymentInitiationStatus, PeerPushPaymentCoinSelection, @@ -828,7 +828,8 @@ export async function preparePeerPushCredit( existing.existingPushInc.peerPushPaymentIncomingId, transactionId: constructTransactionIdentifier({ tag: TransactionType.PeerPushCredit, - peerPushPaymentIncomingId: existing.existingPushInc.peerPushPaymentIncomingId, + peerPushPaymentIncomingId: + existing.existingPushInc.peerPushPaymentIncomingId, }), }; } @@ -892,7 +893,7 @@ export async function preparePeerPushCredit( pursePub: pursePub, timestamp: TalerPreciseTimestamp.now(), contractTermsHash, - status: PeerPushPaymentIncomingStatus.Proposed, + status: PeerPushPaymentIncomingStatus.DialogProposed, withdrawalGroupId, currency: Amounts.currencyOf(purseStatus.balance), estimatedAmountEffective: Amounts.stringify( @@ -1120,7 +1121,7 @@ export async function processPeerPushCredit( return; } if ( - peerInc.status === PeerPushPaymentIncomingStatus.Accepted || + peerInc.status === PeerPushPaymentIncomingStatus.PendingMerge || peerInc.status === PeerPushPaymentIncomingStatus.MergeKycRequired ) { peerInc.status = PeerPushPaymentIncomingStatus.Done; @@ -1149,8 +1150,8 @@ export async function confirmPeerPushCredit( if (!peerInc) { return; } - if (peerInc.status === PeerPushPaymentIncomingStatus.Proposed) { - peerInc.status = PeerPushPaymentIncomingStatus.Accepted; + if (peerInc.status === PeerPushPaymentIncomingStatus.DialogProposed) { + peerInc.status = PeerPushPaymentIncomingStatus.PendingMerge; } await tx.peerPushPaymentIncoming.put(peerInc); }); @@ -1185,7 +1186,7 @@ export async function processPeerPullDebit( if (!peerPullInc) { throw Error("peer pull debit not found"); } - if (peerPullInc.status === PeerPullPaymentIncomingStatus.Accepted) { + if (peerPullInc.status === PeerPullDebitRecordStatus.PendingDeposit) { const pursePub = peerPullInc.pursePub; const coinSel = peerPullInc.coinSel; @@ -1231,8 +1232,8 @@ export async function processPeerPullDebit( if (!pi) { throw Error("peer pull payment not found anymore"); } - if (pi.status === PeerPullPaymentIncomingStatus.Accepted) { - pi.status = PeerPullPaymentIncomingStatus.Paid; + if (pi.status === PeerPullDebitRecordStatus.PendingDeposit) { + pi.status = PeerPullDebitRecordStatus.DonePaid; } await tx.peerPullPaymentIncoming.put(pi); }); @@ -1311,8 +1312,8 @@ export async function confirmPeerPullDebit( if (!pi) { throw Error(); } - if (pi.status === PeerPullPaymentIncomingStatus.Proposed) { - pi.status = PeerPullPaymentIncomingStatus.Accepted; + if (pi.status === PeerPullDebitRecordStatus.DialogProposed) { + pi.status = PeerPullDebitRecordStatus.PendingDeposit; pi.coinSel = { coinPubs: sel.coins.map((x) => x.coinPub), contributions: sel.coins.map((x) => x.contribution), @@ -1374,7 +1375,8 @@ export async function preparePeerPullDebit( existingPullIncomingRecord.peerPullPaymentIncomingId, transactionId: constructTransactionIdentifier({ tag: TransactionType.PeerPullDebit, - peerPullPaymentIncomingId: existingPullIncomingRecord.peerPullPaymentIncomingId, + peerPullPaymentIncomingId: + existingPullIncomingRecord.peerPullPaymentIncomingId, }), }; } @@ -1453,7 +1455,7 @@ export async function preparePeerPullDebit( pursePub: pursePub, timestampCreated: TalerPreciseTimestamp.now(), contractTerms, - status: PeerPullPaymentIncomingStatus.Proposed, + status: PeerPullDebitRecordStatus.DialogProposed, totalCostEstimated: Amounts.stringify(totalAmount), }); }); @@ -2249,12 +2251,12 @@ export function computePeerPushCreditTransactionState( pushCreditRecord: PeerPushPaymentIncomingRecord, ): TransactionState { switch (pushCreditRecord.status) { - case PeerPushPaymentIncomingStatus.Proposed: + case PeerPushPaymentIncomingStatus.DialogProposed: return { major: TransactionMajorState.Dialog, minor: TransactionMinorState.Proposed, }; - case PeerPushPaymentIncomingStatus.Accepted: + case PeerPushPaymentIncomingStatus.PendingMerge: return { major: TransactionMajorState.Pending, minor: TransactionMinorState.Merge, @@ -2268,11 +2270,26 @@ export function computePeerPushCreditTransactionState( major: TransactionMajorState.Pending, minor: TransactionMinorState.KycRequired, }; - case PeerPushPaymentIncomingStatus.Withdrawing: + case PeerPushPaymentIncomingStatus.PendingWithdrawing: return { major: TransactionMajorState.Pending, minor: TransactionMinorState.Withdraw, }; + case PeerPushPaymentIncomingStatus.SuspendedMerge: + return { + major: TransactionMajorState.Suspended, + minor: TransactionMinorState.Merge, + }; + case PeerPushPaymentIncomingStatus.SuspendedMergeKycRequired: + return { + major: TransactionMajorState.Suspended, + minor: TransactionMinorState.MergeKycRequired, + }; + case PeerPushPaymentIncomingStatus.SuspendedWithdrawing: + return { + major: TransactionMajorState.Suspended, + minor: TransactionMinorState.Withdraw, + }; } } @@ -2319,6 +2336,11 @@ export function computePeerPullCreditTransactionState( major: TransactionMajorState.Pending, minor: TransactionMinorState.Withdraw, }; + case PeerPullPaymentInitiationStatus.SuspendedMergeKycRequired: + return { + major: TransactionMajorState.Suspended, + minor: TransactionMinorState.MergeKycRequired, + }; } } @@ -2326,19 +2348,24 @@ export function computePeerPullDebitTransactionState( pullDebitRecord: PeerPullPaymentIncomingRecord, ): TransactionState { switch (pullDebitRecord.status) { - case PeerPullPaymentIncomingStatus.Proposed: + case PeerPullDebitRecordStatus.DialogProposed: return { major: TransactionMajorState.Dialog, minor: TransactionMinorState.Proposed, }; - case PeerPullPaymentIncomingStatus.Accepted: + case PeerPullDebitRecordStatus.PendingDeposit: return { major: TransactionMajorState.Pending, minor: TransactionMinorState.Deposit, }; - case PeerPullPaymentIncomingStatus.Paid: + case PeerPullDebitRecordStatus.DonePaid: return { major: TransactionMajorState.Done, }; + case PeerPullDebitRecordStatus.SuspendedDeposit: + return { + major: TransactionMajorState.Suspended, + minor: TransactionMinorState.Deposit, + }; } } diff --git a/packages/taler-wallet-core/src/operations/pending.ts b/packages/taler-wallet-core/src/operations/pending.ts index 7e098b19c..ed32b781d 100644 --- a/packages/taler-wallet-core/src/operations/pending.ts +++ b/packages/taler-wallet-core/src/operations/pending.ts @@ -29,7 +29,7 @@ import { OperationStatus, OperationStatusRange, PeerPushPaymentInitiationStatus, - PeerPullPaymentIncomingStatus, + PeerPullDebitRecordStatus, PeerPushPaymentIncomingStatus, PeerPullPaymentInitiationStatus, } from "../db.js"; @@ -395,11 +395,11 @@ async function gatherPeerPullDebitPending( ): Promise { await tx.peerPullPaymentIncoming.iter().forEachAsync(async (pi) => { switch (pi.status) { - case PeerPullPaymentIncomingStatus.Paid: + case PeerPullDebitRecordStatus.DonePaid: return; - case PeerPullPaymentIncomingStatus.Proposed: + case PeerPullDebitRecordStatus.DialogProposed: return; - case PeerPullPaymentIncomingStatus.Accepted: + case PeerPullDebitRecordStatus.PendingDeposit: break; } const opId = TaskIdentifiers.forPeerPullPaymentDebit(pi); @@ -452,7 +452,7 @@ async function gatherPeerPushCreditPending( ): Promise { await tx.peerPushPaymentIncoming.iter().forEachAsync(async (pi) => { switch (pi.status) { - case PeerPushPaymentIncomingStatus.Proposed: + case PeerPushPaymentIncomingStatus.DialogProposed: return; case PeerPushPaymentIncomingStatus.Done: return; diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts index 481ffe8bb..3645edd93 100644 --- a/packages/taler-wallet-core/src/operations/transactions.ts +++ b/packages/taler-wallet-core/src/operations/transactions.ts @@ -48,7 +48,7 @@ import { ExchangeDetailsRecord, OperationRetryRecord, PeerPullPaymentIncomingRecord, - PeerPullPaymentIncomingStatus, + PeerPullDebitRecordStatus, PeerPullPaymentInitiationRecord, PeerPushPaymentIncomingRecord, PeerPushPaymentIncomingStatus, @@ -906,8 +906,8 @@ export async function getTransactions( return; } if ( - pi.status !== PeerPullPaymentIncomingStatus.Accepted && - pi.status !== PeerPullPaymentIncomingStatus.Paid + pi.status !== PeerPullDebitRecordStatus.PendingDeposit && + pi.status !== PeerPullDebitRecordStatus.DonePaid ) { return; } @@ -926,7 +926,7 @@ export async function getTransactions( if (shouldSkipSearch(transactionsRequest, [])) { return; } - if (pi.status === PeerPushPaymentIncomingStatus.Proposed) { + if (pi.status === PeerPushPaymentIncomingStatus.DialogProposed) { // We don't report proposed push credit transactions, user needs // to scan URI again and confirm to see it. return;