summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/wallet.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-02-27 15:31:01 +0100
committerFlorian Dold <florian@dold.me>2024-02-27 15:31:01 +0100
commitf78d7dc613946b0316a559aa0161dd02b056b05d (patch)
treebcf37180afbd02d71e4faac896edcd0b18e2f4bb /packages/taler-wallet-core/src/wallet.ts
parent41f34031ae934e8c802cdbb73fffb5a39c9c6a68 (diff)
downloadwallet-core-f78d7dc613946b0316a559aa0161dd02b056b05d.tar.gz
wallet-core-f78d7dc613946b0316a559aa0161dd02b056b05d.tar.bz2
wallet-core-f78d7dc613946b0316a559aa0161dd02b056b05d.zip
-move function
Diffstat (limited to 'packages/taler-wallet-core/src/wallet.ts')
-rw-r--r--packages/taler-wallet-core/src/wallet.ts40
1 files changed, 20 insertions, 20 deletions
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts
index f21db0531..79f7a1be5 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -310,6 +310,24 @@ async function fillDefaults(ws: InternalWalletState): Promise<void> {
}
}
+export async function getDenomInfo(
+ ws: InternalWalletState,
+ tx: WalletDbReadOnlyTransaction<["denominations"]>,
+ exchangeBaseUrl: string,
+ denomPubHash: string,
+): Promise<DenominationInfo | undefined> {
+ const key = `${exchangeBaseUrl}:${denomPubHash}`;
+ const cached = ws.denomCache[key];
+ if (cached) {
+ return cached;
+ }
+ const d = await tx.denominations.get([exchangeBaseUrl, denomPubHash]);
+ if (d) {
+ return DenominationRecord.toDenomInfo(d);
+ }
+ return undefined;
+}
+
/**
* List bank accounts known to the wallet from
* previous withdrawals.
@@ -440,7 +458,7 @@ async function dumpCoins(ws: InternalWalletState): Promise<CoinDumpJson> {
if (cs.type == CoinSourceType.Withdraw) {
withdrawalReservePub = cs.reservePub;
}
- const denomInfo = await ws.getDenomInfo(
+ const denomInfo = await getDenomInfo(
ws,
tx,
c.exchangeBaseUrl,
@@ -1456,7 +1474,7 @@ export class InternalWalletState {
initCalled = false;
// FIXME: Use an LRU cache here.
- private denomCache: Record<string, DenominationInfo> = {};
+ denomCache: Record<string, DenominationInfo> = {};
/**
* Promises that are waiting for a particular resource.
@@ -1517,24 +1535,6 @@ export class InternalWalletState {
}
}
- async getDenomInfo(
- ws: InternalWalletState,
- tx: WalletDbReadOnlyTransaction<["denominations"]>,
- exchangeBaseUrl: string,
- denomPubHash: string,
- ): Promise<DenominationInfo | undefined> {
- const key = `${exchangeBaseUrl}:${denomPubHash}`;
- const cached = this.denomCache[key];
- if (cached) {
- return cached;
- }
- const d = await tx.denominations.get([exchangeBaseUrl, denomPubHash]);
- if (d) {
- return DenominationRecord.toDenomInfo(d);
- }
- return undefined;
- }
-
notify(n: WalletNotification): void {
logger.trace(`Notification: ${j2s(n)}`);
for (const l of this.listeners) {