taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 2490393924aa44e6e3c2c072110a6175aaf41a82
parent f366084d070a3f59bbdfe1fe1d31a0f3719d5c1c
Author: Florian Dold <florian@dold.me>
Date:   Mon,  8 Jan 2024 22:00:32 +0100

wallet-core: notify on exchange tos acceptance

Diffstat:
Mpackages/taler-wallet-core/src/operations/exchanges.ts | 14+++++++++++++-
Mpackages/taler-wallet-core/src/operations/withdraw.ts | 8+-------
2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts b/packages/taler-wallet-core/src/operations/exchanges.ts @@ -272,18 +272,30 @@ export async function acceptExchangeTermsOfService( exchangeBaseUrl: string, etag: string | undefined, ): Promise<void> { - await ws.db + const notif = await ws.db .mktx((x) => [x.exchanges, x.exchangeDetails]) .runReadWrite(async (tx) => { const exch = await tx.exchanges.get(exchangeBaseUrl); if (exch && exch.tosCurrentEtag) { + const oldExchangeState = getExchangeState(exch); exch.tosAcceptedEtag = exch.tosCurrentEtag; exch.tosAcceptedTimestamp = timestampPreciseToDb( TalerPreciseTimestamp.now(), ); await tx.exchanges.put(exch); + const newExchangeState = getExchangeState(exch); + return { + type: NotificationType.ExchangeStateTransition, + exchangeBaseUrl, + newExchangeState: newExchangeState, + oldExchangeState: oldExchangeState, + } satisfies WalletNotification; } + return undefined; }); + if (notif) { + ws.notify(notif); + } } async function validateWireInfo( diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts @@ -34,7 +34,6 @@ import { DenomSelectionState, Duration, ExchangeBatchWithdrawRequest, - ExchangeListItem, ExchangeUpdateStatus, ExchangeWireAccount, ExchangeWithdrawBatchResponse, @@ -100,11 +99,7 @@ import { WithdrawalGroupStatus, WithdrawalRecordType, } from "../db.js"; -import { - ExchangeEntryDbRecordStatus, - isWithdrawableDenom, - timestampPreciseToDb, -} from "../index.js"; +import { isWithdrawableDenom, timestampPreciseToDb } from "../index.js"; import { InternalWalletState } from "../internal-wallet-state.js"; import { TaskIdentifiers, @@ -113,7 +108,6 @@ import { constructTaskIdentifier, makeCoinAvailable, makeCoinsVisible, - makeExchangeListItem, runLongpollAsync, } from "../operations/common.js"; import { PendingTaskType } from "../pending-types.js";