@metamask/notification-services-controller 0.4.0 → 0.5.0

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 (113) hide show
  1. package/CHANGELOG.md +19 -1
  2. package/dist/NotificationServicesController/NotificationServicesController.js +6 -6
  3. package/dist/NotificationServicesController/NotificationServicesController.mjs +5 -5
  4. package/dist/NotificationServicesController/constants/index.js +3 -3
  5. package/dist/NotificationServicesController/constants/index.mjs +2 -2
  6. package/dist/NotificationServicesController/constants/notification-schema.js +2 -2
  7. package/dist/NotificationServicesController/constants/notification-schema.mjs +1 -1
  8. package/dist/NotificationServicesController/index.js +11 -11
  9. package/dist/NotificationServicesController/index.mjs +10 -10
  10. package/dist/NotificationServicesController/processors/index.js +4 -4
  11. package/dist/NotificationServicesController/processors/index.mjs +3 -3
  12. package/dist/NotificationServicesController/processors/process-notifications.js +3 -3
  13. package/dist/NotificationServicesController/processors/process-notifications.mjs +2 -2
  14. package/dist/NotificationServicesController/services/feature-announcements.js +1 -1
  15. package/dist/NotificationServicesController/services/feature-announcements.mjs +1 -1
  16. package/dist/NotificationServicesController/services/onchain-notifications.js +4 -4
  17. package/dist/NotificationServicesController/services/onchain-notifications.mjs +3 -3
  18. package/dist/NotificationServicesController/ui/constants.js +3 -3
  19. package/dist/NotificationServicesController/ui/constants.mjs +2 -2
  20. package/dist/NotificationServicesController/ui/index.js +4 -4
  21. package/dist/NotificationServicesController/ui/index.mjs +3 -3
  22. package/dist/NotificationServicesController/utils/utils.js +3 -3
  23. package/dist/NotificationServicesController/utils/utils.mjs +2 -2
  24. package/dist/NotificationServicesPushController/NotificationServicesPushController.js +14 -14
  25. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +13 -13
  26. package/dist/NotificationServicesPushController/index.js +17 -17
  27. package/dist/NotificationServicesPushController/index.mjs +16 -16
  28. package/dist/NotificationServicesPushController/services/push/push-web.js +12 -12
  29. package/dist/NotificationServicesPushController/services/push/push-web.mjs +11 -11
  30. package/dist/NotificationServicesPushController/services/services.js +13 -13
  31. package/dist/NotificationServicesPushController/services/services.mjs +12 -12
  32. package/dist/NotificationServicesPushController/utils/get-notification-message.js +12 -12
  33. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs +11 -11
  34. package/dist/NotificationServicesPushController/utils/index.js +13 -13
  35. package/dist/NotificationServicesPushController/utils/index.mjs +12 -12
  36. package/dist/{chunk-ZHAD55AN.mjs → chunk-2P5WP5NT.mjs} +2 -2
  37. package/dist/{chunk-J4D2NH6Y.mjs → chunk-53F3SYYM.mjs} +2 -2
  38. package/dist/chunk-53F3SYYM.mjs.map +1 -0
  39. package/dist/{chunk-X42WN3FE.mjs → chunk-5FAAZCBK.mjs} +2 -2
  40. package/dist/{chunk-4HOEZMSV.js → chunk-6FLC6CJD.js} +4 -4
  41. package/dist/{chunk-YZYQYIKS.mjs → chunk-77QIITUL.mjs} +2 -2
  42. package/dist/{chunk-GNN2XQW4.mjs → chunk-7PWKQSM2.mjs} +9 -9
  43. package/dist/{chunk-YHVXD5WW.mjs → chunk-CGPMMFUQ.mjs} +2 -2
  44. package/dist/{chunk-RZXUP2M6.mjs → chunk-CWZQMK63.mjs} +4 -4
  45. package/dist/{chunk-CXWZLA5O.mjs → chunk-ER475D6V.mjs} +49 -34
  46. package/dist/chunk-ER475D6V.mjs.map +1 -0
  47. package/dist/{chunk-BUT7X5F2.js → chunk-HCDICNYK.js} +3 -3
  48. package/dist/{chunk-V6P5JEPT.js → chunk-HE3P5RM7.js} +2 -2
  49. package/dist/{chunk-V6P5JEPT.js.map → chunk-HE3P5RM7.js.map} +1 -1
  50. package/dist/{chunk-GDKHOBJT.js → chunk-HT6T5R4U.js} +3 -3
  51. package/dist/{chunk-2O32EME6.js → chunk-JIJXHO5V.js} +36 -30
  52. package/dist/chunk-JIJXHO5V.js.map +1 -0
  53. package/dist/{chunk-NOYP2T77.js → chunk-JW3TK3NU.js} +5 -5
  54. package/dist/{chunk-5CFEVEAV.js → chunk-KGLHGLER.js} +54 -39
  55. package/dist/chunk-KGLHGLER.js.map +1 -0
  56. package/dist/{chunk-5JDAO4ZC.mjs → chunk-LZMC2QML.mjs} +3 -3
  57. package/dist/{chunk-KCWTVLMK.mjs → chunk-MG5QDUDI.mjs} +2 -2
  58. package/dist/{chunk-DCADU5QI.mjs → chunk-MNBV5FJI.mjs} +2 -2
  59. package/dist/{chunk-H73GATCU.js → chunk-NIPCK74T.js} +8 -8
  60. package/dist/chunk-O45HYLIV.js +67 -0
  61. package/dist/{chunk-FN6GVBCU.mjs → chunk-OHFX4S6R.mjs} +2 -2
  62. package/dist/{chunk-QY4UST5V.js → chunk-OMBFVTP2.js} +10 -10
  63. package/dist/{chunk-KWTSMLND.js → chunk-PJMQ2XEG.js} +4 -4
  64. package/dist/{chunk-IG3KWCQU.js → chunk-QAOZN4AX.js} +7 -7
  65. package/dist/{chunk-5FUMSWDD.js → chunk-SGLVWM4N.js} +3 -3
  66. package/dist/{chunk-ABWWUGTE.js → chunk-UQ6MTYIR.js} +30 -30
  67. package/dist/{chunk-ENRKCWJ6.js → chunk-UZHUVXRM.js} +5 -5
  68. package/dist/{chunk-WGGW6VCR.mjs → chunk-VZMQIJMK.mjs} +2 -2
  69. package/dist/{chunk-XGHB2EF3.js → chunk-W7IP4LDB.js} +11 -11
  70. package/dist/{chunk-DFDFJ4DX.mjs → chunk-WE4RFGT7.mjs} +19 -13
  71. package/dist/chunk-WE4RFGT7.mjs.map +1 -0
  72. package/dist/{chunk-6GUOLD7O.mjs → chunk-WGBEAP2F.mjs} +2 -2
  73. package/dist/{chunk-ILPTPB4U.mjs → chunk-YUMIJSUD.mjs} +2 -2
  74. package/dist/index.js +17 -17
  75. package/dist/index.mjs +16 -16
  76. package/dist/tsconfig.build.tsbuildinfo +1 -1
  77. package/dist/types/NotificationServicesController/NotificationServicesController.d.ts +5 -1
  78. package/dist/types/NotificationServicesController/NotificationServicesController.d.ts.map +1 -1
  79. package/dist/types/NotificationServicesPushController/NotificationServicesPushController.d.ts +6 -1
  80. package/dist/types/NotificationServicesPushController/NotificationServicesPushController.d.ts.map +1 -1
  81. package/package.json +4 -4
  82. package/dist/chunk-2O32EME6.js.map +0 -1
  83. package/dist/chunk-5CFEVEAV.js.map +0 -1
  84. package/dist/chunk-CXWZLA5O.mjs.map +0 -1
  85. package/dist/chunk-DFDFJ4DX.mjs.map +0 -1
  86. package/dist/chunk-J4D2NH6Y.mjs.map +0 -1
  87. package/dist/chunk-QOG3RCXM.js +0 -67
  88. /package/dist/{chunk-ZHAD55AN.mjs.map → chunk-2P5WP5NT.mjs.map} +0 -0
  89. /package/dist/{chunk-X42WN3FE.mjs.map → chunk-5FAAZCBK.mjs.map} +0 -0
  90. /package/dist/{chunk-4HOEZMSV.js.map → chunk-6FLC6CJD.js.map} +0 -0
  91. /package/dist/{chunk-YZYQYIKS.mjs.map → chunk-77QIITUL.mjs.map} +0 -0
  92. /package/dist/{chunk-GNN2XQW4.mjs.map → chunk-7PWKQSM2.mjs.map} +0 -0
  93. /package/dist/{chunk-YHVXD5WW.mjs.map → chunk-CGPMMFUQ.mjs.map} +0 -0
  94. /package/dist/{chunk-RZXUP2M6.mjs.map → chunk-CWZQMK63.mjs.map} +0 -0
  95. /package/dist/{chunk-BUT7X5F2.js.map → chunk-HCDICNYK.js.map} +0 -0
  96. /package/dist/{chunk-GDKHOBJT.js.map → chunk-HT6T5R4U.js.map} +0 -0
  97. /package/dist/{chunk-NOYP2T77.js.map → chunk-JW3TK3NU.js.map} +0 -0
  98. /package/dist/{chunk-5JDAO4ZC.mjs.map → chunk-LZMC2QML.mjs.map} +0 -0
  99. /package/dist/{chunk-KCWTVLMK.mjs.map → chunk-MG5QDUDI.mjs.map} +0 -0
  100. /package/dist/{chunk-DCADU5QI.mjs.map → chunk-MNBV5FJI.mjs.map} +0 -0
  101. /package/dist/{chunk-H73GATCU.js.map → chunk-NIPCK74T.js.map} +0 -0
  102. /package/dist/{chunk-QOG3RCXM.js.map → chunk-O45HYLIV.js.map} +0 -0
  103. /package/dist/{chunk-FN6GVBCU.mjs.map → chunk-OHFX4S6R.mjs.map} +0 -0
  104. /package/dist/{chunk-QY4UST5V.js.map → chunk-OMBFVTP2.js.map} +0 -0
  105. /package/dist/{chunk-KWTSMLND.js.map → chunk-PJMQ2XEG.js.map} +0 -0
  106. /package/dist/{chunk-IG3KWCQU.js.map → chunk-QAOZN4AX.js.map} +0 -0
  107. /package/dist/{chunk-5FUMSWDD.js.map → chunk-SGLVWM4N.js.map} +0 -0
  108. /package/dist/{chunk-ABWWUGTE.js.map → chunk-UQ6MTYIR.js.map} +0 -0
  109. /package/dist/{chunk-ENRKCWJ6.js.map → chunk-UZHUVXRM.js.map} +0 -0
  110. /package/dist/{chunk-WGGW6VCR.mjs.map → chunk-VZMQIJMK.mjs.map} +0 -0
  111. /package/dist/{chunk-XGHB2EF3.js.map → chunk-W7IP4LDB.js.map} +0 -0
  112. /package/dist/{chunk-6GUOLD7O.mjs.map → chunk-WGBEAP2F.mjs.map} +0 -0
  113. /package/dist/{chunk-ILPTPB4U.mjs.map → chunk-YUMIJSUD.mjs.map} +0 -0
