aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/transactions.ts
diff options
context:
space:
mode:
authorÖzgür Kesim <oec-taler@kesim.org>2023-10-06 16:33:05 +0200
committerÖzgür Kesim <oec-taler@kesim.org>2023-10-06 16:33:05 +0200
commitfe7b51ef2736edbf04f5bbd9d19f2a2d04baccc2 (patch)
tree66c68c8d6a666f6e74dc663c9ee4f07879f6626c /packages/taler-wallet-core/src/operations/transactions.ts
parent35611f0bf9cf67638b171c2a300fab1797d3d8f0 (diff)
parent97d7be7503168f4f3bbd05905d32aa76ca1636b2 (diff)
Merge branch 'master' into age-withdraw
Diffstat (limited to 'packages/taler-wallet-core/src/operations/transactions.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/transactions.ts52
1 files changed, 34 insertions, 18 deletions
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts
index d7b277faf..cf2006406 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -20,6 +20,7 @@
import {
AbsoluteTime,
Amounts,
+ DepositTransactionTrackingState,
j2s,
Logger,
NotificationType,
@@ -65,7 +66,13 @@ import {
WithdrawalGroupStatus,
WithdrawalRecordType,
} from "../db.js";
-import { GetReadOnlyAccess, WalletStoresV1 } from "../index.js";
+import {
+ GetReadOnlyAccess,
+ timestampOptionalPreciseFromDb,
+ timestampPreciseFromDb,
+ timestampProtocolFromDb,
+ WalletStoresV1,
+} from "../index.js";
import { InternalWalletState } from "../internal-wallet-state.js";
import { PendingTaskType } from "../pending-types.js";
import { assertUnreachable } from "../util/assertUnreachable.js";
@@ -470,7 +477,7 @@ function buildTransactionForPushPaymentDebit(
expiration: contractTerms.purse_expiration,
summary: contractTerms.summary,
},
- timestamp: pi.timestampCreated,
+ timestamp: timestampPreciseFromDb(pi.timestampCreated),
talerUri: stringifyPayPushUri({
exchangeBaseUrl: pi.exchangeBaseUrl,
contractPriv: pi.contractPriv,
@@ -501,7 +508,7 @@ function buildTransactionForPullPaymentDebit(
expiration: contractTerms.purse_expiration,
summary: contractTerms.summary,
},
- timestamp: pi.timestampCreated,
+ timestamp: timestampPreciseFromDb(pi.timestampCreated),
transactionId: constructTransactionIdentifier({
tag: TransactionType.PeerPullDebit,
peerPullDebitId: pi.peerPullDebitId,
@@ -543,8 +550,7 @@ function buildTransactionForPeerPullCredit(
amountEffective: Amounts.stringify(wsr.denomsSel.totalCoinValue),
amountRaw: Amounts.stringify(wsr.instructedAmount),
exchangeBaseUrl: wsr.exchangeBaseUrl,
- // Old transactions don't have it!
- timestamp: pullCredit.mergeTimestamp ?? TalerPreciseTimestamp.now(),
+ timestamp: timestampPreciseFromDb(pullCredit.mergeTimestamp),
info: {
expiration: peerContractTerms.purse_expiration,
summary: peerContractTerms.summary,
@@ -575,8 +581,7 @@ function buildTransactionForPeerPullCredit(
amountEffective: Amounts.stringify(pullCredit.estimatedAmountEffective),
amountRaw: Amounts.stringify(peerContractTerms.amount),
exchangeBaseUrl: pullCredit.exchangeBaseUrl,
- // Old transactions don't have it!
- timestamp: pullCredit.mergeTimestamp ?? TalerProtocolTimestamp.now(),
+ timestamp: timestampPreciseFromDb(pullCredit.mergeTimestamp),
info: {
expiration: peerContractTerms.purse_expiration,
summary: peerContractTerms.summary,
@@ -617,7 +622,7 @@ function buildTransactionForPeerPushCredit(
expiration: peerContractTerms.purse_expiration,
summary: peerContractTerms.summary,
},
- timestamp: wsr.timestampStart,
+ timestamp: timestampPreciseFromDb(wsr.timestampStart),
transactionId: constructTransactionIdentifier({
tag: TransactionType.PeerPushCredit,
peerPushCreditId: pushInc.peerPushCreditId,
@@ -640,7 +645,7 @@ function buildTransactionForPeerPushCredit(
summary: peerContractTerms.summary,
},
kycUrl: pushInc.kycUrl,
- timestamp: pushInc.timestamp,
+ timestamp: timestampPreciseFromDb(pushInc.timestamp),
transactionId: constructTransactionIdentifier({
tag: TransactionType.PeerPushCredit,
peerPushCreditId: pushInc.peerPushCreditId,
@@ -673,7 +678,7 @@ function buildTransactionForBankIntegratedWithdraw(
},
kycUrl: wgRecord.kycUrl,
exchangeBaseUrl: wgRecord.exchangeBaseUrl,
- timestamp: wgRecord.timestampStart,
+ timestamp: timestampPreciseFromDb(wgRecord.timestampStart),
transactionId: constructTransactionIdentifier({
tag: TransactionType.Withdrawal,
withdrawalGroupId: wgRecord.withdrawalGroupId,
@@ -717,7 +722,7 @@ function buildTransactionForManualWithdraw(
},
kycUrl: withdrawalGroup.kycUrl,
exchangeBaseUrl: withdrawalGroup.exchangeBaseUrl,
- timestamp: withdrawalGroup.timestampStart,
+ timestamp: timestampPreciseFromDb(withdrawalGroup.timestampStart),
transactionId: constructTransactionIdentifier({
tag: TransactionType.Withdrawal,
withdrawalGroupId: withdrawalGroup.withdrawalGroupId,
@@ -748,7 +753,7 @@ function buildTransactionForRefund(
tag: TransactionType.Payment,
proposalId: refundRecord.proposalId,
}),
- timestamp: refundRecord.timestampCreated,
+ timestamp: timestampPreciseFromDb(refundRecord.timestampCreated),
transactionId: constructTransactionIdentifier({
tag: TransactionType.Refund,
refundGroupId: refundRecord.refundGroupId,
@@ -786,7 +791,7 @@ function buildTransactionForRefresh(
refreshOutputAmount: Amounts.stringify(outputAmount),
originatingTransactionId:
refreshGroupRecord.reasonDetails?.originatingTransactionId,
- timestamp: refreshGroupRecord.timestampCreated,
+ timestamp: timestampPreciseFromDb(refreshGroupRecord.timestampCreated),
transactionId: constructTransactionIdentifier({
tag: TransactionType.Refresh,
refreshGroupId: refreshGroupRecord.refreshGroupId,
@@ -806,15 +811,26 @@ function buildTransactionForDeposit(
}
}
+ const trackingState: DepositTransactionTrackingState[] = [];
+
+ for (const ts of Object.values(dg.trackingState ?? {})) {
+ trackingState.push({
+ amountRaw: ts.amountRaw,
+ timestampExecuted: timestampProtocolFromDb(ts.timestampExecuted),
+ wireFee: ts.wireFee,
+ wireTransferId: ts.wireTransferId,
+ });
+ }
+
return {
type: TransactionType.Deposit,
txState: computeDepositTransactionStatus(dg),
txActions: computeDepositTransactionActions(dg),
amountRaw: Amounts.stringify(dg.counterpartyEffectiveDepositAmount),
amountEffective: Amounts.stringify(dg.totalPayCost),
- timestamp: dg.timestampCreated,
+ timestamp: timestampPreciseFromDb(dg.timestampCreated),
targetPaytoUri: dg.wire.payto_uri,
- wireTransferDeadline: dg.wireTransferDeadline,
+ wireTransferDeadline: timestampProtocolFromDb(dg.wireTransferDeadline),
transactionId: constructTransactionIdentifier({
tag: TransactionType.Deposit,
depositGroupId: dg.depositGroupId,
@@ -827,7 +843,7 @@ function buildTransactionForDeposit(
)) /
dg.statusPerCoin.length,
depositGroupId: dg.depositGroupId,
- trackingState: Object.values(dg.trackingState ?? {}),
+ trackingState,
deposited,
...(ort?.lastError ? { error: ort.lastError } : {}),
};
@@ -845,7 +861,7 @@ function buildTransactionForTip(
txActions: computeTipTransactionActions(tipRecord),
amountEffective: Amounts.stringify(tipRecord.rewardAmountEffective),
amountRaw: Amounts.stringify(tipRecord.rewardAmountRaw),
- timestamp: tipRecord.acceptedTimestamp,
+ timestamp: timestampPreciseFromDb(tipRecord.acceptedTimestamp),
transactionId: constructTransactionIdentifier({
tag: TransactionType.Reward,
walletRewardId: tipRecord.walletRewardId,
@@ -922,7 +938,7 @@ async function buildTransactionForPurchase(
: Amounts.stringify(purchaseRecord.refundAmountAwaiting),
refunds,
posConfirmation: purchaseRecord.posConfirmation,
- timestamp,
+ timestamp: timestampPreciseFromDb(timestamp),
transactionId: constructTransactionIdentifier({
tag: TransactionType.Payment,
proposalId: purchaseRecord.proposalId,