diff options
author | Sebastian <sebasjm@gmail.com> | 2024-02-27 12:28:39 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-02-27 12:28:39 -0300 |
commit | ff46a080e55bff821f823256bed1bcebdcc1efe9 (patch) | |
tree | eac428e689195bd27bef968721580c77fe345f3d /packages/taler-wallet-core/src | |
parent | a32836935be4638d5252dbaef3fea17d8e2bee6a (diff) | |
download | wallet-core-ff46a080e55bff821f823256bed1bcebdcc1efe9.tar.xz |
forget tos operation and some pretty format
Diffstat (limited to 'packages/taler-wallet-core/src')
-rw-r--r-- | packages/taler-wallet-core/src/exchanges.ts | 32 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/query.ts | 4 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/remote.ts | 4 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/wallet-api-types.ts | 11 | ||||
-rw-r--r-- | 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 @@ -412,6 +412,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. * * Throw an exception if they are invalid. 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", @@ -679,6 +680,15 @@ export type SetExchangeTosAcceptedOp = { }; /** + * 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. */ export type GetExchangeTosOp = { @@ -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); |