diff options
author | Florian Dold <florian@dold.me> | 2024-01-08 22:00:32 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2024-01-08 22:00:41 +0100 |
commit | 2490393924aa44e6e3c2c072110a6175aaf41a82 (patch) | |
tree | f81309ef31d834ecd32af06d4a0da5f8476ebba3 | |
parent | f366084d070a3f59bbdfe1fe1d31a0f3719d5c1c (diff) | |
download | wallet-core-2490393924aa44e6e3c2c072110a6175aaf41a82.tar.gz wallet-core-2490393924aa44e6e3c2c072110a6175aaf41a82.tar.bz2 wallet-core-2490393924aa44e6e3c2c072110a6175aaf41a82.zip |
wallet-core: notify on exchange tos acceptance
-rw-r--r-- | packages/taler-wallet-core/src/operations/exchanges.ts | 14 | ||||
-rw-r--r-- | packages/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 index 766af27a8..ca3ea8af6 100644 --- 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 index 56f1d91bb..8221abea6 100644 --- 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"; |