diff options
author | Florian Dold <florian@dold.me> | 2021-06-02 13:23:51 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-06-02 13:24:28 +0200 |
commit | 02f1d4b08116c24f0af1f32cb6d82be292fa6d10 (patch) | |
tree | 1fbcc1675e09584a74896909e1d4d0882d10be8e /packages/taler-wallet-core/src/operations/pay.ts | |
parent | c6c17a1c0aaa2c76616ec93df3ebe6621b547cd9 (diff) | |
download | wallet-core-02f1d4b08116c24f0af1f32cb6d82be292fa6d10.tar.gz wallet-core-02f1d4b08116c24f0af1f32cb6d82be292fa6d10.tar.bz2 wallet-core-02f1d4b08116c24f0af1f32cb6d82be292fa6d10.zip |
support multiple exchange details per base URL
Diffstat (limited to 'packages/taler-wallet-core/src/operations/pay.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/pay.ts | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/packages/taler-wallet-core/src/operations/pay.ts b/packages/taler-wallet-core/src/operations/pay.ts index 1ed8d72b9..dad460b8c 100644 --- a/packages/taler-wallet-core/src/operations/pay.ts +++ b/packages/taler-wallet-core/src/operations/pay.ts @@ -94,6 +94,7 @@ import { import { getTotalRefreshCost, createRefreshGroup } from "./refresh.js"; import { InternalWalletState, EXCHANGE_COINS_LOCK } from "./state.js"; import { ContractTermsUtil } from "../util/contractTerms.js"; +import { getExchangeDetails } from "./exchanges.js"; /** * Logger. @@ -170,11 +171,16 @@ export async function getEffectiveDepositAmount( exchangeSet.add(coin.exchangeBaseUrl); } for (const exchangeUrl of exchangeSet.values()) { - const exchange = await ws.db.get(Stores.exchanges, exchangeUrl); - if (!exchange?.wireInfo) { + const exchangeDetails = await ws.db.runWithReadTransaction( + [Stores.exchanges, Stores.exchangeDetails], + async (tx) => { + return getExchangeDetails(tx, exchangeUrl); + }, + ); + if (!exchangeDetails) { continue; } - const fee = exchange.wireInfo.feesForType[wireType].find((x) => { + const fee = exchangeDetails.wireInfo.feesForType[wireType].find((x) => { return timestampIsBetween(getTimestampNow(), x.startStamp, x.endStamp); })?.wireFee; if (fee) { @@ -240,11 +246,16 @@ export async function getCandidatePayCoins( const exchanges = await ws.db.iter(Stores.exchanges).toArray(); for (const exchange of exchanges) { let isOkay = false; - const exchangeDetails = exchange.details; + const exchangeDetails = await ws.db.runWithReadTransaction( + [Stores.exchanges, Stores.exchangeDetails], + async (tx) => { + return getExchangeDetails(tx, exchange.baseUrl); + }, + ); if (!exchangeDetails) { continue; } - const exchangeFees = exchange.wireInfo; + const exchangeFees = exchangeDetails.wireInfo; if (!exchangeFees) { continue; } |