@metamask-previews/notification-services-controller 23.1.1-preview-a96479ea9 → 24.0.0-preview-fe92f4bb3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -10
- package/dist/NotificationServicesController/NotificationServicesController-method-action-types.cjs.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController-method-action-types.d.cts +9 -2
- package/dist/NotificationServicesController/NotificationServicesController-method-action-types.d.cts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController-method-action-types.d.mts +9 -2
- package/dist/NotificationServicesController/NotificationServicesController-method-action-types.d.mts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController-method-action-types.mjs.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.cjs +178 -42
- package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.cts +37 -7
- package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.mts +37 -7
- package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.mjs +178 -42
- package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
- package/dist/NotificationServicesController/mocks/mockResponses.cjs +1 -13
- package/dist/NotificationServicesController/mocks/mockResponses.cjs.map +1 -1
- package/dist/NotificationServicesController/mocks/mockResponses.d.cts +10 -32
- package/dist/NotificationServicesController/mocks/mockResponses.d.cts.map +1 -1
- package/dist/NotificationServicesController/mocks/mockResponses.d.mts +10 -32
- package/dist/NotificationServicesController/mocks/mockResponses.d.mts.map +1 -1
- package/dist/NotificationServicesController/mocks/mockResponses.mjs +1 -12
- package/dist/NotificationServicesController/mocks/mockResponses.mjs.map +1 -1
- package/dist/NotificationServicesController/services/api-notifications.cjs +3 -28
- package/dist/NotificationServicesController/services/api-notifications.cjs.map +1 -1
- package/dist/NotificationServicesController/services/api-notifications.d.cts +1 -20
- package/dist/NotificationServicesController/services/api-notifications.d.cts.map +1 -1
- package/dist/NotificationServicesController/services/api-notifications.d.mts +1 -20
- package/dist/NotificationServicesController/services/api-notifications.d.mts.map +1 -1
- package/dist/NotificationServicesController/services/api-notifications.mjs +2 -25
- package/dist/NotificationServicesController/services/api-notifications.mjs.map +1 -1
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,10 +7,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [24.0.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add `productAnnouncementEnabled` to `NotificationServicesControllerEnableNotificationsOptions`. ([#8784](https://github.com/MetaMask/core/pull/8784))
|
|
15
|
+
|
|
10
16
|
### Changed
|
|
11
17
|
|
|
18
|
+
- **BREAKING:** Enrich notification settings using Authenticated User Storage. ([#8784](https://github.com/MetaMask/core/pull/8784))
|
|
19
|
+
- Replace Trigger API notification settings with AUS notification preferences as the source of truth.
|
|
20
|
+
- `NotificationServicesController` now requires AUS messenger actions for notification setup.
|
|
21
|
+
- When AUS has no stored preferences, `createOnChainTriggers` writes a complete preferences blob for `walletActivity`, `marketing`, `perps`, and `socialAI`.
|
|
22
|
+
- Wallet activity accounts are seeded from the current Trigger API config when at least one current account is already enabled; otherwise all current accounts are initialized as enabled for first-time notification setup.
|
|
23
|
+
- Marketing push notifications are initialized from `hasMarketingConsent`, while marketing in-app notifications are initialized from `productAnnouncementEnabled`.
|
|
12
24
|
- Bump `@metamask/controller-utils` from `^12.0.0` to `^12.1.0` ([#8774](https://github.com/MetaMask/core/pull/8774))
|
|
13
25
|
- Bump `@metamask/profile-sync-controller` from `^28.0.2` to `^28.1.0` ([#8783](https://github.com/MetaMask/core/pull/8783))
|
|
26
|
+
- Bump `@metamask/authenticated-user-storage` from `^1.0.1` to `^2.0.0` ([#8802](https://github.com/MetaMask/core/pull/8802))
|
|
27
|
+
|
|
28
|
+
### Removed
|
|
29
|
+
|
|
30
|
+
- **BREAKING:** Remove unused `resetNotifications` option from `NotificationServicesControllerEnableNotificationsOptions`. ([#8784](https://github.com/MetaMask/core/pull/8784))
|
|
14
31
|
|
|
15
32
|
## [23.1.1]
|
|
16
33
|
|
|
@@ -295,7 +312,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
295
312
|
- Renamed method `updateOnChainTriggersByAccount` to `enableAccounts` in `NotificationServicesController`
|
|
296
313
|
- Renamed method `deleteOnChainTriggersByAccount` to `disableAccounts` in `NotificationServicesController`
|
|
297
314
|
- Deprecated `updateTriggerPushNotifications` from `NotificationServicesPushController` and will be removed in a subsequent release.
|
|
298
|
-
|
|
299
315
|
- Bump `@metamask/controller-utils` to `^11.10.0` ([#5935](https://github.com/MetaMask/core/pull/5935))
|
|
300
316
|
|
|
301
317
|
### Removed
|
|
@@ -488,8 +504,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
488
504
|
|
|
489
505
|
### Changed
|
|
490
506
|
|
|
491
|
-
- **BREAKING:** Bump `@metamask/keyring-controller` peer dependency from `^18.0.0` to `^19.0.0` ([#4195](https://github.com/MetaMask/core/pull/
|
|
492
|
-
- **BREAKING:** Bump `@metamask/profile-sync-controller` peer dependency from `^1.0.0` to `^2.0.0` ([#4195](https://github.com/MetaMask/core/pull/
|
|
507
|
+
- **BREAKING:** Bump `@metamask/keyring-controller` peer dependency from `^18.0.0` to `^19.0.0` ([#4195](https://github.com/MetaMask/core/pull/4195))
|
|
508
|
+
- **BREAKING:** Bump `@metamask/profile-sync-controller` peer dependency from `^1.0.0` to `^2.0.0` ([#4195](https://github.com/MetaMask/core/pull/4195))
|
|
493
509
|
|
|
494
510
|
## [0.13.0]
|
|
495
511
|
|
|
@@ -531,7 +547,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
531
547
|
- update the types described in `types/on-chain-notification/schema` and `types/on-chain-notification/on-chain-notification` ([#4818](https://github.com/MetaMask/core/pull/4818))
|
|
532
548
|
- adds new notifications: aave_v3_health_factor; ens_expiration; lido_staking_rewards; notional_loan_expiration; rocketpool_staking_rewards; spark_fi_health_factor
|
|
533
549
|
- splits Wallet Notifications from Web 3 Notifications
|
|
534
|
-
|
|
535
550
|
- updated and added new notification mocks ([#4818](https://github.com/MetaMask/core/pull/4818))
|
|
536
551
|
- can be accessed through `@metamask/notification-services-controller/notification-services/mocks`
|
|
537
552
|
|
|
@@ -610,7 +625,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
610
625
|
["Are the Types Wrong?"](https://arethetypeswrong.github.io/) tool as
|
|
611
626
|
["masquerading as CJS"](https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseCJS.md).
|
|
612
627
|
All of the ATTW checks now pass.
|
|
613
|
-
- Remove chunk files ([#4648](https://github.com/MetaMask/core/pull/4648))
|
|
628
|
+
- Remove chunk files. ([#4648](https://github.com/MetaMask/core/pull/4648))
|
|
614
629
|
- Previously, the build tool we used to generate JavaScript files extracted
|
|
615
630
|
common code to "chunk" files. While this was intended to make this package
|
|
616
631
|
more tree-shakeable, it also made debugging more difficult for our
|
|
@@ -703,7 +718,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
703
718
|
### Added
|
|
704
719
|
|
|
705
720
|
- added catch statements in NotificationServicesController to silently fail push notifications ([#4536](https://github.com/MetaMask/core/pull/4536))
|
|
706
|
-
|
|
707
721
|
- added checks to see feature announcement environments before fetching announcements ([#4530](https://github.com/MetaMask/core/pull/4530))
|
|
708
722
|
|
|
709
723
|
### Removed
|
|
@@ -715,11 +729,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
715
729
|
### Added
|
|
716
730
|
|
|
717
731
|
- export `defaultState` for `NotificationServicesController` and `NotificationServicesPushController`. ([#4441](https://github.com/MetaMask/core/pull/4441))
|
|
718
|
-
|
|
719
732
|
- export `NOTIFICATION_CHAINS_ID` which is a const-asserted version of `NOTIFICATION_CHAINS` ([#4441](https://github.com/MetaMask/core/pull/4441))
|
|
720
|
-
|
|
721
733
|
- export `NOTIFICATION_NETWORK_CURRENCY_NAME` and `NOTIFICATION_NETWORK_CURRENCY_SYMBOL`. Allows consistent currency names and symbols for supported notification services ([#4441](https://github.com/MetaMask/core/pull/4441))
|
|
722
|
-
|
|
723
734
|
- add `isPushIntegrated` as an optional env property in the `NotificationServicesController` constructor (defaults to true) ([#4441](https://github.com/MetaMask/core/pull/4441))
|
|
724
735
|
|
|
725
736
|
### Fixed
|
|
@@ -732,7 +743,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
732
743
|
|
|
733
744
|
- Initial release
|
|
734
745
|
|
|
735
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@
|
|
746
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@24.0.0...HEAD
|
|
747
|
+
[24.0.0]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@23.1.1...@metamask/notification-services-controller@24.0.0
|
|
736
748
|
[23.1.1]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@23.1.0...@metamask/notification-services-controller@23.1.1
|
|
737
749
|
[23.1.0]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@23.0.1...@metamask/notification-services-controller@23.1.0
|
|
738
750
|
[23.0.1]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@23.0.0...@metamask/notification-services-controller@23.0.1
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationServicesController-method-action-types.cjs","sourceRoot":"","sources":["../../src/NotificationServicesController/NotificationServicesController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { NotificationServicesController } from './NotificationServicesController';\n\nexport type NotificationServicesControllerInitAction = {\n type: `NotificationServicesController:init`;\n handler: NotificationServicesController['init'];\n};\n\n/**\n * Public method to expose enabling push notifications\n */\nexport type NotificationServicesControllerEnablePushNotificationsAction = {\n type: `NotificationServicesController:enablePushNotifications`;\n handler: NotificationServicesController['enablePushNotifications'];\n};\n\n/**\n * Public method to expose disabling push notifications\n */\nexport type NotificationServicesControllerDisablePushNotificationsAction = {\n type: `NotificationServicesController:disablePushNotifications`;\n handler: NotificationServicesController['disablePushNotifications'];\n};\n\nexport type NotificationServicesControllerCheckAccountsPresenceAction = {\n type: `NotificationServicesController:checkAccountsPresence`;\n handler: NotificationServicesController['checkAccountsPresence'];\n};\n\n/**\n * Sets the enabled state of feature announcements.\n *\n * **Action** - used in the notification settings to enable/disable feature announcements.\n *\n * @param featureAnnouncementsEnabled - A boolean value indicating the desired enabled state of the feature announcements.\n * @async\n * @throws {Error} If fails to update\n */\nexport type NotificationServicesControllerSetFeatureAnnouncementsEnabledAction =\n {\n type: `NotificationServicesController:setFeatureAnnouncementsEnabled`;\n handler: NotificationServicesController['setFeatureAnnouncementsEnabled'];\n };\n\n/**\n * This creates/re-creates on-chain triggers defined in User Storage.\n *\n * **Action** - Used during Sign In / Enabling of notifications.\n *\n * @param opts - optional options to mutate this functionality\n * @param opts.resetNotifications - this will not use the users stored preferences, and instead re-create notification triggers\n * It will help in case uses get into a corrupted state or wants to wipe their notifications.\n * @returns The updated or newly created user storage.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerCreateOnChainTriggersAction = {\n type: `NotificationServicesController:createOnChainTriggers`;\n handler: NotificationServicesController['createOnChainTriggers'];\n};\n\n/**\n * Enables all MetaMask notifications for the user.\n * This is identical flow when initializing notifications for the first time.\n *\n * @throws {Error} If there is an error during the process of enabling notifications.\n */\nexport type NotificationServicesControllerEnableMetamaskNotificationsAction = {\n type: `NotificationServicesController:enableMetamaskNotifications`;\n handler: NotificationServicesController['enableMetamaskNotifications'];\n};\n\n/**\n * Disables all MetaMask notifications for the user.\n * This method ensures that the user is authenticated, retrieves all linked accounts,\n * and disables on-chain triggers for each account. It also sets the global notification\n * settings for MetaMask, feature announcements to false.\n *\n * @throws {Error} If the user is not authenticated or if there is an error during the process.\n */\nexport type NotificationServicesControllerDisableNotificationServicesAction = {\n type: `NotificationServicesController:disableNotificationServices`;\n handler: NotificationServicesController['disableNotificationServices'];\n};\n\n/**\n * Deletes on-chain triggers associated with a specific account/s.\n * This method performs several key operations:\n * 1. Validates Auth\n * 2. Deletes accounts\n * (note) We do not need to look through push notifications as we've deleted triggers\n *\n * **Action** - When a user disables notifications for a given account in settings.\n *\n * @param accounts - The account for which on-chain triggers are to be deleted.\n * @returns A promise that resolves to void or an object containing a success message.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerDisableAccountsAction = {\n type: `NotificationServicesController:disableAccounts`;\n handler: NotificationServicesController['disableAccounts'];\n};\n\n/**\n * Updates/Creates on-chain triggers for a specific account.\n *\n * This method performs several key operations:\n * 1. Validates Auth & Storage\n * 2. Finds and creates any missing triggers associated with the account\n * 3. Enables any related push notifications\n * 4. Updates Storage to reflect new state.\n *\n * **Action** - When a user enables notifications for an account\n *\n * @param accounts - List of accounts you want to update.\n * @returns A promise that resolves to the updated user storage.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerEnableAccountsAction = {\n type: `NotificationServicesController:enableAccounts`;\n handler: NotificationServicesController['enableAccounts'];\n};\n\n/**\n * Fetches the list of metamask notifications.\n * This includes OnChain notifications; Feature Announcements; and Snap Notifications.\n *\n * **Action** - When a user views the notification list page/dropdown\n *\n * @param previewToken - the preview token to use if needed\n * @returns A promise that resolves to the list of notifications.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerFetchAndUpdateMetamaskNotificationsAction =\n {\n type: `NotificationServicesController:fetchAndUpdateMetamaskNotifications`;\n handler: NotificationServicesController['fetchAndUpdateMetamaskNotifications'];\n };\n\n/**\n * Gets the specified type of notifications from state.\n *\n * @param type - The trigger type.\n * @returns An array of notifications of the passed in type.\n * @throws Throws an error if an invalid trigger type is passed.\n */\nexport type NotificationServicesControllerGetNotificationsByTypeAction = {\n type: `NotificationServicesController:getNotificationsByType`;\n handler: NotificationServicesController['getNotificationsByType'];\n};\n\n/**\n * Used to delete a notification by id.\n *\n * Note: This function should only be used for notifications that are stored\n * in this controller directly, currently only snaps notifications.\n *\n * @param id - The id of the notification to delete.\n */\nexport type NotificationServicesControllerDeleteNotificationByIdAction = {\n type: `NotificationServicesController:deleteNotificationById`;\n handler: NotificationServicesController['deleteNotificationById'];\n};\n\n/**\n * Used to batch delete notifications by id.\n *\n * Note: This function should only be used for notifications that are stored\n * in this controller directly, currently only snaps notifications.\n *\n * @param ids - The ids of the notifications to delete.\n */\nexport type NotificationServicesControllerDeleteNotificationsByIdAction = {\n type: `NotificationServicesController:deleteNotificationsById`;\n handler: NotificationServicesController['deleteNotificationsById'];\n};\n\n/**\n * Marks specified metamask notifications as read.\n *\n * @param notifications - An array of notifications to be marked as read. Each notification should include its type and read status.\n * @returns A promise that resolves when the operation is complete.\n */\nexport type NotificationServicesControllerMarkMetamaskNotificationsAsReadAction =\n {\n type: `NotificationServicesController:markMetamaskNotificationsAsRead`;\n handler: NotificationServicesController['markMetamaskNotificationsAsRead'];\n };\n\n/**\n * Updates the list of MetaMask notifications by adding a new notification at the beginning of the list.\n * This method ensures that the most recent notification is displayed first in the UI.\n *\n * @param notification - The new notification object to be added to the list.\n * @returns A promise that resolves when the notification list has been successfully updated.\n */\nexport type NotificationServicesControllerUpdateMetamaskNotificationsListAction =\n {\n type: `NotificationServicesController:updateMetamaskNotificationsList`;\n handler: NotificationServicesController['updateMetamaskNotificationsList'];\n };\n\n/**\n * Creates an perp order notification subscription.\n * Requires notifications and auth to be enabled to start receiving this notifications\n *\n * @param input perp input\n */\nexport type NotificationServicesControllerSendPerpPlaceOrderNotificationAction =\n {\n type: `NotificationServicesController:sendPerpPlaceOrderNotification`;\n handler: NotificationServicesController['sendPerpPlaceOrderNotification'];\n };\n\n/**\n * Union of all NotificationServicesController action types.\n */\nexport type NotificationServicesControllerMethodActions =\n | NotificationServicesControllerInitAction\n | NotificationServicesControllerEnablePushNotificationsAction\n | NotificationServicesControllerDisablePushNotificationsAction\n | NotificationServicesControllerCheckAccountsPresenceAction\n | NotificationServicesControllerSetFeatureAnnouncementsEnabledAction\n | NotificationServicesControllerCreateOnChainTriggersAction\n | NotificationServicesControllerEnableMetamaskNotificationsAction\n | NotificationServicesControllerDisableNotificationServicesAction\n | NotificationServicesControllerDisableAccountsAction\n | NotificationServicesControllerEnableAccountsAction\n | NotificationServicesControllerFetchAndUpdateMetamaskNotificationsAction\n | NotificationServicesControllerGetNotificationsByTypeAction\n | NotificationServicesControllerDeleteNotificationByIdAction\n | NotificationServicesControllerDeleteNotificationsByIdAction\n | NotificationServicesControllerMarkMetamaskNotificationsAsReadAction\n | NotificationServicesControllerUpdateMetamaskNotificationsListAction\n | NotificationServicesControllerSendPerpPlaceOrderNotificationAction;\n"]}
|
|
1
|
+
{"version":3,"file":"NotificationServicesController-method-action-types.cjs","sourceRoot":"","sources":["../../src/NotificationServicesController/NotificationServicesController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { NotificationServicesController } from './NotificationServicesController';\n\nexport type NotificationServicesControllerInitAction = {\n type: `NotificationServicesController:init`;\n handler: NotificationServicesController['init'];\n};\n\n/**\n * Public method to expose enabling push notifications\n */\nexport type NotificationServicesControllerEnablePushNotificationsAction = {\n type: `NotificationServicesController:enablePushNotifications`;\n handler: NotificationServicesController['enablePushNotifications'];\n};\n\n/**\n * Public method to expose disabling push notifications\n */\nexport type NotificationServicesControllerDisablePushNotificationsAction = {\n type: `NotificationServicesController:disablePushNotifications`;\n handler: NotificationServicesController['disablePushNotifications'];\n};\n\nexport type NotificationServicesControllerCheckAccountsPresenceAction = {\n type: `NotificationServicesController:checkAccountsPresence`;\n handler: NotificationServicesController['checkAccountsPresence'];\n};\n\n/**\n * Sets the enabled state of feature announcements.\n *\n * **Action** - used in the notification settings to enable/disable feature announcements.\n *\n * @param featureAnnouncementsEnabled - A boolean value indicating the desired enabled state of the feature announcements.\n * @async\n * @throws {Error} If fails to update\n */\nexport type NotificationServicesControllerSetFeatureAnnouncementsEnabledAction =\n {\n type: `NotificationServicesController:setFeatureAnnouncementsEnabled`;\n handler: NotificationServicesController['setFeatureAnnouncementsEnabled'];\n };\n\n/**\n * This creates/re-creates on-chain triggers defined in User Storage.\n *\n * **Action** - Used during Sign In / Enabling of notifications.\n *\n * Notification preferences are initialized only when\n * {@link AuthenticatedUserStorageService} has no stored preferences yet.\n * Existing preferences are left as-is.\n *\n * @param opts - optional options to mutate this functionality\n * @param opts.hasMarketingConsent - The user's marketing-consent flag.\n * Used only during initialization to seed marketing push notifications.\n * @param opts.productAnnouncementEnabled - The user's product-announcement flag.\n * Used only during initialization to seed marketing in-app notifications.\n * @returns The updated or newly created user storage.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerCreateOnChainTriggersAction = {\n type: `NotificationServicesController:createOnChainTriggers`;\n handler: NotificationServicesController['createOnChainTriggers'];\n};\n\n/**\n * Enables all MetaMask notifications for the user.\n * This is identical flow when initializing notifications for the first time.\n *\n * @param opts - Optional settings for first-time AUS notification preferences initialization.\n * @throws {Error} If there is an error during the process of enabling notifications.\n */\nexport type NotificationServicesControllerEnableMetamaskNotificationsAction = {\n type: `NotificationServicesController:enableMetamaskNotifications`;\n handler: NotificationServicesController['enableMetamaskNotifications'];\n};\n\n/**\n * Disables all MetaMask notifications for the user.\n * This method ensures that the user is authenticated, retrieves all linked accounts,\n * and disables on-chain triggers for each account. It also sets the global notification\n * settings for MetaMask, feature announcements to false.\n *\n * @throws {Error} If the user is not authenticated or if there is an error during the process.\n */\nexport type NotificationServicesControllerDisableNotificationServicesAction = {\n type: `NotificationServicesController:disableNotificationServices`;\n handler: NotificationServicesController['disableNotificationServices'];\n};\n\n/**\n * Deletes on-chain triggers associated with a specific account/s.\n * This method performs several key operations:\n * 1. Validates Auth\n * 2. Deletes accounts\n * (note) We do not need to look through push notifications as we've deleted triggers\n *\n * **Action** - When a user disables notifications for a given account in settings.\n *\n * @param accounts - The account for which on-chain triggers are to be deleted.\n * @returns A promise that resolves to void or an object containing a success message.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerDisableAccountsAction = {\n type: `NotificationServicesController:disableAccounts`;\n handler: NotificationServicesController['disableAccounts'];\n};\n\n/**\n * Updates/Creates on-chain triggers for a specific account.\n *\n * This method performs several key operations:\n * 1. Validates Auth & Storage\n * 2. Finds and creates any missing triggers associated with the account\n * 3. Enables any related push notifications\n * 4. Updates Storage to reflect new state.\n *\n * **Action** - When a user enables notifications for an account\n *\n * @param accounts - List of accounts you want to update.\n * @returns A promise that resolves to the updated user storage.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerEnableAccountsAction = {\n type: `NotificationServicesController:enableAccounts`;\n handler: NotificationServicesController['enableAccounts'];\n};\n\n/**\n * Fetches the list of metamask notifications.\n * This includes OnChain notifications; Feature Announcements; and Snap Notifications.\n *\n * **Action** - When a user views the notification list page/dropdown\n *\n * @param previewToken - the preview token to use if needed\n * @returns A promise that resolves to the list of notifications.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerFetchAndUpdateMetamaskNotificationsAction =\n {\n type: `NotificationServicesController:fetchAndUpdateMetamaskNotifications`;\n handler: NotificationServicesController['fetchAndUpdateMetamaskNotifications'];\n };\n\n/**\n * Gets the specified type of notifications from state.\n *\n * @param type - The trigger type.\n * @returns An array of notifications of the passed in type.\n * @throws Throws an error if an invalid trigger type is passed.\n */\nexport type NotificationServicesControllerGetNotificationsByTypeAction = {\n type: `NotificationServicesController:getNotificationsByType`;\n handler: NotificationServicesController['getNotificationsByType'];\n};\n\n/**\n * Used to delete a notification by id.\n *\n * Note: This function should only be used for notifications that are stored\n * in this controller directly, currently only snaps notifications.\n *\n * @param id - The id of the notification to delete.\n */\nexport type NotificationServicesControllerDeleteNotificationByIdAction = {\n type: `NotificationServicesController:deleteNotificationById`;\n handler: NotificationServicesController['deleteNotificationById'];\n};\n\n/**\n * Used to batch delete notifications by id.\n *\n * Note: This function should only be used for notifications that are stored\n * in this controller directly, currently only snaps notifications.\n *\n * @param ids - The ids of the notifications to delete.\n */\nexport type NotificationServicesControllerDeleteNotificationsByIdAction = {\n type: `NotificationServicesController:deleteNotificationsById`;\n handler: NotificationServicesController['deleteNotificationsById'];\n};\n\n/**\n * Marks specified metamask notifications as read.\n *\n * @param notifications - An array of notifications to be marked as read. Each notification should include its type and read status.\n * @returns A promise that resolves when the operation is complete.\n */\nexport type NotificationServicesControllerMarkMetamaskNotificationsAsReadAction =\n {\n type: `NotificationServicesController:markMetamaskNotificationsAsRead`;\n handler: NotificationServicesController['markMetamaskNotificationsAsRead'];\n };\n\n/**\n * Updates the list of MetaMask notifications by adding a new notification at the beginning of the list.\n * This method ensures that the most recent notification is displayed first in the UI.\n *\n * @param notification - The new notification object to be added to the list.\n * @returns A promise that resolves when the notification list has been successfully updated.\n */\nexport type NotificationServicesControllerUpdateMetamaskNotificationsListAction =\n {\n type: `NotificationServicesController:updateMetamaskNotificationsList`;\n handler: NotificationServicesController['updateMetamaskNotificationsList'];\n };\n\n/**\n * Creates an perp order notification subscription.\n * Requires notifications and auth to be enabled to start receiving this notifications\n *\n * @param input perp input\n */\nexport type NotificationServicesControllerSendPerpPlaceOrderNotificationAction =\n {\n type: `NotificationServicesController:sendPerpPlaceOrderNotification`;\n handler: NotificationServicesController['sendPerpPlaceOrderNotification'];\n };\n\n/**\n * Union of all NotificationServicesController action types.\n */\nexport type NotificationServicesControllerMethodActions =\n | NotificationServicesControllerInitAction\n | NotificationServicesControllerEnablePushNotificationsAction\n | NotificationServicesControllerDisablePushNotificationsAction\n | NotificationServicesControllerCheckAccountsPresenceAction\n | NotificationServicesControllerSetFeatureAnnouncementsEnabledAction\n | NotificationServicesControllerCreateOnChainTriggersAction\n | NotificationServicesControllerEnableMetamaskNotificationsAction\n | NotificationServicesControllerDisableNotificationServicesAction\n | NotificationServicesControllerDisableAccountsAction\n | NotificationServicesControllerEnableAccountsAction\n | NotificationServicesControllerFetchAndUpdateMetamaskNotificationsAction\n | NotificationServicesControllerGetNotificationsByTypeAction\n | NotificationServicesControllerDeleteNotificationByIdAction\n | NotificationServicesControllerDeleteNotificationsByIdAction\n | NotificationServicesControllerMarkMetamaskNotificationsAsReadAction\n | NotificationServicesControllerUpdateMetamaskNotificationsListAction\n | NotificationServicesControllerSendPerpPlaceOrderNotificationAction;\n"]}
|
package/dist/NotificationServicesController/NotificationServicesController-method-action-types.d.cts
CHANGED
|
@@ -43,9 +43,15 @@ export type NotificationServicesControllerSetFeatureAnnouncementsEnabledAction =
|
|
|
43
43
|
*
|
|
44
44
|
* **Action** - Used during Sign In / Enabling of notifications.
|
|
45
45
|
*
|
|
46
|
+
* Notification preferences are initialized only when
|
|
47
|
+
* {@link AuthenticatedUserStorageService} has no stored preferences yet.
|
|
48
|
+
* Existing preferences are left as-is.
|
|
49
|
+
*
|
|
46
50
|
* @param opts - optional options to mutate this functionality
|
|
47
|
-
* @param opts.
|
|
48
|
-
*
|
|
51
|
+
* @param opts.hasMarketingConsent - The user's marketing-consent flag.
|
|
52
|
+
* Used only during initialization to seed marketing push notifications.
|
|
53
|
+
* @param opts.productAnnouncementEnabled - The user's product-announcement flag.
|
|
54
|
+
* Used only during initialization to seed marketing in-app notifications.
|
|
49
55
|
* @returns The updated or newly created user storage.
|
|
50
56
|
* @throws {Error} Throws an error if unauthenticated or from other operations.
|
|
51
57
|
*/
|
|
@@ -57,6 +63,7 @@ export type NotificationServicesControllerCreateOnChainTriggersAction = {
|
|
|
57
63
|
* Enables all MetaMask notifications for the user.
|
|
58
64
|
* This is identical flow when initializing notifications for the first time.
|
|
59
65
|
*
|
|
66
|
+
* @param opts - Optional settings for first-time AUS notification preferences initialization.
|
|
60
67
|
* @throws {Error} If there is an error during the process of enabling notifications.
|
|
61
68
|
*/
|
|
62
69
|
export type NotificationServicesControllerEnableMetamaskNotificationsAction = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationServicesController-method-action-types.d.cts","sourceRoot":"","sources":["../../src/NotificationServicesController/NotificationServicesController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,8BAA8B,EAAE,6CAAyC;AAEvF,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,8BAA8B,CAAC,MAAM,CAAC,CAAC;CACjD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,2DAA2D,GAAG;IACxE,IAAI,EAAE,wDAAwD,CAAC;IAC/D,OAAO,EAAE,8BAA8B,CAAC,yBAAyB,CAAC,CAAC;CACpE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4DAA4D,GAAG;IACzE,IAAI,EAAE,yDAAyD,CAAC;IAChE,OAAO,EAAE,8BAA8B,CAAC,0BAA0B,CAAC,CAAC;CACrE,CAAC;AAEF,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,sDAAsD,CAAC;IAC7D,OAAO,EAAE,8BAA8B,CAAC,uBAAuB,CAAC,CAAC;CAClE,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,kEAAkE,GAC5E;IACE,IAAI,EAAE,+DAA+D,CAAC;IACtE,OAAO,EAAE,8BAA8B,CAAC,gCAAgC,CAAC,CAAC;CAC3E,CAAC;AAEJ
|
|
1
|
+
{"version":3,"file":"NotificationServicesController-method-action-types.d.cts","sourceRoot":"","sources":["../../src/NotificationServicesController/NotificationServicesController-method-action-types.ts"],"names":[],"mappings":"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"}
|
package/dist/NotificationServicesController/NotificationServicesController-method-action-types.d.mts
CHANGED
|
@@ -43,9 +43,15 @@ export type NotificationServicesControllerSetFeatureAnnouncementsEnabledAction =
|
|
|
43
43
|
*
|
|
44
44
|
* **Action** - Used during Sign In / Enabling of notifications.
|
|
45
45
|
*
|
|
46
|
+
* Notification preferences are initialized only when
|
|
47
|
+
* {@link AuthenticatedUserStorageService} has no stored preferences yet.
|
|
48
|
+
* Existing preferences are left as-is.
|
|
49
|
+
*
|
|
46
50
|
* @param opts - optional options to mutate this functionality
|
|
47
|
-
* @param opts.
|
|
48
|
-
*
|
|
51
|
+
* @param opts.hasMarketingConsent - The user's marketing-consent flag.
|
|
52
|
+
* Used only during initialization to seed marketing push notifications.
|
|
53
|
+
* @param opts.productAnnouncementEnabled - The user's product-announcement flag.
|
|
54
|
+
* Used only during initialization to seed marketing in-app notifications.
|
|
49
55
|
* @returns The updated or newly created user storage.
|
|
50
56
|
* @throws {Error} Throws an error if unauthenticated or from other operations.
|
|
51
57
|
*/
|
|
@@ -57,6 +63,7 @@ export type NotificationServicesControllerCreateOnChainTriggersAction = {
|
|
|
57
63
|
* Enables all MetaMask notifications for the user.
|
|
58
64
|
* This is identical flow when initializing notifications for the first time.
|
|
59
65
|
*
|
|
66
|
+
* @param opts - Optional settings for first-time AUS notification preferences initialization.
|
|
60
67
|
* @throws {Error} If there is an error during the process of enabling notifications.
|
|
61
68
|
*/
|
|
62
69
|
export type NotificationServicesControllerEnableMetamaskNotificationsAction = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationServicesController-method-action-types.d.mts","sourceRoot":"","sources":["../../src/NotificationServicesController/NotificationServicesController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,8BAA8B,EAAE,6CAAyC;AAEvF,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,8BAA8B,CAAC,MAAM,CAAC,CAAC;CACjD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,2DAA2D,GAAG;IACxE,IAAI,EAAE,wDAAwD,CAAC;IAC/D,OAAO,EAAE,8BAA8B,CAAC,yBAAyB,CAAC,CAAC;CACpE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,4DAA4D,GAAG;IACzE,IAAI,EAAE,yDAAyD,CAAC;IAChE,OAAO,EAAE,8BAA8B,CAAC,0BAA0B,CAAC,CAAC;CACrE,CAAC;AAEF,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,sDAAsD,CAAC;IAC7D,OAAO,EAAE,8BAA8B,CAAC,uBAAuB,CAAC,CAAC;CAClE,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,kEAAkE,GAC5E;IACE,IAAI,EAAE,+DAA+D,CAAC;IACtE,OAAO,EAAE,8BAA8B,CAAC,gCAAgC,CAAC,CAAC;CAC3E,CAAC;AAEJ
|
|
1
|
+
{"version":3,"file":"NotificationServicesController-method-action-types.d.mts","sourceRoot":"","sources":["../../src/NotificationServicesController/NotificationServicesController-method-action-types.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationServicesController-method-action-types.mjs","sourceRoot":"","sources":["../../src/NotificationServicesController/NotificationServicesController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { NotificationServicesController } from './NotificationServicesController';\n\nexport type NotificationServicesControllerInitAction = {\n type: `NotificationServicesController:init`;\n handler: NotificationServicesController['init'];\n};\n\n/**\n * Public method to expose enabling push notifications\n */\nexport type NotificationServicesControllerEnablePushNotificationsAction = {\n type: `NotificationServicesController:enablePushNotifications`;\n handler: NotificationServicesController['enablePushNotifications'];\n};\n\n/**\n * Public method to expose disabling push notifications\n */\nexport type NotificationServicesControllerDisablePushNotificationsAction = {\n type: `NotificationServicesController:disablePushNotifications`;\n handler: NotificationServicesController['disablePushNotifications'];\n};\n\nexport type NotificationServicesControllerCheckAccountsPresenceAction = {\n type: `NotificationServicesController:checkAccountsPresence`;\n handler: NotificationServicesController['checkAccountsPresence'];\n};\n\n/**\n * Sets the enabled state of feature announcements.\n *\n * **Action** - used in the notification settings to enable/disable feature announcements.\n *\n * @param featureAnnouncementsEnabled - A boolean value indicating the desired enabled state of the feature announcements.\n * @async\n * @throws {Error} If fails to update\n */\nexport type NotificationServicesControllerSetFeatureAnnouncementsEnabledAction =\n {\n type: `NotificationServicesController:setFeatureAnnouncementsEnabled`;\n handler: NotificationServicesController['setFeatureAnnouncementsEnabled'];\n };\n\n/**\n * This creates/re-creates on-chain triggers defined in User Storage.\n *\n * **Action** - Used during Sign In / Enabling of notifications.\n *\n * @param opts - optional options to mutate this functionality\n * @param opts.resetNotifications - this will not use the users stored preferences, and instead re-create notification triggers\n * It will help in case uses get into a corrupted state or wants to wipe their notifications.\n * @returns The updated or newly created user storage.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerCreateOnChainTriggersAction = {\n type: `NotificationServicesController:createOnChainTriggers`;\n handler: NotificationServicesController['createOnChainTriggers'];\n};\n\n/**\n * Enables all MetaMask notifications for the user.\n * This is identical flow when initializing notifications for the first time.\n *\n * @throws {Error} If there is an error during the process of enabling notifications.\n */\nexport type NotificationServicesControllerEnableMetamaskNotificationsAction = {\n type: `NotificationServicesController:enableMetamaskNotifications`;\n handler: NotificationServicesController['enableMetamaskNotifications'];\n};\n\n/**\n * Disables all MetaMask notifications for the user.\n * This method ensures that the user is authenticated, retrieves all linked accounts,\n * and disables on-chain triggers for each account. It also sets the global notification\n * settings for MetaMask, feature announcements to false.\n *\n * @throws {Error} If the user is not authenticated or if there is an error during the process.\n */\nexport type NotificationServicesControllerDisableNotificationServicesAction = {\n type: `NotificationServicesController:disableNotificationServices`;\n handler: NotificationServicesController['disableNotificationServices'];\n};\n\n/**\n * Deletes on-chain triggers associated with a specific account/s.\n * This method performs several key operations:\n * 1. Validates Auth\n * 2. Deletes accounts\n * (note) We do not need to look through push notifications as we've deleted triggers\n *\n * **Action** - When a user disables notifications for a given account in settings.\n *\n * @param accounts - The account for which on-chain triggers are to be deleted.\n * @returns A promise that resolves to void or an object containing a success message.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerDisableAccountsAction = {\n type: `NotificationServicesController:disableAccounts`;\n handler: NotificationServicesController['disableAccounts'];\n};\n\n/**\n * Updates/Creates on-chain triggers for a specific account.\n *\n * This method performs several key operations:\n * 1. Validates Auth & Storage\n * 2. Finds and creates any missing triggers associated with the account\n * 3. Enables any related push notifications\n * 4. Updates Storage to reflect new state.\n *\n * **Action** - When a user enables notifications for an account\n *\n * @param accounts - List of accounts you want to update.\n * @returns A promise that resolves to the updated user storage.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerEnableAccountsAction = {\n type: `NotificationServicesController:enableAccounts`;\n handler: NotificationServicesController['enableAccounts'];\n};\n\n/**\n * Fetches the list of metamask notifications.\n * This includes OnChain notifications; Feature Announcements; and Snap Notifications.\n *\n * **Action** - When a user views the notification list page/dropdown\n *\n * @param previewToken - the preview token to use if needed\n * @returns A promise that resolves to the list of notifications.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerFetchAndUpdateMetamaskNotificationsAction =\n {\n type: `NotificationServicesController:fetchAndUpdateMetamaskNotifications`;\n handler: NotificationServicesController['fetchAndUpdateMetamaskNotifications'];\n };\n\n/**\n * Gets the specified type of notifications from state.\n *\n * @param type - The trigger type.\n * @returns An array of notifications of the passed in type.\n * @throws Throws an error if an invalid trigger type is passed.\n */\nexport type NotificationServicesControllerGetNotificationsByTypeAction = {\n type: `NotificationServicesController:getNotificationsByType`;\n handler: NotificationServicesController['getNotificationsByType'];\n};\n\n/**\n * Used to delete a notification by id.\n *\n * Note: This function should only be used for notifications that are stored\n * in this controller directly, currently only snaps notifications.\n *\n * @param id - The id of the notification to delete.\n */\nexport type NotificationServicesControllerDeleteNotificationByIdAction = {\n type: `NotificationServicesController:deleteNotificationById`;\n handler: NotificationServicesController['deleteNotificationById'];\n};\n\n/**\n * Used to batch delete notifications by id.\n *\n * Note: This function should only be used for notifications that are stored\n * in this controller directly, currently only snaps notifications.\n *\n * @param ids - The ids of the notifications to delete.\n */\nexport type NotificationServicesControllerDeleteNotificationsByIdAction = {\n type: `NotificationServicesController:deleteNotificationsById`;\n handler: NotificationServicesController['deleteNotificationsById'];\n};\n\n/**\n * Marks specified metamask notifications as read.\n *\n * @param notifications - An array of notifications to be marked as read. Each notification should include its type and read status.\n * @returns A promise that resolves when the operation is complete.\n */\nexport type NotificationServicesControllerMarkMetamaskNotificationsAsReadAction =\n {\n type: `NotificationServicesController:markMetamaskNotificationsAsRead`;\n handler: NotificationServicesController['markMetamaskNotificationsAsRead'];\n };\n\n/**\n * Updates the list of MetaMask notifications by adding a new notification at the beginning of the list.\n * This method ensures that the most recent notification is displayed first in the UI.\n *\n * @param notification - The new notification object to be added to the list.\n * @returns A promise that resolves when the notification list has been successfully updated.\n */\nexport type NotificationServicesControllerUpdateMetamaskNotificationsListAction =\n {\n type: `NotificationServicesController:updateMetamaskNotificationsList`;\n handler: NotificationServicesController['updateMetamaskNotificationsList'];\n };\n\n/**\n * Creates an perp order notification subscription.\n * Requires notifications and auth to be enabled to start receiving this notifications\n *\n * @param input perp input\n */\nexport type NotificationServicesControllerSendPerpPlaceOrderNotificationAction =\n {\n type: `NotificationServicesController:sendPerpPlaceOrderNotification`;\n handler: NotificationServicesController['sendPerpPlaceOrderNotification'];\n };\n\n/**\n * Union of all NotificationServicesController action types.\n */\nexport type NotificationServicesControllerMethodActions =\n | NotificationServicesControllerInitAction\n | NotificationServicesControllerEnablePushNotificationsAction\n | NotificationServicesControllerDisablePushNotificationsAction\n | NotificationServicesControllerCheckAccountsPresenceAction\n | NotificationServicesControllerSetFeatureAnnouncementsEnabledAction\n | NotificationServicesControllerCreateOnChainTriggersAction\n | NotificationServicesControllerEnableMetamaskNotificationsAction\n | NotificationServicesControllerDisableNotificationServicesAction\n | NotificationServicesControllerDisableAccountsAction\n | NotificationServicesControllerEnableAccountsAction\n | NotificationServicesControllerFetchAndUpdateMetamaskNotificationsAction\n | NotificationServicesControllerGetNotificationsByTypeAction\n | NotificationServicesControllerDeleteNotificationByIdAction\n | NotificationServicesControllerDeleteNotificationsByIdAction\n | NotificationServicesControllerMarkMetamaskNotificationsAsReadAction\n | NotificationServicesControllerUpdateMetamaskNotificationsListAction\n | NotificationServicesControllerSendPerpPlaceOrderNotificationAction;\n"]}
|
|
1
|
+
{"version":3,"file":"NotificationServicesController-method-action-types.mjs","sourceRoot":"","sources":["../../src/NotificationServicesController/NotificationServicesController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { NotificationServicesController } from './NotificationServicesController';\n\nexport type NotificationServicesControllerInitAction = {\n type: `NotificationServicesController:init`;\n handler: NotificationServicesController['init'];\n};\n\n/**\n * Public method to expose enabling push notifications\n */\nexport type NotificationServicesControllerEnablePushNotificationsAction = {\n type: `NotificationServicesController:enablePushNotifications`;\n handler: NotificationServicesController['enablePushNotifications'];\n};\n\n/**\n * Public method to expose disabling push notifications\n */\nexport type NotificationServicesControllerDisablePushNotificationsAction = {\n type: `NotificationServicesController:disablePushNotifications`;\n handler: NotificationServicesController['disablePushNotifications'];\n};\n\nexport type NotificationServicesControllerCheckAccountsPresenceAction = {\n type: `NotificationServicesController:checkAccountsPresence`;\n handler: NotificationServicesController['checkAccountsPresence'];\n};\n\n/**\n * Sets the enabled state of feature announcements.\n *\n * **Action** - used in the notification settings to enable/disable feature announcements.\n *\n * @param featureAnnouncementsEnabled - A boolean value indicating the desired enabled state of the feature announcements.\n * @async\n * @throws {Error} If fails to update\n */\nexport type NotificationServicesControllerSetFeatureAnnouncementsEnabledAction =\n {\n type: `NotificationServicesController:setFeatureAnnouncementsEnabled`;\n handler: NotificationServicesController['setFeatureAnnouncementsEnabled'];\n };\n\n/**\n * This creates/re-creates on-chain triggers defined in User Storage.\n *\n * **Action** - Used during Sign In / Enabling of notifications.\n *\n * Notification preferences are initialized only when\n * {@link AuthenticatedUserStorageService} has no stored preferences yet.\n * Existing preferences are left as-is.\n *\n * @param opts - optional options to mutate this functionality\n * @param opts.hasMarketingConsent - The user's marketing-consent flag.\n * Used only during initialization to seed marketing push notifications.\n * @param opts.productAnnouncementEnabled - The user's product-announcement flag.\n * Used only during initialization to seed marketing in-app notifications.\n * @returns The updated or newly created user storage.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerCreateOnChainTriggersAction = {\n type: `NotificationServicesController:createOnChainTriggers`;\n handler: NotificationServicesController['createOnChainTriggers'];\n};\n\n/**\n * Enables all MetaMask notifications for the user.\n * This is identical flow when initializing notifications for the first time.\n *\n * @param opts - Optional settings for first-time AUS notification preferences initialization.\n * @throws {Error} If there is an error during the process of enabling notifications.\n */\nexport type NotificationServicesControllerEnableMetamaskNotificationsAction = {\n type: `NotificationServicesController:enableMetamaskNotifications`;\n handler: NotificationServicesController['enableMetamaskNotifications'];\n};\n\n/**\n * Disables all MetaMask notifications for the user.\n * This method ensures that the user is authenticated, retrieves all linked accounts,\n * and disables on-chain triggers for each account. It also sets the global notification\n * settings for MetaMask, feature announcements to false.\n *\n * @throws {Error} If the user is not authenticated or if there is an error during the process.\n */\nexport type NotificationServicesControllerDisableNotificationServicesAction = {\n type: `NotificationServicesController:disableNotificationServices`;\n handler: NotificationServicesController['disableNotificationServices'];\n};\n\n/**\n * Deletes on-chain triggers associated with a specific account/s.\n * This method performs several key operations:\n * 1. Validates Auth\n * 2. Deletes accounts\n * (note) We do not need to look through push notifications as we've deleted triggers\n *\n * **Action** - When a user disables notifications for a given account in settings.\n *\n * @param accounts - The account for which on-chain triggers are to be deleted.\n * @returns A promise that resolves to void or an object containing a success message.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerDisableAccountsAction = {\n type: `NotificationServicesController:disableAccounts`;\n handler: NotificationServicesController['disableAccounts'];\n};\n\n/**\n * Updates/Creates on-chain triggers for a specific account.\n *\n * This method performs several key operations:\n * 1. Validates Auth & Storage\n * 2. Finds and creates any missing triggers associated with the account\n * 3. Enables any related push notifications\n * 4. Updates Storage to reflect new state.\n *\n * **Action** - When a user enables notifications for an account\n *\n * @param accounts - List of accounts you want to update.\n * @returns A promise that resolves to the updated user storage.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerEnableAccountsAction = {\n type: `NotificationServicesController:enableAccounts`;\n handler: NotificationServicesController['enableAccounts'];\n};\n\n/**\n * Fetches the list of metamask notifications.\n * This includes OnChain notifications; Feature Announcements; and Snap Notifications.\n *\n * **Action** - When a user views the notification list page/dropdown\n *\n * @param previewToken - the preview token to use if needed\n * @returns A promise that resolves to the list of notifications.\n * @throws {Error} Throws an error if unauthenticated or from other operations.\n */\nexport type NotificationServicesControllerFetchAndUpdateMetamaskNotificationsAction =\n {\n type: `NotificationServicesController:fetchAndUpdateMetamaskNotifications`;\n handler: NotificationServicesController['fetchAndUpdateMetamaskNotifications'];\n };\n\n/**\n * Gets the specified type of notifications from state.\n *\n * @param type - The trigger type.\n * @returns An array of notifications of the passed in type.\n * @throws Throws an error if an invalid trigger type is passed.\n */\nexport type NotificationServicesControllerGetNotificationsByTypeAction = {\n type: `NotificationServicesController:getNotificationsByType`;\n handler: NotificationServicesController['getNotificationsByType'];\n};\n\n/**\n * Used to delete a notification by id.\n *\n * Note: This function should only be used for notifications that are stored\n * in this controller directly, currently only snaps notifications.\n *\n * @param id - The id of the notification to delete.\n */\nexport type NotificationServicesControllerDeleteNotificationByIdAction = {\n type: `NotificationServicesController:deleteNotificationById`;\n handler: NotificationServicesController['deleteNotificationById'];\n};\n\n/**\n * Used to batch delete notifications by id.\n *\n * Note: This function should only be used for notifications that are stored\n * in this controller directly, currently only snaps notifications.\n *\n * @param ids - The ids of the notifications to delete.\n */\nexport type NotificationServicesControllerDeleteNotificationsByIdAction = {\n type: `NotificationServicesController:deleteNotificationsById`;\n handler: NotificationServicesController['deleteNotificationsById'];\n};\n\n/**\n * Marks specified metamask notifications as read.\n *\n * @param notifications - An array of notifications to be marked as read. Each notification should include its type and read status.\n * @returns A promise that resolves when the operation is complete.\n */\nexport type NotificationServicesControllerMarkMetamaskNotificationsAsReadAction =\n {\n type: `NotificationServicesController:markMetamaskNotificationsAsRead`;\n handler: NotificationServicesController['markMetamaskNotificationsAsRead'];\n };\n\n/**\n * Updates the list of MetaMask notifications by adding a new notification at the beginning of the list.\n * This method ensures that the most recent notification is displayed first in the UI.\n *\n * @param notification - The new notification object to be added to the list.\n * @returns A promise that resolves when the notification list has been successfully updated.\n */\nexport type NotificationServicesControllerUpdateMetamaskNotificationsListAction =\n {\n type: `NotificationServicesController:updateMetamaskNotificationsList`;\n handler: NotificationServicesController['updateMetamaskNotificationsList'];\n };\n\n/**\n * Creates an perp order notification subscription.\n * Requires notifications and auth to be enabled to start receiving this notifications\n *\n * @param input perp input\n */\nexport type NotificationServicesControllerSendPerpPlaceOrderNotificationAction =\n {\n type: `NotificationServicesController:sendPerpPlaceOrderNotification`;\n handler: NotificationServicesController['sendPerpPlaceOrderNotification'];\n };\n\n/**\n * Union of all NotificationServicesController action types.\n */\nexport type NotificationServicesControllerMethodActions =\n | NotificationServicesControllerInitAction\n | NotificationServicesControllerEnablePushNotificationsAction\n | NotificationServicesControllerDisablePushNotificationsAction\n | NotificationServicesControllerCheckAccountsPresenceAction\n | NotificationServicesControllerSetFeatureAnnouncementsEnabledAction\n | NotificationServicesControllerCreateOnChainTriggersAction\n | NotificationServicesControllerEnableMetamaskNotificationsAction\n | NotificationServicesControllerDisableNotificationServicesAction\n | NotificationServicesControllerDisableAccountsAction\n | NotificationServicesControllerEnableAccountsAction\n | NotificationServicesControllerFetchAndUpdateMetamaskNotificationsAction\n | NotificationServicesControllerGetNotificationsByTypeAction\n | NotificationServicesControllerDeleteNotificationByIdAction\n | NotificationServicesControllerDeleteNotificationsByIdAction\n | NotificationServicesControllerMarkMetamaskNotificationsAsReadAction\n | NotificationServicesControllerUpdateMetamaskNotificationsListAction\n | NotificationServicesControllerSendPerpPlaceOrderNotificationAction;\n"]}
|
|
@@ -13,9 +13,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
|
-
var _NotificationServicesController_instances, _NotificationServicesController_keyringController, _NotificationServicesController_auth, _NotificationServicesController_pushNotifications, _NotificationServicesController_accounts, _NotificationServicesController_locale, _NotificationServicesController_featureAnnouncementEnv, _NotificationServicesController_env, _NotificationServicesController_clearLoadingStates, _NotificationServicesController_assertAuthEnabled, _NotificationServicesController_enableAuth, _NotificationServicesController_getBearerToken, _NotificationServicesController_setIsUpdatingMetamaskNotifications, _NotificationServicesController_setIsFetchingMetamaskNotifications, _NotificationServicesController_setIsCheckingAccountsPresence, _NotificationServicesController_updateUpdatingAccountsState, _NotificationServicesController_clearUpdatingAccountsState;
|
|
16
|
+
var _NotificationServicesController_instances, _NotificationServicesController_keyringController, _NotificationServicesController_auth, _NotificationServicesController_pushNotifications, _NotificationServicesController_accounts, _NotificationServicesController_locale, _NotificationServicesController_featureAnnouncementEnv, _NotificationServicesController_env, _NotificationServicesController_clearLoadingStates, _NotificationServicesController_assertAuthEnabled, _NotificationServicesController_enableAuth, _NotificationServicesController_getBearerToken, _NotificationServicesController_registerWalletActivityAddresses, _NotificationServicesController_setIsUpdatingMetamaskNotifications, _NotificationServicesController_setIsFetchingMetamaskNotifications, _NotificationServicesController_setIsCheckingAccountsPresence, _NotificationServicesController_updateUpdatingAccountsState, _NotificationServicesController_clearUpdatingAccountsState;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.NotificationServicesController = exports.defaultState = exports.ACCOUNTS_UPDATE_DEBOUNCE_TIME_MS = void 0;
|
|
18
|
+
exports.NotificationServicesController = exports.DEFAULT_SOCIAL_AI_PREFERENCES = exports.DEFAULT_PERPS_PREFERENCES = exports.defaultState = exports.ACCOUNTS_UPDATE_DEBOUNCE_TIME_MS = void 0;
|
|
19
19
|
const base_controller_1 = require("@metamask/base-controller");
|
|
20
20
|
const controller_utils_1 = require("@metamask/controller-utils");
|
|
21
21
|
const utils_1 = require("@metamask/utils");
|
|
@@ -106,6 +106,84 @@ exports.defaultState = {
|
|
|
106
106
|
const locallyPersistedNotificationTypes = new Set([
|
|
107
107
|
notification_schema_1.TRIGGER_TYPES.SNAP,
|
|
108
108
|
]);
|
|
109
|
+
/**
|
|
110
|
+
* Hardcoded default Perps notification preferences. Applied when notification
|
|
111
|
+
* preferences are initialized for the first time.
|
|
112
|
+
*/
|
|
113
|
+
exports.DEFAULT_PERPS_PREFERENCES = {
|
|
114
|
+
inAppNotificationsEnabled: true,
|
|
115
|
+
pushNotificationsEnabled: true,
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Hardcoded default Social AI notification preferences. Applied when
|
|
119
|
+
* notification preferences are initialized for the first time.
|
|
120
|
+
*/
|
|
121
|
+
exports.DEFAULT_SOCIAL_AI_PREFERENCES = {
|
|
122
|
+
inAppNotificationsEnabled: true,
|
|
123
|
+
pushNotificationsEnabled: true,
|
|
124
|
+
txAmountLimit: 500,
|
|
125
|
+
mutedTraderProfileIds: [],
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Builds wallet-activity preferences from the keyring's current accounts.
|
|
129
|
+
*
|
|
130
|
+
* @param accounts - The keyring accounts to build wallet-activity entries for.
|
|
131
|
+
* @returns An array of wallet-activity account entries (lower-cased addresses).
|
|
132
|
+
*/
|
|
133
|
+
const buildWalletActivityAccounts = (accounts) => accounts.map(({ address, enabled }) => {
|
|
134
|
+
const lowercased = address.toLowerCase();
|
|
135
|
+
return {
|
|
136
|
+
address: lowercased,
|
|
137
|
+
enabled,
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
/**
|
|
141
|
+
* Builds wallet-activity initialization from the Trigger API. If Trigger has no
|
|
142
|
+
* enabled entries for the current keyring accounts, this is a first-time
|
|
143
|
+
* notification setup and all current accounts should start enabled.
|
|
144
|
+
*
|
|
145
|
+
* @param bearerToken - JWT used to query Trigger API.
|
|
146
|
+
* @param accounts - The keyring accounts to initialize.
|
|
147
|
+
* @param env - The environment to use for the Trigger API call.
|
|
148
|
+
* @returns Wallet-activity account initialization entries.
|
|
149
|
+
*/
|
|
150
|
+
const buildWalletActivityAccountsFromTriggerConfig = async (bearerToken, accounts, env) => {
|
|
151
|
+
const triggerConfig = await (0, api_notifications_1.getNotificationsApiConfigCached)(bearerToken, accounts, env);
|
|
152
|
+
const triggerConfigByAddress = new Map(triggerConfig.map(({ address, enabled }) => [
|
|
153
|
+
address.toLowerCase(),
|
|
154
|
+
enabled,
|
|
155
|
+
]));
|
|
156
|
+
const hasEnabledTriggerAccount = accounts.some((address) => triggerConfigByAddress.get(address.toLowerCase()) === true);
|
|
157
|
+
return accounts.map((address) => ({
|
|
158
|
+
address,
|
|
159
|
+
enabled: hasEnabledTriggerAccount
|
|
160
|
+
? (triggerConfigByAddress.get(address.toLowerCase()) ?? false)
|
|
161
|
+
: true,
|
|
162
|
+
}));
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Builds a fresh `NotificationPreferences` blob using hardcoded defaults for
|
|
166
|
+
* Perps and Social AI, the supplied wallet-activity accounts and the user's
|
|
167
|
+
* marketing/product-announcement flags.
|
|
168
|
+
*
|
|
169
|
+
* @param walletActivityAccounts - The wallet-activity account config to initialize.
|
|
170
|
+
* @param hasMarketingConsent - Whether marketing push notifications should be enabled.
|
|
171
|
+
* @param productAnnouncementEnabled - Whether marketing in-app notifications should be enabled.
|
|
172
|
+
* @returns A complete `NotificationPreferences` object.
|
|
173
|
+
*/
|
|
174
|
+
const buildFreshPreferences = (walletActivityAccounts, hasMarketingConsent, productAnnouncementEnabled) => ({
|
|
175
|
+
walletActivity: {
|
|
176
|
+
inAppNotificationsEnabled: true,
|
|
177
|
+
pushNotificationsEnabled: true,
|
|
178
|
+
accounts: buildWalletActivityAccounts(walletActivityAccounts),
|
|
179
|
+
},
|
|
180
|
+
marketing: {
|
|
181
|
+
inAppNotificationsEnabled: productAnnouncementEnabled,
|
|
182
|
+
pushNotificationsEnabled: hasMarketingConsent,
|
|
183
|
+
},
|
|
184
|
+
perps: { ...exports.DEFAULT_PERPS_PREFERENCES },
|
|
185
|
+
socialAI: { ...exports.DEFAULT_SOCIAL_AI_PREFERENCES },
|
|
186
|
+
});
|
|
109
187
|
const MESSENGER_EXPOSED_METHODS = [
|
|
110
188
|
'init',
|
|
111
189
|
'enablePushNotifications',
|
|
@@ -375,14 +453,12 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
375
453
|
*/
|
|
376
454
|
async enablePushNotifications() {
|
|
377
455
|
try {
|
|
378
|
-
const
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
if (addresses.length > 0) {
|
|
385
|
-
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").enablePushNotifications(addresses);
|
|
456
|
+
const preferences = await this.messenger.call('AuthenticatedUserStorageService:getNotificationPreferences');
|
|
457
|
+
const enabledAddresses = (preferences?.walletActivity.accounts ?? [])
|
|
458
|
+
.filter((account) => account.enabled)
|
|
459
|
+
.map((account) => account.address);
|
|
460
|
+
if (enabledAddresses.length > 0) {
|
|
461
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").enablePushNotifications(enabledAddresses);
|
|
386
462
|
}
|
|
387
463
|
}
|
|
388
464
|
catch {
|
|
@@ -398,13 +474,15 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
398
474
|
async checkAccountsPresence(accounts) {
|
|
399
475
|
try {
|
|
400
476
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsCheckingAccountsPresence).call(this, true);
|
|
401
|
-
|
|
402
|
-
const
|
|
403
|
-
|
|
477
|
+
const preferences = await this.messenger.call('AuthenticatedUserStorageService:getNotificationPreferences');
|
|
478
|
+
const enabledByAddress = new Map((preferences?.walletActivity.accounts ?? []).map((account) => [
|
|
479
|
+
account.address.toLowerCase(),
|
|
480
|
+
account.enabled,
|
|
481
|
+
]));
|
|
404
482
|
const result = {};
|
|
405
|
-
|
|
406
|
-
result[
|
|
407
|
-
}
|
|
483
|
+
for (const address of accounts) {
|
|
484
|
+
result[address] = enabledByAddress.get(address.toLowerCase()) ?? false;
|
|
485
|
+
}
|
|
408
486
|
return result;
|
|
409
487
|
}
|
|
410
488
|
catch (error) {
|
|
@@ -440,9 +518,15 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
440
518
|
*
|
|
441
519
|
* **Action** - Used during Sign In / Enabling of notifications.
|
|
442
520
|
*
|
|
521
|
+
* Notification preferences are initialized only when
|
|
522
|
+
* {@link AuthenticatedUserStorageService} has no stored preferences yet.
|
|
523
|
+
* Existing preferences are left as-is.
|
|
524
|
+
*
|
|
443
525
|
* @param opts - optional options to mutate this functionality
|
|
444
|
-
* @param opts.
|
|
445
|
-
*
|
|
526
|
+
* @param opts.hasMarketingConsent - The user's marketing-consent flag.
|
|
527
|
+
* Used only during initialization to seed marketing push notifications.
|
|
528
|
+
* @param opts.productAnnouncementEnabled - The user's product-announcement flag.
|
|
529
|
+
* Used only during initialization to seed marketing in-app notifications.
|
|
446
530
|
* @returns The updated or newly created user storage.
|
|
447
531
|
* @throws {Error} Throws an error if unauthenticated or from other operations.
|
|
448
532
|
*/
|
|
@@ -451,19 +535,23 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
451
535
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsUpdatingMetamaskNotifications).call(this, true);
|
|
452
536
|
const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
|
|
453
537
|
const { accounts } = __classPrivateFieldGet(this, _NotificationServicesController_accounts, "f").listAccounts();
|
|
454
|
-
// 1.
|
|
455
|
-
const
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
let
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
if (accountsWithNotifications.length === 0 || opts?.resetNotifications) {
|
|
463
|
-
await (0, api_notifications_1.updateOnChainNotifications)(bearerToken, accounts.map((address) => ({ address, enabled: true })), __classPrivateFieldGet(this, _NotificationServicesController_env, "f"));
|
|
464
|
-
accountsWithNotifications = accounts;
|
|
538
|
+
// 1. Read existing AUS notification preferences and initialize only if absent.
|
|
539
|
+
const preferences = await this.messenger.call('AuthenticatedUserStorageService:getNotificationPreferences');
|
|
540
|
+
const hasMarketingConsent = Boolean(opts?.hasMarketingConsent);
|
|
541
|
+
const productAnnouncementEnabled = Boolean(opts?.productAnnouncementEnabled);
|
|
542
|
+
let nextPreferences;
|
|
543
|
+
if (preferences === null) {
|
|
544
|
+
const walletActivityAccounts = await buildWalletActivityAccountsFromTriggerConfig(bearerToken, accounts, __classPrivateFieldGet(this, _NotificationServicesController_env, "f"));
|
|
545
|
+
nextPreferences = buildFreshPreferences(walletActivityAccounts, hasMarketingConsent, productAnnouncementEnabled);
|
|
465
546
|
}
|
|
466
|
-
|
|
547
|
+
if (nextPreferences) {
|
|
548
|
+
await this.messenger.call('AuthenticatedUserStorageService:putNotificationPreferences', nextPreferences, __classPrivateFieldGet(this, _NotificationServicesController_featureAnnouncementEnv, "f").platform);
|
|
549
|
+
}
|
|
550
|
+
const effectivePreferences = nextPreferences ?? preferences;
|
|
551
|
+
const accountsWithNotifications = (effectivePreferences?.walletActivity.accounts ?? [])
|
|
552
|
+
.filter((account) => account.enabled)
|
|
553
|
+
.map((account) => account.address);
|
|
554
|
+
// 2. Lazily enable push notifications (FCM may take some time, so keeps UI unblocked)
|
|
467
555
|
__classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f")
|
|
468
556
|
.enablePushNotifications(accountsWithNotifications)
|
|
469
557
|
.catch(() => {
|
|
@@ -496,13 +584,14 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
496
584
|
* Enables all MetaMask notifications for the user.
|
|
497
585
|
* This is identical flow when initializing notifications for the first time.
|
|
498
586
|
*
|
|
587
|
+
* @param opts - Optional settings for first-time AUS notification preferences initialization.
|
|
499
588
|
* @throws {Error} If there is an error during the process of enabling notifications.
|
|
500
589
|
*/
|
|
501
|
-
async enableMetamaskNotifications() {
|
|
590
|
+
async enableMetamaskNotifications(opts) {
|
|
502
591
|
try {
|
|
503
592
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_setIsUpdatingMetamaskNotifications).call(this, true);
|
|
504
593
|
await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_enableAuth).call(this);
|
|
505
|
-
await this.createOnChainTriggers();
|
|
594
|
+
await this.createOnChainTriggers(opts);
|
|
506
595
|
}
|
|
507
596
|
catch (error) {
|
|
508
597
|
loglevel_1.default.error('Unable to enable notifications', error);
|
|
@@ -557,10 +646,9 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
557
646
|
async disableAccounts(accounts) {
|
|
558
647
|
try {
|
|
559
648
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_updateUpdatingAccountsState).call(this, accounts);
|
|
560
|
-
//
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
await (0, api_notifications_1.updateOnChainNotifications)(bearerToken, accounts.map((address) => ({ address, enabled: false })), __classPrivateFieldGet(this, _NotificationServicesController_env, "f"));
|
|
649
|
+
// Sign-in gate.
|
|
650
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
|
|
651
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_registerWalletActivityAddresses).call(this, accounts.map((address) => ({ address, enabled: false })));
|
|
564
652
|
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").deletePushNotificationLinks(accounts);
|
|
565
653
|
}
|
|
566
654
|
catch {
|
|
@@ -588,8 +676,9 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
588
676
|
async enableAccounts(accounts) {
|
|
589
677
|
try {
|
|
590
678
|
__classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_updateUpdatingAccountsState).call(this, accounts);
|
|
591
|
-
|
|
592
|
-
await (
|
|
679
|
+
// Sign-in gate.
|
|
680
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
|
|
681
|
+
await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_registerWalletActivityAddresses).call(this, accounts.map((address) => ({ address, enabled: true })));
|
|
593
682
|
await __classPrivateFieldGet(this, _NotificationServicesController_pushNotifications, "f").addPushNotificationLinks(accounts);
|
|
594
683
|
}
|
|
595
684
|
catch (error) {
|
|
@@ -625,10 +714,10 @@ class NotificationServicesController extends base_controller_1.BaseController {
|
|
|
625
714
|
if (isGlobalNotifsEnabled) {
|
|
626
715
|
try {
|
|
627
716
|
const { bearerToken } = await __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_getBearerToken).call(this);
|
|
628
|
-
const
|
|
629
|
-
const addressesWithNotifications = (
|
|
630
|
-
.filter((
|
|
631
|
-
.map((
|
|
717
|
+
const preferences = await this.messenger.call('AuthenticatedUserStorageService:getNotificationPreferences');
|
|
718
|
+
const addressesWithNotifications = (preferences?.walletActivity.accounts ?? [])
|
|
719
|
+
.filter((account) => account.enabled)
|
|
720
|
+
.map((account) => account.address);
|
|
632
721
|
const notifications = await (0, api_notifications_1.getAPINotifications)(bearerToken, addressesWithNotifications, __classPrivateFieldGet(this, _NotificationServicesController_locale, "f").call(this), __classPrivateFieldGet(this, _NotificationServicesController_featureAnnouncementEnv, "f").platform, __classPrivateFieldGet(this, _NotificationServicesController_env, "f")).catch(() => []);
|
|
633
722
|
rawOnChainNotifications.push(...notifications);
|
|
634
723
|
}
|
|
@@ -854,6 +943,53 @@ _NotificationServicesController_keyringController = new WeakMap(), _Notification
|
|
|
854
943
|
throw new Error('Missing BearerToken');
|
|
855
944
|
}
|
|
856
945
|
return { bearerToken };
|
|
946
|
+
}, _NotificationServicesController_registerWalletActivityAddresses =
|
|
947
|
+
/**
|
|
948
|
+
* Updates the `walletActivity.accounts` entries in the user's
|
|
949
|
+
* notification-preferences blob in {@link AuthenticatedUserStorageService}.
|
|
950
|
+
*
|
|
951
|
+
* `putNotificationPreferences` replaces the entire blob, so we read the
|
|
952
|
+
* current preferences, merge the supplied updates into
|
|
953
|
+
* `walletActivity.accounts`, and write the result back. This helper is only
|
|
954
|
+
* meant to be used for incremental updates (enable/disable individual
|
|
955
|
+
* accounts) after the preferences blob has already been initialized via
|
|
956
|
+
* {@link createOnChainTriggers}; callers should not rely on it to perform
|
|
957
|
+
* first-time initialization.
|
|
958
|
+
*
|
|
959
|
+
* @param updates - Addresses to register, each with the desired `enabled` flag
|
|
960
|
+
*/
|
|
961
|
+
async function _NotificationServicesController_registerWalletActivityAddresses(updates) {
|
|
962
|
+
if (updates.length === 0) {
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
965
|
+
const currentPreferences = await this.messenger
|
|
966
|
+
.call('AuthenticatedUserStorageService:getNotificationPreferences')
|
|
967
|
+
.catch((error) => {
|
|
968
|
+
loglevel_1.default.error('Failed to get notification preferences. Re-initializing them instead.', error);
|
|
969
|
+
// TODO: return null once validation error captured
|
|
970
|
+
// return null;
|
|
971
|
+
throw error;
|
|
972
|
+
});
|
|
973
|
+
if (!currentPreferences) {
|
|
974
|
+
loglevel_1.default.warn('Preferences blob not yet initialized; run `createOnChainTriggers` first.');
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
const accountsByAddress = new Map(currentPreferences.walletActivity.accounts.map((account) => [
|
|
978
|
+
account.address.toLowerCase(),
|
|
979
|
+
{ ...account, address: account.address.toLowerCase() },
|
|
980
|
+
]));
|
|
981
|
+
for (const update of updates) {
|
|
982
|
+
const address = update.address.toLowerCase();
|
|
983
|
+
accountsByAddress.set(address, { address, enabled: update.enabled });
|
|
984
|
+
}
|
|
985
|
+
const nextPreferences = {
|
|
986
|
+
...currentPreferences,
|
|
987
|
+
walletActivity: {
|
|
988
|
+
...currentPreferences.walletActivity,
|
|
989
|
+
accounts: [...accountsByAddress.values()],
|
|
990
|
+
},
|
|
991
|
+
};
|
|
992
|
+
await this.messenger.call('AuthenticatedUserStorageService:putNotificationPreferences', nextPreferences, __classPrivateFieldGet(this, _NotificationServicesController_featureAnnouncementEnv, "f").platform);
|
|
857
993
|
}, _NotificationServicesController_setIsUpdatingMetamaskNotifications = function _NotificationServicesController_setIsUpdatingMetamaskNotifications(isUpdatingMetamaskNotifications) {
|
|
858
994
|
this.update((state) => {
|
|
859
995
|
state.isUpdatingMetamaskNotifications = isUpdatingMetamaskNotifications;
|