@metamask/notification-services-controller 21.0.0 → 22.1.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 (193) hide show
  1. package/CHANGELOG.md +41 -1
  2. package/dist/NotificationServicesController/NotificationServicesController.cjs +56 -42
  3. package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -1
  4. package/dist/NotificationServicesController/NotificationServicesController.d.cts +3 -2
  5. package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -1
  6. package/dist/NotificationServicesController/NotificationServicesController.d.mts +3 -2
  7. package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -1
  8. package/dist/NotificationServicesController/NotificationServicesController.mjs +56 -41
  9. package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
  10. package/dist/NotificationServicesController/constants/notification-schema.cjs +4 -12
  11. package/dist/NotificationServicesController/constants/notification-schema.cjs.map +1 -1
  12. package/dist/NotificationServicesController/constants/notification-schema.d.cts +0 -12
  13. package/dist/NotificationServicesController/constants/notification-schema.d.cts.map +1 -1
  14. package/dist/NotificationServicesController/constants/notification-schema.d.mts +0 -12
  15. package/dist/NotificationServicesController/constants/notification-schema.d.mts.map +1 -1
  16. package/dist/NotificationServicesController/constants/notification-schema.mjs +3 -11
  17. package/dist/NotificationServicesController/constants/notification-schema.mjs.map +1 -1
  18. package/dist/NotificationServicesController/index.cjs +1 -2
  19. package/dist/NotificationServicesController/index.cjs.map +1 -1
  20. package/dist/NotificationServicesController/index.d.cts +0 -1
  21. package/dist/NotificationServicesController/index.d.cts.map +1 -1
  22. package/dist/NotificationServicesController/index.d.mts +0 -1
  23. package/dist/NotificationServicesController/index.d.mts.map +1 -1
  24. package/dist/NotificationServicesController/index.mjs +0 -1
  25. package/dist/NotificationServicesController/index.mjs.map +1 -1
  26. package/dist/NotificationServicesController/mocks/mock-feature-announcements.cjs +2 -2
  27. package/dist/NotificationServicesController/mocks/mock-feature-announcements.cjs.map +1 -1
  28. package/dist/NotificationServicesController/mocks/mock-feature-announcements.d.cts.map +1 -1
  29. package/dist/NotificationServicesController/mocks/mock-feature-announcements.d.mts.map +1 -1
  30. package/dist/NotificationServicesController/mocks/mock-feature-announcements.mjs +2 -2
  31. package/dist/NotificationServicesController/mocks/mock-feature-announcements.mjs.map +1 -1
  32. package/dist/NotificationServicesController/mocks/mock-raw-notifications.cjs +120 -0
  33. package/dist/NotificationServicesController/mocks/mock-raw-notifications.cjs.map +1 -1
  34. package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.cts.map +1 -1
  35. package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.mts.map +1 -1
  36. package/dist/NotificationServicesController/mocks/mock-raw-notifications.mjs +120 -0
  37. package/dist/NotificationServicesController/mocks/mock-raw-notifications.mjs.map +1 -1
  38. package/dist/NotificationServicesController/mocks/mock-snap-notification.cjs.map +1 -1
  39. package/dist/NotificationServicesController/mocks/mock-snap-notification.d.cts +1 -1
  40. package/dist/NotificationServicesController/mocks/mock-snap-notification.d.cts.map +1 -1
  41. package/dist/NotificationServicesController/mocks/mock-snap-notification.d.mts +1 -1
  42. package/dist/NotificationServicesController/mocks/mock-snap-notification.d.mts.map +1 -1
  43. package/dist/NotificationServicesController/mocks/mock-snap-notification.mjs.map +1 -1
  44. package/dist/NotificationServicesController/mocks/mockResponses.cjs +6 -0
  45. package/dist/NotificationServicesController/mocks/mockResponses.cjs.map +1 -1
  46. package/dist/NotificationServicesController/mocks/mockResponses.d.cts.map +1 -1
  47. package/dist/NotificationServicesController/mocks/mockResponses.d.mts.map +1 -1
  48. package/dist/NotificationServicesController/mocks/mockResponses.mjs +6 -0
  49. package/dist/NotificationServicesController/mocks/mockResponses.mjs.map +1 -1
  50. package/dist/NotificationServicesController/processors/process-notifications.cjs +11 -9
  51. package/dist/NotificationServicesController/processors/process-notifications.cjs.map +1 -1
  52. package/dist/NotificationServicesController/processors/process-notifications.d.cts +1 -563
  53. package/dist/NotificationServicesController/processors/process-notifications.d.cts.map +1 -1
  54. package/dist/NotificationServicesController/processors/process-notifications.d.mts +1 -563
  55. package/dist/NotificationServicesController/processors/process-notifications.d.mts.map +1 -1
  56. package/dist/NotificationServicesController/processors/process-notifications.mjs +11 -9
  57. package/dist/NotificationServicesController/processors/process-notifications.mjs.map +1 -1
  58. package/dist/NotificationServicesController/processors/process-snap-notifications.cjs.map +1 -1
  59. package/dist/NotificationServicesController/processors/process-snap-notifications.d.cts +1 -1
  60. package/dist/NotificationServicesController/processors/process-snap-notifications.d.cts.map +1 -1
  61. package/dist/NotificationServicesController/processors/process-snap-notifications.d.mts +1 -1
  62. package/dist/NotificationServicesController/processors/process-snap-notifications.d.mts.map +1 -1
  63. package/dist/NotificationServicesController/processors/process-snap-notifications.mjs.map +1 -1
  64. package/dist/NotificationServicesController/services/api-notifications.cjs +21 -21
  65. package/dist/NotificationServicesController/services/api-notifications.cjs.map +1 -1
  66. package/dist/NotificationServicesController/services/api-notifications.d.cts.map +1 -1
  67. package/dist/NotificationServicesController/services/api-notifications.d.mts.map +1 -1
  68. package/dist/NotificationServicesController/services/api-notifications.mjs +21 -21
  69. package/dist/NotificationServicesController/services/api-notifications.mjs.map +1 -1
  70. package/dist/NotificationServicesController/services/feature-announcements.cjs +19 -10
  71. package/dist/NotificationServicesController/services/feature-announcements.cjs.map +1 -1
  72. package/dist/NotificationServicesController/services/feature-announcements.d.cts.map +1 -1
  73. package/dist/NotificationServicesController/services/feature-announcements.d.mts.map +1 -1
  74. package/dist/NotificationServicesController/services/feature-announcements.mjs +19 -10
  75. package/dist/NotificationServicesController/services/feature-announcements.mjs.map +1 -1
  76. package/dist/NotificationServicesController/services/notification-config-cache.cjs +4 -4
  77. package/dist/NotificationServicesController/services/notification-config-cache.cjs.map +1 -1
  78. package/dist/NotificationServicesController/services/notification-config-cache.mjs +4 -4
  79. package/dist/NotificationServicesController/services/notification-config-cache.mjs.map +1 -1
  80. package/dist/NotificationServicesController/services/perp-notifications.cjs +2 -2
  81. package/dist/NotificationServicesController/services/perp-notifications.cjs.map +1 -1
  82. package/dist/NotificationServicesController/services/perp-notifications.d.cts.map +1 -1
  83. package/dist/NotificationServicesController/services/perp-notifications.d.mts.map +1 -1
  84. package/dist/NotificationServicesController/services/perp-notifications.mjs +2 -2
  85. package/dist/NotificationServicesController/services/perp-notifications.mjs.map +1 -1
  86. package/dist/NotificationServicesController/types/notification-api/notification-api.cjs.map +1 -1
  87. package/dist/NotificationServicesController/types/notification-api/notification-api.d.cts +2 -0
  88. package/dist/NotificationServicesController/types/notification-api/notification-api.d.cts.map +1 -1
  89. package/dist/NotificationServicesController/types/notification-api/notification-api.d.mts +2 -0
  90. package/dist/NotificationServicesController/types/notification-api/notification-api.d.mts.map +1 -1
  91. package/dist/NotificationServicesController/types/notification-api/notification-api.mjs.map +1 -1
  92. package/dist/NotificationServicesController/types/notification-api/schema.cjs +2 -0
  93. package/dist/NotificationServicesController/types/notification-api/schema.cjs.map +1 -1
  94. package/dist/NotificationServicesController/types/notification-api/schema.d.cts +23 -0
  95. package/dist/NotificationServicesController/types/notification-api/schema.d.cts.map +1 -1
  96. package/dist/NotificationServicesController/types/notification-api/schema.d.mts +23 -0
  97. package/dist/NotificationServicesController/types/notification-api/schema.d.mts.map +1 -1
  98. package/dist/NotificationServicesController/types/notification-api/schema.mjs +2 -0
  99. package/dist/NotificationServicesController/types/notification-api/schema.mjs.map +1 -1
  100. package/dist/NotificationServicesController/types/perps/schema.cjs +2 -0
  101. package/dist/NotificationServicesController/types/perps/schema.cjs.map +1 -1
  102. package/dist/NotificationServicesController/types/perps/schema.d.cts.map +1 -1
  103. package/dist/NotificationServicesController/types/perps/schema.d.mts.map +1 -1
  104. package/dist/NotificationServicesController/types/perps/schema.mjs +2 -0
  105. package/dist/NotificationServicesController/types/perps/schema.mjs.map +1 -1
  106. package/dist/NotificationServicesController/utils/isVersionInBounds.cjs.map +1 -1
  107. package/dist/NotificationServicesController/utils/isVersionInBounds.d.cts.map +1 -1
  108. package/dist/NotificationServicesController/utils/isVersionInBounds.d.mts.map +1 -1
  109. package/dist/NotificationServicesController/utils/isVersionInBounds.mjs.map +1 -1
  110. package/dist/NotificationServicesController/utils/should-auto-expire.cjs.map +1 -1
  111. package/dist/NotificationServicesController/utils/should-auto-expire.d.cts.map +1 -1
  112. package/dist/NotificationServicesController/utils/should-auto-expire.d.mts.map +1 -1
  113. package/dist/NotificationServicesController/utils/should-auto-expire.mjs.map +1 -1
  114. package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs +0 -1
  115. package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -1
  116. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts +1 -1
  117. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -1
  118. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts +1 -1
  119. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -1
  120. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +0 -1
  121. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -1
  122. package/dist/NotificationServicesPushController/mocks/mockResponse.cjs.map +1 -1
  123. package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts +9 -24
  124. package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts.map +1 -1
  125. package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts +9 -24
  126. package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts.map +1 -1
  127. package/dist/NotificationServicesPushController/mocks/mockResponse.mjs.map +1 -1
  128. package/dist/NotificationServicesPushController/services/endpoints.cjs.map +1 -1
  129. package/dist/NotificationServicesPushController/services/endpoints.d.cts.map +1 -1
  130. package/dist/NotificationServicesPushController/services/endpoints.d.mts.map +1 -1
  131. package/dist/NotificationServicesPushController/services/endpoints.mjs.map +1 -1
  132. package/dist/NotificationServicesPushController/services/services.cjs.map +1 -1
  133. package/dist/NotificationServicesPushController/services/services.d.cts.map +1 -1
  134. package/dist/NotificationServicesPushController/services/services.d.mts.map +1 -1
  135. package/dist/NotificationServicesPushController/services/services.mjs.map +1 -1
  136. package/dist/NotificationServicesPushController/utils/get-notification-data.cjs +4 -4
  137. package/dist/NotificationServicesPushController/utils/get-notification-data.cjs.map +1 -1
  138. package/dist/NotificationServicesPushController/utils/get-notification-data.d.cts +2 -2
  139. package/dist/NotificationServicesPushController/utils/get-notification-data.d.cts.map +1 -1
  140. package/dist/NotificationServicesPushController/utils/get-notification-data.d.mts +2 -2
  141. package/dist/NotificationServicesPushController/utils/get-notification-data.d.mts.map +1 -1
  142. package/dist/NotificationServicesPushController/utils/get-notification-data.mjs +4 -4
  143. package/dist/NotificationServicesPushController/utils/get-notification-data.mjs.map +1 -1
  144. package/dist/NotificationServicesPushController/utils/get-notification-message.cjs +62 -71
  145. package/dist/NotificationServicesPushController/utils/get-notification-message.cjs.map +1 -1
  146. package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts +9 -9
  147. package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts.map +1 -1
  148. package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts +9 -9
  149. package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts.map +1 -1
  150. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs +62 -71
  151. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs.map +1 -1
  152. package/dist/NotificationServicesPushController/web/push-utils.cjs +15 -7
  153. package/dist/NotificationServicesPushController/web/push-utils.cjs.map +1 -1
  154. package/dist/NotificationServicesPushController/web/push-utils.d.cts.map +1 -1
  155. package/dist/NotificationServicesPushController/web/push-utils.d.mts.map +1 -1
  156. package/dist/NotificationServicesPushController/web/push-utils.mjs +16 -8
  157. package/dist/NotificationServicesPushController/web/push-utils.mjs.map +1 -1
  158. package/dist/shared/is-onchain-notification.cjs +3 -3
  159. package/dist/shared/is-onchain-notification.cjs.map +1 -1
  160. package/dist/shared/is-onchain-notification.d.cts +2 -2
  161. package/dist/shared/is-onchain-notification.d.cts.map +1 -1
  162. package/dist/shared/is-onchain-notification.d.mts +2 -2
  163. package/dist/shared/is-onchain-notification.d.mts.map +1 -1
  164. package/dist/shared/is-onchain-notification.mjs +3 -3
  165. package/dist/shared/is-onchain-notification.mjs.map +1 -1
  166. package/dist/shared/to-raw-notification.cjs.map +1 -1
  167. package/dist/shared/to-raw-notification.mjs.map +1 -1
  168. package/package.json +12 -25
  169. package/dist/NotificationServicesController/ui/constants.cjs +0 -75
  170. package/dist/NotificationServicesController/ui/constants.cjs.map +0 -1
  171. package/dist/NotificationServicesController/ui/constants.d.cts +0 -66
  172. package/dist/NotificationServicesController/ui/constants.d.cts.map +0 -1
  173. package/dist/NotificationServicesController/ui/constants.d.mts +0 -66
  174. package/dist/NotificationServicesController/ui/constants.d.mts.map +0 -1
  175. package/dist/NotificationServicesController/ui/constants.mjs +0 -71
  176. package/dist/NotificationServicesController/ui/constants.mjs.map +0 -1
  177. package/dist/NotificationServicesController/ui/index.cjs +0 -18
  178. package/dist/NotificationServicesController/ui/index.cjs.map +0 -1
  179. package/dist/NotificationServicesController/ui/index.d.cts +0 -2
  180. package/dist/NotificationServicesController/ui/index.d.cts.map +0 -1
  181. package/dist/NotificationServicesController/ui/index.d.mts +0 -2
  182. package/dist/NotificationServicesController/ui/index.d.mts.map +0 -1
  183. package/dist/NotificationServicesController/ui/index.mjs +0 -2
  184. package/dist/NotificationServicesController/ui/index.mjs.map +0 -1
  185. package/dist/NotificationServicesPushController/services/push/push-web.cjs +0 -145
  186. package/dist/NotificationServicesPushController/services/push/push-web.cjs.map +0 -1
  187. package/dist/NotificationServicesPushController/services/push/push-web.d.cts +0 -34
  188. package/dist/NotificationServicesPushController/services/push/push-web.d.cts.map +0 -1
  189. package/dist/NotificationServicesPushController/services/push/push-web.d.mts +0 -34
  190. package/dist/NotificationServicesPushController/services/push/push-web.d.mts.map +0 -1
  191. package/dist/NotificationServicesPushController/services/push/push-web.mjs +0 -142
  192. package/dist/NotificationServicesPushController/services/push/push-web.mjs.map +0 -1
  193. package/notification-services/ui/package.json +0 -9
