[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] 02/02: forget tos operation and some pretty format
From: |
gnunet |
Subject: |
[taler-wallet-core] 02/02: forget tos operation and some pretty format |
Date: |
Tue, 27 Feb 2024 16:28:49 +0100 |
This is an automated email from the git hooks/post-receive script.
sebasjm pushed a commit to branch master
in repository wallet-core.
commit ff46a080e55bff821f823256bed1bcebdcc1efe9
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Tue Feb 27 12:28:39 2024 -0300
forget tos operation and some pretty format
---
packages/taler-wallet-core/src/exchanges.ts | 32 ++++++++++++++++++++++
packages/taler-wallet-core/src/query.ts | 4 +--
packages/taler-wallet-core/src/remote.ts | 4 ++-
packages/taler-wallet-core/src/wallet-api-types.ts | 11 ++++++++
packages/taler-wallet-core/src/wallet.ts | 6 ++++
5 files changed, 53 insertions(+), 4 deletions(-)
diff --git a/packages/taler-wallet-core/src/exchanges.ts
b/packages/taler-wallet-core/src/exchanges.ts
index 65a9625c8..932df721d 100644
--- a/packages/taler-wallet-core/src/exchanges.ts
+++ b/packages/taler-wallet-core/src/exchanges.ts
@@ -411,6 +411,38 @@ export async function acceptExchangeTermsOfService(
}
}
+/**
+ * Mark the current ToS version as accepted by the user.
+ */
+export async function forgetExchangeTermsOfService(
+ ws: InternalWalletState,
+ exchangeBaseUrl: string,
+): Promise<void> {
+ const notif = await ws.db.runReadWriteTx(
+ ["exchangeDetails", "exchanges"],
+ async (tx) => {
+ const exch = await tx.exchanges.get(exchangeBaseUrl);
+ if (exch) {
+ const oldExchangeState = getExchangeState(exch);
+ exch.tosAcceptedEtag = undefined;
+ exch.tosAcceptedTimestamp = undefined;
+ 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);
+ }
+}
+
/**
* Validate wire fees and wire accounts.
*
diff --git a/packages/taler-wallet-core/src/query.ts
b/packages/taler-wallet-core/src/query.ts
index 90a3cac70..4c169946c 100644
--- a/packages/taler-wallet-core/src/query.ts
+++ b/packages/taler-wallet-core/src/query.ts
@@ -795,9 +795,7 @@ export class DbAccess<StoreMap> {
runReadWriteTx<T, StoreNameArray extends Array<StoreNames<StoreMap>>>(
storeNames: StoreNameArray,
- txf: (
- tx: DbReadWriteTransaction<StoreMap, StoreNameArray>,
- ) => Promise<T>,
+ txf: (tx: DbReadWriteTransaction<StoreMap, StoreNameArray>) => Promise<T>,
): Promise<T> {
const accessibleStores: { [x: string]: StoreWithIndexes<any, any, any> } =
{};
diff --git a/packages/taler-wallet-core/src/remote.ts
b/packages/taler-wallet-core/src/remote.ts
index 030b7a943..b81c56e0c 100644
--- a/packages/taler-wallet-core/src/remote.ts
+++ b/packages/taler-wallet-core/src/remote.ts
@@ -108,7 +108,9 @@ export async function createRemoteWallet(
}
const h = requestMap.get(id);
if (!h) {
- logger.warn(`${args.name}: no handler registered for response id
${id}`);
+ logger.warn(
+ `${args.name}: no handler registered for response id ${id}`,
+ );
return;
}
h.promiseCapability.resolve(m as any);
diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts
b/packages/taler-wallet-core/src/wallet-api-types.ts
index 1ed1eef87..9cd8e0135 100644
--- a/packages/taler-wallet-core/src/wallet-api-types.ts
+++ b/packages/taler-wallet-core/src/wallet-api-types.ts
@@ -185,6 +185,7 @@ export enum WalletApiOperation {
MarkAttentionRequestAsRead = "markAttentionRequestAsRead",
GetPendingOperations = "getPendingOperations",
SetExchangeTosAccepted = "setExchangeTosAccepted",
+ SetExchangeTosForgotten = "SetExchangeTosForgotten",
StartRefundQueryForUri = "startRefundQueryForUri",
StartRefundQuery = "startRefundQuery",
AcceptBankIntegratedWithdrawal = "acceptBankIntegratedWithdrawal",
@@ -678,6 +679,15 @@ export type SetExchangeTosAcceptedOp = {
response: EmptyObject;
};
+/**
+ * Accept a particular version of the exchange terms of service.
+ */
+export type SetExchangeTosForgottenOp = {
+ op: WalletApiOperation.SetExchangeTosForgotten;
+ request: AcceptExchangeTosRequest;
+ response: EmptyObject;
+};
+
/**
* Get the current terms of a service of an exchange.
*/
@@ -1197,6 +1207,7 @@ export type WalletOperations = {
[WalletApiOperation.AddKnownBankAccounts]: AddKnownBankAccountsOp;
[WalletApiOperation.ForgetKnownBankAccounts]: ForgetKnownBankAccountsOp;
[WalletApiOperation.SetExchangeTosAccepted]: SetExchangeTosAcceptedOp;
+ [WalletApiOperation.SetExchangeTosForgotten]: SetExchangeTosForgottenOp;
[WalletApiOperation.GetExchangeTos]: GetExchangeTosOp;
[WalletApiOperation.GetExchangeDetailedInfo]: GetExchangeDetailedInfoOp;
[WalletApiOperation.GetExchangeEntryByUrl]: GetExchangeEntryByUrlOp;
diff --git a/packages/taler-wallet-core/src/wallet.ts
b/packages/taler-wallet-core/src/wallet.ts
index 779eefe26..f21ba6ec1 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -184,6 +184,7 @@ import {
addPresetExchangeEntry,
deleteExchange,
fetchFreshExchange,
+ forgetExchangeTermsOfService,
getExchangeDetailedInfo,
getExchangeResources,
getExchangeTos,
@@ -871,6 +872,11 @@ async function dispatchRequestInternal<Op extends
WalletApiOperation>(
await acceptExchangeTermsOfService(ws, req.exchangeBaseUrl);
return {};
}
+ case WalletApiOperation.SetExchangeTosForgotten: {
+ const req = codecForAcceptExchangeTosRequest().decode(payload);
+ await forgetExchangeTermsOfService(ws, req.exchangeBaseUrl);
+ return {};
+ }
case WalletApiOperation.AcceptBankIntegratedWithdrawal: {
const req =
codecForAcceptBankIntegratedWithdrawalRequest().decode(payload);
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.