@metamask-previews/notification-services-controller 10.0.0-preview-7dcef379 → 10.0.0-preview-f9611039

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 (144) hide show
  1. package/CHANGELOG.md +0 -16
  2. package/dist/NotificationServicesController/NotificationServicesController.cjs +188 -76
  3. package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -1
  4. package/dist/NotificationServicesController/NotificationServicesController.d.cts +16 -10
  5. package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -1
  6. package/dist/NotificationServicesController/NotificationServicesController.d.mts +16 -10
  7. package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -1
  8. package/dist/NotificationServicesController/NotificationServicesController.mjs +189 -77
  9. package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
  10. package/dist/NotificationServicesController/constants/constants.cjs +7 -0
  11. package/dist/NotificationServicesController/constants/constants.cjs.map +1 -0
  12. package/dist/NotificationServicesController/constants/constants.d.cts +3 -0
  13. package/dist/NotificationServicesController/constants/constants.d.cts.map +1 -0
  14. package/dist/NotificationServicesController/constants/constants.d.mts +3 -0
  15. package/dist/NotificationServicesController/constants/constants.d.mts.map +1 -0
  16. package/dist/NotificationServicesController/constants/constants.mjs +4 -0
  17. package/dist/NotificationServicesController/constants/constants.mjs.map +1 -0
  18. package/dist/NotificationServicesController/constants/index.cjs +1 -0
  19. package/dist/NotificationServicesController/constants/index.cjs.map +1 -1
  20. package/dist/NotificationServicesController/constants/index.d.cts +1 -0
  21. package/dist/NotificationServicesController/constants/index.d.cts.map +1 -1
  22. package/dist/NotificationServicesController/constants/index.d.mts +1 -0
  23. package/dist/NotificationServicesController/constants/index.d.mts.map +1 -1
  24. package/dist/NotificationServicesController/constants/index.mjs +1 -0
  25. package/dist/NotificationServicesController/constants/index.mjs.map +1 -1
  26. package/dist/NotificationServicesController/mocks/index.cjs +2 -0
  27. package/dist/NotificationServicesController/mocks/index.cjs.map +1 -1
  28. package/dist/NotificationServicesController/mocks/index.d.cts +2 -0
  29. package/dist/NotificationServicesController/mocks/index.d.cts.map +1 -1
  30. package/dist/NotificationServicesController/mocks/index.d.mts +2 -0
  31. package/dist/NotificationServicesController/mocks/index.d.mts.map +1 -1
  32. package/dist/NotificationServicesController/mocks/index.mjs +2 -0
  33. package/dist/NotificationServicesController/mocks/index.mjs.map +1 -1
  34. package/dist/NotificationServicesController/mocks/mock-notification-trigger.cjs +22 -0
  35. package/dist/NotificationServicesController/mocks/mock-notification-trigger.cjs.map +1 -0
  36. package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.cts +9 -0
  37. package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.cts.map +1 -0
  38. package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.mts +9 -0
  39. package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.mts.map +1 -0
  40. package/dist/NotificationServicesController/mocks/mock-notification-trigger.mjs +18 -0
  41. package/dist/NotificationServicesController/mocks/mock-notification-trigger.mjs.map +1 -0
  42. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.cjs +82 -0
  43. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.cjs.map +1 -0
  44. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.cts +35 -0
  45. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.cts.map +1 -0
  46. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.mts +35 -0
  47. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.mts.map +1 -0
  48. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.mjs +76 -0
  49. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.mjs.map +1 -0
  50. package/dist/NotificationServicesController/mocks/mockResponses.cjs +9 -9
  51. package/dist/NotificationServicesController/mocks/mockResponses.cjs.map +1 -1
  52. package/dist/NotificationServicesController/mocks/mockResponses.d.cts +4 -7
  53. package/dist/NotificationServicesController/mocks/mockResponses.d.cts.map +1 -1
  54. package/dist/NotificationServicesController/mocks/mockResponses.d.mts +4 -7
  55. package/dist/NotificationServicesController/mocks/mockResponses.d.mts.map +1 -1
  56. package/dist/NotificationServicesController/mocks/mockResponses.mjs +7 -7
  57. package/dist/NotificationServicesController/mocks/mockResponses.mjs.map +1 -1
  58. package/dist/NotificationServicesController/processors/process-notifications.cjs +1 -4
  59. package/dist/NotificationServicesController/processors/process-notifications.cjs.map +1 -1
  60. package/dist/NotificationServicesController/processors/process-notifications.d.cts +0 -623
  61. package/dist/NotificationServicesController/processors/process-notifications.d.cts.map +1 -1
  62. package/dist/NotificationServicesController/processors/process-notifications.d.mts +0 -623
  63. package/dist/NotificationServicesController/processors/process-notifications.d.mts.map +1 -1
  64. package/dist/NotificationServicesController/processors/process-notifications.mjs +0 -2
  65. package/dist/NotificationServicesController/processors/process-notifications.mjs.map +1 -1
  66. package/dist/NotificationServicesController/services/onchain-notifications.cjs +140 -67
  67. package/dist/NotificationServicesController/services/onchain-notifications.cjs.map +1 -1
  68. package/dist/NotificationServicesController/services/onchain-notifications.d.cts +31 -25
  69. package/dist/NotificationServicesController/services/onchain-notifications.d.cts.map +1 -1
  70. package/dist/NotificationServicesController/services/onchain-notifications.d.mts +31 -25
  71. package/dist/NotificationServicesController/services/onchain-notifications.d.mts.map +1 -1
  72. package/dist/NotificationServicesController/services/onchain-notifications.mjs +137 -65
  73. package/dist/NotificationServicesController/services/onchain-notifications.mjs.map +1 -1
  74. package/dist/NotificationServicesController/types/index.cjs.map +1 -1
  75. package/dist/NotificationServicesController/types/index.d.cts +1 -0
  76. package/dist/NotificationServicesController/types/index.d.cts.map +1 -1
  77. package/dist/NotificationServicesController/types/index.d.mts +1 -0
  78. package/dist/NotificationServicesController/types/index.d.mts.map +1 -1
  79. package/dist/NotificationServicesController/types/index.mjs.map +1 -1
  80. package/dist/NotificationServicesController/types/user-storage/index.cjs +3 -0
  81. package/dist/NotificationServicesController/types/user-storage/index.cjs.map +1 -0
  82. package/dist/NotificationServicesController/types/user-storage/index.d.cts +2 -0
  83. package/dist/NotificationServicesController/types/user-storage/index.d.cts.map +1 -0
  84. package/dist/NotificationServicesController/types/user-storage/index.d.mts +2 -0
  85. package/dist/NotificationServicesController/types/user-storage/index.d.mts.map +1 -0
  86. package/dist/NotificationServicesController/types/user-storage/index.mjs +2 -0
  87. package/dist/NotificationServicesController/types/user-storage/index.mjs.map +1 -0
  88. package/dist/NotificationServicesController/types/user-storage/user-storage.cjs +3 -0
  89. package/dist/NotificationServicesController/types/user-storage/user-storage.cjs.map +1 -0
  90. package/dist/NotificationServicesController/types/user-storage/user-storage.d.cts +26 -0
  91. package/dist/NotificationServicesController/types/user-storage/user-storage.d.cts.map +1 -0
  92. package/dist/NotificationServicesController/types/user-storage/user-storage.d.mts +26 -0
  93. package/dist/NotificationServicesController/types/user-storage/user-storage.d.mts.map +1 -0
  94. package/dist/NotificationServicesController/types/user-storage/user-storage.mjs +2 -0
  95. package/dist/NotificationServicesController/types/user-storage/user-storage.mjs.map +1 -0
  96. package/dist/NotificationServicesController/utils/utils.cjs +350 -1
  97. package/dist/NotificationServicesController/utils/utils.cjs.map +1 -1
  98. package/dist/NotificationServicesController/utils/utils.d.cts +141 -0
  99. package/dist/NotificationServicesController/utils/utils.d.cts.map +1 -1
  100. package/dist/NotificationServicesController/utils/utils.d.mts +141 -0
  101. package/dist/NotificationServicesController/utils/utils.d.mts.map +1 -1
  102. package/dist/NotificationServicesController/utils/utils.mjs +337 -0
  103. package/dist/NotificationServicesController/utils/utils.mjs.map +1 -1
  104. package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs +15 -22
  105. package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -1
  106. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts +5 -6
  107. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -1
  108. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts +5 -6
  109. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -1
  110. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +16 -23
  111. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -1
  112. package/dist/NotificationServicesPushController/mocks/mockResponse.cjs +16 -1
  113. package/dist/NotificationServicesPushController/mocks/mockResponse.cjs.map +1 -1
  114. package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts +7 -0
  115. package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts.map +1 -1
  116. package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts +7 -0
  117. package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts.map +1 -1
  118. package/dist/NotificationServicesPushController/mocks/mockResponse.mjs +14 -0
  119. package/dist/NotificationServicesPushController/mocks/mockResponse.mjs.map +1 -1
  120. package/dist/NotificationServicesPushController/services/endpoints.cjs +1 -1
  121. package/dist/NotificationServicesPushController/services/endpoints.cjs.map +1 -1
  122. package/dist/NotificationServicesPushController/services/endpoints.d.cts +1 -1
  123. package/dist/NotificationServicesPushController/services/endpoints.d.cts.map +1 -1
  124. package/dist/NotificationServicesPushController/services/endpoints.d.mts +1 -1
  125. package/dist/NotificationServicesPushController/services/endpoints.d.mts.map +1 -1
  126. package/dist/NotificationServicesPushController/services/endpoints.mjs +1 -1
  127. package/dist/NotificationServicesPushController/services/endpoints.mjs.map +1 -1
  128. package/dist/NotificationServicesPushController/services/services.cjs +41 -18
  129. package/dist/NotificationServicesPushController/services/services.cjs.map +1 -1
  130. package/dist/NotificationServicesPushController/services/services.d.cts +33 -19
  131. package/dist/NotificationServicesPushController/services/services.d.cts.map +1 -1
  132. package/dist/NotificationServicesPushController/services/services.d.mts +33 -19
  133. package/dist/NotificationServicesPushController/services/services.d.mts.map +1 -1
  134. package/dist/NotificationServicesPushController/services/services.mjs +39 -17
  135. package/dist/NotificationServicesPushController/services/services.mjs.map +1 -1
  136. package/package.json +1 -1
  137. package/dist/NotificationServicesController/services/notification-config-cache.cjs +0 -72
  138. package/dist/NotificationServicesController/services/notification-config-cache.cjs.map +0 -1
  139. package/dist/NotificationServicesController/services/notification-config-cache.d.cts +0 -19
  140. package/dist/NotificationServicesController/services/notification-config-cache.d.cts.map +0 -1
  141. package/dist/NotificationServicesController/services/notification-config-cache.d.mts +0 -19
  142. package/dist/NotificationServicesController/services/notification-config-cache.d.mts.map +0 -1
  143. package/dist/NotificationServicesController/services/notification-config-cache.mjs +0 -68
  144. package/dist/NotificationServicesController/services/notification-config-cache.mjs.map +0 -1