@@ -1,4 +1,3 @@
1
- import { TRIGGER_TYPES } from "../constants/notification-schema.mjs";
2
1
  import type { INotification, RawNotificationUnion } from "../types/notification/notification.mjs";
3
2
  /**
4
3
  * Process feature announcement and wallet notifications into a shared/normalised notification shape.
@@ -17,566 +16,5 @@ export declare function processNotification(notification: RawNotificationUnion,
17
16
  * @returns a process notification or undefined if failed to process
18
17
  */
19
18
  export declare function safeProcessNotification(notification: RawNotificationUnion, readNotifications?: string[]): INotification | undefined;
20
- export declare const processAndFilterNotifications: (ns: RawNotificationUnion[], readIds: string[]) => ({
21
- type: TRIGGER_TYPES.FEATURES_ANNOUNCEMENT;
22
- createdAt: string;
23
- data: import("../types/feature-announcement/feature-announcement.mjs").FeatureAnnouncementRawNotificationData;
24
- id: string;
25
- isRead: boolean;
26
- } | {
27
- id: string;
28
- notification_type: "on-chain";
29
- unread: boolean;
30
- created_at: string;
31
- type: TRIGGER_TYPES.METAMASK_SWAP_COMPLETED;
32
- payload: {
33
- address: string;
34
- chain_id: number;
35
- block_number: number;
36
- block_timestamp: string;
37
- tx_hash: string;
38
- data: {
39
- kind: "metamask_swap_completed";
40
- network_fee: {
41
- gas_price: string;
42
- native_token_price_in_usd: string;
43
- };
44
- rate: string;
45
- token_in: {
46
- address: string;
47
- symbol: string;
48
- name: string;
49
- amount: string;
50
- decimals: string;
51
- image: string;
52
- usd: string;
53
- };
54
- token_out: {
55
- address: string;
56
- symbol: string;
57
- name: string;
58
- amount: string;
59
- decimals: string;
60
- image: string;
61
- usd: string;
62
- };
63
- };
64
- };
65
- createdAt: string;
66
- isRead: boolean;
67
- } | {
68
- id: string;
69
- notification_type: "on-chain";
70
- unread: boolean;
71
- created_at: string;
72
- type: TRIGGER_TYPES.ERC20_SENT;
73
- payload: {
74
- address: string;
75
- chain_id: number;
76
- block_number: number;
77
- block_timestamp: string;
78
- tx_hash: string;
79
- data: {
80
- kind: "erc20_sent";
81
- network_fee: {
82
- gas_price: string;
83
- native_token_price_in_usd: string;
84
- };
85
- from: string;
86
- to: string;
87
- token: {
88
- address: string;
89
- symbol: string;
90
- name: string;
91
- amount: string;
92
- decimals: string;
93
- image: string;
94
- usd: string;
95
- };
96
- };
97
- };
98
- createdAt: string;
99
- isRead: boolean;
100
- } | {
101
- id: string;
102
- notification_type: "on-chain";
103
- unread: boolean;
104
- created_at: string;
105
- type: TRIGGER_TYPES.ERC20_RECEIVED;
106
- payload: {
107
- address: string;
108
- chain_id: number;
109
- block_number: number;
110
- block_timestamp: string;
111
- tx_hash: string;
112
- data: {
113
- kind: "erc20_received";
114
- network_fee: {
115
- gas_price: string;
116
- native_token_price_in_usd: string;
117
- };
118
- from: string;
119
- to: string;
120
- token: {
121
- address: string;
122
- symbol: string;
123
- name: string;
124
- amount: string;
125
- decimals: string;
126
- image: string;
127
- usd: string;
128
- };
129
- };
130
- };
131
- createdAt: string;
132
- isRead: boolean;
133
- } | {
134
- id: string;
135
- notification_type: "on-chain";
136
- unread: boolean;
137
- created_at: string;
138
- type: TRIGGER_TYPES.ETH_SENT;
139
- payload: {
140
- address: string;
141
- chain_id: number;
142
- block_number: number;
143
- block_timestamp: string;
144
- tx_hash: string;
145
- data: {
146
- kind: "eth_sent";
147
- network_fee: {
148
- gas_price: string;
149
- native_token_price_in_usd: string;
150
- };
151
- from: string;
152
- to: string;
153
- amount: {
154
- usd: string;
155
- eth: string;
156
- };
157
- };
158
- };
159
- createdAt: string;
160
- isRead: boolean;
161
- } | {
162
- id: string;
163
- notification_type: "on-chain";
164
- unread: boolean;
165
- created_at: string;
166
- type: TRIGGER_TYPES.ETH_RECEIVED;
167
- payload: {
168
- address: string;
169
- chain_id: number;
170
- block_number: number;
171
- block_timestamp: string;
172
- tx_hash: string;
173
- data: {
174
- kind: "eth_received";
175
- network_fee: {
176
- gas_price: string;
177
- native_token_price_in_usd: string;
178
- };
179
- from: string;
180
- to: string;
181
- amount: {
182
- usd: string;
183
- eth: string;
184
- };
185
- };
186
- };
187
- createdAt: string;
188
- isRead: boolean;
189
- } | {
190
- id: string;
191
- notification_type: "on-chain";
192
- unread: boolean;
193
- created_at: string;
194
- type: TRIGGER_TYPES.ROCKETPOOL_STAKE_COMPLETED;
195
- payload: {
196
- address: string;
197
- chain_id: number;
198
- block_number: number;
199
- block_timestamp: string;
200
- tx_hash: string;
201
- data: {
202
- kind: "rocketpool_stake_completed";
203
- network_fee: {
204
- gas_price: string;
205
- native_token_price_in_usd: string;
206
- };
207
- stake_in: {
208
- address: string;
209
- symbol: string;
210
- name: string;
211
- amount: string;
212
- decimals: string;
213
- image: string;
214
- usd: string;
215
- };
216
- stake_out: {
217
- address: string;
218
- symbol: string;
219
- name: string;
220
- amount: string;
221
- decimals: string;
222
- image: string;
223
- usd: string;
224
- };
225
- };
226
- };
227
- createdAt: string;
228
- isRead: boolean;
229
- } | {
230
- id: string;
231
- notification_type: "on-chain";
232
- unread: boolean;
233
- created_at: string;
234
- type: TRIGGER_TYPES.ROCKETPOOL_UNSTAKE_COMPLETED;
235
- payload: {
236
- address: string;
237
- chain_id: number;
238
- block_number: number;
239
- block_timestamp: string;
240
- tx_hash: string;
241
- data: {
242
- kind: "rocketpool_unstake_completed";
243
- network_fee: {
244
- gas_price: string;
245
- native_token_price_in_usd: string;
246
- };
247
- stake_in: {
248
- address: string;
249
- symbol: string;
250
- name: string;
251
- amount: string;
252
- decimals: string;
253
- image: string;
254
- usd: string;
255
- };
256
- stake_out: {
257
- address: string;
258
- symbol: string;
259
- name: string;
260
- amount: string;
261
- decimals: string;
262
- image: string;
263
- usd: string;
264
- };
265
- };
266
- };
267
- createdAt: string;
268
- isRead: boolean;
269
- } | {
270
- id: string;
271
- notification_type: "on-chain";
272
- unread: boolean;
273
- created_at: string;
274
- type: TRIGGER_TYPES.LIDO_STAKE_COMPLETED;
275
- payload: {
276
- address: string;
277
- chain_id: number;
278
- block_number: number;
279
- block_timestamp: string;
280
- tx_hash: string;
281
- data: {
282
- kind: "lido_stake_completed";
283
- network_fee: {
284
- gas_price: string;
285
- native_token_price_in_usd: string;
286
- };
287
- stake_in: {
288
- address: string;
289
- symbol: string;
290
- name: string;
291
- amount: string;
292
- decimals: string;
293
- image: string;
294
- usd: string;
295
- };
296
- stake_out: {
297
- address: string;
298
- symbol: string;
299
- name: string;
300
- amount: string;
301
- decimals: string;
302
- image: string;
303
- usd: string;
304
- };
305
- };
306
- };
307
- createdAt: string;
308
- isRead: boolean;
309
- } | {
310
- id: string;
311
- notification_type: "on-chain";
312
- unread: boolean;
313
- created_at: string;
314
- type: TRIGGER_TYPES.LIDO_WITHDRAWAL_REQUESTED;
315
- payload: {
316
- address: string;
317
- chain_id: number;
318
- block_number: number;
319
- block_timestamp: string;
320
- tx_hash: string;
321
- data: {
322
- kind: "lido_withdrawal_requested";
323
- network_fee: {
324
- gas_price: string;
325
- native_token_price_in_usd: string;
326
- };
327
- stake_in: {
328
- address: string;
329
- symbol: string;
330
- name: string;
331
- amount: string;
332
- decimals: string;
333
- image: string;
334
- usd: string;
335
- };
336
- stake_out: {
337
- address: string;
338
- symbol: string;
339
- name: string;
340
- amount: string;
341
- decimals: string;
342
- image: string;
343
- usd: string;
344
- };
345
- };
346
- };
347
- createdAt: string;
348
- isRead: boolean;
349
- } | {
350
- id: string;
351
- notification_type: "on-chain";
352
- unread: boolean;
353
- created_at: string;
354
- type: TRIGGER_TYPES.LIDO_WITHDRAWAL_COMPLETED;
355
- payload: {
356
- address: string;
357
- chain_id: number;
358
- block_number: number;
359
- block_timestamp: string;
360
- tx_hash: string;
361
- data: {
362
- kind: "lido_withdrawal_completed";
363
- network_fee: {
364
- gas_price: string;
365
- native_token_price_in_usd: string;
366
- };
367
- stake_in: {
368
- address: string;
369
- symbol: string;
370
- name: string;
371
- amount: string;
372
- decimals: string;
373
- image: string;
374
- usd: string;
375
- };
376
- stake_out: {
377
- address: string;
378
- symbol: string;
379
- name: string;
380
- amount: string;
381
- decimals: string;
382
- image: string;
383
- usd: string;
384
- };
385
- };
386
- };
387
- createdAt: string;
388
- isRead: boolean;
389
- } | {
390
- id: string;
391
- notification_type: "on-chain";
392
- unread: boolean;
393
- created_at: string;
394
- type: TRIGGER_TYPES.LIDO_STAKE_READY_TO_BE_WITHDRAWN;
395
- payload: {
396
- address: string;
397
- chain_id: number;
398
- block_number: number;
399
- block_timestamp: string;
400
- tx_hash: string;
401
- data: {
402
- kind: "lido_stake_ready_to_be_withdrawn";
403
- request_id: string;
404
- staked_eth: {
405
- address: string;
406
- symbol: string;
407
- name: string;
408
- amount: string;
409
- decimals: string;
410
- image: string;
411
- usd: string;
412
- };
413
- };
414
- };
415
- createdAt: string;
416
- isRead: boolean;
417
- } | {
418
- id: string;
419
- notification_type: "on-chain";
420
- unread: boolean;
421
- created_at: string;
422
- type: TRIGGER_TYPES.ERC721_SENT;
423
- payload: {
424
- address: string;
425
- chain_id: number;
426
- block_number: number;
427
- block_timestamp: string;
428
- tx_hash: string;
429
- data: {
430
- kind: "erc721_sent";
431
- network_fee: {
432
- gas_price: string;
433
- native_token_price_in_usd: string;
434
- };
435
- from: string;
436
- to: string;
437
- nft: {
438
- name: string;
439
- token_id: string;
440
- image: string;
441
- collection: {
442
- address: string;
443
- name: string;
444
- symbol: string;
445
- image: string;
446
- };
447
- };
448
- };
449
- };
450
- createdAt: string;
451
- isRead: boolean;
452
- } | {
453
- id: string;
454
- notification_type: "on-chain";
455
- unread: boolean;
456
- created_at: string;
457
- type: TRIGGER_TYPES.ERC721_RECEIVED;
458
- payload: {
459
- address: string;
460
- chain_id: number;
461
- block_number: number;
462
- block_timestamp: string;
463
- tx_hash: string;
464
- data: {
465
- kind: "erc721_received";
466
- network_fee: {
467
- gas_price: string;
468
- native_token_price_in_usd: string;
469
- };
470
- from: string;
471
- to: string;
472
- nft: {
473
- name: string;
474
- token_id: string;
475
- image: string;
476
- collection: {
477
- address: string;
478
- name: string;
479
- symbol: string;
480
- image: string;
481
- };
482
- };
483
- };
484
- };
485
- createdAt: string;
486
- isRead: boolean;
487
- } | {
488
- id: string;
489
- notification_type: "on-chain";
490
- unread: boolean;
491
- created_at: string;
492
- type: TRIGGER_TYPES.ERC1155_SENT;
493
- payload: {
494
- address: string;
495
- chain_id: number;
496
- block_number: number;
497
- block_timestamp: string;
498
- tx_hash: string;
499
- data: {
500
- kind: "erc1155_sent";
501
- network_fee: {
502
- gas_price: string;
503
- native_token_price_in_usd: string;
504
- };
505
- from: string;
506
- to: string;
507
- nft?: {
508
- name: string;
509
- token_id: string;
510
- image: string;
511
- collection: {
512
- address: string;
513
- name: string;
514
- symbol: string;
515
- image: string;
516
- };
517
- } | undefined;
518
- };
519
- };
520
- createdAt: string;
521
- isRead: boolean;
522
- } | {
523
- id: string;
524
- notification_type: "on-chain";
525
- unread: boolean;
526
- created_at: string;
527
- type: TRIGGER_TYPES.ERC1155_RECEIVED;
528
- payload: {
529
- address: string;
530
- chain_id: number;
531
- block_number: number;
532
- block_timestamp: string;
533
- tx_hash: string;
534
- data: {
535
- kind: "erc1155_received";
536
- network_fee: {
537
- gas_price: string;
538
- native_token_price_in_usd: string;
539
- };
540
- from: string;
541
- to: string;
542
- nft?: {
543
- name: string;
544
- token_id: string;
545
- image: string;
546
- collection: {
547
- address: string;
548
- name: string;
549
- symbol: string;
550
- image: string;
551
- };
552
- } | undefined;
553
- };
554
- };
555
- createdAt: string;
556
- isRead: boolean;
557
- } | {
558
- id: string;
559
- notification_type: "platform";
560
- unread: boolean;
561
- template: {
562
- image_url: string;
563
- cta?: {
564
- content: string;
565
- link: string;
566
- } | undefined;
567
- title: string;
568
- body: string;
569
- };
570
- created_at: string;
571
- type: TRIGGER_TYPES.PLATFORM;
572
- createdAt: string;
573
- isRead: boolean;
574
- } | {
575
- type: TRIGGER_TYPES.SNAP;
576
- data: import("../types/snaps/index.mjs").RawSnapNotificationData;
577
- readDate: string | null;
578
- id: string;
579
- createdAt: string;
580
- isRead: boolean;
581
- })[];
19
+ export declare const processAndFilterNotifications: (notifications: RawNotificationUnion[], readIds: string[]) => INotification[];
582
20
  //# sourceMappingURL=process-notifications.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"process-notifications.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/processors/process-notifications.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,aAAa,EAEd,6CAAyC;AAE1C,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACrB,+CAA2C;AAkB5C;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,oBAAoB,EAClC,iBAAiB,GAAE,MAAM,EAAO,GAC/B,aAAa,CAuBf;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,oBAAoB,EAClC,iBAAiB,GAAE,MAAM,EAAO,GAC/B,aAAa,GAAG,SAAS,CAU3B;AAGD,eAAO,MAAM,6BAA6B,OACpC,oBAAoB,EAAE,WACjB,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAC2D,CAAC"}
