diff options
Diffstat (limited to 'packages/taler-wallet-core/src/exchanges.ts')
-rw-r--r-- | packages/taler-wallet-core/src/exchanges.ts | 141 |
1 files changed, 77 insertions, 64 deletions
diff --git a/packages/taler-wallet-core/src/exchanges.ts b/packages/taler-wallet-core/src/exchanges.ts index 5f0c744e2..d5ca7abbf 100644 --- a/packages/taler-wallet-core/src/exchanges.ts +++ b/packages/taler-wallet-core/src/exchanges.ts @@ -312,8 +312,8 @@ async function makeExchangeListItem( ): Promise<ExchangeListItem> { const lastUpdateErrorInfo: OperationErrorInfo | undefined = lastError ? { - error: lastError, - } + error: lastError, + } : undefined; let scopeInfo: ScopeInfo | undefined = undefined; @@ -377,13 +377,15 @@ export async function lookupExchangeByUri( req: GetExchangeEntryByUrlRequest, ): Promise<ExchangeListItem> { return await wex.db.runReadOnlyTx( - [ - "exchanges", - "exchangeDetails", - "operationRetries", - "globalCurrencyAuditors", - "globalCurrencyExchanges", - ], + { + storeNames: [ + "exchanges", + "exchangeDetails", + "operationRetries", + "globalCurrencyAuditors", + "globalCurrencyExchanges", + ], + }, async (tx) => { const exchangeRec = await tx.exchanges.get(req.exchangeBaseUrl); if (!exchangeRec) { @@ -414,7 +416,7 @@ export async function acceptExchangeTermsOfService( exchangeBaseUrl: string, ): Promise<void> { const notif = await wex.db.runReadWriteTx( - ["exchangeDetails", "exchanges"], + { storeNames: ["exchangeDetails", "exchanges"] }, async (tx) => { const exch = await tx.exchanges.get(exchangeBaseUrl); if (exch && exch.tosCurrentEtag) { @@ -449,7 +451,7 @@ export async function forgetExchangeTermsOfService( exchangeBaseUrl: string, ): Promise<void> { const notif = await wex.db.runReadWriteTx( - ["exchangeDetails", "exchanges"], + { storeNames: ["exchangeDetails", "exchanges"] }, async (tx) => { const exch = await tx.exchanges.get(exchangeBaseUrl); if (exch) { @@ -915,12 +917,13 @@ async function startUpdateExchangeEntry( const canonBaseUrl = canonicalizeBaseUrl(exchangeBaseUrl); logger.info( - `starting update of exchange entry ${canonBaseUrl}, forced=${options.forceUpdate ?? false + `starting update of exchange entry ${canonBaseUrl}, forced=${ + options.forceUpdate ?? false }`, ); const { notification } = await wex.db.runReadWriteTx( - ["exchanges", "exchangeDetails"], + { storeNames: ["exchanges", "exchangeDetails"] }, async (tx) => { wex.ws.exchangeCache.clear(); return provideExchangeRecordInTx(wex.ws, tx, exchangeBaseUrl); @@ -935,7 +938,7 @@ async function startUpdateExchangeEntry( const { oldExchangeState, newExchangeState, taskId } = await wex.db.runReadWriteTx( - ["exchanges", "operationRetries"], + { storeNames: ["exchanges", "operationRetries"] }, async (tx) => { const r = await tx.exchanges.get(canonBaseUrl); if (!r) { @@ -1029,13 +1032,15 @@ async function internalWaitReadyExchange( logger.info(`waiting for ready exchange ${canonUrl}`); const { exchange, exchangeDetails, retryInfo, scopeInfo } = await wex.db.runReadOnlyTx( - [ - "exchanges", - "exchangeDetails", - "operationRetries", - "globalCurrencyAuditors", - "globalCurrencyExchanges", - ], + { + storeNames: [ + "exchanges", + "exchangeDetails", + "operationRetries", + "globalCurrencyAuditors", + "globalCurrencyExchanges", + ], + }, async (tx) => { const exchange = await tx.exchanges.get(canonUrl); const exchangeDetails = await getExchangeRecordsInternal( @@ -1290,7 +1295,7 @@ export async function updateExchangeFromUrlHandler( exchangeBaseUrl = canonicalizeBaseUrl(exchangeBaseUrl); const oldExchangeRec = await wex.db.runReadOnlyTx( - ["exchanges"], + { storeNames: ["exchanges"] }, async (tx) => { return tx.exchanges.get(exchangeBaseUrl); }, @@ -1450,17 +1455,19 @@ export async function updateExchangeFromUrlHandler( let peerPaymentsDisabled = checkPeerPaymentsDisabled(keysInfo); const updated = await wex.db.runReadWriteTx( - [ - "exchanges", - "exchangeDetails", - "exchangeSignKeys", - "denominations", - "coins", - "refreshGroups", - "recoupGroups", - "coinAvailability", - "denomLossEvents", - ], + { + storeNames: [ + "exchanges", + "exchangeDetails", + "exchangeSignKeys", + "denominations", + "coins", + "refreshGroups", + "recoupGroups", + "coinAvailability", + "denomLossEvents", + ], + }, async (tx) => { const r = await tx.exchanges.get(exchangeBaseUrl); if (!r) { @@ -1666,14 +1673,16 @@ export async function updateExchangeFromUrlHandler( if (refreshCheckNecessary) { // Do auto-refresh. await wex.db.runReadWriteTx( - [ - "coins", - "denominations", - "coinAvailability", - "refreshGroups", - "refreshSessions", - "exchanges", - ], + { + storeNames: [ + "coins", + "denominations", + "coinAvailability", + "refreshGroups", + "refreshSessions", + "exchanges", + ], + }, async (tx) => { const exchange = await tx.exchanges.get(exchangeBaseUrl); if (!exchange || !exchange.detailsPointer) { @@ -1969,7 +1978,7 @@ export class DenomLossTransactionContext implements TransactionContext { } async deleteTransaction(): Promise<void> { const transitionInfo = await this.wex.db.runReadWriteTx( - ["denomLossEvents"], + { storeNames: ["denomLossEvents"] }, async (tx) => { const rec = await tx.denomLossEvents.get(this.denomLossEventId); if (rec) { @@ -2080,7 +2089,7 @@ export async function getExchangePaytoUri( // We do the update here, since the exchange might not even exist // yet in our database. const details = await wex.db.runReadOnlyTx( - ["exchanges", "exchangeDetails"], + { storeNames: ["exchanges", "exchangeDetails"] }, async (tx) => { return getExchangeRecordsInternal(tx, exchangeBaseUrl); }, @@ -2122,7 +2131,7 @@ export async function getExchangeTos( acceptLanguage, ); - await wex.db.runReadWriteTx(["exchanges"], async (tx) => { + await wex.db.runReadWriteTx({ storeNames: ["exchanges"] }, async (tx) => { const updateExchangeEntry = await tx.exchanges.get(exchangeBaseUrl); if (updateExchangeEntry) { updateExchangeEntry.tosCurrentEtag = tosDownload.tosEtag; @@ -2179,13 +2188,15 @@ export async function listExchanges( ): Promise<ExchangesListResponse> { const exchanges: ExchangeListItem[] = []; await wex.db.runReadOnlyTx( - [ - "exchanges", - "operationRetries", - "exchangeDetails", - "globalCurrencyAuditors", - "globalCurrencyExchanges", - ], + { + storeNames: [ + "exchanges", + "operationRetries", + "exchangeDetails", + "globalCurrencyAuditors", + "globalCurrencyExchanges", + ], + }, async (tx) => { const exchangeRecords = await tx.exchanges.iter().toArray(); for (const r of exchangeRecords) { @@ -2262,7 +2273,7 @@ export async function getExchangeDetailedInfo( exchangeBaseurl: string, ): Promise<ExchangeDetailedResponse> { const exchange = await wex.db.runReadOnlyTx( - ["exchanges", "exchangeDetails", "denominations"], + { storeNames: ["exchanges", "exchangeDetails", "denominations"] }, async (tx) => { const ex = await tx.exchanges.get(exchangeBaseurl); const dp = ex?.detailsPointer; @@ -2520,17 +2531,19 @@ export async function deleteExchange( let inUse: boolean = false; const exchangeBaseUrl = canonicalizeBaseUrl(req.exchangeBaseUrl); await wex.db.runReadWriteTx( - [ - "exchanges", - "exchangeDetails", - "transactions", - "coinAvailability", - "coins", - "denominations", - "exchangeSignKeys", - "withdrawalGroups", - "planchets", - ], + { + storeNames: [ + "exchanges", + "exchangeDetails", + "transactions", + "coinAvailability", + "coins", + "denominations", + "exchangeSignKeys", + "withdrawalGroups", + "planchets", + ], + }, async (tx) => { const exchangeRec = await tx.exchanges.get(exchangeBaseUrl); if (!exchangeRec) { @@ -2562,7 +2575,7 @@ export async function getExchangeResources( ): Promise<GetExchangeResourcesResponse> { // Withdrawals include internal withdrawals from peer transactions const res = await wex.db.runReadOnlyTx( - ["exchanges", "withdrawalGroups", "coins"], + { storeNames: ["exchanges", "withdrawalGroups", "coins"] }, async (tx) => { const exchangeRecord = await tx.exchanges.get(exchangeBaseUrl); if (!exchangeRecord) { |