@@ -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,626 +16,4 @@ 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
- trigger_id: string;
29
- chain_id: number;
30
- block_number: number;
31
- block_timestamp: string;
32
- tx_hash: string;
33
- unread: boolean;
34
- created_at: string;
35
- address: string;
36
- type: TRIGGER_TYPES.METAMASK_SWAP_COMPLETED;
37
- data: {
38
- kind: "metamask_swap_completed";
39
- network_fee: {
40
- gas_price: string;
41
- native_token_price_in_usd: string;
42
- };
43
- rate: string;
44
- token_in: {
45
- address: string;
46
- symbol: string;
47
- name: string;
48
- amount: string;
49
- decimals: string;
50
- image: string;
51
- usd: string;
52
- };
53
- token_out: {
54
- address: string;
55
- symbol: string;
56
- name: string;
57
- amount: string;
58
- decimals: string;
59
- image: string;
60
- usd: string;
61
- };
62
- };
63
- createdAt: string;
64
- isRead: boolean;
65
- } | {
66
- id: string;
67
- trigger_id: string;
68
- chain_id: number;
69
- block_number: number;
70
- block_timestamp: string;
71
- tx_hash: string;
72
- unread: boolean;
73
- created_at: string;
74
- address: string;
75
- type: TRIGGER_TYPES.ERC20_SENT;
76
- data: {
77
- kind: "erc20_sent";
78
- network_fee: {
79
- gas_price: string;
80
- native_token_price_in_usd: string;
81
- };
82
- from: string;
83
- to: string;
84
- token: {
85
- address: string;
86
- symbol: string;
87
- name: string;
88
- amount: string;
89
- decimals: string;
90
- image: string;
91
- usd: string;
92
- };
93
- };
94
- createdAt: string;
95
- isRead: boolean;
96
- } | {
97
- id: string;
98
- trigger_id: string;
99
- chain_id: number;
100
- block_number: number;
101
- block_timestamp: string;
102
- tx_hash: string;
103
- unread: boolean;
104
- created_at: string;
105
- address: string;
106
- type: TRIGGER_TYPES.ERC20_RECEIVED;
107
- data: {
108
- kind: "erc20_received";
109
- network_fee: {
110
- gas_price: string;
111
- native_token_price_in_usd: string;
112
- };
113
- from: string;
114
- to: string;
115
- token: {
116
- address: string;
117
- symbol: string;
118
- name: string;
119
- amount: string;
120
- decimals: string;
121
- image: string;
122
- usd: string;
123
- };
124
- };
125
- createdAt: string;
126
- isRead: boolean;
127
- } | {
128
- id: string;
129
- trigger_id: string;
130
- chain_id: number;
131
- block_number: number;
132
- block_timestamp: string;
133
- tx_hash: string;
134
- unread: boolean;
135
- created_at: string;
136
- address: string;
137
- type: TRIGGER_TYPES.ETH_SENT;
138
- data: {
139
- kind: "eth_sent";
140
- network_fee: {
141
- gas_price: string;
142
- native_token_price_in_usd: string;
143
- };
144
- from: string;
145
- to: string;
146
- amount: {
147
- usd: string;
148
- eth: string;
149
- };
150
- };
151
- createdAt: string;
152
- isRead: boolean;
153
- } | {
154
- id: string;
155
- trigger_id: string;
156
- chain_id: number;
157
- block_number: number;
158
- block_timestamp: string;
159
- tx_hash: string;
160
- unread: boolean;
161
- created_at: string;
162
- address: string;
163
- type: TRIGGER_TYPES.ETH_RECEIVED;
164
- data: {
165
- kind: "eth_received";
166
- network_fee: {
167
- gas_price: string;
168
- native_token_price_in_usd: string;
169
- };
170
- from: string;
171
- to: string;
172
- amount: {
173
- usd: string;
174
- eth: string;
175
- };
176
- };
177
- createdAt: string;
178
- isRead: boolean;
179
- } | {
180
- id: string;
181
- trigger_id: string;
182
- chain_id: number;
183
- block_number: number;
184
- block_timestamp: string;
185
- tx_hash: string;
186
- unread: boolean;
187
- created_at: string;
188
- address: string;
189
- type: TRIGGER_TYPES.ROCKETPOOL_STAKE_COMPLETED;
190
- data: {
191
- kind: "rocketpool_stake_completed";
192
- network_fee: {
193
- gas_price: string;
194
- native_token_price_in_usd: string;
195
- };
196
- stake_in: {
197
- address: string;
198
- symbol: string;
199
- name: string;
200
- amount: string;
201
- decimals: string;
202
- image: string;
203
- usd: string;
204
- };
205
- stake_out: {
206
- address: string;
207
- symbol: string;
208
- name: string;
209
- amount: string;
210
- decimals: string;
211
- image: string;
212
- usd: string;
213
- };
214
- };
215
- createdAt: string;
216
- isRead: boolean;
217
- } | {
218
- id: string;
219
- trigger_id: string;
220
- chain_id: number;
221
- block_number: number;
222
- block_timestamp: string;
223
- tx_hash: string;
224
- unread: boolean;
225
- created_at: string;
226
- address: string;
227
- type: TRIGGER_TYPES.ROCKETPOOL_UNSTAKE_COMPLETED;
228
- data: {
229
- kind: "rocketpool_unstake_completed";
230
- network_fee: {
231
- gas_price: string;
232
- native_token_price_in_usd: string;
233
- };
234
- stake_in: {
235
- address: string;
236
- symbol: string;
237
- name: string;
238
- amount: string;
239
- decimals: string;
240
- image: string;
241
- usd: string;
242
- };
243
- stake_out: {
244
- address: string;
245
- symbol: string;
246
- name: string;
247
- amount: string;
248
- decimals: string;
249
- image: string;
250
- usd: string;
251
- };
252
- };
253
- createdAt: string;
254
- isRead: boolean;
255
- } | {
256
- id: string;
257
- trigger_id: string;
258
- chain_id: number;
259
- block_number: number;
260
- block_timestamp: string;
261
- tx_hash: string;
262
- unread: boolean;
263
- created_at: string;
264
- address: string;
265
- type: TRIGGER_TYPES.LIDO_STAKE_COMPLETED;
266
- data: {
267
- kind: "lido_stake_completed";
268
- network_fee: {
269
- gas_price: string;
270
- native_token_price_in_usd: string;
271
- };
272
- stake_in: {
273
- address: string;
274
- symbol: string;
275
- name: string;
276
- amount: string;
277
- decimals: string;
278
- image: string;
279
- usd: string;
280
- };
281
- stake_out: {
282
- address: string;
283
- symbol: string;
284
- name: string;
285
- amount: string;
286
- decimals: string;
287
- image: string;
288
- usd: string;
289
- };
290
- };
291
- createdAt: string;
292
- isRead: boolean;
293
- } | {
294
- id: string;
295
- trigger_id: string;
296
- chain_id: number;
297
- block_number: number;
298
- block_timestamp: string;
299
- tx_hash: string;
300
- unread: boolean;
301
- created_at: string;
302
- address: string;
303
- type: TRIGGER_TYPES.LIDO_WITHDRAWAL_REQUESTED;
304
- data: {
305
- kind: "lido_withdrawal_requested";
306
- network_fee: {
307
- gas_price: string;
308
- native_token_price_in_usd: string;
309
- };
310
- stake_in: {
311
- address: string;
312
- symbol: string;
313
- name: string;
314
- amount: string;
315
- decimals: string;
316
- image: string;
317
- usd: string;
318
- };
319
- stake_out: {
320
- address: string;
321
- symbol: string;
322
- name: string;
323
- amount: string;
324
- decimals: string;
325
- image: string;
326
- usd: string;
327
- };
328
- };
329
- createdAt: string;
330
- isRead: boolean;
331
- } | {
332
- id: string;
333
- trigger_id: string;
334
- chain_id: number;
335
- block_number: number;
336
- block_timestamp: string;
337
- tx_hash: string;
338
- unread: boolean;
339
- created_at: string;
340
- address: string;
341
- type: TRIGGER_TYPES.LIDO_WITHDRAWAL_COMPLETED;
342
- data: {
343
- kind: "lido_withdrawal_completed";
344
- network_fee: {
345
- gas_price: string;
346
- native_token_price_in_usd: string;
347
- };
348
- stake_in: {
349
- address: string;
350
- symbol: string;
351
- name: string;
352
- amount: string;
353
- decimals: string;
354
- image: string;
355
- usd: string;
356
- };
357
- stake_out: {
358
- address: string;
359
- symbol: string;
360
- name: string;
361
- amount: string;
362
- decimals: string;
363
- image: string;
364
- usd: string;
365
- };
366
- };
367
- createdAt: string;
368
- isRead: boolean;
369
- } | {
370
- id: string;
371
- trigger_id: string;
372
- chain_id: number;
373
- block_number: number;
374
- block_timestamp: string;
375
- tx_hash: string;
376
- unread: boolean;
377
- created_at: string;
378
- address: string;
379
- type: TRIGGER_TYPES.LIDO_STAKE_READY_TO_BE_WITHDRAWN;
380
- data: {
381
- kind: "lido_stake_ready_to_be_withdrawn";
382
- request_id: string;
383
- staked_eth: {
384
- address: string;
385
- symbol: string;
386
- name: string;
387
- amount: string;
388
- decimals: string;
389
- image: string;
390
- usd: string;
391
- };
392
- };
393
- createdAt: string;
394
- isRead: boolean;
395
- } | {
396
- id: string;
397
- trigger_id: string;
398
- chain_id: number;
399
- block_number: number;
400
- block_timestamp: string;
401
- tx_hash: string;
402
- unread: boolean;
403
- created_at: string;
404
- address: string;
405
- type: TRIGGER_TYPES.ERC721_SENT;
406
- data: {
407
- kind: "erc721_sent";
408
- network_fee: {
409
- gas_price: string;
410
- native_token_price_in_usd: string;
411
- };
412
- from: string;
413
- to: string;
414
- nft: {
415
- name: string;
416
- token_id: string;
417
- image: string;
418
- collection: {
419
- address: string;
420
- name: string;
421
- symbol: string;
422
- image: string;
423
- };
424
- };
425
- };
426
- createdAt: string;
427
- isRead: boolean;
428
- } | {
429
- id: string;
430
- trigger_id: string;
431
- chain_id: number;
432
- block_number: number;
433
- block_timestamp: string;
434
- tx_hash: string;
435
- unread: boolean;
436
- created_at: string;
437
- address: string;
438
- type: TRIGGER_TYPES.ERC721_RECEIVED;
439
- data: {
440
- kind: "erc721_received";
441
- network_fee: {
442
- gas_price: string;
443
- native_token_price_in_usd: string;
444
- };
445
- from: string;
446
- to: string;
447
- nft: {
448
- name: string;
449
- token_id: string;
450
- image: string;
451
- collection: {
452
- address: string;
453
- name: string;
454
- symbol: string;
455
- image: string;
456
- };
457
- };
458
- };
459
- createdAt: string;
460
- isRead: boolean;
461
- } | {
462
- id: string;
463
- trigger_id: string;
464
- chain_id: number;
465
- block_number: number;
466
- block_timestamp: string;
467
- tx_hash: string;
468
- unread: boolean;
469
- created_at: string;
470
- address: string;
471
- type: TRIGGER_TYPES.ERC1155_SENT;
472
- data: {
473
- kind: "erc1155_sent";
474
- network_fee: {
475
- gas_price: string;
476
- native_token_price_in_usd: string;
477
- };
478
- from: string;
479
- to: string;
480
- nft?: {
481
- name: string;
482
- token_id: string;
483
- image: string;
484
- collection: {
485
- address: string;
486
- name: string;
487
- symbol: string;
488
- image: string;
489
- };
490
- } | undefined;
491
- };
492
- createdAt: string;
493
- isRead: boolean;
494
- } | {
495
- id: string;
496
- trigger_id: string;
497
- chain_id: number;
498
- block_number: number;
499
- block_timestamp: string;
500
- tx_hash: string;
501
- unread: boolean;
502
- created_at: string;
503
- address: string;
504
- type: TRIGGER_TYPES.ERC1155_RECEIVED;
505
- data: {
506
- kind: "erc1155_received";
507
- network_fee: {
508
- gas_price: string;
509
- native_token_price_in_usd: string;
510
- };
511
- from: string;
512
- to: string;
513
- nft?: {
514
- name: string;
515
- token_id: string;
516
- image: string;
517
- collection: {
518
- address: string;
519
- name: string;
520
- symbol: string;
521
- image: string;
522
- };
523
- } | undefined;
524
- };
525
- createdAt: string;
526
- isRead: boolean;
527
- } | {
528
- id: string;
529
- trigger_id: string;
530
- chain_id: number;
531
- unread: boolean;
532
- created_at: string;
533
- address: string;
534
- type: TRIGGER_TYPES.AAVE_V3_HEALTH_FACTOR;
535
- data: {
536
- kind: "aave_v3_health_factor";
537
- chainId: number;
538
- healthFactor: string;
539
- threshold: string;
540
- };
541
- createdAt: string;
542
- isRead: boolean;
543
- } | {
544
- id: string;
545
- trigger_id: string;
546
- chain_id: number;
547
- unread: boolean;
548
- created_at: string;
549
- address: string;
550
- type: TRIGGER_TYPES.ENS_EXPIRATION;
551
- data: {
552
- kind: "ens_expiration";
553
- chainId: number;
554
- reverseEnsName: string;
555
- expirationDateIso: string;
556
- reminderDelayInSeconds: number;
557
- };
558
- createdAt: string;
559
- isRead: boolean;
560
- } | {
561
- id: string;
562
- trigger_id: string;
563
- chain_id: number;
564
- unread: boolean;
565
- created_at: string;
566
- address: string;
567
- type: TRIGGER_TYPES.LIDO_STAKING_REWARDS;
568
- data: {
569
- kind: "lido_staking_rewards";
570
- chainId: number;
571
- currentStethBalance: string;
572
- currentEthValue: string;
573
- estimatedTotalRewardInPeriod: string;
574
- daysSinceLastNotification: number;
575
- notificationIntervalDays: number;
576
- };
577
- createdAt: string;
578
- isRead: boolean;
579
- } | {
580
- id: string;
581
- trigger_id: string;
582
- chain_id: number;
583
- unread: boolean;
584
- created_at: string;
585
- address: string;
586
- type: TRIGGER_TYPES.ROCKETPOOL_STAKING_REWARDS;
587
- data: {
588
- kind: "rocketpool_staking_rewards";
589
- chainId: number;
590
- currentRethBalance: string;
591
- currentEthValue: string;
592
- estimatedTotalRewardInPeriod: string;
593
- daysSinceLastNotification: number;
594
- notificationIntervalDays: number;
595
- };
596
- createdAt: string;
597
- isRead: boolean;
598
- } | {
599
- id: string;
600
- trigger_id: string;
601
- chain_id: number;
602
- unread: boolean;
603
- created_at: string;
604
- address: string;
605
- type: TRIGGER_TYPES.NOTIONAL_LOAN_EXPIRATION;
606
- data: {
607
- kind: "notional_loan_expiration";
608
- chainId: number;
609
- loans: {
610
- amount: string;
611
- symbol: string;
612
- maturityDateIso: string;
613
- }[];
614
- reminderDelayInSeconds: number;
615
- };
616
- createdAt: string;
617
- isRead: boolean;
618
- } | {
619
- id: string;
620
- trigger_id: string;
621
- chain_id: number;
622
- unread: boolean;
623
- created_at: string;
624
- address: string;
625
- type: TRIGGER_TYPES.SPARK_FI_HEALTH_FACTOR;
626
- data: {
627
- kind: "spark_fi_health_factor";
628
- chainId: number;
629
- healthFactor: string;
630
- threshold: string;
631
- };
632
- createdAt: string;
633
- isRead: boolean;
634
- } | {
635
- type: TRIGGER_TYPES.SNAP;
636
- data: import("../types/snaps/index.mjs").RawSnapNotificationData;
637
- readDate: string | null;
638
- id: string;
639
- createdAt: string;
640
- isRead: boolean;
641
- })[];
642
19
  //# 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,EAAE,aAAa,EAAE,6CAAyC;AAEjE,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACrB,+CAA2C;AAiB5C;;;;;;;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":"AAQA,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACrB,+CAA2C;AAiB5C;;;;;;;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"}
