aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/transactions.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core/src/operations/transactions.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/transactions.ts63
1 files changed, 34 insertions, 29 deletions
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts
index 9deb050d8..3a219b39b 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -47,7 +47,6 @@ import {
import {
DepositElementStatus,
DepositGroupRecord,
- ExchangeDetailsRecord,
OperationRetryRecord,
PeerPullCreditRecord,
PeerPullDebitRecordStatus,
@@ -91,7 +90,10 @@ import {
resumeDepositGroup,
suspendDepositGroup,
} from "./deposits.js";
-import { getExchangeDetails } from "./exchanges.js";
+import {
+ ExchangeWireDetails,
+ getExchangeWireDetailsInTx,
+} from "./exchanges.js";
import {
abortPayMerchant,
computePayMerchantTransactionActions,
@@ -137,8 +139,8 @@ import {
} from "./pay-peer-push-debit.js";
import {
iterRecordsForDeposit,
- iterRecordsForPeerPullDebit,
iterRecordsForPeerPullInitiation as iterRecordsForPeerPullCredit,
+ iterRecordsForPeerPullDebit,
iterRecordsForPeerPushCredit,
iterRecordsForPeerPushInitiation as iterRecordsForPeerPushDebit,
iterRecordsForPurchase,
@@ -240,9 +242,8 @@ export async function getTransactionById(
x.operationRetries,
])
.runReadWrite(async (tx) => {
- const withdrawalGroupRecord = await tx.withdrawalGroups.get(
- withdrawalGroupId,
- );
+ const withdrawalGroupRecord =
+ await tx.withdrawalGroups.get(withdrawalGroupId);
if (!withdrawalGroupRecord) throw Error("not found");
@@ -258,7 +259,7 @@ export async function getTransactionById(
ort,
);
}
- const exchangeDetails = await getExchangeDetails(
+ const exchangeDetails = await getExchangeWireDetailsInTx(
tx,
withdrawalGroupRecord.exchangeBaseUrl,
);
@@ -290,7 +291,9 @@ export async function getTransactionById(
const payOpId = TaskIdentifiers.forPay(purchase);
const payRetryRecord = await tx.operationRetries.get(payOpId);
- const refunds = await tx.refundGroups.indexes.byProposalId.getAll(purchase.proposalId)
+ const refunds = await tx.refundGroups.indexes.byProposalId.getAll(
+ purchase.proposalId,
+ );
return buildTransactionForPurchase(
purchase,
@@ -544,7 +547,7 @@ function buildTransactionForPeerPullCredit(
const silentWithdrawalErrorForInvoice =
wsrOrt?.lastError &&
wsrOrt.lastError.code ===
- TalerErrorCode.WALLET_WITHDRAWAL_GROUP_INCOMPLETE &&
+ TalerErrorCode.WALLET_WITHDRAWAL_GROUP_INCOMPLETE &&
Object.values(wsrOrt.lastError.errorsPerCoin ?? {}).every((e) => {
return (
e.code === TalerErrorCode.WALLET_UNEXPECTED_REQUEST_ERROR &&
@@ -574,10 +577,10 @@ function buildTransactionForPeerPullCredit(
kycUrl: pullCredit.kycUrl,
...(wsrOrt?.lastError
? {
- error: silentWithdrawalErrorForInvoice
- ? undefined
- : wsrOrt.lastError,
- }
+ error: silentWithdrawalErrorForInvoice
+ ? undefined
+ : wsrOrt.lastError,
+ }
: {}),
};
}
@@ -698,7 +701,7 @@ function buildTransactionForBankIntegratedWithdraw(
function buildTransactionForManualWithdraw(
withdrawalGroup: WithdrawalGroupRecord,
- exchangeDetails: ExchangeDetailsRecord,
+ exchangeDetails: ExchangeWireDetails,
ort?: OperationRetryRecord,
): Transaction {
if (withdrawalGroup.wgInfo.withdrawalType !== WithdrawalRecordType.BankManual)
@@ -725,7 +728,8 @@ function buildTransactionForManualWithdraw(
type: WithdrawalType.ManualTransfer,
reservePub: withdrawalGroup.reservePub,
exchangePaytoUris,
- exchangeCreditAccountDetails: withdrawalGroup.wgInfo.exchangeCreditAccounts,
+ exchangeCreditAccountDetails:
+ withdrawalGroup.wgInfo.exchangeCreditAccounts,
reserveIsReady:
withdrawalGroup.status === WithdrawalGroupStatus.Done ||
withdrawalGroup.status === WithdrawalGroupStatus.PendingReady,
@@ -928,14 +932,16 @@ async function buildTransactionForPurchase(
info.fulfillmentUrl = contractData.fulfillmentUrl;
}
- const refunds: RefundInfoShort[] = refundsInfo.map(r => ({
+ const refunds: RefundInfoShort[] = refundsInfo.map((r) => ({
amountEffective: r.amountEffective,
amountRaw: r.amountRaw,
- timestamp: TalerPreciseTimestamp.round(timestampPreciseFromDb(r.timestampCreated)),
+ timestamp: TalerPreciseTimestamp.round(
+ timestampPreciseFromDb(r.timestampCreated),
+ ),
transactionId: constructTransactionIdentifier({
tag: TransactionType.Refund,
refundGroupId: r.refundGroupId,
- })
+ }),
}));
const timestamp = purchaseRecord.timestampAccept;
@@ -1193,7 +1199,7 @@ export async function getTransactions(
);
return;
case WithdrawalRecordType.BankManual: {
- const exchangeDetails = await getExchangeDetails(
+ const exchangeDetails = await getExchangeWireDetailsInTx(
tx,
wsr.exchangeBaseUrl,
);
@@ -1258,7 +1264,9 @@ export async function getTransactions(
const payOpId = TaskIdentifiers.forPay(purchase);
const payRetryRecord = await tx.operationRetries.get(payOpId);
- const refunds = await tx.refundGroups.indexes.byProposalId.getAll(purchase.proposalId)
+ const refunds = await tx.refundGroups.indexes.byProposalId.getAll(
+ purchase.proposalId,
+ );
transactions.push(
await buildTransactionForPurchase(
@@ -1723,9 +1731,8 @@ export async function deleteTransaction(
}
if (pushInc.withdrawalGroupId) {
const withdrawalGroupId = pushInc.withdrawalGroupId;
- const withdrawalGroupRecord = await tx.withdrawalGroups.get(
- withdrawalGroupId,
- );
+ const withdrawalGroupRecord =
+ await tx.withdrawalGroups.get(withdrawalGroupId);
if (withdrawalGroupRecord) {
await tx.withdrawalGroups.delete(withdrawalGroupId);
await tx.tombstones.put({
@@ -1753,9 +1760,8 @@ export async function deleteTransaction(
}
if (pullIni.withdrawalGroupId) {
const withdrawalGroupId = pullIni.withdrawalGroupId;
- const withdrawalGroupRecord = await tx.withdrawalGroups.get(
- withdrawalGroupId,
- );
+ const withdrawalGroupRecord =
+ await tx.withdrawalGroups.get(withdrawalGroupId);
if (withdrawalGroupRecord) {
await tx.withdrawalGroups.delete(withdrawalGroupId);
await tx.tombstones.put({
@@ -1778,9 +1784,8 @@ export async function deleteTransaction(
await ws.db
.mktx((x) => [x.withdrawalGroups, x.tombstones])
.runReadWrite(async (tx) => {
- const withdrawalGroupRecord = await tx.withdrawalGroups.get(
- withdrawalGroupId,
- );
+ const withdrawalGroupRecord =
+ await tx.withdrawalGroups.get(withdrawalGroupId);
if (withdrawalGroupRecord) {
await tx.withdrawalGroups.delete(withdrawalGroupId);
await tx.tombstones.put({