@@ -3,21 +3,21 @@ import {
3
3
  } from "./chunk-B4ECJJ5C.mjs";
4
4
  import {
5
5
  ui_exports
6
- } from "./chunk-5JDAO4ZC.mjs";
6
+ } from "./chunk-LZMC2QML.mjs";
7
7
  import {
8
8
  constants_exports
9
- } from "./chunk-ZHAD55AN.mjs";
9
+ } from "./chunk-2P5WP5NT.mjs";
10
10
  import {
11
11
  processors_exports
12
- } from "./chunk-X42WN3FE.mjs";
12
+ } from "./chunk-5FAAZCBK.mjs";
13
13
  import {
14
14
  NotificationServicesController,
15
15
  defaultState
16
- } from "./chunk-DFDFJ4DX.mjs";
16
+ } from "./chunk-WE4RFGT7.mjs";
17
17
  import {
18
18
  processNotification,
19
19
  safeProcessNotification
20
- } from "./chunk-KCWTVLMK.mjs";
20
+ } from "./chunk-MG5QDUDI.mjs";
21
21
  import {
22
22
  processOnChainNotification
23
23
  } from "./chunk-BONB66A2.mjs";
@@ -32,10 +32,10 @@ import {
32
32
  NOTIFICATION_API_LIST_ENDPOINT,
33
33
  NOTIFICATION_API_MARK_ALL_AS_READ_ENDPOINT,
34
34
  TRIGGER_API_BATCH_ENDPOINT
35
- } from "./chunk-FN6GVBCU.mjs";
35
+ } from "./chunk-OHFX4S6R.mjs";
36
36
  import {
37
37
  initializeUserStorage
38
- } from "./chunk-ILPTPB4U.mjs";
38
+ } from "./chunk-YUMIJSUD.mjs";
39
39
  import {
40
40
  CHAIN_SYMBOLS,
41
41
  NOTIFICATION_CHAINS,
@@ -45,7 +45,7 @@ import {
45
45
  TRIGGER_TYPES,
46
46
  TRIGGER_TYPES_GROUPS,
47
47
  TRIGGER_TYPES_WALLET_SET
48
- } from "./chunk-J4D2NH6Y.mjs";
48
+ } from "./chunk-53F3SYYM.mjs";
49
49
  import {
50
50
  USER_STORAGE_VERSION,
51
51
  USER_STORAGE_VERSION_KEY
@@ -969,4 +969,4 @@ export {
969
969
  NotificationServicesController_default,
970
970
  NotificationServicesController_exports
971
971
  };
972
- //# sourceMappingURL=chunk-GNN2XQW4.mjs.map
972
+ //# sourceMappingURL=chunk-7PWKQSM2.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  processors_exports
3
- } from "./chunk-X42WN3FE.mjs";
3
+ } from "./chunk-5FAAZCBK.mjs";
4
4
  import {
5
5
  toRawOnChainNotification
6
6
  } from "./chunk-DINCLRZT.mjs";
@@ -93,4 +93,4 @@ export {
93
93
  listenToPushNotificationsReceived,
94
94
  listenToPushNotificationsClicked
95
95
  };
96
- //# sourceMappingURL=chunk-YHVXD5WW.mjs.map
96
+ //# sourceMappingURL=chunk-CGPMMFUQ.mjs.map
@@ -3,12 +3,12 @@ import {
3
3
  } from "./chunk-IOMDG67D.mjs";
