summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/balance.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-02-27 17:39:58 +0100
committerFlorian Dold <florian@dold.me>2024-02-27 17:40:03 +0100
commit523280b3862b528512ff93c651bc0d9ed632fbf6 (patch)
treeb99f866db59b572685c8c7215136270e22210ca2 /packages/taler-wallet-core/src/balance.ts
parent3a889c177dd35a114d2c95efd296274cd185ce52 (diff)
downloadwallet-core-523280b3862b528512ff93c651bc0d9ed632fbf6.tar.gz
wallet-core-523280b3862b528512ff93c651bc0d9ed632fbf6.tar.bz2
wallet-core-523280b3862b528512ff93c651bc0d9ed632fbf6.zip
wallet-core: thread through wallet execution context
Diffstat (limited to 'packages/taler-wallet-core/src/balance.ts')
-rw-r--r--packages/taler-wallet-core/src/balance.ts32
1 files changed, 16 insertions, 16 deletions
diff --git a/packages/taler-wallet-core/src/balance.ts b/packages/taler-wallet-core/src/balance.ts
index a287748f1..3b53699ac 100644
--- a/packages/taler-wallet-core/src/balance.ts
+++ b/packages/taler-wallet-core/src/balance.ts
@@ -80,7 +80,7 @@ import {
getExchangeScopeInfo,
getExchangeWireDetailsInTx,
} from "./exchanges.js";
-import { InternalWalletState } from "./wallet.js";
+import { InternalWalletState, WalletExecutionContext } from "./wallet.js";
/**
* Logger.
@@ -131,7 +131,7 @@ class BalancesStore {
private balanceStore: Record<string, WalletBalance> = {};
constructor(
- private ws: InternalWalletState,
+ private wex: WalletExecutionContext,
private tx: WalletDbReadOnlyTransaction<
[
"globalCurrencyAuditors",
@@ -281,7 +281,7 @@ class BalancesStore {
* Get balance information.
*/
export async function getBalancesInsideTransaction(
- ws: InternalWalletState,
+ wex: WalletExecutionContext,
tx: WalletDbReadOnlyTransaction<
[
"exchanges",
@@ -295,7 +295,7 @@ export async function getBalancesInsideTransaction(
]
>,
): Promise<BalancesResponse> {
- const balanceStore: BalancesStore = new BalancesStore(ws, tx);
+ const balanceStore: BalancesStore = new BalancesStore(wex, tx);
const keyRangeActive = GlobalIDB.KeyRange.bound(
OPERATION_STATUS_ACTIVE_FIRST,
@@ -428,11 +428,11 @@ export async function getBalancesInsideTransaction(
* Get detailed balance information, sliced by exchange and by currency.
*/
export async function getBalances(
- ws: InternalWalletState,
+ wex: WalletExecutionContext,
): Promise<BalancesResponse> {
logger.trace("starting to compute balance");
- const wbal = await ws.db.runReadWriteTx(
+ const wbal = await wex.db.runReadWriteTx(
[
"coinAvailability",
"coins",
@@ -446,7 +446,7 @@ export async function getBalances(
"withdrawalGroups",
],
async (tx) => {
- return getBalancesInsideTransaction(ws, tx);
+ return getBalancesInsideTransaction(wex, tx);
},
);
@@ -488,12 +488,12 @@ export interface AcceptableExchanges {
* Get all exchanges that are acceptable for a particular payment.
*/
export async function getAcceptableExchangeBaseUrls(
- ws: InternalWalletState,
+ wex: WalletExecutionContext,
req: MerchantPaymentRestrictionsForBalance,
): Promise<AcceptableExchanges> {
const acceptableExchangeUrls = new Set<string>();
const depositableExchangeUrls = new Set<string>();
- await ws.db.runReadOnlyTx(["exchanges", "exchangeDetails"], async (tx) => {
+ await wex.db.runReadOnlyTx(["exchanges", "exchangeDetails"], async (tx) => {
// FIXME: We should have a DB index to look up all exchanges
// for a particular auditor ...
@@ -600,10 +600,10 @@ export interface MerchantPaymentBalanceDetails {
}
export async function getMerchantPaymentBalanceDetails(
- ws: InternalWalletState,
+ wex: WalletExecutionContext,
req: MerchantPaymentRestrictionsForBalance,
): Promise<MerchantPaymentBalanceDetails> {
- const acceptability = await getAcceptableExchangeBaseUrls(ws, req);
+ const acceptability = await getAcceptableExchangeBaseUrls(wex, req);
const d: MerchantPaymentBalanceDetails = {
balanceAvailable: Amounts.zeroOfCurrency(req.currency),
@@ -613,7 +613,7 @@ export async function getMerchantPaymentBalanceDetails(
balanceMerchantDepositable: Amounts.zeroOfCurrency(req.currency),
};
- await ws.db.runReadOnlyTx(
+ await wex.db.runReadOnlyTx(
["coinAvailability", "refreshGroups"],
async (tx) => {
await tx.coinAvailability.iter().forEach((ca) => {
@@ -665,12 +665,12 @@ export async function getMerchantPaymentBalanceDetails(
}
export async function getBalanceDetail(
- ws: InternalWalletState,
+ wex: WalletExecutionContext,
req: GetBalanceDetailRequest,
): Promise<MerchantPaymentBalanceDetails> {
const exchanges: { exchangeBaseUrl: string; exchangePub: string }[] = [];
const wires = new Array<string>();
- await ws.db.runReadOnlyTx(["exchanges", "exchangeDetails"], async (tx) => {
+ await wex.db.runReadOnlyTx(["exchanges", "exchangeDetails"], async (tx) => {
const allExchanges = await tx.exchanges.iter().toArray();
for (const e of allExchanges) {
const details = await getExchangeWireDetailsInTx(tx, e.baseUrl);
@@ -690,7 +690,7 @@ export async function getBalanceDetail(
}
});
- return await getMerchantPaymentBalanceDetails(ws, {
+ return await getMerchantPaymentBalanceDetails(wex, {
currency: req.currency,
acceptedAuditors: [],
acceptedExchanges: exchanges,
@@ -717,7 +717,7 @@ export interface PeerPaymentBalanceDetails {
}
export async function getPeerPaymentBalanceDetailsInTx(
- ws: InternalWalletState,
+ wex: WalletExecutionContext,
tx: WalletDbReadOnlyTransaction<["coinAvailability", "refreshGroups"]>,
req: PeerPaymentRestrictionsForBalance,
): Promise<PeerPaymentBalanceDetails> {