From d70f722866b62e4a0076c805b65d66d5a049b366 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 20 Feb 2024 18:48:42 +0100 Subject: wallet-core: get rid of separate InternalWalletState interface --- packages/taler-wallet-core/src/wallet.ts | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) (limited to 'packages/taler-wallet-core/src/wallet.ts') diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index 63b7ca4f2..5a6cfb96b 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -162,7 +162,6 @@ import { ConfigRecordKey, DenominationRecord, WalletDbReadOnlyTransaction, - WalletDbReadWriteTransaction, WalletStoresV1, clearDatabase, exportDb, @@ -188,13 +187,6 @@ import { listExchanges, lookupExchangeByUri, } from "./exchanges.js"; -import { - CancelFn, - InternalWalletState, - MerchantInfo, - NotificationListener, - RecoupOperations, -} from "./internal-wallet-state.js"; import { computePayMerchantTransactionState, computeRefundTransactionState, @@ -227,7 +219,6 @@ import { initiatePeerPushDebit, } from "./pay-peer-push-debit.js"; import { DbAccess } from "./query.js"; -import { createRecoupGroup } from "./recoup.js"; import { computeRefreshTransactionState, forceRefresh } from "./refresh.js"; import { computeRewardTransactionStatus } from "./reward.js"; import { TaskScheduler } from "./shepherd.js"; @@ -287,6 +278,13 @@ import { const logger = new Logger("wallet.ts"); +export const EXCHANGE_COINS_LOCK = "exchange-coins-lock"; +export const EXCHANGE_RESERVES_LOCK = "exchange-reserves-lock"; + +export type NotificationListener = (n: WalletNotification) => void; + +type CancelFn = () => void; + async function runTaskLoop( ws: InternalWalletState, opts: RetryLoopOpts = {}, @@ -493,7 +491,7 @@ async function dumpCoins(ws: InternalWalletState): Promise { /** * Get an API client from an internal wallet state object. */ -export async function getClientFromWalletState( +async function getClientFromWalletState( ws: InternalWalletState, ): Promise { let id = 0; @@ -1363,7 +1361,7 @@ export class Wallet { cryptoWorkerFactory: CryptoWorkerFactory, config?: WalletConfigParameter, ) { - this.ws = new InternalWalletStateImpl( + this.ws = new InternalWalletState( idb, http, timer, @@ -1446,24 +1444,18 @@ export class Wallet { * * This ties together all the operation implementations. */ -class InternalWalletStateImpl implements InternalWalletState { +export class InternalWalletState { cryptoApi: TalerCryptoInterface; cryptoDispatcher: CryptoDispatcher; - merchantInfoCache: Record = {}; - readonly timerGroup: TimerGroup; workAvailable = new AsyncCondition(); stopped = false; - listeners: NotificationListener[] = []; + private listeners: NotificationListener[] = []; initCalled = false; - recoupOps: RecoupOperations = { - createRecoupGroup, - }; - // FIXME: Use an LRU cache here. private denomCache: Record = {}; @@ -1621,7 +1613,7 @@ class InternalWalletStateImpl implements InternalWalletState { async getDenomInfo( ws: InternalWalletState, - tx: WalletDbReadWriteTransaction<["denominations"]>, + tx: WalletDbReadOnlyTransaction<["denominations"]>, exchangeBaseUrl: string, denomPubHash: string, ): Promise { -- cgit v1.2.3