summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-05-24 14:46:03 +0200
committerFlorian Dold <florian@dold.me>2023-05-24 14:46:03 +0200
commita2ef2e391a8f030857d0f9cd56c6157cffb33659 (patch)
tree7da5030d2695b4c6ba24b007198726bea6016b13 /packages/taler-wallet-core/src
parentf475f98f86d03e808d2c88c13eafa712c2013fe3 (diff)
downloadwallet-core-a2ef2e391a8f030857d0f9cd56c6157cffb33659.tar.gz
wallet-core-a2ef2e391a8f030857d0f9cd56c6157cffb33659.tar.bz2
wallet-core-a2ef2e391a8f030857d0f9cd56c6157cffb33659.zip
wallet-core: remove legacy non-DD37 tx status fields
Diffstat (limited to 'packages/taler-wallet-core/src')
-rw-r--r--packages/taler-wallet-core/src/operations/transactions.ts111
1 files changed, 7 insertions, 104 deletions
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts
index b5a6ba74e..41c74f4d1 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -20,9 +20,6 @@
import {
AbsoluteTime,
Amounts,
- constructPayPullUri,
- constructPayPushUri,
- ExtendedStatus,
j2s,
Logger,
NotificationType,
@@ -413,12 +410,6 @@ function buildTransactionForPushPaymentDebit(
expiration: contractTerms.purse_expiration,
summary: contractTerms.summary,
},
- frozen: false,
- extendedStatus:
- pi.status != PeerPushPaymentInitiationStatus.Done
- ? ExtendedStatus.Pending
- : ExtendedStatus.Done,
- pending: pi.status != PeerPushPaymentInitiationStatus.Done,
timestamp: pi.timestampCreated,
talerUri: stringifyPayPushUri({
exchangeBaseUrl: pi.exchangeBaseUrl,
@@ -444,9 +435,6 @@ function buildTransactionForPullPaymentDebit(
: Amounts.stringify(pi.contractTerms.amount),
amountRaw: Amounts.stringify(pi.contractTerms.amount),
exchangeBaseUrl: pi.exchangeBaseUrl,
- frozen: false,
- pending: false,
- extendedStatus: ExtendedStatus.Done,
info: {
expiration: pi.contractTerms.purse_expiration,
summary: pi.contractTerms.summary,
@@ -492,10 +480,6 @@ function buildTransactionForPeerPullCredit(
amountEffective: Amounts.stringify(wsr.denomsSel.totalCoinValue),
amountRaw: Amounts.stringify(wsr.instructedAmount),
exchangeBaseUrl: wsr.exchangeBaseUrl,
- extendedStatus: wsr.timestampFinish
- ? ExtendedStatus.Done
- : ExtendedStatus.Pending,
- pending: !wsr.timestampFinish,
// Old transactions don't have it!
timestamp: pullCredit.mergeTimestamp ?? TalerProtocolTimestamp.now(),
info: {
@@ -510,7 +494,6 @@ function buildTransactionForPeerPullCredit(
tag: TransactionType.PeerPullCredit,
pursePub: pullCredit.pursePub,
}),
- frozen: false,
...(wsrOrt?.lastError
? {
error: silentWithdrawalErrorForInvoice
@@ -527,8 +510,6 @@ function buildTransactionForPeerPullCredit(
amountEffective: Amounts.stringify(pullCredit.estimatedAmountEffective),
amountRaw: Amounts.stringify(peerContractTerms.amount),
exchangeBaseUrl: pullCredit.exchangeBaseUrl,
- extendedStatus: ExtendedStatus.Pending,
- pending: true,
// Old transactions don't have it!
timestamp: pullCredit.mergeTimestamp ?? TalerProtocolTimestamp.now(),
info: {
@@ -543,7 +524,6 @@ function buildTransactionForPeerPullCredit(
tag: TransactionType.PeerPullCredit,
pursePub: pullCredit.pursePub,
}),
- frozen: false,
...(pullCreditOrt?.lastError ? { error: pullCreditOrt.lastError } : {}),
};
}
@@ -570,16 +550,11 @@ function buildTransactionForPeerPushCredit(
expiration: wsr.wgInfo.contractTerms.purse_expiration,
summary: wsr.wgInfo.contractTerms.summary,
},
- extendedStatus: wsr.timestampFinish
- ? ExtendedStatus.Done
- : ExtendedStatus.Pending,
- pending: !wsr.timestampFinish,
timestamp: wsr.timestampStart,
transactionId: constructTransactionIdentifier({
tag: TransactionType.PeerPushCredit,
peerPushPaymentIncomingId: pushInc.peerPushPaymentIncomingId,
}),
- frozen: false,
...(wsrOrt?.lastError ? { error: wsrOrt.lastError } : {}),
};
}
@@ -595,14 +570,11 @@ function buildTransactionForPeerPushCredit(
expiration: peerContractTerms.purse_expiration,
summary: peerContractTerms.summary,
},
- extendedStatus: ExtendedStatus.Pending,
- pending: true,
timestamp: pushInc.timestamp,
transactionId: constructTransactionIdentifier({
tag: TransactionType.PeerPushCredit,
peerPushPaymentIncomingId: pushInc.peerPushPaymentIncomingId,
}),
- frozen: false,
...(pushOrt?.lastError ? { error: pushOrt.lastError } : {}),
};
}
@@ -629,16 +601,11 @@ function buildTransactionForBankIntegratedWithdraw(
wgRecord.status === WithdrawalGroupStatus.PendingReady,
},
exchangeBaseUrl: wgRecord.exchangeBaseUrl,
- extendedStatus: wgRecord.timestampFinish
- ? ExtendedStatus.Done
- : ExtendedStatus.Pending,
- pending: !wgRecord.timestampFinish,
timestamp: wgRecord.timestampStart,
transactionId: constructTransactionIdentifier({
tag: TransactionType.Withdrawal,
withdrawalGroupId: wgRecord.withdrawalGroupId,
}),
- frozen: false,
...(ort?.lastError ? { error: ort.lastError } : {}),
};
}
@@ -676,16 +643,11 @@ function buildTransactionForManualWithdraw(
withdrawalGroup.status === WithdrawalGroupStatus.PendingReady,
},
exchangeBaseUrl: withdrawalGroup.exchangeBaseUrl,
- extendedStatus: withdrawalGroup.timestampFinish
- ? ExtendedStatus.Done
- : ExtendedStatus.Pending,
- pending: !withdrawalGroup.timestampFinish,
timestamp: withdrawalGroup.timestampStart,
transactionId: constructTransactionIdentifier({
tag: TransactionType.Withdrawal,
withdrawalGroupId: withdrawalGroup.withdrawalGroupId,
}),
- frozen: false,
...(ort?.lastError ? { error: ort.lastError } : {}),
};
}
@@ -718,9 +680,6 @@ function buildTransactionForRefund(
refundGroupId: refundRecord.refundGroupId,
}),
txState: computeRefundTransactionState(refundRecord),
- extendedStatus: ExtendedStatus.Done,
- frozen: false,
- pending: false,
paymentInfo,
};
}
@@ -729,15 +688,6 @@ function buildTransactionForRefresh(
refreshGroupRecord: RefreshGroupRecord,
ort?: OperationRetryRecord,
): Transaction {
- let extendedStatus: ExtendedStatus;
- switch (refreshGroupRecord.operationStatus) {
- case RefreshOperationStatus.Finished:
- case RefreshOperationStatus.FinishedWithError:
- extendedStatus = ExtendedStatus.Done;
- break;
- default:
- extendedStatus = ExtendedStatus.Pending;
- }
const inputAmount = Amounts.sumOrZero(
refreshGroupRecord.currency,
refreshGroupRecord.inputPerCoin,
@@ -760,19 +710,11 @@ function buildTransactionForRefresh(
refreshOutputAmount: Amounts.stringify(outputAmount),
originatingTransactionId:
refreshGroupRecord.reasonDetails?.originatingTransactionId,
- extendedStatus:
- refreshGroupRecord.operationStatus === RefreshOperationStatus.Finished ||
- refreshGroupRecord.operationStatus ===
- RefreshOperationStatus.FinishedWithError
- ? ExtendedStatus.Done
- : ExtendedStatus.Pending,
- pending: extendedStatus == ExtendedStatus.Pending,
timestamp: refreshGroupRecord.timestampCreated,
transactionId: constructTransactionIdentifier({
tag: TransactionType.Refresh,
refreshGroupId: refreshGroupRecord.refreshGroupId,
}),
- frozen: false,
...(ort?.lastError ? { error: ort.lastError } : {}),
};
}
@@ -793,11 +735,6 @@ function buildTransactionForDeposit(
txState: computeDepositTransactionStatus(dg),
amountRaw: Amounts.stringify(dg.effectiveDepositAmount),
amountEffective: Amounts.stringify(dg.totalPayCost),
- extendedStatus: dg.timestampFinished
- ? ExtendedStatus.Done
- : ExtendedStatus.Pending,
- pending: !dg.timestampFinished,
- frozen: false,
timestamp: dg.timestampCreated,
targetPaytoUri: dg.wire.payto_uri,
wireTransferDeadline: dg.contractTermsRaw.wire_transfer_deadline,
@@ -830,11 +767,6 @@ function buildTransactionForTip(
txState: computeTipTransactionStatus(tipRecord),
amountEffective: Amounts.stringify(tipRecord.tipAmountEffective),
amountRaw: Amounts.stringify(tipRecord.tipAmountRaw),
- extendedStatus: tipRecord.pickedUpTimestamp
- ? ExtendedStatus.Done
- : ExtendedStatus.Pending,
- pending: !tipRecord.pickedUpTimestamp,
- frozen: false,
timestamp: tipRecord.acceptedTimestamp,
transactionId: constructTransactionIdentifier({
tag: TransactionType.Tip,
@@ -899,32 +831,6 @@ async function buildTransactionForPurchase(
checkDbInvariant(!!timestamp);
checkDbInvariant(!!purchaseRecord.payInfo);
- let status: ExtendedStatus;
- switch (purchaseRecord.purchaseStatus) {
- case PurchaseStatus.AbortingWithRefund:
- status = ExtendedStatus.Aborting;
- break;
- case PurchaseStatus.Done:
- case PurchaseStatus.RepurchaseDetected:
- status = ExtendedStatus.Done;
- break;
- case PurchaseStatus.DownloadingProposal:
- case PurchaseStatus.QueryingRefund:
- case PurchaseStatus.Proposed:
- case PurchaseStatus.Paying:
- status = ExtendedStatus.Pending;
- break;
- case PurchaseStatus.FailedClaim:
- status = ExtendedStatus.Failed;
- break;
- case PurchaseStatus.AbortedIncompletePayment:
- status = ExtendedStatus.Aborted;
- break;
- default:
- // FIXME: Should we have some unknown status?
- status = ExtendedStatus.Pending;
- }
-
return {
type: TransactionType.Payment,
txState: computePayMerchantTransactionState(purchaseRecord),
@@ -936,11 +842,6 @@ async function buildTransactionForPurchase(
purchaseRecord.refundAmountAwaiting === undefined
? undefined
: Amounts.stringify(purchaseRecord.refundAmountAwaiting),
- status: purchaseRecord.timestampFirstSuccessfulPay
- ? PaymentStatus.Paid
- : PaymentStatus.Accepted,
- extendedStatus: status,
- pending: purchaseRecord.purchaseStatus === PurchaseStatus.Paying,
refunds,
posConfirmation: purchaseRecord.posConfirmation,
timestamp,
@@ -952,9 +853,6 @@ async function buildTransactionForPurchase(
info,
refundQueryActive:
purchaseRecord.purchaseStatus === PurchaseStatus.QueryingRefund,
- frozen:
- purchaseRecord.purchaseStatus ===
- PurchaseStatus.AbortedIncompletePayment ?? false,
...(ort?.lastError ? { error: ort.lastError } : {}),
};
}
@@ -1272,8 +1170,13 @@ export async function getTransactions(
}
}
- const txPending = transactions.filter((x) => x.pending);
- const txNotPending = transactions.filter((x) => !x.pending);
+ const isPending = (x: Transaction) =>
+ x.txState.major === TransactionMajorState.Pending ||
+ x.txState.major === TransactionMajorState.Aborting ||
+ x.txState.major === TransactionMajorState.Dialog;
+
+ const txPending = transactions.filter((x) => isPending(x));
+ const txNotPending = transactions.filter((x) => !isPending(x));
const txCmp = (h1: Transaction, h2: Transaction) => {
const tsCmp = AbsoluteTime.cmp(