@metamask-previews/notification-services-controller 22.1.0-preview-b2ccba4 → 22.1.0-preview-61aec42b1

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/NotificationServicesController/NotificationServicesController-method-action-types.cjs +7 -0
  3. package/dist/NotificationServicesController/NotificationServicesController-method-action-types.cjs.map +1 -0
  4. package/dist/NotificationServicesController/NotificationServicesController-method-action-types.d.cts +198 -0
  5. package/dist/NotificationServicesController/NotificationServicesController-method-action-types.d.cts.map +1 -0
  6. package/dist/NotificationServicesController/NotificationServicesController-method-action-types.d.mts +198 -0
  7. package/dist/NotificationServicesController/NotificationServicesController-method-action-types.d.mts.map +1 -0
  8. package/dist/NotificationServicesController/NotificationServicesController-method-action-types.mjs +6 -0
  9. package/dist/NotificationServicesController/NotificationServicesController-method-action-types.mjs.map +1 -0
  10. package/dist/NotificationServicesController/NotificationServicesController.cjs +24 -10
  11. package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -1
  12. package/dist/NotificationServicesController/NotificationServicesController.d.cts +5 -20
  13. package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -1
  14. package/dist/NotificationServicesController/NotificationServicesController.d.mts +5 -20
  15. package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -1
  16. package/dist/NotificationServicesController/NotificationServicesController.mjs +23 -10
  17. package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
  18. package/dist/NotificationServicesController/index.cjs +3 -7
  19. package/dist/NotificationServicesController/index.cjs.map +1 -1
  20. package/dist/NotificationServicesController/index.d.cts +3 -3
  21. package/dist/NotificationServicesController/index.d.cts.map +1 -1
  22. package/dist/NotificationServicesController/index.d.mts +3 -3
  23. package/dist/NotificationServicesController/index.d.mts.map +1 -1
  24. package/dist/NotificationServicesController/index.mjs +2 -3
  25. package/dist/NotificationServicesController/index.mjs.map +1 -1
  26. package/dist/NotificationServicesPushController/NotificationServicesPushController-method-action-types.cjs +7 -0
  27. package/dist/NotificationServicesPushController/NotificationServicesPushController-method-action-types.cjs.map +1 -0
  28. package/dist/NotificationServicesPushController/NotificationServicesPushController-method-action-types.d.cts +48 -0
  29. package/dist/NotificationServicesPushController/NotificationServicesPushController-method-action-types.d.cts.map +1 -0
  30. package/dist/NotificationServicesPushController/NotificationServicesPushController-method-action-types.d.mts +48 -0
  31. package/dist/NotificationServicesPushController/NotificationServicesPushController-method-action-types.d.mts.map +1 -0
  32. package/dist/NotificationServicesPushController/NotificationServicesPushController-method-action-types.mjs +6 -0
  33. package/dist/NotificationServicesPushController/NotificationServicesPushController-method-action-types.mjs.map +1 -0
  34. package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs +11 -10
  35. package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -1
  36. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts +3 -18
  37. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -1
  38. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts +3 -18
  39. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -1
  40. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +10 -10
  41. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -1
  42. package/dist/NotificationServicesPushController/index.cjs +3 -7
  43. package/dist/NotificationServicesPushController/index.cjs.map +1 -1
  44. package/dist/NotificationServicesPushController/index.d.cts +3 -3
  45. package/dist/NotificationServicesPushController/index.d.cts.map +1 -1
  46. package/dist/NotificationServicesPushController/index.d.mts +3 -3
  47. package/dist/NotificationServicesPushController/index.d.mts.map +1 -1
  48. package/dist/NotificationServicesPushController/index.mjs +2 -3
  49. package/dist/NotificationServicesPushController/index.mjs.map +1 -1
  50. package/package.json +5 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Added
