From 60805f3ff88d7ecd149a88ec7cea846384155c5b Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Fri, 5 May 2023 10:56:42 +0200 Subject: DD37 wip --- .../src/operations/transactions.ts | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'packages/taler-wallet-core/src/operations/transactions.ts') diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts index c122bb651..02f11d82d 100644 --- a/packages/taler-wallet-core/src/operations/transactions.ts +++ b/packages/taler-wallet-core/src/operations/transactions.ts @@ -87,14 +87,14 @@ import { } from "./deposits.js"; import { getExchangeDetails } from "./exchanges.js"; import { - abortPay, + abortPayMerchant, computePayMerchantTransactionState, expectProposalDownload, extractContractData, processPurchasePay, } from "./pay-merchant.js"; -import { processPeerPullCredit } from "./pay-peer.js"; -import { processRefreshGroup } from "./refresh.js"; +import { computePeerPullCreditTransactionState, computePeerPullDebitTransactionState, computePeerPushCreditTransactionState, computePeerPushDebitTransactionState, processPeerPullCredit } from "./pay-peer.js"; +import { computeRefreshTransactionState, processRefreshGroup } from "./refresh.js"; import { computeTipTransactionStatus, processTip } from "./tip.js"; import { abortWithdrawalTransaction, @@ -445,7 +445,7 @@ function buildTransactionForPushPaymentDebit( ): Transaction { return { type: TransactionType.PeerPushDebit, - txState: mkTxStateUnknown(), + txState: computePeerPushDebitTransactionState(pi), amountEffective: pi.totalCost, amountRaw: pi.amount, exchangeBaseUrl: pi.exchangeBaseUrl, @@ -455,10 +455,10 @@ function buildTransactionForPushPaymentDebit( }, frozen: false, extendedStatus: - pi.status != PeerPushPaymentInitiationStatus.PurseCreated + pi.status != PeerPushPaymentInitiationStatus.Done ? ExtendedStatus.Pending : ExtendedStatus.Done, - pending: pi.status != PeerPushPaymentInitiationStatus.PurseCreated, + pending: pi.status != PeerPushPaymentInitiationStatus.Done, timestamp: pi.timestampCreated, talerUri: constructPayPushUri({ exchangeBaseUrl: pi.exchangeBaseUrl, @@ -478,7 +478,7 @@ function buildTransactionForPullPaymentDebit( ): Transaction { return { type: TransactionType.PeerPullDebit, - txState: mkTxStateUnknown(), + txState: computePeerPullDebitTransactionState(pi), amountEffective: pi.coinSel?.totalCost ? pi.coinSel?.totalCost : Amounts.stringify(pi.contractTerms.amount), @@ -528,7 +528,7 @@ function buildTransactionForPeerPullCredit( }); return { type: TransactionType.PeerPullCredit, - txState: mkTxStateUnknown(), + txState: computePeerPullCreditTransactionState(pullCredit), amountEffective: Amounts.stringify(wsr.denomsSel.totalCoinValue), amountRaw: Amounts.stringify(wsr.instructedAmount), exchangeBaseUrl: wsr.exchangeBaseUrl, @@ -563,7 +563,7 @@ function buildTransactionForPeerPullCredit( return { type: TransactionType.PeerPullCredit, - txState: mkTxStateUnknown(), + txState: computePeerPullCreditTransactionState(pullCredit), amountEffective: Amounts.stringify(pullCredit.estimatedAmountEffective), amountRaw: Amounts.stringify(peerContractTerms.amount), exchangeBaseUrl: pullCredit.exchangeBaseUrl, @@ -602,7 +602,7 @@ function buildTransactionForPeerPushCredit( return { type: TransactionType.PeerPushCredit, - txState: mkTxStateUnknown(), + txState: computePeerPushCreditTransactionState(pushInc), amountEffective: Amounts.stringify(wsr.denomsSel.totalCoinValue), amountRaw: Amounts.stringify(wsr.instructedAmount), exchangeBaseUrl: wsr.exchangeBaseUrl, @@ -626,7 +626,7 @@ function buildTransactionForPeerPushCredit( return { type: TransactionType.PeerPushCredit, - txState: mkTxStateUnknown(), + txState: computePeerPushCreditTransactionState(pushInc), // FIXME: This is wrong, needs to consider fees! amountEffective: Amounts.stringify(peerContractTerms.amount), amountRaw: Amounts.stringify(peerContractTerms.amount), @@ -666,7 +666,7 @@ function buildTransactionForBankIntegratedWithdraw( bankConfirmationUrl: wgRecord.wgInfo.bankInfo.confirmUrl, reserveIsReady: wgRecord.status === WithdrawalGroupStatus.Finished || - wgRecord.status === WithdrawalGroupStatus.Ready, + wgRecord.status === WithdrawalGroupStatus.PendingReady, }, exchangeBaseUrl: wgRecord.exchangeBaseUrl, extendedStatus: wgRecord.timestampFinish @@ -713,7 +713,7 @@ function buildTransactionForManualWithdraw( exchangePaytoUris, reserveIsReady: withdrawalGroup.status === WithdrawalGroupStatus.Finished || - withdrawalGroup.status === WithdrawalGroupStatus.Ready, + withdrawalGroup.status === WithdrawalGroupStatus.PendingReady, }, exchangeBaseUrl: withdrawalGroup.exchangeBaseUrl, extendedStatus: withdrawalGroup.timestampFinish @@ -753,7 +753,7 @@ function buildTransactionForRefresh( ).amount; return { type: TransactionType.Refresh, - txState: mkTxStateUnknown(), + txState: computeRefreshTransactionState(refreshGroupRecord), refreshReason: refreshGroupRecord.reason, amountEffective: Amounts.stringify( Amounts.zeroOfCurrency(refreshGroupRecord.currency), @@ -1538,7 +1538,7 @@ export async function retryTransaction( switch (parsedTx.tag) { case TransactionType.PeerPullCredit: { const taskId = constructTaskIdentifier({ - tag: PendingTaskType.PeerPullInitiation, + tag: PendingTaskType.PeerPullCredit, pursePub: parsedTx.pursePub, }); await resetOperationTimeout(ws, taskId); @@ -1866,7 +1866,7 @@ export async function abortTransaction( switch (txId.tag) { case TransactionType.Payment: { - await abortPay(ws, txId.proposalId); + await abortPayMerchant(ws, txId.proposalId); break; } case TransactionType.Withdrawal: { -- cgit v1.2.3