commit 46e2a26ce572255751d0d7c76a8d3da91da23588
parent 8135a3a0b86ccf7d3fd0d5c52d79df9fd81c1b5d
Author: Florian Dold <florian@dold.me>
Date: Wed, 15 Jul 2026 14:38:47 +0200
wallet-core: notify directly
Diffstat:
1 file changed, 24 insertions(+), 43 deletions(-)
diff --git a/packages/taler-wallet-core/src/exchanges.ts b/packages/taler-wallet-core/src/exchanges.ts
@@ -605,7 +605,7 @@ export async function acceptExchangeTermsOfService(
wex: WalletExecutionContext,
exchangeBaseUrl: string,
): Promise<void> {
- const notif = await wex.runLegacyWalletDbTx(async (tx) => {
+ await wex.runLegacyWalletDbTx(async (tx) => {
const exch = await tx.exchanges.get(exchangeBaseUrl);
if (exch && exch.tosCurrentEtag) {
const oldExchangeState = getExchangeState(exch);
@@ -616,18 +616,14 @@ export async function acceptExchangeTermsOfService(
await tx.exchanges.put(exch);
const newExchangeState = getExchangeState(exch);
wex.ws.exchangeCache.clear();
- return {
+ tx.notify({
type: NotificationType.ExchangeStateTransition,
exchangeBaseUrl,
newExchangeState: newExchangeState,
oldExchangeState: oldExchangeState,
- } satisfies WalletNotification;
+ });
}
- return undefined;
});
- if (notif) {
- wex.ws.notify(notif);
- }
}
/**
@@ -3676,7 +3672,7 @@ export async function handleStartExchangeWalletKyc(
req: StartExchangeWalletKycRequest,
): Promise<EmptyObject> {
const newReservePair = await wex.cryptoApi.createEddsaKeypair({});
- const dbRes = await wex.runLegacyWalletDbTx(async (tx) => {
+ await wex.runLegacyWalletDbTx(async (tx) => {
const exchange = await tx.exchanges.get(req.exchangeBaseUrl);
if (!exchange) {
throw Error("exchange not found");
@@ -3706,14 +3702,12 @@ export async function handleStartExchangeWalletKyc(
reserveRec.thresholdRequested = req.amount;
reserveRec.status = ReserveRecordStatus.PendingLegiInit;
await tx.reserves.put(reserveRec);
- return {
- notification: {
- type: NotificationType.ExchangeStateTransition,
- exchangeBaseUrl: exchange.baseUrl,
- oldExchangeState,
- newExchangeState: getExchangeState(exchange),
- } satisfies WalletNotification,
- };
+ tx.notify({
+ type: NotificationType.ExchangeStateTransition,
+ exchangeBaseUrl: exchange.baseUrl,
+ oldExchangeState,
+ newExchangeState: getExchangeState(exchange),
+ });
} else {
logger.info(
`another KYC process is already active for ${req.exchangeBaseUrl} over ${reserveRec.thresholdRequested}`,
@@ -3728,9 +3722,6 @@ export async function handleStartExchangeWalletKyc(
return undefined;
}
});
- if (dbRes && dbRes.notification) {
- wex.ws.notify(dbRes.notification);
- }
const taskId = constructTaskIdentifier({
tag: PendingTaskType.ExchangeWalletKyc,
exchangeBaseUrl: req.exchangeBaseUrl,
@@ -3807,7 +3798,7 @@ async function handleExchangeKycSuccess(
nextThreshold: AmountLike | undefined,
): Promise<TaskRunResult> {
logger.info(`kyc check for ${exchangeBaseUrl} satisfied`);
- const dbRes = await wex.runLegacyWalletDbTx(async (tx) => {
+ await wex.runLegacyWalletDbTx(async (tx) => {
const exchange = await tx.exchanges.get(exchangeBaseUrl);
if (!exchange) {
throw Error("exchange not found");
@@ -3837,18 +3828,13 @@ async function handleExchangeKycSuccess(
await tx.reserves.put(reserve);
logger.info(`newly granted threshold: ${reserve.thresholdGranted}`);
- return {
- notification: {
- type: NotificationType.ExchangeStateTransition,
- exchangeBaseUrl: exchange.baseUrl,
- oldExchangeState,
- newExchangeState: getExchangeState(exchange),
- } satisfies WalletNotification,
- };
+ tx.notify({
+ type: NotificationType.ExchangeStateTransition,
+ exchangeBaseUrl: exchange.baseUrl,
+ oldExchangeState,
+ newExchangeState: getExchangeState(exchange),
+ });
});
- if (dbRes && dbRes.notification) {
- wex.ws.notify(dbRes.notification);
- }
return TaskRunResult.progress();
}
@@ -3925,7 +3911,7 @@ async function handleExchangeKycRespLegi(
codecForAccountKycStatus(),
);
- const dbRes = await wex.runLegacyWalletDbTx(async (tx) => {
+ await wex.runLegacyWalletDbTx(async (tx) => {
const exchange = await tx.exchanges.get(exchangeBaseUrl);
if (!exchange) {
throw Error("exchange not found");
@@ -3949,18 +3935,13 @@ async function handleExchangeKycRespLegi(
reserve.kycAccessToken = accountKycStatusResp.access_token;
await tx.reserves.put(reserve);
- return {
- notification: {
- type: NotificationType.ExchangeStateTransition,
- exchangeBaseUrl: exchange.baseUrl,
- oldExchangeState,
- newExchangeState: getExchangeState(exchange),
- } satisfies WalletNotification,
- };
+ tx.notify({
+ type: NotificationType.ExchangeStateTransition,
+ exchangeBaseUrl: exchange.baseUrl,
+ oldExchangeState,
+ newExchangeState: getExchangeState(exchange),
+ });
});
- if (dbRes && dbRes.notification) {
- wex.ws.notify(dbRes.notification);
- }
return TaskRunResult.progress();
}