1
+ {"version":3,"file":"process-notifications.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/processors/process-notifications.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACrB,+CAA2C;AAmB5C;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,oBAAoB,EAClC,iBAAiB,GAAE,MAAM,EAAO,GAC/B,aAAa,CAwBf;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,oBAAoB,EAClC,iBAAiB,GAAE,MAAM,EAAO,GAC/B,aAAa,GAAG,SAAS,CAU3B;AAGD,eAAO,MAAM,6BAA6B,kBACzB,oBAAoB,EAAE,WAC5B,MAAM,EAAE,KAChB,aAAa,EAGW,CAAC"}
@@ -2,9 +2,9 @@ import { processAPINotifications } from "./process-api-notifications.mjs";
2
2
  import { isFeatureAnnouncementRead, processFeatureAnnouncement } from "./process-feature-announcement.mjs";
3
3
  import { processSnapNotification } from "./process-snap-notifications.mjs";
4
4
  import { TRIGGER_TYPES, NOTIFICATION_API_TRIGGER_TYPES_SET } from "../constants/notification-schema.mjs";
5
- const isOnChainNotification = (n) => NOTIFICATION_API_TRIGGER_TYPES_SET.has(n.type);
6
- const isFeatureAnnouncement = (n) => n.type === TRIGGER_TYPES.FEATURES_ANNOUNCEMENT;
7
- const isSnapNotification = (n) => n.type === TRIGGER_TYPES.SNAP;
5
+ const isOnChainNotification = (notification) => NOTIFICATION_API_TRIGGER_TYPES_SET.has(notification.type);
6
+ const isFeatureAnnouncement = (notification) => notification.type === TRIGGER_TYPES.FEATURES_ANNOUNCEMENT;
7
+ const isSnapNotification = (notification) => notification.type === TRIGGER_TYPES.SNAP;
8
8
  /**
9
9
  * Process feature announcement and wallet notifications into a shared/normalised notification shape.
10
10
  * We can still differentiate notifications by the `type` property
@@ -14,14 +14,14 @@ const isSnapNotification = (n) => n.type === TRIGGER_TYPES.SNAP;
14
14
  * @returns a processed notification
15
15
  */
