[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] branch master updated: wallet-core: notify on exchan
From: |
gnunet |
Subject: |
[taler-wallet-core] branch master updated: wallet-core: notify on exchange deletion |
Date: |
Wed, 02 Oct 2024 10:46:27 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-core.
The following commit(s) were added to refs/heads/master by this push:
new 3bf07a819 wallet-core: notify on exchange deletion
3bf07a819 is described below
commit 3bf07a819c805b2c1df8afa995c2de4fd02b4257
Author: Florian Dold <florian@dold.me>
AuthorDate: Wed Oct 2 10:46:18 2024 +0200
wallet-core: notify on exchange deletion
---
.../taler-harness/src/integrationtests/test-wallet-dd48.ts | 9 ++++++---
.../src/integrationtests/test-wallet-exchange-update.ts | 2 +-
packages/taler-util/src/notifications.ts | 4 +++-
packages/taler-wallet-core/src/exchanges.ts | 13 ++++++++++++-
.../src/components/WalletActivity.tsx | 12 ++++++------
5 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/packages/taler-harness/src/integrationtests/test-wallet-dd48.ts
b/packages/taler-harness/src/integrationtests/test-wallet-dd48.ts
index 7378e272a..dc729b830 100644
--- a/packages/taler-harness/src/integrationtests/test-wallet-dd48.ts
+++ b/packages/taler-harness/src/integrationtests/test-wallet-dd48.ts
@@ -29,7 +29,7 @@ import {
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js";
import {
- BankService,
+ BankService,
ExchangeService,
GlobalTestState,
WalletClient,
@@ -69,7 +69,10 @@ export async function runWalletDd48Test(t: GlobalTestState) {
await exchange.addBankAccount("1", {
accountName: exchangeBankUsername,
accountPassword: exchangeBankPassword,
- wireGatewayApiBaseUrl: new URL("accounts/exchange/taler-wire-gateway/",
bank.baseUrl).href,
+ wireGatewayApiBaseUrl: new URL(
+ "accounts/exchange/taler-wire-gateway/",
+ bank.baseUrl,
+ ).href,
accountPaytoUri: exchangePaytoUri,
});
@@ -178,7 +181,7 @@ export async function runWalletDd48Test(t: GlobalTestState)
{
(x) =>
x.type === NotificationType.ExchangeStateTransition &&
x.oldExchangeState == null &&
- x.newExchangeState.exchangeEntryStatus ===
+ x.newExchangeState?.exchangeEntryStatus ===
ExchangeEntryStatus.Ephemeral,
),
);
diff --git
a/packages/taler-harness/src/integrationtests/test-wallet-exchange-update.ts
b/packages/taler-harness/src/integrationtests/test-wallet-exchange-update.ts
index 3d7ea32e6..93abd69c6 100644
--- a/packages/taler-harness/src/integrationtests/test-wallet-exchange-update.ts
+++ b/packages/taler-harness/src/integrationtests/test-wallet-exchange-update.ts
@@ -180,7 +180,7 @@ export async function runWalletExchangeUpdateTest(
console.log(`got notif ${j2s(n)}`);
return (
n.type === NotificationType.ExchangeStateTransition &&
- n.newExchangeState.exchangeUpdateStatus === ExchangeUpdateStatus.Ready
+ n.newExchangeState?.exchangeUpdateStatus === ExchangeUpdateStatus.Ready
);
});
diff --git a/packages/taler-util/src/notifications.ts
b/packages/taler-util/src/notifications.ts
index c3e0070bc..eefa21cde 100644
--- a/packages/taler-util/src/notifications.ts
+++ b/packages/taler-util/src/notifications.ts
@@ -85,8 +85,10 @@ export interface ExchangeStateTransitionNotification {
/**
* New state of the exchange.
+ *
+ * If missing, exchange got deleted.
*/
- newExchangeState: ExchangeEntryState;
+ newExchangeState?: ExchangeEntryState;
/**
* Summary of the error that occurred when trying to update the exchange
entry,
diff --git a/packages/taler-wallet-core/src/exchanges.ts
b/packages/taler-wallet-core/src/exchanges.ts
index 773ad0d59..40ba9c227 100644
--- a/packages/taler-wallet-core/src/exchanges.ts
+++ b/packages/taler-wallet-core/src/exchanges.ts
@@ -2868,13 +2868,14 @@ export async function deleteExchange(
): Promise<void> {
let inUse: boolean = false;
const exchangeBaseUrl = req.exchangeBaseUrl;
- await wex.db.runAllStoresReadWriteTx({}, async (tx) => {
+ const notif = await wex.db.runAllStoresReadWriteTx({}, async (tx) => {
const exchangeRec = await tx.exchanges.get(exchangeBaseUrl);
if (!exchangeRec) {
// Nothing to delete!
logger.info("no exchange found to delete");
return;
}
+ const oldExchangeState = getExchangeState(exchangeRec);
const res = await internalGetExchangeResources(wex, tx, exchangeBaseUrl);
if (res.hasResources && !req.purge) {
inUse = true;
@@ -2882,6 +2883,13 @@ export async function deleteExchange(
}
await purgeExchange(wex, tx, exchangeBaseUrl);
wex.ws.exchangeCache.clear();
+
+ return {
+ type: NotificationType.ExchangeStateTransition,
+ oldExchangeState,
+ newExchangeState: undefined,
+ exchangeBaseUrl,
+ } satisfies WalletNotification;
});
if (inUse) {
@@ -2890,6 +2898,9 @@ export async function deleteExchange(
hint: "Exchange in use.",
});
}
+ if (notif) {
+ wex.ws.notify(notif);
+ }
}
export async function getExchangeResources(
diff --git
a/packages/taler-wallet-webextension/src/components/WalletActivity.tsx
b/packages/taler-wallet-webextension/src/components/WalletActivity.tsx
index d8d25f90c..ab3668ca0 100644
--- a/packages/taler-wallet-webextension/src/components/WalletActivity.tsx
+++ b/packages/taler-wallet-webextension/src/components/WalletActivity.tsx
@@ -312,34 +312,34 @@ function ShowExchangeStateTransition({ events }:
MoreInfoPRops): VNode {
<dt>Exchange</dt>
<dd>{not.exchangeBaseUrl}</dd>
{not.oldExchangeState &&
- not.newExchangeState.exchangeEntryStatus !==
+ not.newExchangeState?.exchangeEntryStatus !==
not.oldExchangeState?.exchangeEntryStatus && (
<Fragment>
<dt>Entry status</dt>
<dd>
from {not.oldExchangeState.exchangeEntryStatus} to{" "}
- {not.newExchangeState.exchangeEntryStatus}
+ {not.newExchangeState?.exchangeEntryStatus}
</dd>
</Fragment>
)}
{not.oldExchangeState &&
- not.newExchangeState.exchangeUpdateStatus !==
+ not.newExchangeState?.exchangeUpdateStatus !==
not.oldExchangeState?.exchangeUpdateStatus && (
<Fragment>
<dt>Update status</dt>
<dd>
from {not.oldExchangeState.exchangeUpdateStatus} to{" "}
- {not.newExchangeState.exchangeUpdateStatus}
+ {not.newExchangeState?.exchangeUpdateStatus}
</dd>
</Fragment>
)}
{not.oldExchangeState &&
- not.newExchangeState.tosStatus !== not.oldExchangeState?.tosStatus && (
+ not.newExchangeState?.tosStatus !== not.oldExchangeState?.tosStatus &&
(
<Fragment>
<dt>Tos status</dt>
<dd>
from {not.oldExchangeState.tosStatus} to{" "}
- {not.newExchangeState.tosStatus}
+ {not.newExchangeState?.tosStatus}
</dd>
</Fragment>
)}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-wallet-core] branch master updated: wallet-core: notify on exchange deletion,
gnunet <=