@metamask-previews/notification-services-controller 21.0.0-preview-7bc2d97e → 21.0.0-preview-6bed60a6

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 (124) hide show
  1. package/CHANGELOG.md +0 -2
  2. package/dist/NotificationServicesController/NotificationServicesController.cjs +37 -41
  3. package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -1
  4. package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -1
  5. package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -1
  6. package/dist/NotificationServicesController/NotificationServicesController.mjs +37 -41
  7. package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
  8. package/dist/NotificationServicesController/constants/notification-schema.cjs +0 -3
  9. package/dist/NotificationServicesController/constants/notification-schema.cjs.map +1 -1
  10. package/dist/NotificationServicesController/constants/notification-schema.d.cts.map +1 -1
  11. package/dist/NotificationServicesController/constants/notification-schema.d.mts.map +1 -1
  12. package/dist/NotificationServicesController/constants/notification-schema.mjs +0 -3
  13. package/dist/NotificationServicesController/constants/notification-schema.mjs.map +1 -1
  14. package/dist/NotificationServicesController/mocks/mockResponses.cjs +0 -6
  15. package/dist/NotificationServicesController/mocks/mockResponses.cjs.map +1 -1
  16. package/dist/NotificationServicesController/mocks/mockResponses.d.cts.map +1 -1
  17. package/dist/NotificationServicesController/mocks/mockResponses.d.mts.map +1 -1
  18. package/dist/NotificationServicesController/mocks/mockResponses.mjs +0 -6
  19. package/dist/NotificationServicesController/mocks/mockResponses.mjs.map +1 -1
  20. package/dist/NotificationServicesController/processors/process-notifications.cjs +9 -11
  21. package/dist/NotificationServicesController/processors/process-notifications.cjs.map +1 -1
  22. package/dist/NotificationServicesController/processors/process-notifications.d.cts +563 -1
  23. package/dist/NotificationServicesController/processors/process-notifications.d.cts.map +1 -1
  24. package/dist/NotificationServicesController/processors/process-notifications.d.mts +563 -1
  25. package/dist/NotificationServicesController/processors/process-notifications.d.mts.map +1 -1
  26. package/dist/NotificationServicesController/processors/process-notifications.mjs +9 -11
  27. package/dist/NotificationServicesController/processors/process-notifications.mjs.map +1 -1
  28. package/dist/NotificationServicesController/services/api-notifications.cjs +21 -21
  29. package/dist/NotificationServicesController/services/api-notifications.cjs.map +1 -1
  30. package/dist/NotificationServicesController/services/api-notifications.d.cts.map +1 -1
  31. package/dist/NotificationServicesController/services/api-notifications.d.mts.map +1 -1
  32. package/dist/NotificationServicesController/services/api-notifications.mjs +21 -21
  33. package/dist/NotificationServicesController/services/api-notifications.mjs.map +1 -1
  34. package/dist/NotificationServicesController/services/feature-announcements.cjs +10 -10
  35. package/dist/NotificationServicesController/services/feature-announcements.cjs.map +1 -1
  36. package/dist/NotificationServicesController/services/feature-announcements.d.cts.map +1 -1
  37. package/dist/NotificationServicesController/services/feature-announcements.d.mts.map +1 -1
  38. package/dist/NotificationServicesController/services/feature-announcements.mjs +10 -10
  39. package/dist/NotificationServicesController/services/feature-announcements.mjs.map +1 -1
  40. package/dist/NotificationServicesController/services/notification-config-cache.cjs +4 -4
  41. package/dist/NotificationServicesController/services/notification-config-cache.cjs.map +1 -1
  42. package/dist/NotificationServicesController/services/notification-config-cache.mjs +4 -4
  43. package/dist/NotificationServicesController/services/notification-config-cache.mjs.map +1 -1
  44. package/dist/NotificationServicesController/services/perp-notifications.cjs +2 -2
  45. package/dist/NotificationServicesController/services/perp-notifications.cjs.map +1 -1
  46. package/dist/NotificationServicesController/services/perp-notifications.d.cts.map +1 -1
  47. package/dist/NotificationServicesController/services/perp-notifications.d.mts.map +1 -1
  48. package/dist/NotificationServicesController/services/perp-notifications.mjs +2 -2
  49. package/dist/NotificationServicesController/services/perp-notifications.mjs.map +1 -1
  50. package/dist/NotificationServicesController/types/notification-api/notification-api.cjs.map +1 -1
  51. package/dist/NotificationServicesController/types/notification-api/notification-api.d.cts.map +1 -1
  52. package/dist/NotificationServicesController/types/notification-api/notification-api.d.mts.map +1 -1
  53. package/dist/NotificationServicesController/types/notification-api/notification-api.mjs.map +1 -1
  54. package/dist/NotificationServicesController/types/notification-api/schema.cjs +0 -2
  55. package/dist/NotificationServicesController/types/notification-api/schema.cjs.map +1 -1
  56. package/dist/NotificationServicesController/types/notification-api/schema.d.cts.map +1 -1
  57. package/dist/NotificationServicesController/types/notification-api/schema.d.mts.map +1 -1
  58. package/dist/NotificationServicesController/types/notification-api/schema.mjs +0 -2
  59. package/dist/NotificationServicesController/types/notification-api/schema.mjs.map +1 -1
  60. package/dist/NotificationServicesController/types/perps/schema.cjs +0 -2
  61. package/dist/NotificationServicesController/types/perps/schema.cjs.map +1 -1
  62. package/dist/NotificationServicesController/types/perps/schema.d.cts.map +1 -1
  63. package/dist/NotificationServicesController/types/perps/schema.d.mts.map +1 -1
  64. package/dist/NotificationServicesController/types/perps/schema.mjs +0 -2
  65. package/dist/NotificationServicesController/types/perps/schema.mjs.map +1 -1
  66. package/dist/NotificationServicesController/utils/isVersionInBounds.cjs.map +1 -1
  67. package/dist/NotificationServicesController/utils/isVersionInBounds.d.cts.map +1 -1
  68. package/dist/NotificationServicesController/utils/isVersionInBounds.d.mts.map +1 -1
  69. package/dist/NotificationServicesController/utils/isVersionInBounds.mjs.map +1 -1
  70. package/dist/NotificationServicesController/utils/should-auto-expire.cjs.map +1 -1
  71. package/dist/NotificationServicesController/utils/should-auto-expire.d.cts.map +1 -1
  72. package/dist/NotificationServicesController/utils/should-auto-expire.d.mts.map +1 -1
  73. package/dist/NotificationServicesController/utils/should-auto-expire.mjs.map +1 -1
  74. package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -1
  75. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -1
  76. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -1
  77. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -1
  78. package/dist/NotificationServicesPushController/mocks/mockResponse.cjs.map +1 -1
  79. package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts +24 -9
  80. package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts.map +1 -1
  81. package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts +24 -9
  82. package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts.map +1 -1
  83. package/dist/NotificationServicesPushController/mocks/mockResponse.mjs.map +1 -1
  84. package/dist/NotificationServicesPushController/services/endpoints.cjs.map +1 -1
  85. package/dist/NotificationServicesPushController/services/endpoints.d.cts.map +1 -1
  86. package/dist/NotificationServicesPushController/services/endpoints.d.mts.map +1 -1
  87. package/dist/NotificationServicesPushController/services/endpoints.mjs.map +1 -1
  88. package/dist/NotificationServicesPushController/services/services.cjs.map +1 -1
  89. package/dist/NotificationServicesPushController/services/services.d.cts.map +1 -1
  90. package/dist/NotificationServicesPushController/services/services.d.mts.map +1 -1
  91. package/dist/NotificationServicesPushController/services/services.mjs.map +1 -1
  92. package/dist/NotificationServicesPushController/utils/get-notification-data.cjs +4 -4
  93. package/dist/NotificationServicesPushController/utils/get-notification-data.cjs.map +1 -1
  94. package/dist/NotificationServicesPushController/utils/get-notification-data.d.cts +2 -2
  95. package/dist/NotificationServicesPushController/utils/get-notification-data.d.cts.map +1 -1
  96. package/dist/NotificationServicesPushController/utils/get-notification-data.d.mts +2 -2
  97. package/dist/NotificationServicesPushController/utils/get-notification-data.d.mts.map +1 -1
  98. package/dist/NotificationServicesPushController/utils/get-notification-data.mjs +4 -4
  99. package/dist/NotificationServicesPushController/utils/get-notification-data.mjs.map +1 -1
  100. package/dist/NotificationServicesPushController/utils/get-notification-message.cjs +61 -62
  101. package/dist/NotificationServicesPushController/utils/get-notification-message.cjs.map +1 -1
  102. package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts +9 -9
  103. package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts.map +1 -1
  104. package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts +9 -9
  105. package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts.map +1 -1
  106. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs +61 -62
  107. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs.map +1 -1
  108. package/dist/NotificationServicesPushController/web/push-utils.cjs +0 -3
  109. package/dist/NotificationServicesPushController/web/push-utils.cjs.map +1 -1
  110. package/dist/NotificationServicesPushController/web/push-utils.d.cts.map +1 -1
  111. package/dist/NotificationServicesPushController/web/push-utils.d.mts.map +1 -1
  112. package/dist/NotificationServicesPushController/web/push-utils.mjs +0 -3
  113. package/dist/NotificationServicesPushController/web/push-utils.mjs.map +1 -1
  114. package/dist/shared/is-onchain-notification.cjs +3 -3
  115. package/dist/shared/is-onchain-notification.cjs.map +1 -1
  116. package/dist/shared/is-onchain-notification.d.cts +2 -2
  117. package/dist/shared/is-onchain-notification.d.cts.map +1 -1
  118. package/dist/shared/is-onchain-notification.d.mts +2 -2
  119. package/dist/shared/is-onchain-notification.d.mts.map +1 -1
  120. package/dist/shared/is-onchain-notification.mjs +3 -3
  121. package/dist/shared/is-onchain-notification.mjs.map +1 -1
  122. package/dist/shared/to-raw-notification.cjs.map +1 -1
  123. package/dist/shared/to-raw-notification.mjs.map +1 -1
  124. package/package.json +3 -3