11
+
12
+ - Expose missing public `NotificationServicesController` methods through its messenger ([#8176](https://github.com/MetaMask/core/pull/8176))
13
+ - The following actions are now available:
14
+ - `NotificationServicesController:init`
15
+ - `NotificationServicesController:enablePushNotification`
16
+ - `NotificationServicesController:disablePushNotification`
17
+ - `NotificationServicesController:checkAccountsPresence`
18
+ - `NotificationServicesController:setFeatureAnnouncementsEnabled`
19
+ - `NotificationServicesController:createOnChainTriggers`
20
+ - `NotificationServicesController:enableMetamaskNotifications`
21
+ - `NotificationServicesController:disableAccounts`
22
+ - `NotificationServicesController:enableAccounts`
23
+ - `NotificationServicesController:fetchAndUpdateMetamaskNotifications`
24
+ - `NotificationServicesController:deleteNotificationById`
25
+ - `NotificationServicesController:markMetamaskNotificationsAsRead`
26
+ - `NotificationServicesController:sendPerpPlaceOrderNotification`
27
+ - Corresponding action types (e.g. `NotificationServicesControllerEnablePushNotificationAction`) are available as well.
28
+
29
+ ### Changed
30
+
31
+ - **BREAKING:** Standardize names of `NotificationServicesController` and `NotificationServicesPushController` messenger action types ([#8176](https://github.com/MetaMask/core/pull/8176))
32
+ - All existing types for messenger actions have been renamed so they end in `Action` (e.g. `NotificationServicesControllerUpdateMetamaskNotificationsList` -> `NotificationServicesControllerUpdateMetamaskNotificationsListAction`). You will need to update imports appropriately.
33
+ - The `NotificationServicesPushController` action `NotificationServicesPushControllerSubscribeToNotificationsAction` has been renamed to `NotificationServicesPushControllerSubscribeToPushNotificationsAction` so it matches the method name.
34
+ - These changes only affect the types. The action type strings themselves have not changed, so you do not need to update the list of actions you pass when initializing `NotificationServicesController` and `NotificationServicesPushController` messengers.
35
+
10
36
  ## [22.1.0]
11
37
 
12
38
  ### Changed
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * This file is auto generated by `scripts/generate-method-action-types.ts`.
4
+ * Do not edit manually.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=NotificationServicesController-method-action-types.cjs.map
@@ -0,0 +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 by `scripts/generate-method-action-types.ts`.\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"]}
@@ -0,0 +1,198 @@
1
+ /**
2
+ * This file is auto generated by `scripts/generate-method-action-types.ts`.
3
+ * Do not edit manually.
4
+ */
5
+ import type { NotificationServicesController } from "./NotificationServicesController.cjs";
6
+ export type NotificationServicesControllerInitAction = {
7
+ type: `NotificationServicesController:init`;
8
+ handler: NotificationServicesController['init'];
9
+ };
10
+ /**
11
+ * Public method to expose enabling push notifications
12
+ */
13
+ export type NotificationServicesControllerEnablePushNotificationsAction = {
14
+ type: `NotificationServicesController:enablePushNotifications`;
15
+ handler: NotificationServicesController['enablePushNotifications'];
16
+ };
17
+ /**
18
+ * Public method to expose disabling push notifications
19
+ */
20
+ export type NotificationServicesControllerDisablePushNotificationsAction = {
21
+ type: `NotificationServicesController:disablePushNotifications`;
22
+ handler: NotificationServicesController['disablePushNotifications'];
23
+ };
24
+ export type NotificationServicesControllerCheckAccountsPresenceAction = {
25
+ type: `NotificationServicesController:checkAccountsPresence`;
26
+ handler: NotificationServicesController['checkAccountsPresence'];
27
+ };
28
+ /**
29
+ * Sets the enabled state of feature announcements.
30
+ *
31
+ * **Action** - used in the notification settings to enable/disable feature announcements.
32
+ *
33
+ * @param featureAnnouncementsEnabled - A boolean value indicating the desired enabled state of the feature announcements.
34
+ * @async
35
+ * @throws {Error} If fails to update
36
+ */
37
+ export type NotificationServicesControllerSetFeatureAnnouncementsEnabledAction = {
38
+ type: `NotificationServicesController:setFeatureAnnouncementsEnabled`;
39
+ handler: NotificationServicesController['setFeatureAnnouncementsEnabled'];
40
+ };
41
+ /**
42
+ * This creates/re-creates on-chain triggers defined in User Storage.
43
+ *
44
+ * **Action** - Used during Sign In / Enabling of notifications.
45
+ *
46
+ * @param opts - optional options to mutate this functionality
47
+ * @param opts.resetNotifications - this will not use the users stored preferences, and instead re-create notification triggers
48
+ * It will help in case uses get into a corrupted state or wants to wipe their notifications.
49
+ * @returns The updated or newly created user storage.
50
+ * @throws {Error} Throws an error if unauthenticated or from other operations.
51
+ */
52
+ export type NotificationServicesControllerCreateOnChainTriggersAction = {
53
+ type: `NotificationServicesController:createOnChainTriggers`;
54
+ handler: NotificationServicesController['createOnChainTriggers'];
55
+ };
56
+ /**
57
+ * Enables all MetaMask notifications for the user.
58
+ * This is identical flow when initializing notifications for the first time.
59
+ *
60
+ * @throws {Error} If there is an error during the process of enabling notifications.
61
+ */
62
+ export type NotificationServicesControllerEnableMetamaskNotificationsAction = {
63
+ type: `NotificationServicesController:enableMetamaskNotifications`;
64
+ handler: NotificationServicesController['enableMetamaskNotifications'];
65
+ };
66
+ /**
67
+ * Disables all MetaMask notifications for the user.
68
+ * This method ensures that the user is authenticated, retrieves all linked accounts,
69
+ * and disables on-chain triggers for each account. It also sets the global notification
70
+ * settings for MetaMask, feature announcements to false.
71
+ *
72
+ * @throws {Error} If the user is not authenticated or if there is an error during the process.
73
+ */
74
+ export type NotificationServicesControllerDisableNotificationServicesAction = {
75
+ type: `NotificationServicesController:disableNotificationServices`;
76
+ handler: NotificationServicesController['disableNotificationServices'];
77
+ };
78
+ /**
79
+ * Deletes on-chain triggers associated with a specific account/s.
80
+ * This method performs several key operations:
81
+ * 1. Validates Auth
82
+ * 2. Deletes accounts
83
+ * (note) We do not need to look through push notifications as we've deleted triggers
84
+ *
85
+ * **Action** - When a user disables notifications for a given account in settings.
86
+ *
87
+ * @param accounts - The account for which on-chain triggers are to be deleted.
88
+ * @returns A promise that resolves to void or an object containing a success message.
89
+ * @throws {Error} Throws an error if unauthenticated or from other operations.
90
+ */
91
+ export type NotificationServicesControllerDisableAccountsAction = {
92
+ type: `NotificationServicesController:disableAccounts`;
93
+ handler: NotificationServicesController['disableAccounts'];
94
+ };
95
+ /**
96
+ * Updates/Creates on-chain triggers for a specific account.
97
+ *
98
+ * This method performs several key operations:
99
+ * 1. Validates Auth & Storage
100
+ * 2. Finds and creates any missing triggers associated with the account
101
+ * 3. Enables any related push notifications
102
+ * 4. Updates Storage to reflect new state.
103
+ *
104
+ * **Action** - When a user enables notifications for an account
105
+ *
106
+ * @param accounts - List of accounts you want to update.
107
+ * @returns A promise that resolves to the updated user storage.
108
+ * @throws {Error} Throws an error if unauthenticated or from other operations.
109
+ */
110
+ export type NotificationServicesControllerEnableAccountsAction = {
111
+ type: `NotificationServicesController:enableAccounts`;
112
+ handler: NotificationServicesController['enableAccounts'];
113
+ };
114
+ /**
115
+ * Fetches the list of metamask notifications.
116
+ * This includes OnChain notifications; Feature Announcements; and Snap Notifications.
117
+ *
118
+ * **Action** - When a user views the notification list page/dropdown
119
+ *
120
+ * @param previewToken - the preview token to use if needed
121
+ * @returns A promise that resolves to the list of notifications.
122
+ * @throws {Error} Throws an error if unauthenticated or from other operations.
123
+ */
124
+ export type NotificationServicesControllerFetchAndUpdateMetamaskNotificationsAction = {
125
+ type: `NotificationServicesController:fetchAndUpdateMetamaskNotifications`;
126
+ handler: NotificationServicesController['fetchAndUpdateMetamaskNotifications'];
127
+ };
128
+ /**
129
+ * Gets the specified type of notifications from state.
130
+ *
131
+ * @param type - The trigger type.
132
+ * @returns An array of notifications of the passed in type.
133
+ * @throws Throws an error if an invalid trigger type is passed.
134
+ */
135
+ export type NotificationServicesControllerGetNotificationsByTypeAction = {
136
+ type: `NotificationServicesController:getNotificationsByType`;
137
+ handler: NotificationServicesController['getNotificationsByType'];
138
+ };
139
+ /**
140
+ * Used to delete a notification by id.
141
+ *
142
+ * Note: This function should only be used for notifications that are stored
143
+ * in this controller directly, currently only snaps notifications.
144
+ *
145
+ * @param id - The id of the notification to delete.
146
+ */
147
+ export type NotificationServicesControllerDeleteNotificationByIdAction = {
148
+ type: `NotificationServicesController:deleteNotificationById`;
149
+ handler: NotificationServicesController['deleteNotificationById'];
150
+ };
151
+ /**
152
+ * Used to batch delete notifications by id.
153
+ *
154
+ * Note: This function should only be used for notifications that are stored
155
+ * in this controller directly, currently only snaps notifications.
156
+ *
157
+ * @param ids - The ids of the notifications to delete.
158
+ */
159
+ export type NotificationServicesControllerDeleteNotificationsByIdAction = {
160
+ type: `NotificationServicesController:deleteNotificationsById`;
161
+ handler: NotificationServicesController['deleteNotificationsById'];
162
+ };
163
+ /**
164
+ * Marks specified metamask notifications as read.
165
+ *
166
+ * @param notifications - An array of notifications to be marked as read. Each notification should include its type and read status.
167
+ * @returns A promise that resolves when the operation is complete.
168
+ */
169
+ export type NotificationServicesControllerMarkMetamaskNotificationsAsReadAction = {
170
+ type: `NotificationServicesController:markMetamaskNotificationsAsRead`;
171
+ handler: NotificationServicesController['markMetamaskNotificationsAsRead'];
172
+ };
173
+ /**
174
+ * Updates the list of MetaMask notifications by adding a new notification at the beginning of the list.
175
+ * This method ensures that the most recent notification is displayed first in the UI.
176
+ *
177
+ * @param notification - The new notification object to be added to the list.
178
+ * @returns A promise that resolves when the notification list has been successfully updated.
179
+ */
180
+ export type NotificationServicesControllerUpdateMetamaskNotificationsListAction = {
181
+ type: `NotificationServicesController:updateMetamaskNotificationsList`;
182
+ handler: NotificationServicesController['updateMetamaskNotificationsList'];
183
+ };
184
+ /**
185
+ * Creates an perp order notification subscription.
186
+ * Requires notifications and auth to be enabled to start receiving this notifications
187
+ *
188
+ * @param input perp input
189
+ */
190
+ export type NotificationServicesControllerSendPerpPlaceOrderNotificationAction = {
191
+ type: `NotificationServicesController:sendPerpPlaceOrderNotification`;
192
+ handler: NotificationServicesController['sendPerpPlaceOrderNotification'];
193
+ };
194
+ /**
195
+ * Union of all NotificationServicesController action types.
196
+ */
197
+ export type NotificationServicesControllerMethodActions = NotificationServicesControllerInitAction | NotificationServicesControllerEnablePushNotificationsAction | NotificationServicesControllerDisablePushNotificationsAction | NotificationServicesControllerCheckAccountsPresenceAction | NotificationServicesControllerSetFeatureAnnouncementsEnabledAction | NotificationServicesControllerCreateOnChainTriggersAction | NotificationServicesControllerEnableMetamaskNotificationsAction | NotificationServicesControllerDisableNotificationServicesAction | NotificationServicesControllerDisableAccountsAction | NotificationServicesControllerEnableAccountsAction | NotificationServicesControllerFetchAndUpdateMetamaskNotificationsAction | NotificationServicesControllerGetNotificationsByTypeAction | NotificationServicesControllerDeleteNotificationByIdAction | NotificationServicesControllerDeleteNotificationsByIdAction | NotificationServicesControllerMarkMetamaskNotificationsAsReadAction | NotificationServicesControllerUpdateMetamaskNotificationsListAction | NotificationServicesControllerSendPerpPlaceOrderNotificationAction;
198
+ //# sourceMappingURL=NotificationServicesController-method-action-types.d.cts.map
@@ -0,0 +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;;;;;;;;;;GAUG;AACH,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,sDAAsD,CAAC;IAC7D,OAAO,EAAE,8BAA8B,CAAC,uBAAuB,CAAC,CAAC;CAClE,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,+DAA+D,GAAG;IAC5E,IAAI,EAAE,4DAA4D,CAAC;IACnE,OAAO,EAAE,8BAA8B,CAAC,6BAA6B,CAAC,CAAC;CACxE,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,+DAA+D,GAAG;IAC5E,IAAI,EAAE,4DAA4D,CAAC;IACnE,OAAO,EAAE,8BA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AAC;CAC5E,CAAC;AAEJ;;;;;GAKG;AACH,MAAM,MAAM,kEAAkE,GAC5E;IACE,IAAI,EAAE,+DAA+D,CAAC;IACtE,OAAO,EAAE,8BAA8B,CAAC,gCAAgC,CAAC,CAAC;CAC3E,CAAC;AAEJ;;GAEG;AACH,MAAM,MAAM,2CAA2C,GACnD,wCAAwC,GACxC,2DAA2D,GAC3D,4DAA4D,GAC5D,yDAAyD,GACzD,kEAAkE,GAClE,yDAAyD,GACzD,+DAA+D,GAC/D,+DAA+D,GAC/D,mDAAmD,GACnD,kDAAkD,GAClD,uEAAuE,GACvE,0DAA0D,GAC1D,0DAA0D,GAC1D,2DAA2D,GAC3D,mEAAmE,GACnE,mEAAmE,GACnE,kEAAkE,CAAC"}
@@ -0,0 +1,198 @@
1
+ /**
2
+ * This file is auto generated by `scripts/generate-method-action-types.ts`.
3
+ * Do not edit manually.
4
+ */
5
+ import type { NotificationServicesController } from "./NotificationServicesController.mjs";
6
+ export type NotificationServicesControllerInitAction = {
7
+ type: `NotificationServicesController:init`;
8
+ handler: NotificationServicesController['init'];
9
+ };
10
+ /**
11
+ * Public method to expose enabling push notifications
12
+ */
13
+ export type NotificationServicesControllerEnablePushNotificationsAction = {
14
+ type: `NotificationServicesController:enablePushNotifications`;
15
+ handler: NotificationServicesController['enablePushNotifications'];
16
+ };
17
+ /**
18
+ * Public method to expose disabling push notifications
19
+ */
20
+ export type NotificationServicesControllerDisablePushNotificationsAction = {
21
+ type: `NotificationServicesController:disablePushNotifications`;
22
+ handler: NotificationServicesController['disablePushNotifications'];
23
+ };
24
+ export type NotificationServicesControllerCheckAccountsPresenceAction = {
25
+ type: `NotificationServicesController:checkAccountsPresence`;
26
+ handler: NotificationServicesController['checkAccountsPresence'];
27
+ };
28
+ /**
29
+ * Sets the enabled state of feature announcements.
30
+ *
31
+ * **Action** - used in the notification settings to enable/disable feature announcements.
32
+ *
33
+ * @param featureAnnouncementsEnabled - A boolean value indicating the desired enabled state of the feature announcements.
34
+ * @async
35
+ * @throws {Error} If fails to update
36
+ */
37
+ export type NotificationServicesControllerSetFeatureAnnouncementsEnabledAction = {
38
+ type: `NotificationServicesController:setFeatureAnnouncementsEnabled`;
39
+ handler: NotificationServicesController['setFeatureAnnouncementsEnabled'];
40
+ };
41
+ /**
42
+ * This creates/re-creates on-chain triggers defined in User Storage.
43
+ *
44
+ * **Action** - Used during Sign In / Enabling of notifications.
45
+ *
46
+ * @param opts - optional options to mutate this functionality
47
+ * @param opts.resetNotifications - this will not use the users stored preferences, and instead re-create notification triggers
48
+ * It will help in case uses get into a corrupted state or wants to wipe their notifications.
49
+ * @returns The updated or newly created user storage.
50
+ * @throws {Error} Throws an error if unauthenticated or from other operations.
51
+ */
52
+ export type NotificationServicesControllerCreateOnChainTriggersAction = {
53
+ type: `NotificationServicesController:createOnChainTriggers`;
54
+ handler: NotificationServicesController['createOnChainTriggers'];
55
+ };
56
+ /**
57
+ * Enables all MetaMask notifications for the user.
58
+ * This is identical flow when initializing notifications for the first time.
59
+ *
60
+ * @throws {Error} If there is an error during the process of enabling notifications.
61
+ */
62
+ export type NotificationServicesControllerEnableMetamaskNotificationsAction = {
63
+ type: `NotificationServicesController:enableMetamaskNotifications`;
64
+ handler: NotificationServicesController['enableMetamaskNotifications'];
65
+ };
66
+ /**
67
+ * Disables all MetaMask notifications for the user.
68
+ * This method ensures that the user is authenticated, retrieves all linked accounts,
69
+ * and disables on-chain triggers for each account. It also sets the global notification
70
+ * settings for MetaMask, feature announcements to false.
71
+ *
72
+ * @throws {Error} If the user is not authenticated or if there is an error during the process.
73
+ */
74
+ export type NotificationServicesControllerDisableNotificationServicesAction = {
75
+ type: `NotificationServicesController:disableNotificationServices`;
76
+ handler: NotificationServicesController['disableNotificationServices'];
77
+ };
78
+ /**
79
+ * Deletes on-chain triggers associated with a specific account/s.
80
+ * This method performs several key operations:
81
+ * 1. Validates Auth
82
+ * 2. Deletes accounts
83
+ * (note) We do not need to look through push notifications as we've deleted triggers
84
+ *
85
+ * **Action** - When a user disables notifications for a given account in settings.
86
+ *
87
+ * @param accounts - The account for which on-chain triggers are to be deleted.
88
+ * @returns A promise that resolves to void or an object containing a success message.
89
+ * @throws {Error} Throws an error if unauthenticated or from other operations.
90
+ */
91
+ export type NotificationServicesControllerDisableAccountsAction = {
92
+ type: `NotificationServicesController:disableAccounts`;
93
+ handler: NotificationServicesController['disableAccounts'];
94
+ };
95
+ /**
96
+ * Updates/Creates on-chain triggers for a specific account.
97
+ *
98
+ * This method performs several key operations:
99
+ * 1. Validates Auth & Storage
100
+ * 2. Finds and creates any missing triggers associated with the account
101
+ * 3. Enables any related push notifications
102
+ * 4. Updates Storage to reflect new state.
103
+ *
104
+ * **Action** - When a user enables notifications for an account
105
+ *
106
+ * @param accounts - List of accounts you want to update.
107
+ * @returns A promise that resolves to the updated user storage.
108
+ * @throws {Error} Throws an error if unauthenticated or from other operations.
109
+ */
110
+ export type NotificationServicesControllerEnableAccountsAction = {
111
+ type: `NotificationServicesController:enableAccounts`;
112
+ handler: NotificationServicesController['enableAccounts'];
113
+ };
114
+ /**
115
+ * Fetches the list of metamask notifications.
116
+ * This includes OnChain notifications; Feature Announcements; and Snap Notifications.
117
+ *
118
+ * **Action** - When a user views the notification list page/dropdown
119
+ *
120
+ * @param previewToken - the preview token to use if needed
121
+ * @returns A promise that resolves to the list of notifications.
122
+ * @throws {Error} Throws an error if unauthenticated or from other operations.
123
+ */
124
+ export type NotificationServicesControllerFetchAndUpdateMetamaskNotificationsAction = {
125
+ type: `NotificationServicesController:fetchAndUpdateMetamaskNotifications`;
126
+ handler: NotificationServicesController['fetchAndUpdateMetamaskNotifications'];
127
+ };
128
+ /**
129
+ * Gets the specified type of notifications from state.
130
+ *
131
+ * @param type - The trigger type.
132
+ * @returns An array of notifications of the passed in type.
133
+ * @throws Throws an error if an invalid trigger type is passed.
134
+ */
135
+ export type NotificationServicesControllerGetNotificationsByTypeAction = {
136
+ type: `NotificationServicesController:getNotificationsByType`;
137
+ handler: NotificationServicesController['getNotificationsByType'];
138
+ };
139
+ /**
140
+ * Used to delete a notification by id.
141
+ *
142
+ * Note: This function should only be used for notifications that are stored
143
+ * in this controller directly, currently only snaps notifications.
144
+ *
145
+ * @param id - The id of the notification to delete.
146
+ */
147
+ export type NotificationServicesControllerDeleteNotificationByIdAction = {
148
+ type: `NotificationServicesController:deleteNotificationById`;
149
+ handler: NotificationServicesController['deleteNotificationById'];
150
+ };
151
+ /**
152
+ * Used to batch delete notifications by id.
153
+ *
154
+ * Note: This function should only be used for notifications that are stored
155
+ * in this controller directly, currently only snaps notifications.
156
+ *
157
+ * @param ids - The ids of the notifications to delete.
158
+ */
159
+ export type NotificationServicesControllerDeleteNotificationsByIdAction = {
160
+ type: `NotificationServicesController:deleteNotificationsById`;
161
+ handler: NotificationServicesController['deleteNotificationsById'];
162
+ };
163
+ /**
164
+ * Marks specified metamask notifications as read.
165
+ *
166
+ * @param notifications - An array of notifications to be marked as read. Each notification should include its type and read status.
167
+ * @returns A promise that resolves when the operation is complete.
168
+ */
169
+ export type NotificationServicesControllerMarkMetamaskNotificationsAsReadAction = {
170
+ type: `NotificationServicesController:markMetamaskNotificationsAsRead`;
171
+ handler: NotificationServicesController['markMetamaskNotificationsAsRead'];
172
+ };
173
+ /**
174
+ * Updates the list of MetaMask notifications by adding a new notification at the beginning of the list.
175
+ * This method ensures that the most recent notification is displayed first in the UI.
176
+ *
177
+ * @param notification - The new notification object to be added to the list.
178
+ * @returns A promise that resolves when the notification list has been successfully updated.
179
+ */
180
+ export type NotificationServicesControllerUpdateMetamaskNotificationsListAction = {
181
+ type: `NotificationServicesController:updateMetamaskNotificationsList`;
182
+ handler: NotificationServicesController['updateMetamaskNotificationsList'];
183
+ };
184
+ /**
185
+ * Creates an perp order notification subscription.
186
+ * Requires notifications and auth to be enabled to start receiving this notifications
187
+ *
188
+ * @param input perp input
189
+ */
190
+ export type NotificationServicesControllerSendPerpPlaceOrderNotificationAction = {
191
+ type: `NotificationServicesController:sendPerpPlaceOrderNotification`;
192
+ handler: NotificationServicesController['sendPerpPlaceOrderNotification'];
193
+ };
194
+ /**
195
+ * Union of all NotificationServicesController action types.
196
+ */
197
+ export type NotificationServicesControllerMethodActions = NotificationServicesControllerInitAction | NotificationServicesControllerEnablePushNotificationsAction | NotificationServicesControllerDisablePushNotificationsAction | NotificationServicesControllerCheckAccountsPresenceAction | NotificationServicesControllerSetFeatureAnnouncementsEnabledAction | NotificationServicesControllerCreateOnChainTriggersAction | NotificationServicesControllerEnableMetamaskNotificationsAction | NotificationServicesControllerDisableNotificationServicesAction | NotificationServicesControllerDisableAccountsAction | NotificationServicesControllerEnableAccountsAction | NotificationServicesControllerFetchAndUpdateMetamaskNotificationsAction | NotificationServicesControllerGetNotificationsByTypeAction | NotificationServicesControllerDeleteNotificationByIdAction | NotificationServicesControllerDeleteNotificationsByIdAction | NotificationServicesControllerMarkMetamaskNotificationsAsReadAction | NotificationServicesControllerUpdateMetamaskNotificationsListAction | NotificationServicesControllerSendPerpPlaceOrderNotificationAction;
198
+ //# sourceMappingURL=NotificationServicesController-method-action-types.d.mts.map
@@ -0,0 +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,8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+ * This file is auto generated by `scripts/generate-method-action-types.ts`.
3
+ * Do not edit manually.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=NotificationServicesController-method-action-types.mjs.map
@@ -0,0 +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 by `scripts/generate-method-action-types.ts`.\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"]}
@@ -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_registerMessageHandlers, _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_setIsUpdatingMetamaskNotifications, _NotificationServicesController_setIsFetchingMetamaskNotifications, _NotificationServicesController_setIsCheckingAccountsPresence, _NotificationServicesController_updateUpdatingAccountsState, _NotificationServicesController_clearUpdatingAccountsState;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.defaultState = exports.ACCOUNTS_UPDATE_DEBOUNCE_TIME_MS = void 0;
18
+ exports.NotificationServicesController = 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 keyring_controller_1 = require("@metamask/keyring-controller");
@@ -107,6 +107,25 @@ exports.defaultState = {
107
107
  const locallyPersistedNotificationTypes = new Set([
108
108
  notification_schema_1.TRIGGER_TYPES.SNAP,
109
109
  ]);
110
+ const MESSENGER_EXPOSED_METHODS = [
111
+ 'init',
112
+ 'enablePushNotifications',
113
+ 'disablePushNotifications',
114
+ 'checkAccountsPresence',
115
+ 'setFeatureAnnouncementsEnabled',
116
+ 'createOnChainTriggers',
117
+ 'enableMetamaskNotifications',
118
+ 'disableNotificationServices',
119
+ 'disableAccounts',
120
+ 'enableAccounts',
121
+ 'fetchAndUpdateMetamaskNotifications',
122
+ 'getNotificationsByType',
123
+ 'deleteNotificationById',
124
+ 'deleteNotificationsById',
125
+ 'markMetamaskNotificationsAsRead',
126
+ 'updateMetamaskNotificationsList',
127
+ 'sendPerpPlaceOrderNotification',
128
+ ];
110
129
  /**
111
130
  * Controller that enables wallet notifications and feature announcements
112
131
  */
@@ -311,7 +330,7 @@ class NotificationServicesController extends base_controller_1.BaseController {
311
330
  __classPrivateFieldSet(this, _NotificationServicesController_featureAnnouncementEnv, env.featureAnnouncements, "f");
312
331
  __classPrivateFieldSet(this, _NotificationServicesController_locale, env.locale ?? (() => 'en'), "f");
313
332
  __classPrivateFieldSet(this, _NotificationServicesController_env, env.env ?? 'prd', "f");
314
- __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_registerMessageHandlers).call(this);
333
+ this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
315
334
  __classPrivateFieldGet(this, _NotificationServicesController_instances, "m", _NotificationServicesController_clearLoadingStates).call(this);
316
335
  }
317
336
  init() {
@@ -780,12 +799,8 @@ class NotificationServicesController extends base_controller_1.BaseController {
780
799
  }
781
800
  }
782
801
  }
783
- _NotificationServicesController_keyringController = new WeakMap(), _NotificationServicesController_auth = new WeakMap(), _NotificationServicesController_pushNotifications = new WeakMap(), _NotificationServicesController_accounts = new WeakMap(), _NotificationServicesController_locale = new WeakMap(), _NotificationServicesController_featureAnnouncementEnv = new WeakMap(), _NotificationServicesController_env = new WeakMap(), _NotificationServicesController_instances = new WeakSet(), _NotificationServicesController_registerMessageHandlers = function _NotificationServicesController_registerMessageHandlers() {
784
- this.messenger.registerActionHandler(`${controllerName}:updateMetamaskNotificationsList`, this.updateMetamaskNotificationsList.bind(this));
785
- this.messenger.registerActionHandler(`${controllerName}:disableNotificationServices`, this.disableNotificationServices.bind(this));
786
- this.messenger.registerActionHandler(`${controllerName}:getNotificationsByType`, this.getNotificationsByType.bind(this));
787
- this.messenger.registerActionHandler(`${controllerName}:deleteNotificationsById`, this.deleteNotificationsById.bind(this));
788
- }, _NotificationServicesController_clearLoadingStates = function _NotificationServicesController_clearLoadingStates() {
802
+ exports.NotificationServicesController = NotificationServicesController;
803
+ _NotificationServicesController_keyringController = new WeakMap(), _NotificationServicesController_auth = new WeakMap(), _NotificationServicesController_pushNotifications = new WeakMap(), _NotificationServicesController_accounts = new WeakMap(), _NotificationServicesController_locale = new WeakMap(), _NotificationServicesController_featureAnnouncementEnv = new WeakMap(), _NotificationServicesController_env = new WeakMap(), _NotificationServicesController_instances = new WeakSet(), _NotificationServicesController_clearLoadingStates = function _NotificationServicesController_clearLoadingStates() {
789
804
  this.update((state) => {
790
805
  state.isUpdatingMetamaskNotifications = false;
791
806
  state.isCheckingAccountsPresence = false;
@@ -837,5 +852,4 @@ _NotificationServicesController_keyringController = new WeakMap(), _Notification
837
852
  state.isUpdatingMetamaskNotificationsAccount.filter((existingAccount) => !accounts.includes(existingAccount));
838
853
  });
839
854
  };
840
- exports.default = NotificationServicesController;
841
855
  //# sourceMappingURL=NotificationServicesController.cjs.map