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/reserves.ts | |
parent | c6c17a1c0aaa2c76616ec93df3ebe6621b547cd9 (diff) | |
download | wallet-core-02f1d4b08116c24f0af1f32cb6d82be292fa6d10.tar.xz |
support multiple exchange details per base URL
Diffstat (limited to 'packages/taler-wallet-core/src/operations/reserves.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/reserves.ts | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/packages/taler-wallet-core/src/operations/reserves.ts b/packages/taler-wallet-core/src/operations/reserves.ts index d8821d560..d06ce31ed 100644 --- a/packages/taler-wallet-core/src/operations/reserves.ts +++ b/packages/taler-wallet-core/src/operations/reserves.ts @@ -58,7 +58,11 @@ import { updateRetryInfoTimeout, } from "../util/retries.js"; import { guardOperationException, OperationFailedError } from "./errors.js"; -import { updateExchangeFromUrl, getExchangePaytoUri } from "./exchanges.js"; +import { + updateExchangeFromUrl, + getExchangePaytoUri, + getExchangeDetails, +} from "./exchanges.js"; import { InternalWalletState } from "./state.js"; import { updateWithdrawalDenoms, @@ -148,12 +152,15 @@ export async function createReserve( }; const exchangeInfo = await updateExchangeFromUrl(ws, req.exchange); - const exchangeDetails = exchangeInfo.details; + const exchangeDetails = exchangeInfo.exchangeDetails; if (!exchangeDetails) { logger.trace(exchangeDetails); throw Error("exchange not updated"); } - const { isAudited, isTrusted } = await getExchangeTrust(ws, exchangeInfo); + const { isAudited, isTrusted } = await getExchangeTrust( + ws, + exchangeInfo.exchange, + ); const resp = await ws.db.runWithWriteTransaction( [Stores.exchangeTrustStore, Stores.reserves, Stores.bankWithdrawUris], @@ -728,7 +735,11 @@ export async function createTalerWithdrawReserve( * Get payto URIs needed to fund a reserve. */ export async function getFundingPaytoUris( - tx: TransactionHandle<typeof Stores.reserves | typeof Stores.exchanges>, + tx: TransactionHandle< + | typeof Stores.reserves + | typeof Stores.exchanges + | typeof Stores.exchangeDetails + >, reservePub: string, ): Promise<string[]> { const r = await tx.get(Stores.reserves, reservePub); @@ -736,13 +747,13 @@ export async function getFundingPaytoUris( logger.error(`reserve ${reservePub} not found (DB corrupted?)`); return []; } - const exchange = await tx.get(Stores.exchanges, r.exchangeBaseUrl); - if (!exchange) { + const exchangeDetails = await getExchangeDetails(tx, r.exchangeBaseUrl); + if (!exchangeDetails) { logger.error(`exchange ${r.exchangeBaseUrl} not found (DB corrupted?)`); return []; } const plainPaytoUris = - exchange.wireInfo?.accounts.map((x) => x.payto_uri) ?? []; + exchangeDetails.wireInfo?.accounts.map((x) => x.payto_uri) ?? []; if (!plainPaytoUris) { logger.error(`exchange ${r.exchangeBaseUrl} has no wire info`); return []; |