diff options
Diffstat (limited to 'packages/taler-wallet-core/src/operations/transactions.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/transactions.ts | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts index 31655ad71..d7b277faf 100644 --- a/packages/taler-wallet-core/src/operations/transactions.ts +++ b/packages/taler-wallet-core/src/operations/transactions.ts @@ -346,11 +346,19 @@ export async function getTransactionById( } case TransactionType.PeerPullDebit: { return await ws.db - .mktx((x) => [x.peerPullDebit]) + .mktx((x) => [x.peerPullDebit, x.contractTerms]) .runReadWrite(async (tx) => { const debit = await tx.peerPullDebit.get(parsedTx.peerPullDebitId); if (!debit) throw Error("not found"); - return buildTransactionForPullPaymentDebit(debit); + const contractTermsRec = await tx.contractTerms.get( + debit.contractTermsHash, + ); + if (!contractTermsRec) + throw Error("contract terms for peer-pull-debit not found"); + return buildTransactionForPullPaymentDebit( + debit, + contractTermsRec.contractTermsRaw, + ); }); } @@ -477,6 +485,7 @@ function buildTransactionForPushPaymentDebit( function buildTransactionForPullPaymentDebit( pi: PeerPullPaymentIncomingRecord, + contractTerms: PeerContractTerms, ort?: OperationRetryRecord, ): Transaction { return { @@ -485,12 +494,12 @@ function buildTransactionForPullPaymentDebit( txActions: computePeerPullDebitTransactionActions(pi), amountEffective: pi.coinSel?.totalCost ? pi.coinSel?.totalCost - : Amounts.stringify(pi.contractTerms.amount), - amountRaw: Amounts.stringify(pi.contractTerms.amount), + : Amounts.stringify(pi.amount), + amountRaw: Amounts.stringify(pi.amount), exchangeBaseUrl: pi.exchangeBaseUrl, info: { - expiration: pi.contractTerms.purse_expiration, - summary: pi.contractTerms.summary, + expiration: contractTerms.purse_expiration, + summary: contractTerms.summary, }, timestamp: pi.timestampCreated, transactionId: constructTransactionIdentifier({ @@ -805,7 +814,7 @@ function buildTransactionForDeposit( amountEffective: Amounts.stringify(dg.totalPayCost), timestamp: dg.timestampCreated, targetPaytoUri: dg.wire.payto_uri, - wireTransferDeadline: dg.contractTermsRaw.wire_transfer_deadline, + wireTransferDeadline: dg.wireTransferDeadline, transactionId: constructTransactionIdentifier({ tag: TransactionType.Deposit, depositGroupId: dg.depositGroupId, @@ -980,7 +989,7 @@ export async function getTransactions( }); await iterRecordsForPeerPullDebit(tx, filter, async (pi) => { - const amount = Amounts.parseOrThrow(pi.contractTerms.amount); + const amount = Amounts.parseOrThrow(pi.amount); if (shouldSkipCurrency(transactionsRequest, amount.currency)) { return; } @@ -991,10 +1000,23 @@ export async function getTransactions( pi.status !== PeerPullDebitRecordStatus.PendingDeposit && pi.status !== PeerPullDebitRecordStatus.Done ) { + // FIXME: Why?! return; } - transactions.push(buildTransactionForPullPaymentDebit(pi)); + const contractTermsRec = await tx.contractTerms.get( + pi.contractTermsHash, + ); + if (!contractTermsRec) { + return; + } + + transactions.push( + buildTransactionForPullPaymentDebit( + pi, + contractTermsRec.contractTermsRaw, + ), + ); }); await iterRecordsForPeerPushCredit(tx, filter, async (pi) => { @@ -1158,7 +1180,7 @@ export async function getTransactions( }); await iterRecordsForDeposit(tx, filter, async (dg) => { - const amount = Amounts.parseOrThrow(dg.contractTermsRaw.amount); + const amount = Amounts.parseOrThrow(dg.amount); if (shouldSkipCurrency(transactionsRequest, amount.currency)) { return; } |