@@ -1,3 +1,4 @@
1
+ import { TRIGGER_TYPES } from "../constants/notification-schema.mjs";
1
2
  import type { INotification, RawNotificationUnion } from "../types/notification/notification.mjs";
2
3
  /**
3
4
  * Process feature announcement and wallet notifications into a shared/normalised notification shape.
@@ -16,5 +17,566 @@ export declare function processNotification(notification: RawNotificationUnion,
16
17
  * @returns a process notification or undefined if failed to process
17
18
  */
18
19
  export declare function safeProcessNotification(notification: RawNotificationUnion, readNotifications?: string[]): INotification | undefined;
19
- export declare const processAndFilterNotifications: (notifications: RawNotificationUnion[], readIds: string[]) => INotification[];
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
+ })[];
20
582
  //# 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":"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"}
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,CAqBf;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"}
@@ -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 = (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;
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;
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 = (notification) => notification.type === TRIGGER_TYPES
14
14
  * @returns a processed notification
15
15
  */
16
16
  export function processNotification(notification, readNotifications = []) {
17
- const exhaustedAllCases = (_uncheckedCase) => {
17
+ const exhaustedAllCases = (_) => {
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 processedNotification = processFeatureAnnouncement(notification);
23
- processedNotification.isRead = isFeatureAnnouncementRead(processedNotification, readNotifications);
24
- return processedNotification;
22
+ const n = processFeatureAnnouncement(notification);
23
+ n.isRead = isFeatureAnnouncementRead(n, readNotifications);
24
+ return n;
25
25
  }
26
26
  if (isSnapNotification(notification)) {
27
27
  return processSnapNotification(notification);
@@ -47,8 +47,6 @@ export function safeProcessNotification(notification, readNotifications = []) {
47
47
  return undefined;
48
48
  }
49
49
  }
50
- const isNotUndefined = (item) => Boolean(item);
51
- export const processAndFilterNotifications = (notifications, readIds) => notifications
52
- .map((notification) => safeProcessNotification(notification, readIds))
53
- .filter(isNotUndefined);
50
+ const isNotUndefined = (t) => Boolean(t);
51
+ export const processAndFilterNotifications = (ns, readIds) => ns.map((n) => safeProcessNotification(n, readIds)).filter(isNotUndefined);
54
52
  //# 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,YAAkC,EACS,EAAE,CAC7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C/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
+ {"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,q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AAM,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(notification);\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);\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"]}