summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/wallet.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-02-20 18:48:42 +0100
committerFlorian Dold <florian@dold.me>2024-02-20 18:55:02 +0100
commitd70f722866b62e4a0076c805b65d66d5a049b366 (patch)
treeeae153cb78a4987c12e18bd1dedcd8ab34030d71 /packages/taler-wallet-core/src/wallet.ts
parentba3e64470ae035c431ca8107ed547269e7307c4a (diff)
downloadwallet-core-d70f722866b62e4a0076c805b65d66d5a049b366.tar.gz
wallet-core-d70f722866b62e4a0076c805b65d66d5a049b366.tar.bz2
wallet-core-d70f722866b62e4a0076c805b65d66d5a049b366.zip
wallet-core: get rid of separate InternalWalletState interface
Diffstat (limited to 'packages/taler-wallet-core/src/wallet.ts')
-rw-r--r--packages/taler-wallet-core/src/wallet.ts32
1 files changed, 12 insertions, 20 deletions
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,
@@ -189,13 +188,6 @@ import {
lookupExchangeByUri,
} from "./exchanges.js";
import {
- CancelFn,
- InternalWalletState,
- MerchantInfo,
- NotificationListener,
- RecoupOperations,
-} from "./internal-wallet-state.js";
-import {
computePayMerchantTransactionState,
computeRefundTransactionState,
confirmPay,
@@ -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<CoinDumpJson> {
/**
* Get an API client from an internal wallet state object.
*/
-export async function getClientFromWalletState(
+async function getClientFromWalletState(
ws: InternalWalletState,
): Promise<WalletCoreApiClient> {
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<string, MerchantInfo> = {};
-
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<string, DenominationInfo> = {};
@@ -1621,7 +1613,7 @@ class InternalWalletStateImpl implements InternalWalletState {
async getDenomInfo(
ws: InternalWalletState,
- tx: WalletDbReadWriteTransaction<["denominations"]>,
+ tx: WalletDbReadOnlyTransaction<["denominations"]>,
exchangeBaseUrl: string,
denomPubHash: string,
): Promise<DenominationInfo | undefined> {