commit 350ea196d6acad605cefbc3e18088eb773c93999
parent cf10cdeeb6277818bd231f4ce6000e587c304a41
Author: Florian Dold <dold@taler.net>
Date: Sat, 18 Jul 2026 20:07:07 +0200
db: use runWalletDbTx where the legacy handle is unused
Diffstat:
5 files changed, 22 insertions(+), 24 deletions(-)
diff --git a/packages/taler-wallet-core/src/balance.ts b/packages/taler-wallet-core/src/balance.ts
@@ -98,7 +98,6 @@ import {
import { WalletDbTransaction } from "./dbtx.js";
import {
getDenomInfo,
- LegacyWalletTxHandle,
WalletExecutionContext,
} from "./wallet.js";
@@ -852,10 +851,9 @@ export async function getPaymentBalanceDetails(
export async function getPaymentBalanceDetailsInTx(
wex: WalletExecutionContext,
- tx: WalletDbTransaction | LegacyWalletTxHandle,
+ tx: WalletDbTransaction,
req: PaymentRestrictionsForBalance,
): Promise<PaymentBalanceDetails> {
- const dbTx = "wtx" in tx ? tx.wtx : tx;
const d: PaymentBalanceDetails = {
balanceAvailable: Amounts.zeroOfCurrency(req.currency),
balanceMaterial: Amounts.zeroOfCurrency(req.currency),
@@ -871,7 +869,7 @@ export async function getPaymentBalanceDetailsInTx(
logger.trace(`computing balance details for ${j2s(req)}`);
- const availableCoins = await dbTx.getCoinAvailabilities();
+ const availableCoins = await tx.getCoinAvailabilities();
for (const ca of availableCoins) {
if (ca.currency != req.currency) {
@@ -880,7 +878,7 @@ export async function getPaymentBalanceDetailsInTx(
const denom = await getDenomInfo(
wex,
- dbTx,
+ tx,
ca.exchangeBaseUrl,
ca.denomPubHash,
);
@@ -891,7 +889,7 @@ export async function getPaymentBalanceDetailsInTx(
// Skip exchanges if excluded by the receiver.
if (
req.restrictSenderScope &&
- !(await dbTx.checkExchangeInScope(
+ !(await tx.checkExchangeInScope(
ca.exchangeBaseUrl,
req.restrictSenderScope,
))
@@ -899,7 +897,7 @@ export async function getPaymentBalanceDetailsInTx(
continue;
}
- const wireDetails = await dbTx.getExchangeDetails(ca.exchangeBaseUrl);
+ const wireDetails = await tx.getExchangeDetails(ca.exchangeBaseUrl);
if (!wireDetails) {
continue;
}
@@ -1026,7 +1024,7 @@ export async function getPaymentBalanceDetailsInTx(
}
}
- const refreshGroups = await dbTx.getActiveRefreshGroups();
+ const refreshGroups = await tx.getActiveRefreshGroups();
for (const r of refreshGroups) {
if (r.currency != req.currency) {
continue;
diff --git a/packages/taler-wallet-core/src/coinSelection.ts b/packages/taler-wallet-core/src/coinSelection.ts
@@ -503,7 +503,7 @@ export async function reportInsufficientBalanceDetails(
req: ReportInsufficientBalanceRequest,
): Promise<PaymentInsufficientBalanceDetails> {
const currency = Amounts.currencyOf(req.instructedAmount);
- const details = await getPaymentBalanceDetailsInTx(wex, tx, {
+ const details = await getPaymentBalanceDetailsInTx(wex, tx.wtx, {
restrictSenderScope: undefined,
restrictReceiverExchanges: req.restrictExchanges,
restrictWireMethods: req.wireMethod ? [req.wireMethod] : undefined,
@@ -532,7 +532,7 @@ export async function reportInsufficientBalanceDetails(
// Do not report anything for an exchange with a different currency.
continue;
}
- const exchDet = await getPaymentBalanceDetailsInTx(wex, tx, {
+ const exchDet = await getPaymentBalanceDetailsInTx(wex, tx.wtx, {
restrictSenderScope: {
type: ScopeType.Exchange,
currency,
diff --git a/packages/taler-wallet-core/src/mailbox.ts b/packages/taler-wallet-core/src/mailbox.ts
@@ -68,8 +68,8 @@ export async function addMailboxMessage(
wex: WalletExecutionContext,
req: AddMailboxMessageRequest,
): Promise<EmptyObject> {
- await wex.runLegacyWalletDbTx(async (tx) => {
- await tx.wtx.upsertMailboxMessage(req.message);
+ await wex.runWalletDbTx(async (tx) => {
+ await tx.upsertMailboxMessage(req.message);
tx.notify({
type: NotificationType.MailboxMessageAdded,
message: req.message,
@@ -85,8 +85,8 @@ export async function deleteMailboxMessage(
wex: WalletExecutionContext,
req: DeleteMailboxMessageRequest,
): Promise<EmptyObject> {
- await wex.runLegacyWalletDbTx(async (tx) => {
- await tx.wtx.deleteMailboxMessage(
+ await wex.runWalletDbTx(async (tx) => {
+ await tx.deleteMailboxMessage(
req.message.originMailboxBaseUrl,
req.message.talerUri,
);
@@ -105,8 +105,8 @@ export async function listMailboxMessages(
wex: WalletExecutionContext,
req: EmptyObject,
): Promise<MailboxMessagesResponse> {
- const messages = await wex.runLegacyWalletDbTx(async (tx) => {
- return await tx.wtx.listMailboxMessages();
+ const messages = await wex.runWalletDbTx(async (tx) => {
+ return await tx.listMailboxMessages();
});
return { messages: messages };
}
@@ -180,9 +180,9 @@ export async function getMailbox(
wex: WalletExecutionContext,
mailboxBaseUrl: MailboxBaseUrl,
): Promise<GetMailboxResponse> {
- return await wex.runLegacyWalletDbTx(async (tx) => {
+ return await wex.runWalletDbTx(async (tx) => {
return {
- mailboxConfiguration: await tx.wtx.getMailboxConfiguration(
+ mailboxConfiguration: await tx.getMailboxConfiguration(
mailboxBaseUrl.mailboxBaseUrl,
),
};
@@ -227,8 +227,8 @@ export async function createNewMailbox(
undefined,
);
}
- await wex.runLegacyWalletDbTx(async (tx) => {
- return await tx.wtx.upsertMailboxConfiguration(mailboxConf);
+ await wex.runWalletDbTx(async (tx) => {
+ return await tx.upsertMailboxConfiguration(mailboxConf);
});
return mailboxConf;
}
diff --git a/packages/taler-wallet-core/src/testing.ts b/packages/taler-wallet-core/src/testing.ts
@@ -974,10 +974,10 @@ export async function testPay(
if (r.type != ConfirmPayResultType.Done) {
throw Error("payment not done");
}
- const purchase = await wex.runLegacyWalletDbTx(async (tx) => {
+ const purchase = await wex.runWalletDbTx(async (tx) => {
const parsedTx = parseTransactionIdentifier(r.transactionId);
checkLogicInvariant(parsedTx?.tag === TransactionType.Payment);
- return tx.wtx.getPurchase(parsedTx.proposalId);
+ return tx.getPurchase(parsedTx.proposalId);
});
checkLogicInvariant(!!purchase);
return {
diff --git a/packages/taler-wallet-core/src/tokenSelection.ts b/packages/taler-wallet-core/src/tokenSelection.ts
@@ -216,8 +216,8 @@ export async function selectPayTokens(
wex: WalletExecutionContext,
req: SelectPayTokensRequest,
): Promise<SelectPayTokensResult> {
- return await wex.runLegacyWalletDbTx(async (tx) => {
- return selectPayTokensInTx(tx.wtx, req);
+ return await wex.runWalletDbTx(async (tx) => {
+ return selectPayTokensInTx(tx, req);
});
}