taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 6cd293b2805637ba315861fc5a8eabda8174ed3c
parent a91c3384243bf38578ae17f72ef5e4787c9d2faa
Author: Florian Dold <dold@taler.net>
Date:   Sat, 18 Jul 2026 21:37:00 +0200

db: add exchange entry accessors

Diffstat:
Mpackages/taler-wallet-core/src/coinSelection.ts | 10+++++-----
Mpackages/taler-wallet-core/src/dbtx-indexeddb.ts | 17+++++++++++++++++
Mpackages/taler-wallet-core/src/dbtx.ts | 9+++++++++
Mpackages/taler-wallet-core/src/deposits.ts | 8++++----
Mpackages/taler-wallet-core/src/exchanges.ts | 92++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mpackages/taler-wallet-core/src/instructedAmountConversion.ts | 2+-
Mpackages/taler-wallet-core/src/pay-peer-common.ts | 4++--
Mpackages/taler-wallet-core/src/recoup.ts | 2+-
Mpackages/taler-wallet-core/src/withdraw.ts | 6+++---
9 files changed, 88 insertions(+), 62 deletions(-)

diff --git a/packages/taler-wallet-core/src/coinSelection.ts b/packages/taler-wallet-core/src/coinSelection.ts @@ -512,7 +512,7 @@ export async function reportInsufficientBalanceDetails( depositPaytoUri: req.depositPaytoUri, }); const perExchange: PaymentInsufficientBalanceDetails["perExchange"] = {}; - const exchanges = await tx.exchanges.getAll(); + const exchanges = await tx.wtx.getExchanges(); for (const exch of exchanges) { if (!exch.detailsPointer) { @@ -963,7 +963,7 @@ async function selectPayCandidates( logger.shouldLogTrace() && logger.trace(`selecting available coin candidates for ${j2s(req)}`); const denoms: AvailableCoinsOfDenom[] = []; - const exchanges = await tx.exchanges.iter().toArray(); + const exchanges = await tx.wtx.getExchanges(); const wfPerExchange: Record<string, AmountJson> = {}; const depositRestrictions: Record< string, @@ -1281,7 +1281,7 @@ export async function selectPeerCoinsInTx( ); } - const exchanges = await tx.exchanges.iter().toArray(); + const exchanges = await tx.wtx.getExchanges(); const currency = Amounts.currencyOf(instructedAmount); for (const exch of exchanges) { if (exch.detailsPointer?.currency !== currency) { @@ -1410,7 +1410,7 @@ export async function getExchangesForDepositInTx( ): Promise<Exchange[]> { logger.trace(`getting exchanges for deposit ${j2s(req)}`); const exchangeInfos: Exchange[] = []; - const allExchanges = await tx.exchanges.iter().toArray(); + const allExchanges = await tx.wtx.getExchanges(); for (const e of allExchanges) { const details = await getExchangeDetailsInTx(tx, e.baseUrl); if (!details) { @@ -1541,7 +1541,7 @@ export async function getMaxPeerPushDebitAmount( async (tx): Promise<GetMaxPeerPushDebitAmountResponse> => { let result: GetMaxDepositAmountResponse | undefined = undefined; const currency = req.currency; - const exchanges = await tx.exchanges.iter().toArray(); + const exchanges = await tx.wtx.getExchanges(); for (const exch of exchanges) { if (exch.detailsPointer?.currency !== currency) { continue; diff --git a/packages/taler-wallet-core/src/dbtx-indexeddb.ts b/packages/taler-wallet-core/src/dbtx-indexeddb.ts @@ -347,6 +347,23 @@ export class IdbWalletTransaction implements WalletDbTransaction { }); } + async getExchange( + baseUrl: string, + ): Promise<WalletExchangeEntry | undefined> { + const tx = this.tx; + return await tx.exchanges.get(baseUrl); + } + + async upsertExchange(rec: WalletExchangeEntry): Promise<void> { + const tx = this.tx; + await tx.exchanges.put(rec); + } + + async deleteExchange(baseUrl: string): Promise<void> { + const tx = this.tx; + await tx.exchanges.delete(baseUrl); + } + async upsertPurchase(rec: WalletPurchase): Promise<void> { const tx = this.tx; await tx.purchases.put(rec); diff --git a/packages/taler-wallet-core/src/dbtx.ts b/packages/taler-wallet-core/src/dbtx.ts @@ -235,6 +235,15 @@ export interface WalletDbTransaction { */ upsertContractTerms(rec: WalletContractTerms): Promise<void>; + /** + * Get an exchange entry by its base URL. + */ + getExchange(baseUrl: string): Promise<WalletExchangeEntry | undefined>; + + upsertExchange(rec: WalletExchangeEntry): Promise<void>; + + deleteExchange(baseUrl: string): Promise<void>; + upsertPurchase(rec: WalletPurchase): Promise<void>; deletePurchase(proposalId: string): Promise<void>; diff --git a/packages/taler-wallet-core/src/deposits.ts b/packages/taler-wallet-core/src/deposits.ts @@ -1309,7 +1309,7 @@ async function provideDepositAccountKeypair( exchangeBaseUrl: string, ): Promise<EddsaKeyPairStrings> { const existingPair = await wex.runLegacyWalletDbTx(async (tx) => { - const exchange = await tx.exchanges.get(exchangeBaseUrl); + const exchange = await tx.wtx.getExchange(exchangeBaseUrl); if (!exchange) { throw Error("exchange for deposit not found anymore"); } @@ -1323,7 +1323,7 @@ async function provideDepositAccountKeypair( if (res != null) { exchange.currentAccountPriv = res.priv; exchange.currentAccountPub = res.pub; - await tx.exchanges.put(exchange); + await tx.wtx.upsertExchange(exchange); } return res; }); @@ -1332,13 +1332,13 @@ async function provideDepositAccountKeypair( } const newPair = await wex.cryptoApi.createEddsaKeypair({}); await wex.runLegacyWalletDbTx(async (tx) => { - const exchange = await tx.exchanges.get(exchangeBaseUrl); + const exchange = await tx.wtx.getExchange(exchangeBaseUrl); if (!exchange) { throw Error("exchange for deposit not found anymore"); } exchange.currentAccountPriv = newPair.priv; exchange.currentAccountPub = newPair.pub; - await tx.exchanges.put(exchange); + await tx.wtx.upsertExchange(exchange); }); return newPair; } diff --git a/packages/taler-wallet-core/src/exchanges.ts b/packages/taler-wallet-core/src/exchanges.ts @@ -218,7 +218,7 @@ async function getExchangeRecordsInternal( tx: LegacyWalletTxHandle, exchangeBaseUrl: string, ): Promise<WalletExchangeDetails | undefined> { - const r = await tx.exchanges.get(exchangeBaseUrl); + const r = await tx.wtx.getExchange(exchangeBaseUrl); if (!r) { logger.warn(`no exchange found for ${exchangeBaseUrl}`); return; @@ -508,7 +508,7 @@ export async function lookupExchangeByUri( req: GetExchangeEntryByUrlRequest, ): Promise<ExchangeListItem> { const res = await wex.runLegacyWalletDbTx(async (tx) => { - const exchangeRec = await tx.exchanges.get(req.exchangeBaseUrl); + const exchangeRec = await tx.wtx.getExchange(req.exchangeBaseUrl); if (!exchangeRec) { return undefined; } @@ -550,14 +550,14 @@ export async function acceptExchangeTermsOfService( exchangeBaseUrl: string, ): Promise<void> { await wex.runLegacyWalletDbTx(async (tx) => { - const exch = await tx.exchanges.get(exchangeBaseUrl); + const exch = await tx.wtx.getExchange(exchangeBaseUrl); if (exch && exch.tosCurrentEtag) { const oldExchangeState = getExchangeState(exch); exch.tosAcceptedEtag = exch.tosCurrentEtag; exch.tosAcceptedTimestamp = timestampPreciseToDb( TalerPreciseTimestamp.now(), ); - await tx.exchanges.put(exch); + await tx.wtx.upsertExchange(exch); const newExchangeState = getExchangeState(exch); wex.ws.exchangeCache.clear(); tx.notify({ @@ -579,14 +579,14 @@ export async function forgetExchangeTermsOfService( exchangeBaseUrl: string, ): Promise<void> { await wex.runLegacyWalletDbTx(async (tx) => { - const exch = await tx.exchanges.get(exchangeBaseUrl); + const exch = await tx.wtx.getExchange(exchangeBaseUrl); if (!exch) { return; } const oldExchangeState = getExchangeState(exch); exch.tosAcceptedEtag = undefined; exch.tosAcceptedTimestamp = undefined; - await tx.exchanges.put(exch); + await tx.wtx.upsertExchange(exch); const newExchangeState = getExchangeState(exch); wex.ws.exchangeCache.clear(); tx.notify({ @@ -729,7 +729,7 @@ export async function putPresetExchangeEntry( currencyHint?: string, currencySpec?: CurrencySpecification, ): Promise<void> { - let exchange = await tx.exchanges.get(exchangeBaseUrl); + let exchange = await tx.wtx.getExchange(exchangeBaseUrl); if (!exchange) { const r: WalletExchangeEntry = { entryStatus: ExchangeEntryDbRecordStatus.Preset, @@ -751,7 +751,7 @@ export async function putPresetExchangeEntry( tosAcceptedTimestamp: undefined, tosCurrentEtag: undefined, }; - await tx.exchanges.put(r); + await tx.wtx.upsertExchange(r); tx.notify({ type: NotificationType.ExchangeStateTransition, exchangeBaseUrl: exchangeBaseUrl, @@ -764,7 +764,7 @@ export async function putPresetExchangeEntry( exchange.presetCurrencySpec = currencySpec; exchange.presetCurrencyHint = currencyHint; exchange.presetType = exchangeType; - await tx.exchanges.put(exchange); + await tx.wtx.upsertExchange(exchange); } } @@ -776,7 +776,7 @@ async function provideExchangeRecordInTx( exchange: WalletExchangeEntry; exchangeDetails: WalletExchangeDetails | undefined; }> { - let exchange = await tx.exchanges.get(baseUrl); + let exchange = await tx.wtx.getExchange(baseUrl); if (!exchange) { const r: WalletExchangeEntry = { entryStatus: ExchangeEntryDbRecordStatus.Ephemeral, @@ -799,7 +799,7 @@ async function provideExchangeRecordInTx( tosAcceptedTimestamp: undefined, tosCurrentEtag: undefined, }; - await tx.exchanges.put(r); + await tx.wtx.upsertExchange(r); exchange = r; tx.notify({ type: NotificationType.ExchangeStateTransition, @@ -1045,7 +1045,7 @@ export async function startUpdateExchangeEntry( let readySummary: ReadyExchangeSummary | undefined = undefined; const res = await wex.runLegacyWalletDbTx(async (tx) => { - const r = await tx.exchanges.get(exchangeBaseUrl); + const r = await tx.wtx.getExchange(exchangeBaseUrl); if (!r) { throw Error("exchange not found"); } @@ -1125,7 +1125,7 @@ export async function startUpdateExchangeEntry( } } wex.ws.exchangeCache.clear(); - await tx.exchanges.put(r); + await tx.wtx.upsertExchange(r); const newExchangeState = getExchangeState(r); tx.notify({ type: NotificationType.ExchangeStateTransition, @@ -1204,7 +1204,7 @@ export async function requireExchangeReadyTx( tx: LegacyWalletTxHandle, exchangeBaseUrl: string, ): Promise<void> { - const exchange = await tx.exchanges.get(exchangeBaseUrl); + const exchange = await tx.wtx.getExchange(exchangeBaseUrl); if (!exchange) { // This is fatal, outer transaction will not be retried. throw Error("exchange does not exist in database"); @@ -1326,7 +1326,7 @@ export async function waitReadyExchange( async checkState(): Promise<boolean> { const { exchange, exchangeDetails, retryInfo, scopeInfo } = await wex.runLegacyWalletDbTx(async (tx) => { - const exchange = await tx.exchanges.get(exchangeBaseUrl); + const exchange = await tx.wtx.getExchange(exchangeBaseUrl); const exchangeDetails = await getExchangeRecordsInternal( tx, exchangeBaseUrl, @@ -1582,7 +1582,7 @@ async function handleExchageUpdateIncompatible( exchangeProtocolVersion: string, ): Promise<TaskRunResult> { await wex.runLegacyWalletDbTx(async (tx) => { - const r = await tx.exchanges.get(exchangeBaseUrl); + const r = await tx.wtx.getExchange(exchangeBaseUrl); if (!r) { logger.warn(`exchange ${exchangeBaseUrl} no longer present`); return; @@ -1606,7 +1606,7 @@ async function handleExchageUpdateIncompatible( }, ); const newExchangeState = getExchangeState(r); - await tx.exchanges.put(r); + await tx.wtx.upsertExchange(r); tx.notify({ type: NotificationType.ExchangeStateTransition, exchangeBaseUrl, @@ -1635,7 +1635,7 @@ export async function updateExchangeFromUrlHandler( logger.trace(`updating exchange info for ${exchangeBaseUrl}`); const oldExchangeRec = await wex.runLegacyWalletDbTx(async (tx) => { - return await tx.exchanges.get(exchangeBaseUrl); + return await tx.wtx.getExchange(exchangeBaseUrl); }); if (!oldExchangeRec) { @@ -1890,7 +1890,7 @@ export async function updateExchangeFromUrlHandler( } const taskRes = await wex.runLegacyWalletDbTx(async (tx) => { - const r = await tx.exchanges.get(exchangeBaseUrl); + const r = await tx.wtx.getExchange(exchangeBaseUrl); if (!r) { logger.warn(`exchange ${exchangeBaseUrl} no longer present`); return TaskRunResult.progress(); @@ -1935,7 +1935,7 @@ export async function updateExchangeFromUrlHandler( AbsoluteTime.toPreciseTimestamp(AbsoluteTime.never()), ); r.cachebreakNextUpdate = true; - await tx.exchanges.put(r); + await tx.wtx.upsertExchange(r); tx.notify({ type: NotificationType.ExchangeStateTransition, exchangeBaseUrl, @@ -2003,7 +2003,7 @@ export async function updateExchangeFromUrlHandler( r.updateStatus = ExchangeEntryDbUpdateStatus.Ready; r.cachebreakNextUpdate = false; - await tx.exchanges.put(r); + await tx.wtx.upsertExchange(r); if (keysInfo.currency_specification) { // Since this is the per-exchange currency info, @@ -2218,7 +2218,7 @@ async function doExchangeAutoRefresh( ); await wex.runLegacyWalletDbTx(async (tx) => { - const exchange = await tx.exchanges.get(exchangeBaseUrl); + const exchange = await tx.wtx.getExchange(exchangeBaseUrl); if (!exchange || !exchange.detailsPointer) { return; } @@ -2269,7 +2269,7 @@ async function doExchangeAutoRefresh( AbsoluteTime.toPreciseTimestamp(minCheckThreshold), ); wex.ws.exchangeCache.clear(); - await tx.exchanges.put(exchange); + await tx.wtx.upsertExchange(exchange); const st = getExchangeState(exchange); tx.notify({ type: NotificationType.ExchangeStateTransition, @@ -2288,7 +2288,7 @@ export async function processTaskExchangeAutoRefresh( logger.trace(`doing auto-refresh check for '${exchangeBaseUrl}'`); const oldExchangeRec = await wex.runLegacyWalletDbTx(async (tx) => { - return await tx.exchanges.get(exchangeBaseUrl); + return await tx.wtx.getExchange(exchangeBaseUrl); }); if (!oldExchangeRec) { @@ -2834,11 +2834,11 @@ export async function getExchangeTos( checkLogicInvariant(!!tosDownload); await wex.runLegacyWalletDbTx(async (tx) => { - const updateExchangeEntry = await tx.exchanges.get(exchangeBaseUrl); + const updateExchangeEntry = await tx.wtx.getExchange(exchangeBaseUrl); if (updateExchangeEntry) { updateExchangeEntry.tosCurrentEtag = tosDownload.tosEtag; wex.ws.exchangeCache.clear(); - await tx.exchanges.put(updateExchangeEntry); + await tx.wtx.upsertExchange(updateExchangeEntry); } }); @@ -2894,7 +2894,7 @@ export async function listExchanges( ): Promise<ExchangesListResponse> { const exchanges: ExchangeListItem[] = []; await wex.runLegacyWalletDbTx(async (tx) => { - const exchangeRecords = await tx.exchanges.iter().toArray(); + const exchangeRecords = await tx.wtx.getExchanges(); for (const exchangeRec of exchangeRecords) { const taskId = constructTaskIdentifier({ tag: PendingTaskType.ExchangeUpdate, @@ -2961,7 +2961,7 @@ export async function markExchangeUsed( exchangeBaseUrl: string, ): Promise<void> { logger.trace(`marking exchange ${exchangeBaseUrl} as used`); - const exch = await tx.exchanges.get(exchangeBaseUrl); + const exch = await tx.wtx.getExchange(exchangeBaseUrl); if (!exch) { logger.info(`exchange ${exchangeBaseUrl} NOT found`); return; @@ -2972,7 +2972,7 @@ export async function markExchangeUsed( case ExchangeEntryDbRecordStatus.Ephemeral: case ExchangeEntryDbRecordStatus.Preset: { exch.entryStatus = ExchangeEntryDbRecordStatus.Used; - await tx.exchanges.put(exch); + await tx.wtx.upsertExchange(exch); const newExchangeState = getExchangeState(exch); tx.notify({ type: NotificationType.ExchangeStateTransition, @@ -2997,7 +2997,7 @@ export async function getExchangeDetailedInfo( exchangeBaseurl: string, ): Promise<ExchangeDetailedResponse> { const exchange = await wex.runLegacyWalletDbTx(async (tx) => { - const ex = await tx.exchanges.get(exchangeBaseurl); + const ex = await tx.wtx.getExchange(exchangeBaseurl); const dp = ex?.detailsPointer; if (!dp) { return; @@ -3192,7 +3192,7 @@ async function purgeExchange( const oldExchangeState = getExchangeState(exchangeRec); - await tx.exchanges.delete(exchangeBaseUrl); + await tx.wtx.deleteExchange(exchangeBaseUrl); tx.notify({ type: NotificationType.ExchangeStateTransition, oldExchangeState, @@ -3358,7 +3358,7 @@ export async function deleteExchange( let inUse: boolean = false; const exchangeBaseUrl = req.exchangeBaseUrl; await wex.runLegacyWalletDbTx(async (tx) => { - const exchangeRec = await tx.exchanges.get(exchangeBaseUrl); + const exchangeRec = await tx.wtx.getExchange(exchangeBaseUrl); if (!exchangeRec) { // Nothing to delete! logger.info("no exchange found to delete"); @@ -3388,7 +3388,7 @@ export async function getExchangeResources( ): Promise<GetExchangeResourcesResponse> { // Withdrawals include internal withdrawals from peer transactions const res = await wex.runLegacyWalletDbTx(async (tx) => { - const exchangeRecord = await tx.exchanges.get(exchangeBaseUrl); + const exchangeRecord = await tx.wtx.getExchange(exchangeBaseUrl); if (!exchangeRecord) { return undefined; } @@ -3410,7 +3410,7 @@ export async function getExchangeWireFee( time: TalerProtocolTimestamp, ): Promise<WireFee> { const exchangeDetails = await wex.runLegacyWalletDbTx(async (tx) => { - const ex = await tx.exchanges.get(baseUrl); + const ex = await tx.wtx.getExchange(baseUrl); if (!ex || !ex.detailsPointer) return undefined; return await tx.exchangeDetails.indexes.byPointer.get([ baseUrl, @@ -3465,7 +3465,7 @@ export async function checkIncomingAmountLegalUnderKycBalanceThreshold( logger.trace(`checking ${exchangeBaseUrl} +${amountIncoming} for KYC`); return await wex.runLegacyWalletDbTx( async (tx): Promise<BalanceThresholdCheckResult> => { - const exchangeRec = await tx.exchanges.get(exchangeBaseUrl); + const exchangeRec = await tx.wtx.getExchange(exchangeBaseUrl); if (!exchangeRec) { throw Error("exchange not found"); } @@ -3581,7 +3581,7 @@ export async function waitExchangeWalletKyc( await genericWaitForState(wex, { async checkState(): Promise<boolean> { return await wex.runLegacyWalletDbTx(async (tx) => { - const exchange = await tx.exchanges.get(exchangeBaseUrl); + const exchange = await tx.wtx.getExchange(exchangeBaseUrl); if (!exchange) { throw new Error("exchange not found"); } @@ -3680,7 +3680,7 @@ export async function handleStartExchangeWalletKyc( ): Promise<EmptyObject> { const newReservePair = await wex.cryptoApi.createEddsaKeypair({}); await wex.runLegacyWalletDbTx(async (tx) => { - const exchange = await tx.exchanges.get(req.exchangeBaseUrl); + const exchange = await tx.wtx.getExchange(req.exchangeBaseUrl); if (!exchange) { throw Error("exchange not found"); } @@ -3692,7 +3692,7 @@ export async function handleStartExchangeWalletKyc( reservePub: newReservePair.pub, }); exchange.currentMergeReserveRowId = mergeReserveRowId; - await tx.exchanges.put(exchange); + await tx.wtx.upsertExchange(exchange); } const reserveRec = await tx.wtx.getReserve(mergeReserveRowId); checkDbInvariant(reserveRec != null, "reserve record exists"); @@ -3805,7 +3805,7 @@ async function handleExchangeKycSuccess( ): Promise<TaskRunResult> { logger.info(`kyc check for ${exchangeBaseUrl} satisfied`); await wex.runLegacyWalletDbTx(async (tx) => { - const exchange = await tx.exchanges.get(exchangeBaseUrl); + const exchange = await tx.wtx.getExchange(exchangeBaseUrl); if (!exchange) { throw Error("exchange not found"); } @@ -3919,7 +3919,7 @@ async function handleExchangeKycRespLegi( ); await wex.runLegacyWalletDbTx(async (tx) => { - const exchange = await tx.exchanges.get(exchangeBaseUrl); + const exchange = await tx.wtx.getExchange(exchangeBaseUrl); if (!exchange) { throw Error("exchange not found"); } @@ -4028,7 +4028,7 @@ export async function processExchangeKyc( exchangeBaseUrl: string, ): Promise<TaskRunResult> { const res = await wex.runLegacyWalletDbTx(async (tx) => { - const exchange = await tx.exchanges.get(exchangeBaseUrl); + const exchange = await tx.wtx.getExchange(exchangeBaseUrl); if (!exchange) { return undefined; } @@ -4122,7 +4122,7 @@ export async function getPreferredExchangeForCurrency( // Find an exchange with the matching currency. // Prefer exchanges with the most recent withdrawal. const url = await wex.runLegacyWalletDbTx(async (tx) => { - const exchanges = await tx.exchanges.iter().toArray(); + const exchanges = await tx.wtx.getExchanges(); logger.trace(`have ${exchanges.length} exchanges`); let candidate = undefined; for (const e of exchanges) { @@ -4191,7 +4191,7 @@ export async function migrateExchange( return; } - const exch = await tx.exchanges.get(req.oldExchangeBaseUrl); + const exch = await tx.wtx.getExchange(req.oldExchangeBaseUrl); if (!exch) { logger.warn(`exchange ${req.oldExchangeBaseUrl} does not exist anymore`); return; @@ -4261,7 +4261,7 @@ export async function migrateExchange( } { - const rec = await tx.exchanges.get(req.oldExchangeBaseUrl); + const rec = await tx.wtx.getExchange(req.oldExchangeBaseUrl); if (rec) { existingNewExchangeSt = { exchangeEntryStatus: getExchangeEntryStatusFromRecord(rec), @@ -4269,8 +4269,8 @@ export async function migrateExchange( tosStatus: getExchangeTosStatusFromRecord(rec), }; rec.baseUrl = req.newExchangeBaseUrl; - await tx.exchanges.delete(req.oldExchangeBaseUrl); - await tx.exchanges.put(rec); + await tx.wtx.deleteExchange(req.oldExchangeBaseUrl); + await tx.wtx.upsertExchange(rec); } } diff --git a/packages/taler-wallet-core/src/instructedAmountConversion.ts b/packages/taler-wallet-core/src/instructedAmountConversion.ts @@ -131,7 +131,7 @@ async function getAvailableCoins( const list: CoinInfo[] = []; const exchanges: Record<string, ExchangeInfo> = {}; - const databaseExchanges = await tx.exchanges.iter().toArray(); + const databaseExchanges = await tx.wtx.getExchanges(); const filteredExchanges = filters.exchanges ?? databaseExchanges.map((e) => e.baseUrl); diff --git a/packages/taler-wallet-core/src/pay-peer-common.ts b/packages/taler-wallet-core/src/pay-peer-common.ts @@ -134,7 +134,7 @@ export async function getMergeReserveInfo( const mergeReserveRecord: WalletReserve = await wex.runLegacyWalletDbTx( async (tx) => { - const ex = await tx.exchanges.get(req.exchangeBaseUrl); + const ex = await tx.wtx.getExchange(req.exchangeBaseUrl); checkDbInvariant(!!ex, `no exchange record for ${req.exchangeBaseUrl}`); if (ex.currentMergeReserveRowId != null) { const reserve = await tx.wtx.getReserve(ex.currentMergeReserveRowId); @@ -150,7 +150,7 @@ export async function getMergeReserveInfo( }; reserve.rowId = await tx.wtx.upsertReserve(reserve); ex.currentMergeReserveRowId = reserve.rowId; - await tx.exchanges.put(ex); + await tx.wtx.upsertExchange(ex); return reserve; }, ); diff --git a/packages/taler-wallet-core/src/recoup.ts b/packages/taler-wallet-core/src/recoup.ts @@ -429,7 +429,7 @@ export class RecoupTransactionContext implements TransactionContext { await tx.wtx.deleteTransactionMeta(this.transactionId); return; } - const exch = await tx.exchanges.get(recoupRec.exchangeBaseUrl); + const exch = await tx.wtx.getExchange(recoupRec.exchangeBaseUrl); if (!exch || !exch.detailsPointer) { await tx.wtx.deleteTransactionMeta(this.transactionId); return; diff --git a/packages/taler-wallet-core/src/withdraw.ts b/packages/taler-wallet-core/src/withdraw.ts @@ -1987,7 +1987,7 @@ export async function updateWithdrawalDenomsForCurrency( currency: string, ): Promise<void> { const res = await wex.runLegacyWalletDbTx(async (tx) => { - return await tx.exchanges.getAll(); + return await tx.wtx.getExchanges(); }); for (const exch of res) { if (exch.detailsPointer?.currency === currency) { @@ -3631,10 +3631,10 @@ async function internalPerformExchangeWasUsed( tx: LegacyWalletTxHandle, canonExchange: string, ): Promise<void> { - const exchange = await tx.exchanges.get(canonExchange); + const exchange = await tx.wtx.getExchange(canonExchange); if (exchange) { exchange.lastWithdrawal = timestampPreciseToDb(TalerPreciseTimestamp.now()); - await tx.exchanges.put(exchange); + await tx.wtx.upsertExchange(exchange); } await markExchangeUsed(tx, canonExchange);