16
16
  export function processNotification(notification, readNotifications = []) {
17
- const exhaustedAllCases = (_) => {
17
+ const exhaustedAllCases = (_uncheckedCase) => {
18
18
  const type = notification?.type;
19
19
  throw new Error(`No processor found for notification kind ${type}`);
20
20
  };
21
21
  if (isFeatureAnnouncement(notification)) {
22
- const n = processFeatureAnnouncement(notification);
23
- n.isRead = isFeatureAnnouncementRead(n, readNotifications);
24
- return n;
22
+ const processedNotification = processFeatureAnnouncement(notification);
23
+ processedNotification.isRead = isFeatureAnnouncementRead(processedNotification, readNotifications);
24
+ return processedNotification;
25
25
  }
26
26
  if (isSnapNotification(notification)) {
27
27
  return processSnapNotification(notification);
@@ -47,6 +47,8 @@ export function safeProcessNotification(notification, readNotifications = []) {
47
47
  return undefined;
48
48
  }
49
49
  }
50
- const isNotUndefined = (t) => Boolean(t);
51
- export const processAndFilterNotifications = (ns, readIds) => ns.map((n) => safeProcessNotification(n, readIds)).filter(isNotUndefined);
50
+ const isNotUndefined = (item) => Boolean(item);
51
+ export const processAndFilterNotifications = (notifications, readIds) => notifications
52
+ .map((notification) => safeProcessNotification(notification, readIds))
53
+ .filter(isNotUndefined);
52
54
  //# sourceMappingURL=process-notifications.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"process-notifications.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/processors/process-notifications.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,wCAAoC;AACtE,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC3B,2CAAuC;AACxC,OAAO,EAAE,uBAAuB,EAAE,yCAAqC;AACvE,OAAO,EACL,aAAa,EACb,kCAAkC,EACnC,6CAAyC;AAS1C,MAAM,qBAAqB,GAAG,CAC5B,CAAuB,EACS,EAAE,CAClC,kCAAkC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAEjD,MAAM,qBAAqB,GAAG,CAC5B,CAAuB,EACkB,EAAE,CAC3C,CAAC,CAAC,IAAI,KAAK,aAAa,CAAC,qBAAqB,CAAC;AAEjD,MAAM,kBAAkB,GAAG,CACzB,CAAuB,EACG,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,CAAC,IAAI,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CACjC,YAAkC,EAClC,oBAA8B,EAAE;IAEhC,MAAM,iBAAiB,GAAG,CAAC,CAAQ,EAAE,EAAE;QACrC,MAAM,IAAI,GAAW,YAAY,EAAE,IAAI,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,4CAA4C,IAAI,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC;IAEF,IAAI,qBAAqB,CAAC,YAAY,CAAC,EAAE,CAAC;QACxC,MAAM,CAAC,GAAG,0BAA0B,CAClC,YAAkD,CACnD,CAAC;QACF,CAAC,CAAC,MAAM,GAAG,yBAAyB,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC;QAC3D,OAAO,CAAC,CAAC;IACX,CAAC;IAED,IAAI,kBAAkB,CAAC,YAAY,CAAC,EAAE,CAAC;QACrC,OAAO,uBAAuB,CAAC,YAAY,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,qBAAqB,CAAC,YAAY,CAAC,EAAE,CAAC;QACxC,OAAO,uBAAuB,CAAC,YAAY,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,iBAAiB,CAAC,YAAqB,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACrC,YAAkC,EAClC,oBAA8B,EAAE;IAEhC,IAAI,CAAC;QACH,MAAM,qBAAqB,GAAG,mBAAmB,CAC/C,YAAY,EACZ,iBAAiB,CAClB,CAAC;QACF,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,cAAc,GAAG,CAAO,CAAQ,EAAa,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACjE,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,EAA0B,EAC1B,OAAiB,EACjB,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,uBAAuB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC","sourcesContent":["import { processAPINotifications } from './process-api-notifications';\nimport {\n isFeatureAnnouncementRead,\n processFeatureAnnouncement,\n} from './process-feature-announcement';\nimport { processSnapNotification } from './process-snap-notifications';\nimport {\n TRIGGER_TYPES,\n NOTIFICATION_API_TRIGGER_TYPES_SET,\n} from '../constants/notification-schema';\nimport type { FeatureAnnouncementRawNotification } from '../types/feature-announcement/feature-announcement';\nimport type {\n INotification,\n RawNotificationUnion,\n} from '../types/notification/notification';\nimport type { NormalisedAPINotification } from '../types/notification-api/notification-api';\nimport type { RawSnapNotification } from '../types/snaps';\n\nconst isOnChainNotification = (\n n: RawNotificationUnion,\n): n is NormalisedAPINotification =>\n NOTIFICATION_API_TRIGGER_TYPES_SET.has(n.type);\n\nconst isFeatureAnnouncement = (\n n: RawNotificationUnion,\n): n is FeatureAnnouncementRawNotification =>\n n.type === TRIGGER_TYPES.FEATURES_ANNOUNCEMENT;\n\nconst isSnapNotification = (\n n: RawNotificationUnion,\n): n is RawSnapNotification => n.type === TRIGGER_TYPES.SNAP;\n\n/**\n * Process feature announcement and wallet notifications into a shared/normalised notification shape.\n * We can still differentiate notifications by the `type` property\n *\n * @param notification - a feature announcement or on chain notification\n * @param readNotifications - all read notifications currently\n * @returns a processed notification\n */\nexport function processNotification(\n notification: RawNotificationUnion,\n readNotifications: string[] = [],\n): INotification {\n const exhaustedAllCases = (_: never) => {\n const type: string = notification?.type;\n throw new Error(`No processor found for notification kind ${type}`);\n };\n\n if (isFeatureAnnouncement(notification)) {\n const n = processFeatureAnnouncement(\n notification as FeatureAnnouncementRawNotification,\n );\n n.isRead = isFeatureAnnouncementRead(n, readNotifications);\n return n;\n }\n\n if (isSnapNotification(notification)) {\n return processSnapNotification(notification);\n }\n\n if (isOnChainNotification(notification)) {\n return processAPINotifications(notification);\n }\n\n return exhaustedAllCases(notification as never);\n}\n\n/**\n * Safe version of processing a notification. Rather than throwing an error if failed to process, it will return the Notification or undefined\n *\n * @param notification - notification to processes\n * @param readNotifications - all read notifications currently\n * @returns a process notification or undefined if failed to process\n */\nexport function safeProcessNotification(\n notification: RawNotificationUnion,\n readNotifications: string[] = [],\n): INotification | undefined {\n try {\n const processedNotification = processNotification(\n notification,\n readNotifications,\n );\n return processedNotification;\n } catch {\n return undefined;\n }\n}\n\nconst isNotUndefined = <Item>(t?: Item): t is Item => Boolean(t);\nexport const processAndFilterNotifications = (\n ns: RawNotificationUnion[],\n readIds: string[],\n) => ns.map((n) => safeProcessNotification(n, readIds)).filter(isNotUndefined);\n"]}
1
+ {"version":3,"file":"process-notifications.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/processors/process-notifications.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,wCAAoC;AACtE,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC3B,2CAAuC;AACxC,OAAO,EAAE,uBAAuB,EAAE,yCAAqC;AACvE,OAAO,EACL,aAAa,EACb,kCAAkC,EACnC,6CAAyC;AAS1C,MAAM,qBAAqB,GAAG,CAC5B,YAAkC,EACS,EAAE,CAC7C,kCAAkC,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AAE5D,MAAM,qBAAqB,GAAG,CAC5B,YAAkC,EACkB,EAAE,CACtD,YAAY,CAAC,IAAI,KAAK,aAAa,CAAC,qBAAqB,CAAC;AAE5D,MAAM,kBAAkB,GAAG,CACzB,YAAkC,EACG,EAAE,CACvC,YAAY,CAAC,IAAI,KAAK,aAAa,CAAC,IAAI,CAAC;AAE3C;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CACjC,YAAkC,EAClC,oBAA8B,EAAE;IAEhC,MAAM,iBAAiB,GAAG,CAAC,cAAqB,EAAS,EAAE;QACzD,MAAM,IAAI,GAAW,YAAY,EAAE,IAAI,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,4CAA4C,IAAI,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC;IAEF,IAAI,qBAAqB,CAAC,YAAY,CAAC,EAAE,CAAC;QACxC,MAAM,qBAAqB,GAAG,0BAA0B,CAAC,YAAY,CAAC,CAAC;QACvE,qBAAqB,CAAC,MAAM,GAAG,yBAAyB,CACtD,qBAAqB,EACrB,iBAAiB,CAClB,CAAC;QACF,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IAED,IAAI,kBAAkB,CAAC,YAAY,CAAC,EAAE,CAAC;QACrC,OAAO,uBAAuB,CAAC,YAAY,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,qBAAqB,CAAC,YAAY,CAAC,EAAE,CAAC;QACxC,OAAO,uBAAuB,CAAC,YAAY,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,iBAAiB,CAAC,YAAY,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACrC,YAAkC,EAClC,oBAA8B,EAAE;IAEhC,IAAI,CAAC;QACH,MAAM,qBAAqB,GAAG,mBAAmB,CAC/C,YAAY,EACZ,iBAAiB,CAClB,CAAC;QACF,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,cAAc,GAAG,CAAO,IAAW,EAAgB,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC1E,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,aAAqC,EACrC,OAAiB,EACA,EAAE,CACnB,aAAa;KACV,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,uBAAuB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;KACrE,MAAM,CAAC,cAAc,CAAC,CAAC","sourcesContent":["import { processAPINotifications } from './process-api-notifications';\nimport {\n isFeatureAnnouncementRead,\n processFeatureAnnouncement,\n} from './process-feature-announcement';\nimport { processSnapNotification } from './process-snap-notifications';\nimport {\n TRIGGER_TYPES,\n NOTIFICATION_API_TRIGGER_TYPES_SET,\n} from '../constants/notification-schema';\nimport type { FeatureAnnouncementRawNotification } from '../types/feature-announcement/feature-announcement';\nimport type {\n INotification,\n RawNotificationUnion,\n} from '../types/notification/notification';\nimport type { NormalisedAPINotification } from '../types/notification-api/notification-api';\nimport type { RawSnapNotification } from '../types/snaps';\n\nconst isOnChainNotification = (\n notification: RawNotificationUnion,\n): notification is NormalisedAPINotification =>\n NOTIFICATION_API_TRIGGER_TYPES_SET.has(notification.type);\n\nconst isFeatureAnnouncement = (\n notification: RawNotificationUnion,\n): notification is FeatureAnnouncementRawNotification =>\n notification.type === TRIGGER_TYPES.FEATURES_ANNOUNCEMENT;\n\nconst isSnapNotification = (\n notification: RawNotificationUnion,\n): notification is RawSnapNotification =>\n notification.type === TRIGGER_TYPES.SNAP;\n\n/**\n * Process feature announcement and wallet notifications into a shared/normalised notification shape.\n * We can still differentiate notifications by the `type` property\n *\n * @param notification - a feature announcement or on chain notification\n * @param readNotifications - all read notifications currently\n * @returns a processed notification\n */\nexport function processNotification(\n notification: RawNotificationUnion,\n readNotifications: string[] = [],\n): INotification {\n const exhaustedAllCases = (_uncheckedCase: never): never => {\n const type: string = notification?.type;\n throw new Error(`No processor found for notification kind ${type}`);\n };\n\n if (isFeatureAnnouncement(notification)) {\n const processedNotification = processFeatureAnnouncement(notification);\n processedNotification.isRead = isFeatureAnnouncementRead(\n processedNotification,\n readNotifications,\n );\n return processedNotification;\n }\n\n if (isSnapNotification(notification)) {\n return processSnapNotification(notification);\n }\n\n if (isOnChainNotification(notification)) {\n return processAPINotifications(notification);\n }\n\n return exhaustedAllCases(notification);\n}\n\n/**\n * Safe version of processing a notification. Rather than throwing an error if failed to process, it will return the Notification or undefined\n *\n * @param notification - notification to processes\n * @param readNotifications - all read notifications currently\n * @returns a process notification or undefined if failed to process\n */\nexport function safeProcessNotification(\n notification: RawNotificationUnion,\n readNotifications: string[] = [],\n): INotification | undefined {\n try {\n const processedNotification = processNotification(\n notification,\n readNotifications,\n );\n return processedNotification;\n } catch {\n return undefined;\n }\n}\n\nconst isNotUndefined = <Item>(item?: Item): item is Item => Boolean(item);\nexport const processAndFilterNotifications = (\n notifications: RawNotificationUnion[],\n readIds: string[],\n): INotification[] =>\n notifications\n .map((notification) => safeProcessNotification(notification, readIds))\n .filter(isNotUndefined);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"process-snap-notifications.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/processors/process-snap-notifications.ts"],"names":[],"mappings":";;;AAAA,+BAAkC;AAKlC;;;;;GAKG;AACI,MAAM,uBAAuB,GAAG,CACrC,gBAAqC,EACtB,EAAE;IACjB,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,gBAAgB,CAAC;IAClD,OAAO;QACL,EAAE,EAAE,IAAA,SAAI,GAAE;QACV,QAAQ;QACR,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,MAAM,EAAE,KAAK;QACb,IAAI;QACJ,IAAI;KACL,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,uBAAuB,2BAYlC","sourcesContent":["import { v4 as uuid } from 'uuid';\n\nimport { type INotification } from '../types';\nimport type { RawSnapNotification } from '../types/snaps';\n\n/**\n * Processes a snap notification into a normalized shape.\n *\n * @param snapNotification - A raw snap notification.\n * @returns a normalized snap notification.\n */\nexport const processSnapNotification = (\n snapNotification: RawSnapNotification,\n): INotification => {\n const { data, type, readDate } = snapNotification;\n return {\n id: uuid(),\n readDate,\n createdAt: new Date().toISOString(),\n isRead: false,\n type,\n data,\n };\n};\n"]}
1
+ {"version":3,"file":"process-snap-notifications.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/processors/process-snap-notifications.ts"],"names":[],"mappings":";;;AAAA,+BAAkC;AAKlC;;;;;GAKG;AACI,MAAM,uBAAuB,GAAG,CACrC,gBAAqC,EACtB,EAAE;IACjB,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,gBAAgB,CAAC;IAClD,OAAO;QACL,EAAE,EAAE,IAAA,SAAI,GAAE;QACV,QAAQ;QACR,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,MAAM,EAAE,KAAK;QACb,IAAI;QACJ,IAAI;KACL,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,uBAAuB,2BAYlC","sourcesContent":["import { v4 as uuid } from 'uuid';\n\nimport type { INotification } from '../types';\nimport type { RawSnapNotification } from '../types/snaps';\n\n/**\n * Processes a snap notification into a normalized shape.\n *\n * @param snapNotification - A raw snap notification.\n * @returns a normalized snap notification.\n */\nexport const processSnapNotification = (\n snapNotification: RawSnapNotification,\n): INotification => {\n const { data, type, readDate } = snapNotification;\n return {\n id: uuid(),\n readDate,\n createdAt: new Date().toISOString(),\n isRead: false,\n type,\n data,\n };\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { type INotification } from "../types/index.cjs";
1
+ import type { INotification } from "../types/index.cjs";
2
2
  import type { RawSnapNotification } from "../types/snaps/index.cjs";
3
3
  /**
4
4
  * Processes a snap notification into a normalized shape.
@@ -1 +1 @@
1
- {"version":3,"file":"process-snap-notifications.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/processors/process-snap-notifications.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAE,2BAAiB;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,iCAAuB;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,qBAChB,mBAAmB,KACpC,aAUF,CAAC"}
1
+ {"version":3,"file":"process-snap-notifications.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/processors/process-snap-notifications.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,2BAAiB;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,iCAAuB;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,qBAChB,mBAAmB,KACpC,aAUF,CAAC"}
@@ -1,4 +1,4 @@
1
- import { type INotification } from "../types/index.mjs";
1
+ import type { INotification } from "../types/index.mjs";
2
2
  import type { RawSnapNotification } from "../types/snaps/index.mjs";
3
3
  /**
4
4
  * Processes a snap notification into a normalized shape.
@@ -1 +1 @@
1
- {"version":3,"file":"process-snap-notifications.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/processors/process-snap-notifications.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAE,2BAAiB;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,iCAAuB;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,qBAChB,mBAAmB,KACpC,aAUF,CAAC"}
1
+ {"version":3,"file":"process-snap-notifications.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/processors/process-snap-notifications.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,2BAAiB;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,iCAAuB;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,qBAChB,mBAAmB,KACpC,aAUF,CAAC"}