summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/instructedAmountConversion.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/instructedAmountConversion.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/instructedAmountConversion.ts')
-rw-r--r--packages/taler-wallet-core/src/instructedAmountConversion.ts24
1 files changed, 13 insertions, 11 deletions
diff --git a/packages/taler-wallet-core/src/instructedAmountConversion.ts b/packages/taler-wallet-core/src/instructedAmountConversion.ts
index 2250188b7..ccad050bf 100644
--- a/packages/taler-wallet-core/src/instructedAmountConversion.ts
+++ b/packages/taler-wallet-core/src/instructedAmountConversion.ts
@@ -34,7 +34,7 @@ import {
import { CoinInfo } from "./coinSelection.js";
import { DenominationRecord, timestampProtocolFromDb } from "./db.js";
import { getExchangeWireDetailsInTx } from "./exchanges.js";
-import { InternalWalletState } from "./wallet.js";
+import { InternalWalletState, WalletExecutionContext } from "./wallet.js";
/**
* If the operation going to be plan subtracts
@@ -129,14 +129,14 @@ interface AvailableCoins {
* of being cached
*/
async function getAvailableDenoms(
- ws: InternalWalletState,
+ wex: WalletExecutionContext,
op: TransactionType,
currency: string,
filters: CoinsFilter = {},
): Promise<AvailableCoins> {
const operationType = getOperationType(TransactionType.Deposit);
- return await ws.db.runReadOnlyTx(
+ return await wex.db.runReadOnlyTx(
["exchanges", "exchangeDetails", "denominations", "coinAvailability"],
async (tx) => {
const list: CoinInfo[] = [];
@@ -328,14 +328,14 @@ function buildCoinInfoFromDenom(
}
export async function convertDepositAmount(
- ws: InternalWalletState,
+ wex: WalletExecutionContext,
req: ConvertAmountRequest,
): Promise<AmountResponse> {
const amount = Amounts.parseOrThrow(req.amount);
// const filter = getCoinsFilter(req);
const denoms = await getAvailableDenoms(
- ws,
+ wex,
TransactionType.Deposit,
amount.currency,
{},
@@ -430,13 +430,13 @@ export function convertDepositAmountForAvailableCoins(
}
export async function getMaxDepositAmount(
- ws: InternalWalletState,
+ wex: WalletExecutionContext,
req: GetAmountRequest,
): Promise<AmountResponse> {
// const filter = getCoinsFilter(req);
const denoms = await getAvailableDenoms(
- ws,
+ wex,
TransactionType.Deposit,
req.currency,
{},
@@ -473,25 +473,27 @@ export function getMaxDepositAmountForAvailableCoins(
}
export async function convertPeerPushAmount(
- ws: InternalWalletState,
+ wex: WalletExecutionContext,
req: ConvertAmountRequest,
): Promise<AmountResponse> {
throw Error("to be implemented after 1.0");
}
+
export async function getMaxPeerPushAmount(
- ws: InternalWalletState,
+ wex: WalletExecutionContext,
req: GetAmountRequest,
): Promise<AmountResponse> {
throw Error("to be implemented after 1.0");
}
+
export async function convertWithdrawalAmount(
- ws: InternalWalletState,
+ wex: WalletExecutionContext,
req: ConvertAmountRequest,
): Promise<AmountResponse> {
const amount = Amounts.parseOrThrow(req.amount);
const denoms = await getAvailableDenoms(
- ws,
+ wex,
TransactionType.Withdrawal,
amount.currency,
{},