4
4
  import {
5
5
  utils_exports
6
- } from "./chunk-DCADU5QI.mjs";
6
+ } from "./chunk-MNBV5FJI.mjs";
7
7
  import {
8
8
  createOnChainPushNotificationMessage,
9
9
  createOnChainPushNotificationMessages,
10
10
  isOnChainNotification
11
- } from "./chunk-6GUOLD7O.mjs";
11
+ } from "./chunk-WGBEAP2F.mjs";
12
12
  import {
13
13
  calcTokenAmount,
14
14
  formatAmount,
@@ -18,7 +18,7 @@ import {
18
18
  import {
19
19
  NotificationServicesPushController,
20
20
  defaultState
21
- } from "./chunk-CXWZLA5O.mjs";
21
+ } from "./chunk-ER475D6V.mjs";
22
22
  import {
23
23
  REGISTRATION_TOKENS_ENDPOINT
24
24
  } from "./chunk-IKWNHNJQ.mjs";
@@ -115,4 +115,4 @@ export {
115
115
  NotificationServicesPushController_default,
116
116
  NotificationServicesPushController_exports
117
117
  };
118
- //# sourceMappingURL=chunk-RZXUP2M6.mjs.map
118
+ //# sourceMappingURL=chunk-CWZQMK63.mjs.map
@@ -3,11 +3,11 @@ import {
3
3
  deactivatePushNotifications,
4
4
  listenToPushNotifications,
5
5
  updateTriggerPushNotifications
6
- } from "./chunk-WGGW6VCR.mjs";
6
+ } from "./chunk-VZMQIJMK.mjs";
7
7
  import {
8
8
  createRegToken,
9
9
  deleteRegToken
10
- } from "./chunk-YHVXD5WW.mjs";
10
+ } from "./chunk-CGPMMFUQ.mjs";
11
11
  import {
12
12
  __privateAdd,
13
13
  __privateGet,
@@ -51,33 +51,13 @@ var NotificationServicesPushController = class extends BaseController {
51
51
  __privateSet(this, _config, config);
52
52
  __privateMethod(this, _registerMessageHandlers, registerMessageHandlers_fn).call(this);
53
53
  }
54
- /**
55
- * Enables push notifications for the application.
56
- *
57
- * This method sets up the necessary infrastructure for handling push notifications by:
58
- * 1. Registering the service worker to listen for messages.
59
- * 2. Fetching the Firebase Cloud Messaging (FCM) token from Firebase.
60
- * 3. Sending the FCM token to the server responsible for sending notifications, to register the device.
61
- *
62
- * @param UUIDs - An array of UUIDs to enable push notifications for.
63
- */
64
- async enablePushNotifications(UUIDs) {
65
- if (!__privateGet(this, _config).isPushEnabled) {
66
- return;
54
+ async subscribeToPushNotifications() {
55
+ if (__privateGet(this, _pushListenerUnsubscribe)) {
56
+ __privateGet(this, _pushListenerUnsubscribe).call(this);
57
+ __privateSet(this, _pushListenerUnsubscribe, void 0);
67
58
  }
68
- const bearerToken = await __privateMethod(this, _getAndAssertBearerToken, getAndAssertBearerToken_fn).call(this);
69
59
  try {
70
- const regToken = await activatePushNotifications({
71
- bearerToken,
72
- triggers: UUIDs,
73
- env: __privateGet(this, _env),
74
- createRegToken,
75
- platform: __privateGet(this, _config).platform
76
- });
77
- if (!regToken) {
78
- return;
79
- }
80
- __privateGet(this, _pushListenerUnsubscribe) ?? __privateSet(this, _pushListenerUnsubscribe, await listenToPushNotifications({
60
+ __privateSet(this, _pushListenerUnsubscribe, await listenToPushNotifications({
81
61
  env: __privateGet(this, _env),
82
62
  listenToPushReceived: async (n) => {
83
63
  this.messagingSystem.publish(
@@ -96,13 +76,44 @@ var NotificationServicesPushController = class extends BaseController {
96
76
  __privateGet(this, _config).onPushNotificationClicked(e, n);
97
77
  }
98
78
  }));
99
- this.update((state) => {
100
- state.fcmToken = regToken;
101
- });
102
- } catch (error) {
103
- log.error("Failed to enable push notifications:", error);
104
- throw new Error("Failed to enable push notifications");
79
+ } catch (e) {
80
+ }
81
+ }
82
+ /**
83
+ * Enables push notifications for the application.
84
+ *
85
+ * This method sets up the necessary infrastructure for handling push notifications by:
86
+ * 1. Registering the service worker to listen for messages.
87
+ * 2. Fetching the Firebase Cloud Messaging (FCM) token from Firebase.
88
+ * 3. Sending the FCM token to the server responsible for sending notifications, to register the device.
89
+ *
90
+ * @param UUIDs - An array of UUIDs to enable push notifications for.
91
+ */
92
+ async enablePushNotifications(UUIDs) {
93
+ if (!__privateGet(this, _config).isPushEnabled) {
94
+ return;
105
95
  }
96
+ try {
97
+ const bearerToken = await __privateMethod(this, _getAndAssertBearerToken, getAndAssertBearerToken_fn).call(this).catch(
98
+ () => null
99
+ );
100
+ if (bearerToken) {
101
+ const regToken = await activatePushNotifications({
102
+ bearerToken,
103
+ triggers: UUIDs,
104
+ env: __privateGet(this, _env),
105
+ createRegToken,
106
+ platform: __privateGet(this, _config).platform
107
+ }).catch(() => null);
108
+ if (regToken) {
109
+ this.update((state) => {
110
+ state.fcmToken = regToken;
111
+ });
112
+ }
113
+ }
114
+ } catch {
115
+ }
116
+ await this.subscribeToPushNotifications();
106
117
  }
107
118
  /**
108
119
  * Disables push notifications for the application.
@@ -194,6 +205,10 @@ registerMessageHandlers_fn = function() {
194
205
  "NotificationServicesPushController:updateTriggerPushNotifications",
195
206
  this.updateTriggerPushNotifications.bind(this)
196
207
  );
208
+ this.messagingSystem.registerActionHandler(
209
+ "NotificationServicesPushController:subscribeToPushNotifications",
210
+ this.subscribeToPushNotifications.bind(this)
211
+ );
197
212
  };
198
213
  _getAndAssertBearerToken = new WeakSet();
199
214
  getAndAssertBearerToken_fn = async function() {
@@ -213,4 +228,4 @@ export {
213
228
  defaultState,
214
229
  NotificationServicesPushController
215
230
  };
216
- //# sourceMappingURL=chunk-CXWZLA5O.mjs.map
231
+ //# sourceMappingURL=chunk-ER475D6V.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/NotificationServicesPushController/NotificationServicesPushController.ts"],"sourcesContent":["import type {\n RestrictedControllerMessenger,\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { AuthenticationController } from '@metamask/profile-sync-controller';\nimport log from 'loglevel';\n\nimport type { Types } from '../NotificationServicesController';\nimport { createRegToken, deleteRegToken } from './services/push/push-web';\nimport {\n activatePushNotifications,\n deactivatePushNotifications,\n listenToPushNotifications,\n updateTriggerPushNotifications,\n} from './services/services';\nimport type { PushNotificationEnv } from './types';\n\nconst controllerName = 'NotificationServicesPushController';\n\nexport type NotificationServicesPushControllerState = {\n fcmToken: string;\n};\n\nexport type NotificationServicesPushControllerGetStateAction =\n ControllerGetStateAction<\n typeof controllerName,\n NotificationServicesPushControllerState\n >;\n\nexport type NotificationServicesPushControllerEnablePushNotificationsAction = {\n type: `${typeof controllerName}:enablePushNotifications`;\n handler: NotificationServicesPushController['enablePushNotifications'];\n};\nexport type NotificationServicesPushControllerDisablePushNotificationsAction = {\n type: `${typeof controllerName}:disablePushNotifications`;\n handler: NotificationServicesPushController['disablePushNotifications'];\n};\nexport type NotificationServicesPushControllerUpdateTriggerPushNotificationsAction =\n {\n type: `${typeof controllerName}:updateTriggerPushNotifications`;\n handler: NotificationServicesPushController['updateTriggerPushNotifications'];\n };\nexport type NotificationServicesPushControllerSubscribeToNotificationsAction = {\n type: `${typeof controllerName}:subscribeToPushNotifications`;\n handler: NotificationServicesPushController['subscribeToPushNotifications'];\n};\n\nexport type Actions =\n | NotificationServicesPushControllerGetStateAction\n | NotificationServicesPushControllerEnablePushNotificationsAction\n | NotificationServicesPushControllerDisablePushNotificationsAction\n | NotificationServicesPushControllerUpdateTriggerPushNotificationsAction\n | NotificationServicesPushControllerSubscribeToNotificationsAction;\n\nexport type AllowedActions =\n AuthenticationController.AuthenticationControllerGetBearerToken;\n\nexport type NotificationServicesPushControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof controllerName,\n NotificationServicesPushControllerState\n >;\n\nexport type NotificationServicesPushControllerOnNewNotificationEvent = {\n type: `${typeof controllerName}:onNewNotifications`;\n payload: [Types.INotification];\n};\n\nexport type NotificationServicesPushControllerPushNotificationClickedEvent = {\n type: `${typeof controllerName}:pushNotificationClicked`;\n payload: [Types.INotification];\n};\n\nexport type Events =\n | NotificationServicesPushControllerStateChangeEvent\n | NotificationServicesPushControllerOnNewNotificationEvent\n | NotificationServicesPushControllerPushNotificationClickedEvent;\n\nexport type AllowedEvents = never;\n\nexport type NotificationServicesPushControllerMessenger =\n RestrictedControllerMessenger<\n typeof controllerName,\n Actions | AllowedActions,\n Events | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n >;\n\nexport const defaultState: NotificationServicesPushControllerState = {\n fcmToken: '',\n};\nconst metadata: StateMetadata<NotificationServicesPushControllerState> = {\n fcmToken: {\n persist: true,\n anonymous: true,\n },\n};\n\ntype ControllerConfig = {\n /**\n * Config to turn on/off push notifications.\n * This is currently linked to MV3 builds on extension.\n */\n isPushEnabled: boolean;\n\n /**\n * Must handle when a push notification is received.\n * You must call `registration.showNotification` or equivalent to show the notification on web/mobile\n */\n onPushNotificationReceived: (\n notification: Types.INotification,\n ) => void | Promise<void>;\n\n /**\n * Must handle when a push notification is clicked.\n * You must call `event.notification.close();` or equivalent for closing and opening notification in a new window.\n */\n onPushNotificationClicked: (\n event: NotificationEvent,\n notification?: Types.INotification,\n ) => void;\n\n /**\n * determine the config used for push notification services\n */\n platform: 'extension' | 'mobile';\n};\n\n/**\n * Manages push notifications for the application, including enabling, disabling, and updating triggers for push notifications.\n * This controller integrates with Firebase Cloud Messaging (FCM) to handle the registration and management of push notifications.\n * It is responsible for registering and unregistering the service worker that listens for push notifications,\n * managing the FCM token, and communicating with the server to register or unregister the device for push notifications.\n * Additionally, it provides functionality to update the server with new UUIDs that should trigger push notifications.\n *\n * @augments {BaseController<typeof controllerName, NotificationServicesPushControllerState, NotificationServicesPushControllerMessenger>}\n */\nexport default class NotificationServicesPushController extends BaseController<\n typeof controllerName,\n NotificationServicesPushControllerState,\n NotificationServicesPushControllerMessenger\n> {\n #pushListenerUnsubscribe: (() => void) | undefined = undefined;\n\n #env: PushNotificationEnv;\n\n #config: ControllerConfig;\n\n constructor({\n messenger,\n state,\n env,\n config,\n }: {\n messenger: NotificationServicesPushControllerMessenger;\n state: NotificationServicesPushControllerState;\n env: PushNotificationEnv;\n config: ControllerConfig;\n }) {\n super({\n messenger,\n metadata,\n name: controllerName,\n state: { ...defaultState, ...state },\n });\n\n this.#env = env;\n this.#config = config;\n\n this.#registerMessageHandlers();\n }\n\n #registerMessageHandlers(): void {\n this.messagingSystem.registerActionHandler(\n 'NotificationServicesPushController:enablePushNotifications',\n this.enablePushNotifications.bind(this),\n );\n this.messagingSystem.registerActionHandler(\n 'NotificationServicesPushController:disablePushNotifications',\n this.disablePushNotifications.bind(this),\n );\n this.messagingSystem.registerActionHandler(\n 'NotificationServicesPushController:updateTriggerPushNotifications',\n this.updateTriggerPushNotifications.bind(this),\n );\n this.messagingSystem.registerActionHandler(\n 'NotificationServicesPushController:subscribeToPushNotifications',\n this.subscribeToPushNotifications.bind(this),\n );\n }\n\n async #getAndAssertBearerToken() {\n const bearerToken = await this.messagingSystem.call(\n 'AuthenticationController:getBearerToken',\n );\n if (!bearerToken) {\n log.error(\n 'Failed to enable push notifications: BearerToken token is missing.',\n );\n throw new Error('BearerToken token is missing');\n }\n\n return bearerToken;\n }\n\n async subscribeToPushNotifications() {\n if (this.#pushListenerUnsubscribe) {\n this.#pushListenerUnsubscribe();\n this.#pushListenerUnsubscribe = undefined;\n }\n\n try {\n this.#pushListenerUnsubscribe = await listenToPushNotifications({\n env: this.#env,\n listenToPushReceived: async (n) => {\n this.messagingSystem.publish(\n 'NotificationServicesPushController:onNewNotifications',\n n,\n );\n await this.#config.onPushNotificationReceived(n);\n },\n listenToPushClicked: (e, n) => {\n if (n) {\n this.messagingSystem.publish(\n 'NotificationServicesPushController:pushNotificationClicked',\n n,\n );\n }\n\n this.#config.onPushNotificationClicked(e, n);\n },\n });\n } catch (e) {\n // Do nothing, we are silently failing if push notification registration fails\n }\n }\n\n /**\n * Enables push notifications for the application.\n *\n * This method sets up the necessary infrastructure for handling push notifications by:\n * 1. Registering the service worker to listen for messages.\n * 2. Fetching the Firebase Cloud Messaging (FCM) token from Firebase.\n * 3. Sending the FCM token to the server responsible for sending notifications, to register the device.\n *\n * @param UUIDs - An array of UUIDs to enable push notifications for.\n */\n async enablePushNotifications(UUIDs: string[]) {\n if (!this.#config.isPushEnabled) {\n return;\n }\n\n // Handle creating new reg token (if available)\n try {\n const bearerToken = await this.#getAndAssertBearerToken().catch(\n () => null,\n );\n\n // If there is a bearer token, lets try to refresh/create new reg token\n if (bearerToken) {\n // Activate Push Notifications\n const regToken = await activatePushNotifications({\n bearerToken,\n triggers: UUIDs,\n env: this.#env,\n createRegToken,\n platform: this.#config.platform,\n }).catch(() => null);\n\n if (regToken) {\n this.update((state) => {\n state.fcmToken = regToken;\n });\n }\n }\n } catch {\n // Do nothing, we are silently failing\n }\n\n // New token created, (re)subscribe to push notifications\n await this.subscribeToPushNotifications();\n }\n\n /**\n * Disables push notifications for the application.\n * This method handles the process of disabling push notifications by:\n * 1. Unregistering the service worker to stop listening for messages.\n * 2. Sending a request to the server to unregister the device using the FCM token.\n * 3. Removing the FCM token from the state to complete the process.\n *\n * @param UUIDs - An array of UUIDs for which push notifications should be disabled.\n */\n async disablePushNotifications(UUIDs: string[]) {\n if (!this.#config.isPushEnabled) {\n return;\n }\n\n const bearerToken = await this.#getAndAssertBearerToken();\n let isPushNotificationsDisabled: boolean;\n\n try {\n // Send a request to the server to unregister the token/device\n isPushNotificationsDisabled = await deactivatePushNotifications({\n bearerToken,\n triggers: UUIDs,\n env: this.#env,\n deleteRegToken,\n regToken: this.state.fcmToken,\n });\n } catch (error) {\n const errorMessage = `Failed to disable push notifications: ${\n error as string\n }`;\n log.error(errorMessage);\n throw new Error(errorMessage);\n }\n\n // Remove the FCM token from the state\n if (!isPushNotificationsDisabled) {\n return;\n }\n\n // Unsubscribe from push notifications\n this.#pushListenerUnsubscribe?.();\n\n // Update State\n if (isPushNotificationsDisabled) {\n this.update((state) => {\n state.fcmToken = '';\n });\n }\n }\n\n /**\n * Updates the triggers for push notifications.\n * This method is responsible for updating the server with the new set of UUIDs that should trigger push notifications.\n * It uses the current FCM token and a BearerToken for authentication.\n *\n * @param UUIDs - An array of UUIDs that should trigger push notifications.\n */\n async updateTriggerPushNotifications(UUIDs: string[]) {\n if (!this.#config.isPushEnabled) {\n return;\n }\n\n const bearerToken = await this.#getAndAssertBearerToken();\n\n try {\n const { fcmToken } = await updateTriggerPushNotifications({\n bearerToken,\n triggers: UUIDs,\n env: this.#env,\n createRegToken,\n deleteRegToken,\n platform: this.#config.platform,\n regToken: this.state.fcmToken,\n });\n\n // update the state with the new FCM token\n if (fcmToken) {\n this.update((state) => {\n state.fcmToken = fcmToken;\n });\n }\n } catch (error) {\n const errorMessage = `Failed to update triggers for push notifications: ${\n error as string\n }`;\n log.error(errorMessage);\n throw new Error(errorMessage);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAMA,SAAS,sBAAsB;AAE/B,OAAO,SAAS;AAYhB,IAAM,iBAAiB;AAwEhB,IAAM,eAAwD;AAAA,EACnE,UAAU;AACZ;AACA,IAAM,WAAmE;AAAA,EACvE,UAAU;AAAA,IACR,SAAS;AAAA,IACT,WAAW;AAAA,EACb;AACF;AApGA;AA6IA,IAAqB,qCAArB,cAAgE,eAI9D;AAAA,EAOA,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAKG;AACD,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN,OAAO,EAAE,GAAG,cAAc,GAAG,MAAM;AAAA,IACrC,CAAC;AAQH;AAmBA,uBAAM;AAjDN,iDAAqD;AAErD;AAEA;AAoBE,uBAAK,MAAO;AACZ,uBAAK,SAAU;AAEf,0BAAK,sDAAL;AAAA,EACF;AAAA,EAmCA,MAAM,+BAA+B;AACnC,QAAI,mBAAK,2BAA0B;AACjC,yBAAK,0BAAL;AACA,yBAAK,0BAA2B;AAAA,IAClC;AAEA,QAAI;AACF,yBAAK,0BAA2B,MAAM,0BAA0B;AAAA,QAC9D,KAAK,mBAAK;AAAA,QACV,sBAAsB,OAAO,MAAM;AACjC,eAAK,gBAAgB;AAAA,YACnB;AAAA,YACA;AAAA,UACF;AACA,gBAAM,mBAAK,SAAQ,2BAA2B,CAAC;AAAA,QACjD;AAAA,QACA,qBAAqB,CAAC,GAAG,MAAM;AAC7B,cAAI,GAAG;AACL,iBAAK,gBAAgB;AAAA,cACnB;AAAA,cACA;AAAA,YACF;AAAA,UACF;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AC,aAAa;AAChB,QAAI;AAAA,MACF;AAAA,IACF;AACA,UAAM,IAAI,MAAM,8BAA8B;AAAA,EAChD;AAEA,SAAO;AACT;","names":[]}
@@ -4,7 +4,7 @@
4
4
  var _chunkEJ52BDLBjs = require('./chunk-EJ52BDLB.js');
5
5
 
6
6
 
7
- var _chunkQY4UST5Vjs = require('./chunk-QY4UST5V.js');
7
+ var _chunkOMBFVTP2js = require('./chunk-OMBFVTP2.js');
8
8
 
9
9
  // src/NotificationServicesPushController/utils/get-notification-message.ts
10
10
  var createOnChainPushNotificationMessages = (translationKeys) => {
@@ -165,7 +165,7 @@ var createOnChainPushNotificationMessages = (translationKeys) => {
165
165
  };
166
166
  };
167
167
  function getChainSymbol(chainId) {
168
- return _chunkQY4UST5Vjs.constants_exports.CHAIN_SYMBOLS[chainId] ?? null;
168
+ return _chunkOMBFVTP2js.constants_exports.CHAIN_SYMBOLS[chainId] ?? null;
169
169
  }
170
170
  function isOnChainNotification(n) {
171
171
  const assumed = n;
@@ -204,4 +204,4 @@ function createOnChainPushNotificationMessage(n, translations) {
204
204
 
205
205
 
206
206
  exports.createOnChainPushNotificationMessages = createOnChainPushNotificationMessages; exports.isOnChainNotification = isOnChainNotification; exports.createOnChainPushNotificationMessage = createOnChainPushNotificationMessage;
207
- //# sourceMappingURL=chunk-BUT7X5F2.js.map
207
+ //# sourceMappingURL=chunk-HCDICNYK.js.map
@@ -55,7 +55,7 @@ var CHAIN_SYMBOLS = {
55
55
  [NOTIFICATION_CHAINS.ETHEREUM]: "ETH",
56
56
  [NOTIFICATION_CHAINS.OPTIMISM]: "ETH",
57
57
  [NOTIFICATION_CHAINS.BSC]: "BNB",
58
- [NOTIFICATION_CHAINS.POLYGON]: "MATIC",
58
+ [NOTIFICATION_CHAINS.POLYGON]: "POL",
59
59
  [NOTIFICATION_CHAINS.ARBITRUM]: "ETH",
60
60
  [NOTIFICATION_CHAINS.AVALANCHE]: "AVAX",
61
61
  [NOTIFICATION_CHAINS.LINEA]: "ETH"
@@ -175,4 +175,4 @@ var TRIGGERS = {
175
175
 
176
176
 
177
177
  exports.TRIGGER_TYPES = TRIGGER_TYPES; exports.TRIGGER_TYPES_WALLET_SET = TRIGGER_TYPES_WALLET_SET; exports.TRIGGER_TYPES_GROUPS = TRIGGER_TYPES_GROUPS; exports.NOTIFICATION_CHAINS_ID = NOTIFICATION_CHAINS_ID; exports.NOTIFICATION_CHAINS = NOTIFICATION_CHAINS; exports.CHAIN_SYMBOLS = CHAIN_SYMBOLS; exports.SUPPORTED_CHAINS = SUPPORTED_CHAINS; exports.TRIGGERS = TRIGGERS;
178
- //# sourceMappingURL=chunk-V6P5JEPT.js.map
178
+ //# sourceMappingURL=chunk-HE3P5RM7.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/NotificationServicesController/constants/notification-schema.ts"],"names":["TRIGGER_TYPES","TRIGGER_TYPES_GROUPS"],"mappings":";AAGO,IAAK,gBAAL,kBAAKA,mBAAL;AACL,EAAAA,eAAA,2BAAwB;AACxB,EAAAA,eAAA,6BAA0B;AAC1B,EAAAA,eAAA,gBAAa;AACb,EAAAA,eAAA,oBAAiB;AACjB,EAAAA,eAAA,cAAW;AACX,EAAAA,eAAA,kBAAe;AACf,EAAAA,eAAA,gCAA6B;AAC7B,EAAAA,eAAA,kCAA+B;AAC/B,EAAAA,eAAA,0BAAuB;AACvB,EAAAA,eAAA,+BAA4B;AAC5B,EAAAA,eAAA,+BAA4B;AAC5B,EAAAA,eAAA,sCAAmC;AACnC,EAAAA,eAAA,iBAAc;AACd,EAAAA,eAAA,qBAAkB;AAClB,EAAAA,eAAA,kBAAe;AACf,EAAAA,eAAA,sBAAmB;AAhBT,SAAAA;AAAA,GAAA;AAmBL,IAAM,2BAAwC,oBAAI,IAAI;AAAA,EAC3D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAA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EACA,CAAC,iEAA0C,GAAG;AAAA,IAC5C,kBAAkB,CAAC,oBAAoB,QAAQ;AAAA,EACjD;AAAA,EACA,CAAC,iDAAkC,GAAG;AAAA,IACpC,kBAAkB,CAAC,oBAAoB,QAAQ;AAAA,EACjD;AAAA,EACA,CAAC,2DAAuC,GAAG;AAAA,IACzC,kBAAkB,CAAC,oBAAoB,QAAQ;AAAA,EACjD;AAAA,EACA,CAAC,2DAAuC,GAAG;AAAA,IACzC,kBAAkB,CAAC,oBAAoB,QAAQ;AAAA,EACjD;AACF","sourcesContent":["import type { Compute } from '../types/type-utils';\n\n/* eslint-disable @typescript-eslint/naming-convention */\nexport enum TRIGGER_TYPES {\n FEATURES_ANNOUNCEMENT = 'features_announcement',\n METAMASK_SWAP_COMPLETED = 'metamask_swap_completed',\n ERC20_SENT = 'erc20_sent',\n ERC20_RECEIVED = 'erc20_received',\n ETH_SENT = 'eth_sent',\n ETH_RECEIVED = 'eth_received',\n ROCKETPOOL_STAKE_COMPLETED = 'rocketpool_stake_completed',\n ROCKETPOOL_UNSTAKE_COMPLETED = 'rocketpool_unstake_completed',\n LIDO_STAKE_COMPLETED = 'lido_stake_completed',\n LIDO_WITHDRAWAL_REQUESTED = 'lido_withdrawal_requested',\n LIDO_WITHDRAWAL_COMPLETED = 'lido_withdrawal_completed',\n LIDO_STAKE_READY_TO_BE_WITHDRAWN = 'lido_stake_ready_to_be_withdrawn',\n ERC721_SENT = 'erc721_sent',\n ERC721_RECEIVED = 'erc721_received',\n ERC1155_SENT = 'erc1155_sent',\n ERC1155_RECEIVED = 'erc1155_received',\n}\n\nexport const TRIGGER_TYPES_WALLET_SET: Set<string> = new Set([\n TRIGGER_TYPES.METAMASK_SWAP_COMPLETED,\n TRIGGER_TYPES.ERC20_SENT,\n TRIGGER_TYPES.ERC20_RECEIVED,\n TRIGGER_TYPES.ETH_SENT,\n TRIGGER_TYPES.ETH_RECEIVED,\n TRIGGER_TYPES.ROCKETPOOL_STAKE_COMPLETED,\n TRIGGER_TYPES.ROCKETPOOL_UNSTAKE_COMPLETED,\n TRIGGER_TYPES.LIDO_STAKE_COMPLETED,\n TRIGGER_TYPES.LIDO_WITHDRAWAL_REQUESTED,\n TRIGGER_TYPES.LIDO_WITHDRAWAL_COMPLETED,\n TRIGGER_TYPES.LIDO_STAKE_READY_TO_BE_WITHDRAWN,\n TRIGGER_TYPES.ERC721_SENT,\n TRIGGER_TYPES.ERC721_RECEIVED,\n TRIGGER_TYPES.ERC1155_SENT,\n TRIGGER_TYPES.ERC1155_RECEIVED,\n]) satisfies Set<Exclude<TRIGGER_TYPES, TRIGGER_TYPES.FEATURES_ANNOUNCEMENT>>;\n\nexport enum TRIGGER_TYPES_GROUPS {\n RECEIVED = 'received',\n SENT = 'sent',\n DEFI = 'defi',\n}\n\nexport const NOTIFICATION_CHAINS_ID = {\n ETHEREUM: '1',\n OPTIMISM: '10',\n BSC: '56',\n POLYGON: '137',\n ARBITRUM: '42161',\n AVALANCHE: '43114',\n LINEA: '59144',\n} as const;\n\ntype ToPrimitiveKeys<TObj> = Compute<{\n [K in keyof TObj]: TObj[K] extends string ? string : TObj[K];\n}>;\nexport const NOTIFICATION_CHAINS: ToPrimitiveKeys<\n typeof NOTIFICATION_CHAINS_ID\n> = NOTIFICATION_CHAINS_ID;\n\nexport const CHAIN_SYMBOLS = {\n [NOTIFICATION_CHAINS.ETHEREUM]: 'ETH',\n [NOTIFICATION_CHAINS.OPTIMISM]: 'ETH',\n [NOTIFICATION_CHAINS.BSC]: 'BNB',\n [NOTIFICATION_CHAINS.POLYGON]: 'MATIC',\n [NOTIFICATION_CHAINS.ARBITRUM]: 'ETH',\n [NOTIFICATION_CHAINS.AVALANCHE]: 'AVAX',\n [NOTIFICATION_CHAINS.LINEA]: 'ETH',\n};\n\nexport const SUPPORTED_CHAINS = [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.OPTIMISM,\n NOTIFICATION_CHAINS.BSC,\n NOTIFICATION_CHAINS.POLYGON,\n NOTIFICATION_CHAINS.ARBITRUM,\n NOTIFICATION_CHAINS.AVALANCHE,\n NOTIFICATION_CHAINS.LINEA,\n];\n\nexport type Trigger = {\n supported_chains: (typeof SUPPORTED_CHAINS)[number][];\n};\n\nexport const TRIGGERS: Partial<Record<TRIGGER_TYPES, Trigger>> = {\n [TRIGGER_TYPES.METAMASK_SWAP_COMPLETED]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.OPTIMISM,\n NOTIFICATION_CHAINS.BSC,\n NOTIFICATION_CHAINS.POLYGON,\n NOTIFICATION_CHAINS.ARBITRUM,\n NOTIFICATION_CHAINS.AVALANCHE,\n ],\n },\n [TRIGGER_TYPES.ERC20_SENT]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.OPTIMISM,\n NOTIFICATION_CHAINS.BSC,\n NOTIFICATION_CHAINS.POLYGON,\n NOTIFICATION_CHAINS.ARBITRUM,\n NOTIFICATION_CHAINS.AVALANCHE,\n NOTIFICATION_CHAINS.LINEA,\n ],\n },\n [TRIGGER_TYPES.ERC20_RECEIVED]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.OPTIMISM,\n NOTIFICATION_CHAINS.BSC,\n NOTIFICATION_CHAINS.POLYGON,\n NOTIFICATION_CHAINS.ARBITRUM,\n NOTIFICATION_CHAINS.AVALANCHE,\n NOTIFICATION_CHAINS.LINEA,\n ],\n },\n [TRIGGER_TYPES.ERC721_SENT]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.POLYGON,\n ],\n },\n [TRIGGER_TYPES.ERC721_RECEIVED]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.POLYGON,\n ],\n },\n [TRIGGER_TYPES.ERC1155_SENT]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.POLYGON,\n ],\n },\n [TRIGGER_TYPES.ERC1155_RECEIVED]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.POLYGON,\n ],\n },\n [TRIGGER_TYPES.ETH_SENT]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.OPTIMISM,\n NOTIFICATION_CHAINS.BSC,\n NOTIFICATION_CHAINS.POLYGON,\n NOTIFICATION_CHAINS.ARBITRUM,\n NOTIFICATION_CHAINS.AVALANCHE,\n NOTIFICATION_CHAINS.LINEA,\n ],\n },\n [TRIGGER_TYPES.ETH_RECEIVED]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.OPTIMISM,\n NOTIFICATION_CHAINS.BSC,\n NOTIFICATION_CHAINS.POLYGON,\n NOTIFICATION_CHAINS.ARBITRUM,\n NOTIFICATION_CHAINS.AVALANCHE,\n NOTIFICATION_CHAINS.LINEA,\n ],\n },\n [TRIGGER_TYPES.ROCKETPOOL_STAKE_COMPLETED]: {\n supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],\n },\n [TRIGGER_TYPES.ROCKETPOOL_UNSTAKE_COMPLETED]: {\n supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],\n },\n [TRIGGER_TYPES.LIDO_STAKE_COMPLETED]: {\n supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],\n },\n [TRIGGER_TYPES.LIDO_WITHDRAWAL_REQUESTED]: {\n supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],\n },\n [TRIGGER_TYPES.LIDO_WITHDRAWAL_COMPLETED]: {\n supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],\n },\n};\n"]}
1
+ {"version":3,"sources":["../src/NotificationServicesController/constants/notification-schema.ts"],"names":["TRIGGER_TYPES","TRIGGER_TYPES_GROUPS"],"mappings":";AAGO,IAAK,gBAAL,kBAAK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A,EACA,CAAC,yCAA8B,GAAG;AAAA,IAChC,kBAAkB;AAAA,MAChB,oBAAoB;AAAA,MACpB,oBAAoB;AAAA,IACtB;AAAA,EACF;AAAA,EACA,CAAC,yBAAsB,GAAG;AAAA,IACxB,kBAAkB;AAAA,MAChB,oBAAoB;AAAA,MACpB,oBAAoB;AAAA,MACpB,oBAAoB;AAAA,MACpB,oBAAoB;AAAA,MACpB,oBAAoB;AAAA,MACpB,oBAAoB;AAAA,MACpB,oBAAoB;AAAA,IACtB;AAAA,EACF;AAAA,EACA,CAAC,iCAA0B,GAAG;AAAA,IAC5B,kBAAkB;AAAA,MAChB,oBAAoB;AAAA,MACpB,oBAAoB;AAAA,MACpB,oBAAoB;AAAA,MACpB,oBAAoB;AAAA,MACpB,oBAAoB;AAAA,MACpB,oBAAoB;AAAA,MACpB,oBAAoB;AAAA,IACtB;AAAA,EACF;AAAA,EACA,CAAC,6DAAwC,GAAG;AAAA,IAC1C,kBAAkB,CAAC,oBAAoB,QAAQ;AAAA,EACjD;AAAA,EACA,CAAC,iEAA0C,GAAG;AAAA,IAC5C,kBAAkB,CAAC,oBAAoB,QAAQ;AAAA,EACjD;AAAA,EACA,CAAC,iDAAkC,GAAG;AAAA,IACpC,kBAAkB,CAAC,oBAAoB,QAAQ;AAAA,EACjD;AAAA,EACA,CAAC,2DAAuC,GAAG;AAAA,IACzC,kBAAkB,CAAC,oBAAoB,QAAQ;AAAA,EACjD;AAAA,EACA,CAAC,2DAAuC,GAAG;AAAA,IACzC,kBAAkB,CAAC,oBAAoB,QAAQ;AAAA,EACjD;AACF","sourcesContent":["import type { Compute } from '../types/type-utils';\n\n/* eslint-disable @typescript-eslint/naming-convention */\nexport enum TRIGGER_TYPES {\n FEATURES_ANNOUNCEMENT = 'features_announcement',\n METAMASK_SWAP_COMPLETED = 'metamask_swap_completed',\n ERC20_SENT = 'erc20_sent',\n ERC20_RECEIVED = 'erc20_received',\n ETH_SENT = 'eth_sent',\n ETH_RECEIVED = 'eth_received',\n ROCKETPOOL_STAKE_COMPLETED = 'rocketpool_stake_completed',\n ROCKETPOOL_UNSTAKE_COMPLETED = 'rocketpool_unstake_completed',\n LIDO_STAKE_COMPLETED = 'lido_stake_completed',\n LIDO_WITHDRAWAL_REQUESTED = 'lido_withdrawal_requested',\n LIDO_WITHDRAWAL_COMPLETED = 'lido_withdrawal_completed',\n LIDO_STAKE_READY_TO_BE_WITHDRAWN = 'lido_stake_ready_to_be_withdrawn',\n ERC721_SENT = 'erc721_sent',\n ERC721_RECEIVED = 'erc721_received',\n ERC1155_SENT = 'erc1155_sent',\n ERC1155_RECEIVED = 'erc1155_received',\n}\n\nexport const TRIGGER_TYPES_WALLET_SET: Set<string> = new Set([\n TRIGGER_TYPES.METAMASK_SWAP_COMPLETED,\n TRIGGER_TYPES.ERC20_SENT,\n TRIGGER_TYPES.ERC20_RECEIVED,\n TRIGGER_TYPES.ETH_SENT,\n TRIGGER_TYPES.ETH_RECEIVED,\n TRIGGER_TYPES.ROCKETPOOL_STAKE_COMPLETED,\n TRIGGER_TYPES.ROCKETPOOL_UNSTAKE_COMPLETED,\n TRIGGER_TYPES.LIDO_STAKE_COMPLETED,\n TRIGGER_TYPES.LIDO_WITHDRAWAL_REQUESTED,\n TRIGGER_TYPES.LIDO_WITHDRAWAL_COMPLETED,\n TRIGGER_TYPES.LIDO_STAKE_READY_TO_BE_WITHDRAWN,\n TRIGGER_TYPES.ERC721_SENT,\n TRIGGER_TYPES.ERC721_RECEIVED,\n TRIGGER_TYPES.ERC1155_SENT,\n TRIGGER_TYPES.ERC1155_RECEIVED,\n]) satisfies Set<Exclude<TRIGGER_TYPES, TRIGGER_TYPES.FEATURES_ANNOUNCEMENT>>;\n\nexport enum TRIGGER_TYPES_GROUPS {\n RECEIVED = 'received',\n SENT = 'sent',\n DEFI = 'defi',\n}\n\nexport const NOTIFICATION_CHAINS_ID = {\n ETHEREUM: '1',\n OPTIMISM: '10',\n BSC: '56',\n POLYGON: '137',\n ARBITRUM: '42161',\n AVALANCHE: '43114',\n LINEA: '59144',\n} as const;\n\ntype ToPrimitiveKeys<TObj> = Compute<{\n [K in keyof TObj]: TObj[K] extends string ? string : TObj[K];\n}>;\nexport const NOTIFICATION_CHAINS: ToPrimitiveKeys<\n typeof NOTIFICATION_CHAINS_ID\n> = NOTIFICATION_CHAINS_ID;\n\nexport const CHAIN_SYMBOLS = {\n [NOTIFICATION_CHAINS.ETHEREUM]: 'ETH',\n [NOTIFICATION_CHAINS.OPTIMISM]: 'ETH',\n [NOTIFICATION_CHAINS.BSC]: 'BNB',\n [NOTIFICATION_CHAINS.POLYGON]: 'POL',\n [NOTIFICATION_CHAINS.ARBITRUM]: 'ETH',\n [NOTIFICATION_CHAINS.AVALANCHE]: 'AVAX',\n [NOTIFICATION_CHAINS.LINEA]: 'ETH',\n};\n\nexport const SUPPORTED_CHAINS = [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.OPTIMISM,\n NOTIFICATION_CHAINS.BSC,\n NOTIFICATION_CHAINS.POLYGON,\n NOTIFICATION_CHAINS.ARBITRUM,\n NOTIFICATION_CHAINS.AVALANCHE,\n NOTIFICATION_CHAINS.LINEA,\n];\n\nexport type Trigger = {\n supported_chains: (typeof SUPPORTED_CHAINS)[number][];\n};\n\nexport const TRIGGERS: Partial<Record<TRIGGER_TYPES, Trigger>> = {\n [TRIGGER_TYPES.METAMASK_SWAP_COMPLETED]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.OPTIMISM,\n NOTIFICATION_CHAINS.BSC,\n NOTIFICATION_CHAINS.POLYGON,\n NOTIFICATION_CHAINS.ARBITRUM,\n NOTIFICATION_CHAINS.AVALANCHE,\n ],\n },\n [TRIGGER_TYPES.ERC20_SENT]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.OPTIMISM,\n NOTIFICATION_CHAINS.BSC,\n NOTIFICATION_CHAINS.POLYGON,\n NOTIFICATION_CHAINS.ARBITRUM,\n NOTIFICATION_CHAINS.AVALANCHE,\n NOTIFICATION_CHAINS.LINEA,\n ],\n },\n [TRIGGER_TYPES.ERC20_RECEIVED]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.OPTIMISM,\n NOTIFICATION_CHAINS.BSC,\n NOTIFICATION_CHAINS.POLYGON,\n NOTIFICATION_CHAINS.ARBITRUM,\n NOTIFICATION_CHAINS.AVALANCHE,\n NOTIFICATION_CHAINS.LINEA,\n ],\n },\n [TRIGGER_TYPES.ERC721_SENT]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.POLYGON,\n ],\n },\n [TRIGGER_TYPES.ERC721_RECEIVED]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.POLYGON,\n ],\n },\n [TRIGGER_TYPES.ERC1155_SENT]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.POLYGON,\n ],\n },\n [TRIGGER_TYPES.ERC1155_RECEIVED]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.POLYGON,\n ],\n },\n [TRIGGER_TYPES.ETH_SENT]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.OPTIMISM,\n NOTIFICATION_CHAINS.BSC,\n NOTIFICATION_CHAINS.POLYGON,\n NOTIFICATION_CHAINS.ARBITRUM,\n NOTIFICATION_CHAINS.AVALANCHE,\n NOTIFICATION_CHAINS.LINEA,\n ],\n },\n [TRIGGER_TYPES.ETH_RECEIVED]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.OPTIMISM,\n NOTIFICATION_CHAINS.BSC,\n NOTIFICATION_CHAINS.POLYGON,\n NOTIFICATION_CHAINS.ARBITRUM,\n NOTIFICATION_CHAINS.AVALANCHE,\n NOTIFICATION_CHAINS.LINEA,\n ],\n },\n [TRIGGER_TYPES.ROCKETPOOL_STAKE_COMPLETED]: {\n supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],\n },\n [TRIGGER_TYPES.ROCKETPOOL_UNSTAKE_COMPLETED]: {\n supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],\n },\n [TRIGGER_TYPES.LIDO_STAKE_COMPLETED]: {\n supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],\n },\n [TRIGGER_TYPES.LIDO_WITHDRAWAL_REQUESTED]: {\n supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],\n },\n [TRIGGER_TYPES.LIDO_WITHDRAWAL_COMPLETED]: {\n supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],\n },\n};\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
2
 
3
- var _chunkKWTSMLNDjs = require('./chunk-KWTSMLND.js');
3
+ var _chunkPJMQ2XEGjs = require('./chunk-PJMQ2XEG.js');
4
4
 
5
5
 
6
6
  var _chunkDT6SLUWJjs = require('./chunk-DT6SLUWJ.js');
@@ -63,7 +63,7 @@ async function listenToPushNotificationsReceived(env, handler) {
63
63
  return;
64
64
  }
65
65
  const notificationData = _chunkDT6SLUWJjs.toRawOnChainNotification.call(void 0, data);
66
- const notification = _chunkKWTSMLNDjs.processors_exports.processNotification(notificationData);
66
+ const notification = _chunkPJMQ2XEGjs.processors_exports.processNotification(notificationData);
67
67
  await handler(notification);
68
68
  } catch (error) {
69
69
  _loglevel2.default.error("Unable to send push notification:", {
@@ -93,4 +93,4 @@ function listenToPushNotificationsClicked(handler) {
93
93
 
94
94
 
95
95
  exports.createRegToken = createRegToken; exports.deleteRegToken = deleteRegToken; exports.listenToPushNotificationsReceived = listenToPushNotificationsReceived; exports.listenToPushNotificationsClicked = listenToPushNotificationsClicked;
96
- //# sourceMappingURL=chunk-GDKHOBJT.js.map
96
+ //# sourceMappingURL=chunk-HT6T5R4U.js.map
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
2
 
3
- var _chunk5FUMSWDDjs = require('./chunk-5FUMSWDD.js');
3
+ var _chunkSGLVWM4Njs = require('./chunk-SGLVWM4N.js');
4
4
 
5
5
 
6
6
  var _chunkLGXHJ24Kjs = require('./chunk-LGXHJ24K.js');
@@ -9,7 +9,7 @@ var _chunkLGXHJ24Kjs = require('./chunk-LGXHJ24K.js');
9
9
 
10
10
 
11
11
 
12
- var _chunkH73GATCUjs = require('./chunk-H73GATCU.js');
12
+ var _chunkNIPCK74Tjs = require('./chunk-NIPCK74T.js');
13
13
 
14
14
 
15
15
 
@@ -17,7 +17,7 @@ var _chunkH73GATCUjs = require('./chunk-H73GATCU.js');
17
17
 
18
18
 
19
19
 
20
- var _chunkNOYP2T77js = require('./chunk-NOYP2T77.js');
20
+ var _chunkJW3TK3NUjs = require('./chunk-JW3TK3NU.js');
21
21
 
22
22
 
23
23
  var _chunkTLX5QQK5js = require('./chunk-TLX5QQK5.js');
@@ -224,6 +224,11 @@ var NotificationServicesController = class extends _basecontroller.BaseControlle
224
224
  }
225
225
  });
226
226
  _chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _pushNotifications, {
227
+ subscribeToPushNotifications: async () => {
228
+ await this.messagingSystem.call(
229
+ "NotificationServicesPushController:subscribeToPushNotifications"
230
+ );
231
+ },
227
232
  enablePushNotifications: async (UUIDs) => {
228
233
  if (!_chunkIGY2S5BCjs.__privateGet.call(void 0, this, _isPushIntegrated)) {
229
234
  return;
@@ -284,16 +289,17 @@ var NotificationServicesController = class extends _basecontroller.BaseControlle
284
289
  if (_chunkIGY2S5BCjs.__privateGet.call(void 0, this, _isPushNotificationsSetup)) {
285
290
  return;
286
291
  }
287
- if (!_chunkIGY2S5BCjs.__privateGet.call(void 0, this, _isUnlocked)) {
288
- return;
289
- }
290
- const storage = await _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _getUserStorage, getUserStorage_fn).call(this);
291
- if (!storage) {
292
- return;
292
+ if (_chunkIGY2S5BCjs.__privateGet.call(void 0, this, _isUnlocked)) {
293
+ const storage = await _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _getUserStorage, getUserStorage_fn).call(this);
294
+ if (!storage) {
295
+ return;
296
+ }
297
+ const uuids = _chunkJW3TK3NUjs.getAllUUIDs.call(void 0, storage);
298
+ await _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _pushNotifications).enablePushNotifications(uuids);
299
+ _chunkIGY2S5BCjs.__privateSet.call(void 0, this, _isPushNotificationsSetup, true);
300
+ } else {
301
+ await _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _pushNotifications).subscribeToPushNotifications();
293
302
  }
294
- const uuids = _chunkNOYP2T77js.getAllUUIDs.call(void 0, storage);
295
- await _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _pushNotifications).enablePushNotifications(uuids);
296
- _chunkIGY2S5BCjs.__privateSet.call(void 0, this, _isPushNotificationsSetup, true);
297
303
  }
298
304
  });
299
305
  _chunkIGY2S5BCjs.__privateAdd.call(void 0, this, _accounts, {
@@ -400,7 +406,7 @@ var NotificationServicesController = class extends _basecontroller.BaseControlle
400
406
  _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _setIsCheckingAccountsPresence, setIsCheckingAccountsPresence_fn).call(this, true);
401
407
  const userStorage = await _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _getUserStorage, getUserStorage_fn).call(this);
402
408
  _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _assertUserStorage, assertUserStorage_fn).call(this, userStorage);
403
- const presence = _chunkNOYP2T77js.checkAccountsPresence.call(void 0, userStorage, accounts);
409
+ const presence = _chunkJW3TK3NUjs.checkAccountsPresence.call(void 0, userStorage, accounts);
404
410
  return presence;
405
411
  } catch (error) {
406
412
  _loglevel2.default.error("Failed to check accounts presence", error);
@@ -444,20 +450,20 @@ var NotificationServicesController = class extends _basecontroller.BaseControlle
444
450
  const { accounts } = await _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _accounts).listAccounts();
445
451
  let userStorage = await _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _getUserStorage, getUserStorage_fn).call(this);
446
452
  if (userStorage?.[_chunkTLX5QQK5js.USER_STORAGE_VERSION_KEY] === void 0) {
447
- userStorage = _chunkNOYP2T77js.initializeUserStorage.call(void 0,
453
+ userStorage = _chunkJW3TK3NUjs.initializeUserStorage.call(void 0,
448
454
  accounts.map((account) => ({ address: account })),
449
455
  false
450
456
  );
451
457
  await _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _storage).setNotificationStorage(JSON.stringify(userStorage));
452
458
  }
453
- const triggers = _chunkNOYP2T77js.traverseUserStorageTriggers.call(void 0, userStorage);
454
- await _chunkH73GATCUjs.createOnChainTriggers.call(void 0,
459
+ const triggers = _chunkJW3TK3NUjs.traverseUserStorageTriggers.call(void 0, userStorage);
460
+ await _chunkNIPCK74Tjs.createOnChainTriggers.call(void 0,
455
461
  userStorage,
456
462
  storageKey,
457
463
  bearerToken,
458
464
  triggers
459
465
  );
460
- const allUUIDS = _chunkNOYP2T77js.getAllUUIDs.call(void 0, userStorage);
466
+ const allUUIDS = _chunkJW3TK3NUjs.getAllUUIDs.call(void 0, userStorage);
461
467
  await _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _pushNotifications).enablePushNotifications(allUUIDS);
462
468
  await _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _storage).setNotificationStorage(JSON.stringify(userStorage));
463
469
  this.update((state) => {
@@ -507,7 +513,7 @@ var NotificationServicesController = class extends _basecontroller.BaseControlle
507
513
  _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _setIsUpdatingMetamaskNotifications, setIsUpdatingMetamaskNotifications_fn).call(this, true);
508
514
  const userStorage = await _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _getUserStorage, getUserStorage_fn).call(this);
509
515
  _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _assertUserStorage, assertUserStorage_fn).call(this, userStorage);
510
- const UUIDs = _chunkNOYP2T77js.getAllUUIDs.call(void 0, userStorage);
516
+ const UUIDs = _chunkJW3TK3NUjs.getAllUUIDs.call(void 0, userStorage);
511
517
  await _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _pushNotifications).disablePushNotifications(UUIDs);
512
518
  this.update((state) => {
513
519
  state.isNotificationServicesEnabled = false;
@@ -541,11 +547,11 @@ var NotificationServicesController = class extends _basecontroller.BaseControlle
541
547
  const { bearerToken, storageKey } = await _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _getValidStorageKeyAndBearerToken, getValidStorageKeyAndBearerToken_fn).call(this);
542
548
  const userStorage = await _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _getUserStorage, getUserStorage_fn).call(this);
543
549
  _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _assertUserStorage, assertUserStorage_fn).call(this, userStorage);
544
- const UUIDs = accounts.map((a) => _chunkNOYP2T77js.getUUIDsForAccount.call(void 0, userStorage, a.toLowerCase())).flat();
550
+ const UUIDs = accounts.map((a) => _chunkJW3TK3NUjs.getUUIDsForAccount.call(void 0, userStorage, a.toLowerCase())).flat();
545
551
  if (UUIDs.length === 0) {
546
552
  return userStorage;
547
553
  }
548
- await _chunkH73GATCUjs.deleteOnChainTriggers.call(void 0,
554
+ await _chunkNIPCK74Tjs.deleteOnChainTriggers.call(void 0,
549
555
  userStorage,
550
556
  storageKey,
551
557
  bearerToken,
@@ -582,8 +588,8 @@ var NotificationServicesController = class extends _basecontroller.BaseControlle
582
588
  const { bearerToken, storageKey } = await _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _getValidStorageKeyAndBearerToken, getValidStorageKeyAndBearerToken_fn).call(this);
583
589
  const userStorage = await _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _getUserStorage, getUserStorage_fn).call(this);
584
590
  _chunkIGY2S5BCjs.__privateMethod.call(void 0, this, _assertUserStorage, assertUserStorage_fn).call(this, userStorage);
585
- accounts.forEach((a) => _chunkNOYP2T77js.upsertAddressTriggers.call(void 0, a, userStorage));
586
- const newTriggers = _chunkNOYP2T77js.traverseUserStorageTriggers.call(void 0, userStorage, {
591
+ accounts.forEach((a) => _chunkJW3TK3NUjs.upsertAddressTriggers.call(void 0, a, userStorage));
592
+ const newTriggers = _chunkJW3TK3NUjs.traverseUserStorageTriggers.call(void 0, userStorage, {
587
593
  mapTrigger: (t) => {
588
594
  if (!t.enabled) {
589
595
  return t;
@@ -593,7 +599,7 @@ var NotificationServicesController = class extends _basecontroller.BaseControlle
593
599
  });
594
600
  if (newTriggers.length > 0) {
595
601
  await _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _storage).setNotificationStorage(JSON.stringify(userStorage));
596
- const triggers = _chunkNOYP2T77js.traverseUserStorageTriggers.call(void 0, userStorage, {
602
+ const triggers = _chunkJW3TK3NUjs.traverseUserStorageTriggers.call(void 0, userStorage, {
597
603
  mapTrigger: (t) => {
598
604
  if (accounts.some((a) => a.toLowerCase() === t.address.toLowerCase())) {
599
605
  return t;
@@ -601,14 +607,14 @@ var NotificationServicesController = class extends _basecontroller.BaseControlle
601
607
  return void 0;
602
608
  }
603
609
  });
604
- await _chunkH73GATCUjs.createOnChainTriggers.call(void 0,
610
+ await _chunkNIPCK74Tjs.createOnChainTriggers.call(void 0,
605
611
  userStorage,
606
612
  storageKey,
607
613
  bearerToken,
608
614
  triggers
609
615
  );
610
616
  }
611
- const UUIDs = _chunkNOYP2T77js.getAllUUIDs.call(void 0, userStorage);
617
+ const UUIDs = _chunkJW3TK3NUjs.getAllUUIDs.call(void 0, userStorage);
612
618
  await _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _pushNotifications).updatePushNotifications(UUIDs);
613
619
  await _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _storage).setNotificationStorage(JSON.stringify(userStorage));
614
620
  return userStorage;
@@ -637,7 +643,7 @@ var NotificationServicesController = class extends _basecontroller.BaseControlle
637
643
  const userStorage = await _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _storage).getNotificationStorage().then((s) => s && JSON.parse(s)).catch(() => null);
638
644
  const bearerToken = await _chunkIGY2S5BCjs.__privateGet.call(void 0, this, _auth).getBearerToken().catch(() => null);
639
645
  if (userStorage && bearerToken) {
640
- const notifications = await _chunkH73GATCUjs.getOnChainNotifications.call(void 0,
646
+ const notifications = await _chunkNIPCK74Tjs.getOnChainNotifications.call(void 0,
641
647
  userStorage,
642
648
  bearerToken
643
649
  ).catch(() => []);
@@ -645,7 +651,7 @@ var NotificationServicesController = class extends _basecontroller.BaseControlle
645
651
  }
646
652
  const readIds = this.state.metamaskNotificationsReadList;
647
653
  const isNotUndefined = (t) => Boolean(t);
648
- const processAndFilter = (ns) => ns.map((n) => _chunk5FUMSWDDjs.safeProcessNotification.call(void 0, n, readIds)).filter(isNotUndefined);
654
+ const processAndFilter = (ns) => ns.map((n) => _chunkSGLVWM4Njs.safeProcessNotification.call(void 0, n, readIds)).filter(isNotUndefined);
649
655
  const featureAnnouncementNotifications = processAndFilter(
650
656
  rawFeatureAnnouncementNotifications
651
657
  );
@@ -694,7 +700,7 @@ var NotificationServicesController = class extends _basecontroller.BaseControlle
694
700
  onchainNotificationIds = onChainNotifications.map(
695
701
  (notification) => notification.id
696
702
  );
697
- await _chunkH73GATCUjs.markNotificationsAsRead.call(void 0,
703
+ await _chunkNIPCK74Tjs.markNotificationsAsRead.call(void 0,
698
704
  bearerToken,
699
705
  onchainNotificationIds
700
706
  ).catch(() => {
@@ -742,7 +748,7 @@ var NotificationServicesController = class extends _basecontroller.BaseControlle
742
748
  if (this.state.metamaskNotificationsList.some((n) => n.id === notification.id)) {
743
749
  return;
744
750
  }
745
- const processedNotification = _chunk5FUMSWDDjs.safeProcessNotification.call(void 0, notification);
751
+ const processedNotification = _chunkSGLVWM4Njs.safeProcessNotification.call(void 0, notification);
746
752
  if (processedNotification) {
747
753
  this.update((state) => {
748
754
  const existingNotificationIds = new Set(
@@ -876,4 +882,4 @@ clearUpdatingAccountsState_fn = function(accounts) {
876
882
 
877
883
 
878
884
  exports.defaultState = defaultState; exports.NotificationServicesController = NotificationServicesController;
879
- //# sourceMappingURL=chunk-2O32EME6.js.map
885
+ //# sourceMappingURL=chunk-JIJXHO5V.js.map