@@ -47,6 +47,4 @@ 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);
52
50
  //# 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,EACL,yBAAyB,EACzB,0BAA0B,EAC3B,2CAAuC;AACxC,OAAO,EAAE,0BAA0B,EAAE,4CAAwC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,yCAAqC;AACvE,OAAO,EAAE,aAAa,EAAE,6CAAyC;AASjE,MAAM,qBAAqB,GAAG,CAC5B,CAAuB,EACM,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAEhF,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;QACvC,MAAM,CAAC,GAAG,0BAA0B,CAClC,YAAkD,CACnD,CAAC;QACF,CAAC,CAAC,MAAM,GAAG,yBAAyB,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC;QAC3D,OAAO,CAAC,CAAC;KACV;IAED,IAAI,kBAAkB,CAAC,YAAY,CAAC,EAAE;QACpC,OAAO,uBAAuB,CAAC,YAAY,CAAC,CAAC;KAC9C;IAED,IAAI,qBAAqB,CAAC,YAAY,CAAC,EAAE;QACvC,OAAO,0BAA0B,CAAC,YAAY,CAAC,CAAC;KACjD;IAED,OAAO,iBAAiB,CAAC,YAAqB,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACrC,YAAkC,EAClC,oBAA8B,EAAE;IAEhC,IAAI;QACF,MAAM,qBAAqB,GAAG,mBAAmB,CAC/C,YAAY,EACZ,iBAAiB,CAClB,CAAC;QACF,OAAO,qBAAqB,CAAC;KAC9B;IAAC,MAAM;QACN,OAAO,SAAS,CAAC;KAClB;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 {\n isFeatureAnnouncementRead,\n processFeatureAnnouncement,\n} from './process-feature-announcement';\nimport { processOnChainNotification } from './process-onchain-notifications';\nimport { processSnapNotification } from './process-snap-notifications';\nimport { TRIGGER_TYPES } 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 { OnChainRawNotification } from '../types/on-chain-notification/on-chain-notification';\nimport type { RawSnapNotification } from '../types/snaps';\n\nconst isOnChainNotification = (\n n: RawNotificationUnion,\n): n is OnChainRawNotification => Object.values(TRIGGER_TYPES).includes(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 processOnChainNotification(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,EACL,yBAAyB,EACzB,0BAA0B,EAC3B,2CAAuC;AACxC,OAAO,EAAE,0BAA0B,EAAE,4CAAwC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,yCAAqC;AACvE,OAAO,EAAE,aAAa,EAAE,6CAAyC;AASjE,MAAM,qBAAqB,GAAG,CAC5B,CAAuB,EACM,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAEhF,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;QACvC,MAAM,CAAC,GAAG,0BAA0B,CAClC,YAAkD,CACnD,CAAC;QACF,CAAC,CAAC,MAAM,GAAG,yBAAyB,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC;QAC3D,OAAO,CAAC,CAAC;KACV;IAED,IAAI,kBAAkB,CAAC,YAAY,CAAC,EAAE;QACpC,OAAO,uBAAuB,CAAC,YAAY,CAAC,CAAC;KAC9C;IAED,IAAI,qBAAqB,CAAC,YAAY,CAAC,EAAE;QACvC,OAAO,0BAA0B,CAAC,YAAY,CAAC,CAAC;KACjD;IAED,OAAO,iBAAiB,CAAC,YAAqB,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACrC,YAAkC,EAClC,oBAA8B,EAAE;IAEhC,IAAI;QACF,MAAM,qBAAqB,GAAG,mBAAmB,CAC/C,YAAY,EACZ,iBAAiB,CAClB,CAAC;QACF,OAAO,qBAAqB,CAAC;KAC9B;IAAC,MAAM;QACN,OAAO,SAAS,CAAC;KAClB;AACH,CAAC","sourcesContent":["import {\n isFeatureAnnouncementRead,\n processFeatureAnnouncement,\n} from './process-feature-announcement';\nimport { processOnChainNotification } from './process-onchain-notifications';\nimport { processSnapNotification } from './process-snap-notifications';\nimport { TRIGGER_TYPES } 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 { OnChainRawNotification } from '../types/on-chain-notification/on-chain-notification';\nimport type { RawSnapNotification } from '../types/snaps';\n\nconst isOnChainNotification = (\n n: RawNotificationUnion,\n): n is OnChainRawNotification => Object.values(TRIGGER_TYPES).includes(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 processOnChainNotification(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"]}