summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/util
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-01-08 21:17:00 +0100
committerFlorian Dold <florian@dold.me>2024-01-08 21:17:08 +0100
commit6f2b03021d7946a61d6b8e53dbba7fc10e5f9a4d (patch)
tree82a3985ab7267e6f4a57c0b275f1929558b5e572 /packages/taler-wallet-core/src/util
parentc019f4c040e82baebdbbda8208f10be2fbc19566 (diff)
downloadwallet-core-6f2b03021d7946a61d6b8e53dbba7fc10e5f9a4d.tar.gz
wallet-core-6f2b03021d7946a61d6b8e53dbba7fc10e5f9a4d.tar.bz2
wallet-core-6f2b03021d7946a61d6b8e53dbba7fc10e5f9a4d.zip
wallet-core: exchange management cleanup
Diffstat (limited to 'packages/taler-wallet-core/src/util')
-rw-r--r--packages/taler-wallet-core/src/util/coinSelection.ts7
-rw-r--r--packages/taler-wallet-core/src/util/instructedAmountConversion.ts18
2 files changed, 16 insertions, 9 deletions
diff --git a/packages/taler-wallet-core/src/util/coinSelection.ts b/packages/taler-wallet-core/src/util/coinSelection.ts
index e3fbffe98..f24184609 100644
--- a/packages/taler-wallet-core/src/util/coinSelection.ts
+++ b/packages/taler-wallet-core/src/util/coinSelection.ts
@@ -57,7 +57,7 @@ import {
import { DenominationRecord } from "../db.js";
import {
getAutoRefreshExecuteThreshold,
- getExchangeDetails,
+ getExchangeWireDetailsInTx,
isWithdrawableDenom,
WalletDbReadOnlyTransaction,
} from "../index.js";
@@ -615,7 +615,10 @@ async function selectPayMerchantCandidates(
const exchanges = await tx.exchanges.iter().toArray();
const wfPerExchange: Record<string, AmountJson> = {};
for (const exchange of exchanges) {
- const exchangeDetails = await getExchangeDetails(tx, exchange.baseUrl);
+ const exchangeDetails = await getExchangeWireDetailsInTx(
+ tx,
+ exchange.baseUrl,
+ );
// 1.- exchange has same currency
if (exchangeDetails?.currency !== req.contractTermsAmount.currency) {
continue;
diff --git a/packages/taler-wallet-core/src/util/instructedAmountConversion.ts b/packages/taler-wallet-core/src/util/instructedAmountConversion.ts
index 4365e6d32..caa3fdca5 100644
--- a/packages/taler-wallet-core/src/util/instructedAmountConversion.ts
+++ b/packages/taler-wallet-core/src/util/instructedAmountConversion.ts
@@ -33,7 +33,7 @@ import {
import {
DenominationRecord,
InternalWalletState,
- getExchangeDetails,
+ getExchangeWireDetailsInTx,
timestampProtocolFromDb,
} from "../index.js";
import { CoinInfo } from "./coinSelection.js";
@@ -61,8 +61,8 @@ function getOperationType(txType: TransactionType): OperationType {
txType === TransactionType.Withdrawal
? OperationType.Credit
: txType === TransactionType.Deposit
- ? OperationType.Debit
- : undefined;
+ ? OperationType.Debit
+ : undefined;
if (!operationType) {
throw Error(`operation type ${txType} not yet supported`);
}
@@ -155,7 +155,10 @@ async function getAvailableDenoms(
filters.exchanges ?? databaseExchanges.map((e) => e.baseUrl);
for (const exchangeBaseUrl of filteredExchanges) {
- const exchangeDetails = await getExchangeDetails(tx, exchangeBaseUrl);
+ const exchangeDetails = await getExchangeWireDetailsInTx(
+ tx,
+ exchangeBaseUrl,
+ );
// 1.- exchange has same currency
if (exchangeDetails?.currency !== currency) {
continue;
@@ -221,9 +224,10 @@ async function getAvailableDenoms(
//4.- filter coins restricted by age
if (operationType === OperationType.Credit) {
// FIXME: Use denom groups instead of querying all denominations!
- const ds = await tx.denominations.indexes.byExchangeBaseUrl.getAll(
- exchangeBaseUrl,
- );
+ const ds =
+ await tx.denominations.indexes.byExchangeBaseUrl.getAll(
+ exchangeBaseUrl,
+ );
for (const denom of ds) {
const expiresWithdraw = AbsoluteTime.fromProtocolTimestamp(
timestampProtocolFromDb(denom.stampExpireWithdraw),