@metamask-previews/notification-services-controller 0.5.0-preview-9edcf0e0 → 0.5.0-preview-9d310688
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.
- package/dist/NotificationServicesController/NotificationServicesController.cjs +803 -0
- package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -0
- package/dist/{types/NotificationServicesController/NotificationServicesController.d.ts → NotificationServicesController/NotificationServicesController.d.cts} +7 -7
- package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -0
- package/dist/NotificationServicesController/NotificationServicesController.d.mts +238 -0
- package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -0
- package/dist/NotificationServicesController/NotificationServicesController.mjs +779 -17
- package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
- package/dist/NotificationServicesController/__fixtures__/index.cjs +22 -0
- package/dist/NotificationServicesController/__fixtures__/index.cjs.map +1 -0
- package/dist/NotificationServicesController/__fixtures__/index.d.cts +6 -0
- package/dist/NotificationServicesController/__fixtures__/index.d.cts.map +1 -0
- package/dist/NotificationServicesController/__fixtures__/index.d.mts +6 -0
- package/dist/NotificationServicesController/__fixtures__/index.d.mts.map +1 -0
- package/dist/NotificationServicesController/__fixtures__/index.mjs +6 -0
- package/dist/NotificationServicesController/__fixtures__/index.mjs.map +1 -0
- package/dist/NotificationServicesController/__fixtures__/mock-feature-announcements.cjs +210 -0
- package/dist/NotificationServicesController/__fixtures__/mock-feature-announcements.cjs.map +1 -0
- package/dist/{types/NotificationServicesController/__fixtures__/mock-feature-announcements.d.ts → NotificationServicesController/__fixtures__/mock-feature-announcements.d.cts} +3 -3
- package/dist/NotificationServicesController/__fixtures__/mock-feature-announcements.d.cts.map +1 -0
- package/dist/NotificationServicesController/__fixtures__/mock-feature-announcements.d.mts +15 -0
- package/dist/NotificationServicesController/__fixtures__/mock-feature-announcements.d.mts.map +1 -0
- package/dist/NotificationServicesController/__fixtures__/mock-feature-announcements.mjs +205 -0
- package/dist/NotificationServicesController/__fixtures__/mock-feature-announcements.mjs.map +1 -0
- package/dist/NotificationServicesController/__fixtures__/mock-notification-trigger.cjs +22 -0
- package/dist/NotificationServicesController/__fixtures__/mock-notification-trigger.cjs.map +1 -0
- package/dist/{types/NotificationServicesController/__fixtures__/mock-notification-trigger.d.ts → NotificationServicesController/__fixtures__/mock-notification-trigger.d.cts} +2 -2
- package/dist/NotificationServicesController/__fixtures__/mock-notification-trigger.d.cts.map +1 -0
- package/dist/NotificationServicesController/__fixtures__/mock-notification-trigger.d.mts +9 -0
- package/dist/NotificationServicesController/__fixtures__/mock-notification-trigger.d.mts.map +1 -0
- package/dist/NotificationServicesController/__fixtures__/mock-notification-trigger.mjs +18 -0
- package/dist/NotificationServicesController/__fixtures__/mock-notification-trigger.mjs.map +1 -0
- package/dist/NotificationServicesController/__fixtures__/mock-notification-user-storage.cjs +82 -0
- package/dist/NotificationServicesController/__fixtures__/mock-notification-user-storage.cjs.map +1 -0
- package/dist/{types/NotificationServicesController/__fixtures__/mock-notification-user-storage.d.ts → NotificationServicesController/__fixtures__/mock-notification-user-storage.d.cts} +3 -3
- package/dist/NotificationServicesController/__fixtures__/mock-notification-user-storage.d.cts.map +1 -0
- package/dist/NotificationServicesController/__fixtures__/mock-notification-user-storage.d.mts +35 -0
- package/dist/NotificationServicesController/__fixtures__/mock-notification-user-storage.d.mts.map +1 -0
- package/dist/NotificationServicesController/__fixtures__/mock-notification-user-storage.mjs +76 -0
- package/dist/NotificationServicesController/__fixtures__/mock-notification-user-storage.mjs.map +1 -0
- package/dist/NotificationServicesController/__fixtures__/mock-raw-notifications.cjs +624 -0
- package/dist/NotificationServicesController/__fixtures__/mock-raw-notifications.cjs.map +1 -0
- package/dist/{types/NotificationServicesController/__fixtures__/mock-raw-notifications.d.ts → NotificationServicesController/__fixtures__/mock-raw-notifications.d.cts} +2 -2
- package/dist/NotificationServicesController/__fixtures__/mock-raw-notifications.d.cts.map +1 -0
- package/dist/NotificationServicesController/__fixtures__/mock-raw-notifications.d.mts +82 -0
- package/dist/NotificationServicesController/__fixtures__/mock-raw-notifications.d.mts.map +1 -0
- package/dist/NotificationServicesController/__fixtures__/mock-raw-notifications.mjs +605 -0
- package/dist/NotificationServicesController/__fixtures__/mock-raw-notifications.mjs.map +1 -0
- package/dist/NotificationServicesController/__fixtures__/mockResponses.cjs +50 -0
- package/dist/NotificationServicesController/__fixtures__/mockResponses.cjs.map +1 -0
- package/dist/{types/NotificationServicesController/__fixtures__/mockResponses.d.ts → NotificationServicesController/__fixtures__/mockResponses.d.cts} +5 -5
- package/dist/NotificationServicesController/__fixtures__/mockResponses.d.cts.map +1 -0
- package/dist/NotificationServicesController/__fixtures__/mockResponses.d.mts +28 -0
- package/dist/NotificationServicesController/__fixtures__/mockResponses.d.mts.map +1 -0
- package/dist/NotificationServicesController/__fixtures__/mockResponses.mjs +42 -0
- package/dist/NotificationServicesController/__fixtures__/mockResponses.mjs.map +1 -0
- package/dist/NotificationServicesController/__fixtures__/mockServices.cjs +56 -0
- package/dist/NotificationServicesController/__fixtures__/mockServices.cjs.map +1 -0
- package/dist/{types/NotificationServicesController/__fixtures__/mockServices.d.ts → NotificationServicesController/__fixtures__/mockServices.d.cts} +2 -2
- package/dist/NotificationServicesController/__fixtures__/mockServices.d.cts.map +1 -0
- package/dist/NotificationServicesController/__fixtures__/mockServices.d.mts +12 -0
- package/dist/NotificationServicesController/__fixtures__/mockServices.d.mts.map +1 -0
- package/dist/NotificationServicesController/__fixtures__/mockServices.mjs +52 -0
- package/dist/NotificationServicesController/__fixtures__/mockServices.mjs.map +1 -0
- package/dist/NotificationServicesController/__fixtures__/test-utils.cjs +31 -0
- package/dist/NotificationServicesController/__fixtures__/test-utils.cjs.map +1 -0
- package/dist/{types/NotificationServicesController/__fixtures__/test-utils.d.ts → NotificationServicesController/__fixtures__/test-utils.d.cts} +1 -1
- package/dist/NotificationServicesController/__fixtures__/test-utils.d.cts.map +1 -0
- package/dist/NotificationServicesController/__fixtures__/test-utils.d.mts +14 -0
- package/dist/NotificationServicesController/__fixtures__/test-utils.d.mts.map +1 -0
- package/dist/NotificationServicesController/__fixtures__/test-utils.mjs +27 -0
- package/dist/NotificationServicesController/__fixtures__/test-utils.mjs.map +1 -0
- package/dist/NotificationServicesController/constants/constants.cjs +7 -0
- package/dist/NotificationServicesController/constants/constants.cjs.map +1 -0
- package/dist/{types/NotificationServicesController/constants/constants.d.ts → NotificationServicesController/constants/constants.d.cts} +1 -1
- package/dist/NotificationServicesController/constants/constants.d.cts.map +1 -0
- package/dist/NotificationServicesController/constants/constants.d.mts +3 -0
- package/dist/NotificationServicesController/constants/constants.d.mts.map +1 -0
- package/dist/NotificationServicesController/constants/constants.mjs +3 -9
- package/dist/NotificationServicesController/constants/constants.mjs.map +1 -1
- package/dist/NotificationServicesController/constants/index.cjs +19 -0
- package/dist/NotificationServicesController/constants/index.cjs.map +1 -0
- package/dist/NotificationServicesController/constants/index.d.cts +3 -0
- package/dist/NotificationServicesController/constants/index.d.cts.map +1 -0
- package/dist/NotificationServicesController/constants/index.d.mts +3 -0
- package/dist/NotificationServicesController/constants/index.d.mts.map +1 -0
- package/dist/NotificationServicesController/constants/index.mjs +2 -28
- package/dist/NotificationServicesController/constants/index.mjs.map +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.cjs +170 -0
- package/dist/NotificationServicesController/constants/notification-schema.cjs.map +1 -0
- package/dist/{types/NotificationServicesController/constants/notification-schema.d.ts → NotificationServicesController/constants/notification-schema.d.cts} +2 -2
- package/dist/NotificationServicesController/constants/notification-schema.d.cts.map +1 -0
- package/dist/NotificationServicesController/constants/notification-schema.d.mts +48 -0
- package/dist/NotificationServicesController/constants/notification-schema.d.mts.map +1 -0
- package/dist/NotificationServicesController/constants/notification-schema.mjs +165 -20
- package/dist/NotificationServicesController/constants/notification-schema.mjs.map +1 -1
- package/dist/NotificationServicesController/index.cjs +46 -0
- package/dist/NotificationServicesController/index.cjs.map +1 -0
- package/dist/NotificationServicesController/index.d.cts +14 -0
- package/dist/NotificationServicesController/index.d.cts.map +1 -0
- package/dist/NotificationServicesController/index.d.mts +14 -0
- package/dist/NotificationServicesController/index.d.mts.map +1 -0
- package/dist/NotificationServicesController/index.mjs +13 -86
- package/dist/NotificationServicesController/index.mjs.map +1 -1
- package/dist/NotificationServicesController/processors/index.cjs +20 -0
- package/dist/NotificationServicesController/processors/index.cjs.map +1 -0
- package/dist/NotificationServicesController/processors/index.d.cts +4 -0
- package/dist/NotificationServicesController/processors/index.d.cts.map +1 -0
- package/dist/NotificationServicesController/processors/index.d.mts +4 -0
- package/dist/NotificationServicesController/processors/index.d.mts.map +1 -0
- package/dist/NotificationServicesController/processors/index.mjs +3 -21
- package/dist/NotificationServicesController/processors/index.mjs.map +1 -1
- package/dist/NotificationServicesController/processors/process-feature-announcement.cjs +41 -0
- package/dist/{chunk-52CALMRA.js.map → NotificationServicesController/processors/process-feature-announcement.cjs.map} +1 -1
- package/dist/{types/NotificationServicesController/processors/process-feature-announcement.d.ts → NotificationServicesController/processors/process-feature-announcement.d.cts} +3 -3
- package/dist/NotificationServicesController/processors/process-feature-announcement.d.cts.map +1 -0
- package/dist/NotificationServicesController/processors/process-feature-announcement.d.mts +19 -0
- package/dist/NotificationServicesController/processors/process-feature-announcement.d.mts.map +1 -0
- package/dist/NotificationServicesController/processors/process-feature-announcement.mjs +34 -8
- package/dist/NotificationServicesController/processors/process-feature-announcement.mjs.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.cjs +50 -0
- package/dist/NotificationServicesController/processors/process-notifications.cjs.map +1 -0
- package/dist/{types/NotificationServicesController/processors/process-notifications.d.ts → NotificationServicesController/processors/process-notifications.d.cts} +2 -2
- package/dist/NotificationServicesController/processors/process-notifications.d.cts.map +1 -0
- package/dist/NotificationServicesController/processors/process-notifications.d.mts +19 -0
- package/dist/NotificationServicesController/processors/process-notifications.d.mts.map +1 -0
- package/dist/NotificationServicesController/processors/process-notifications.mjs +44 -12
- package/dist/NotificationServicesController/processors/process-notifications.mjs.map +1 -1
- package/dist/NotificationServicesController/processors/process-onchain-notifications.cjs +19 -0
- package/dist/NotificationServicesController/processors/process-onchain-notifications.cjs.map +1 -0
- package/dist/{types/NotificationServicesController/processors/process-onchain-notifications.d.ts → NotificationServicesController/processors/process-onchain-notifications.d.cts} +3 -3
- package/dist/NotificationServicesController/processors/process-onchain-notifications.d.cts.map +1 -0
- package/dist/NotificationServicesController/processors/process-onchain-notifications.d.mts +10 -0
- package/dist/NotificationServicesController/processors/process-onchain-notifications.d.mts.map +1 -0
- package/dist/NotificationServicesController/processors/process-onchain-notifications.mjs +14 -7
- package/dist/NotificationServicesController/processors/process-onchain-notifications.mjs.map +1 -1
- package/dist/NotificationServicesController/services/feature-announcements.cjs +97 -0
- package/dist/NotificationServicesController/services/feature-announcements.cjs.map +1 -0
- package/dist/{types/NotificationServicesController/services/feature-announcements.d.ts → NotificationServicesController/services/feature-announcements.d.cts} +4 -4
- package/dist/NotificationServicesController/services/feature-announcements.d.cts.map +1 -0
- package/dist/NotificationServicesController/services/feature-announcements.d.mts +28 -0
- package/dist/NotificationServicesController/services/feature-announcements.d.mts.map +1 -0
- package/dist/NotificationServicesController/services/feature-announcements.mjs +91 -12
- package/dist/NotificationServicesController/services/feature-announcements.mjs.map +1 -1
- package/dist/NotificationServicesController/services/onchain-notifications.cjs +195 -0
- package/dist/NotificationServicesController/services/onchain-notifications.cjs.map +1 -0
- package/dist/{types/NotificationServicesController/services/onchain-notifications.d.ts → NotificationServicesController/services/onchain-notifications.d.cts} +3 -3
- package/dist/NotificationServicesController/services/onchain-notifications.d.cts.map +1 -0
- package/dist/NotificationServicesController/services/onchain-notifications.d.mts +62 -0
- package/dist/NotificationServicesController/services/onchain-notifications.d.mts.map +1 -0
- package/dist/NotificationServicesController/services/onchain-notifications.mjs +190 -29
- package/dist/NotificationServicesController/services/onchain-notifications.mjs.map +1 -1
- package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.cjs +3 -0
- package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.cjs.map +1 -0
- package/dist/{types/NotificationServicesController/types/feature-announcement/feature-announcement.d.ts → NotificationServicesController/types/feature-announcement/feature-announcement.d.cts} +3 -3
- package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.d.mts +32 -0
- package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.mjs +1 -1
- package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.mjs.map +1 -1
- package/dist/NotificationServicesController/types/feature-announcement/index.cjs +20 -0
- package/dist/NotificationServicesController/types/feature-announcement/index.cjs.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/index.d.cts +4 -0
- package/dist/NotificationServicesController/types/feature-announcement/index.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/index.d.mts +4 -0
- package/dist/NotificationServicesController/types/feature-announcement/index.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/index.mjs +3 -4
- package/dist/NotificationServicesController/types/feature-announcement/index.mjs.map +1 -1
- package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.cjs +3 -0
- package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.cjs.map +1 -0
- package/dist/{types/NotificationServicesController/types/feature-announcement/type-feature-announcement.d.ts → NotificationServicesController/types/feature-announcement/type-feature-announcement.d.cts} +3 -3
- package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.d.mts +39 -0
- package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.mjs +1 -1
- package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.mjs.map +1 -1
- package/dist/NotificationServicesController/types/feature-announcement/type-links.cjs +3 -0
- package/dist/NotificationServicesController/types/feature-announcement/type-links.cjs.map +1 -0
- package/dist/{types/NotificationServicesController/types/feature-announcement/type-links.d.ts → NotificationServicesController/types/feature-announcement/type-links.d.cts} +1 -1
- package/dist/NotificationServicesController/types/feature-announcement/type-links.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/type-links.d.mts +29 -0
- package/dist/NotificationServicesController/types/feature-announcement/type-links.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/feature-announcement/type-links.mjs +1 -1
- package/dist/NotificationServicesController/types/feature-announcement/type-links.mjs.map +1 -1
- package/dist/NotificationServicesController/types/index.cjs +21 -0
- package/dist/NotificationServicesController/types/index.cjs.map +1 -0
- package/dist/NotificationServicesController/types/index.d.cts +5 -0
- package/dist/NotificationServicesController/types/index.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/index.d.mts +5 -0
- package/dist/NotificationServicesController/types/index.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/index.mjs +4 -11
- package/dist/NotificationServicesController/types/index.mjs.map +1 -1
- package/dist/NotificationServicesController/types/notification/index.cjs +18 -0
- package/dist/NotificationServicesController/types/notification/index.cjs.map +1 -0
- package/dist/NotificationServicesController/types/notification/index.d.cts +2 -0
- package/dist/NotificationServicesController/types/notification/index.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/notification/index.d.mts +2 -0
- package/dist/NotificationServicesController/types/notification/index.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/notification/index.mjs +1 -2
- package/dist/NotificationServicesController/types/notification/index.mjs.map +1 -1
- package/dist/NotificationServicesController/types/notification/notification.cjs +3 -0
- package/dist/NotificationServicesController/types/notification/notification.cjs.map +1 -0
- package/dist/{types/NotificationServicesController/types/notification/notification.d.ts → NotificationServicesController/types/notification/notification.d.cts} +4 -4
- package/dist/NotificationServicesController/types/notification/notification.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/notification/notification.d.mts +25 -0
- package/dist/NotificationServicesController/types/notification/notification.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/notification/notification.mjs +1 -1
- package/dist/NotificationServicesController/types/notification/notification.mjs.map +1 -1
- package/dist/NotificationServicesController/types/on-chain-notification/index.cjs +18 -0
- package/dist/NotificationServicesController/types/on-chain-notification/index.cjs.map +1 -0
- package/dist/NotificationServicesController/types/on-chain-notification/index.d.cts +2 -0
- package/dist/NotificationServicesController/types/on-chain-notification/index.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/on-chain-notification/index.d.mts +2 -0
- package/dist/NotificationServicesController/types/on-chain-notification/index.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/on-chain-notification/index.mjs +1 -2
- package/dist/NotificationServicesController/types/on-chain-notification/index.mjs.map +1 -1
- package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.cjs +3 -0
- package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.cjs.map +1 -0
- package/dist/{types/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.ts → NotificationServicesController/types/on-chain-notification/on-chain-notification.d.cts} +4 -4
- package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.mts +43 -0
- package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.mjs +1 -1
- package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.mjs.map +1 -1
- package/dist/NotificationServicesController/types/on-chain-notification/schema.cjs +9 -0
- package/dist/NotificationServicesController/types/on-chain-notification/schema.cjs.map +1 -0
- package/dist/{types/NotificationServicesController/types/on-chain-notification/schema.d.ts → NotificationServicesController/types/on-chain-notification/schema.d.cts} +1 -1
- package/dist/NotificationServicesController/types/on-chain-notification/schema.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/on-chain-notification/schema.d.mts +283 -0
- package/dist/NotificationServicesController/types/on-chain-notification/schema.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/on-chain-notification/schema.mjs +7 -0
- package/dist/NotificationServicesController/types/on-chain-notification/schema.mjs.map +1 -1
- package/dist/NotificationServicesController/types/type-utils.cjs +3 -0
- package/dist/NotificationServicesController/types/type-utils.cjs.map +1 -0
- package/dist/{types/NotificationServicesController/types/type-utils.d.ts → NotificationServicesController/types/type-utils.d.cts} +1 -1
- package/dist/NotificationServicesController/types/type-utils.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/type-utils.d.mts +7 -0
- package/dist/NotificationServicesController/types/type-utils.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/type-utils.mjs +1 -0
- package/dist/NotificationServicesController/types/type-utils.mjs.map +1 -1
- package/dist/NotificationServicesController/types/user-storage/index.cjs +18 -0
- package/dist/NotificationServicesController/types/user-storage/index.cjs.map +1 -0
- package/dist/NotificationServicesController/types/user-storage/index.d.cts +2 -0
- package/dist/NotificationServicesController/types/user-storage/index.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/user-storage/index.d.mts +2 -0
- package/dist/NotificationServicesController/types/user-storage/index.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/user-storage/index.mjs +1 -2
- package/dist/NotificationServicesController/types/user-storage/index.mjs.map +1 -1
- package/dist/NotificationServicesController/types/user-storage/user-storage.cjs +3 -0
- package/dist/NotificationServicesController/types/user-storage/user-storage.cjs.map +1 -0
- package/dist/{types/NotificationServicesController/types/user-storage/user-storage.d.ts → NotificationServicesController/types/user-storage/user-storage.d.cts} +3 -3
- package/dist/NotificationServicesController/types/user-storage/user-storage.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/user-storage/user-storage.d.mts +26 -0
- package/dist/NotificationServicesController/types/user-storage/user-storage.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/user-storage/user-storage.mjs +1 -1
- package/dist/NotificationServicesController/types/user-storage/user-storage.mjs.map +1 -1
- package/dist/NotificationServicesController/ui/constants.cjs +62 -0
- package/dist/NotificationServicesController/ui/constants.cjs.map +1 -0
- package/dist/{types/NotificationServicesController/ui/constants.d.ts → NotificationServicesController/ui/constants.d.cts} +2 -2
- package/dist/NotificationServicesController/ui/constants.d.cts.map +1 -0
- package/dist/NotificationServicesController/ui/constants.d.mts +54 -0
- package/dist/NotificationServicesController/ui/constants.d.mts.map +1 -0
- package/dist/NotificationServicesController/ui/constants.mjs +56 -14
- package/dist/NotificationServicesController/ui/constants.mjs.map +1 -1
- package/dist/NotificationServicesController/ui/index.cjs +18 -0
- package/dist/NotificationServicesController/ui/index.cjs.map +1 -0
- package/dist/NotificationServicesController/ui/index.d.cts +2 -0
- package/dist/NotificationServicesController/ui/index.d.cts.map +1 -0
- package/dist/NotificationServicesController/ui/index.d.mts +2 -0
- package/dist/NotificationServicesController/ui/index.d.mts.map +1 -0
- package/dist/NotificationServicesController/ui/index.mjs +1 -16
- package/dist/NotificationServicesController/ui/index.mjs.map +1 -1
- package/dist/NotificationServicesController/utils/utils.cjs +348 -0
- package/dist/NotificationServicesController/utils/utils.cjs.map +1 -0
- package/dist/{types/NotificationServicesController/utils/utils.d.ts → NotificationServicesController/utils/utils.d.cts} +3 -3
- package/dist/NotificationServicesController/utils/utils.d.cts.map +1 -0
- package/dist/NotificationServicesController/utils/utils.d.mts +142 -0
- package/dist/NotificationServicesController/utils/utils.d.mts.map +1 -0
- package/dist/NotificationServicesController/utils/utils.mjs +332 -31
- package/dist/NotificationServicesController/utils/utils.mjs.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs +215 -0
- package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -0
- package/dist/{types/NotificationServicesPushController/NotificationServicesPushController.d.ts → NotificationServicesPushController/NotificationServicesPushController.d.cts} +6 -6
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts +112 -0
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +214 -37
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -1
- package/dist/NotificationServicesPushController/__fixtures__/index.cjs +18 -0
- package/dist/NotificationServicesPushController/__fixtures__/index.cjs.map +1 -0
- package/dist/NotificationServicesPushController/__fixtures__/index.d.cts +2 -0
- package/dist/NotificationServicesPushController/__fixtures__/index.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/__fixtures__/index.d.mts +2 -0
- package/dist/NotificationServicesPushController/__fixtures__/index.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/__fixtures__/index.mjs +2 -0
- package/dist/NotificationServicesPushController/__fixtures__/index.mjs.map +1 -0
- package/dist/NotificationServicesPushController/__fixtures__/mockResponse.cjs +57 -0
- package/dist/NotificationServicesPushController/__fixtures__/mockResponse.cjs.map +1 -0
- package/dist/{types/NotificationServicesPushController/__fixtures__/mockResponse.d.ts → NotificationServicesPushController/__fixtures__/mockResponse.d.cts} +2 -2
- package/dist/NotificationServicesPushController/__fixtures__/mockResponse.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/__fixtures__/mockResponse.d.mts +43 -0
- package/dist/NotificationServicesPushController/__fixtures__/mockResponse.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/__fixtures__/mockResponse.mjs +50 -0
- package/dist/NotificationServicesPushController/__fixtures__/mockResponse.mjs.map +1 -0
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.cjs +31 -0
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.cjs.map +1 -0
- package/dist/{types/NotificationServicesPushController/__fixtures__/mockServices.d.ts → NotificationServicesPushController/__fixtures__/mockServices.d.cts} +2 -2
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.d.mts +9 -0
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.mjs +30 -0
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.mjs.map +1 -0
- package/dist/NotificationServicesPushController/constants.cjs +14 -0
- package/dist/NotificationServicesPushController/constants.cjs.map +1 -0
- package/dist/{types/NotificationServicesPushController/constants.d.ts → NotificationServicesPushController/constants.d.cts} +1 -1
- package/dist/NotificationServicesPushController/constants.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/constants.d.mts +11 -0
- package/dist/NotificationServicesPushController/constants.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/constants.mjs +10 -25
- package/dist/NotificationServicesPushController/constants.mjs.map +1 -1
- package/dist/NotificationServicesPushController/index.cjs +43 -0
- package/dist/NotificationServicesPushController/index.cjs.map +1 -0
- package/dist/NotificationServicesPushController/index.d.cts +11 -0
- package/dist/NotificationServicesPushController/index.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/index.d.mts +11 -0
- package/dist/NotificationServicesPushController/index.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/index.mjs +10 -71
- package/dist/NotificationServicesPushController/index.mjs.map +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.cjs +6 -0
- package/dist/NotificationServicesPushController/services/endpoints.cjs.map +1 -0
- package/dist/{types/NotificationServicesPushController/services/endpoints.d.ts → NotificationServicesPushController/services/endpoints.d.cts} +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/services/endpoints.d.mts +2 -0
- package/dist/NotificationServicesPushController/services/endpoints.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/services/endpoints.mjs +2 -7
- package/dist/NotificationServicesPushController/services/endpoints.mjs.map +1 -1
- package/dist/NotificationServicesPushController/services/push/index.cjs +3 -0
- package/dist/NotificationServicesPushController/services/push/index.cjs.map +1 -0
- package/dist/{types/NotificationServicesPushController/services/push/index.d.ts → NotificationServicesPushController/services/push/index.d.cts} +2 -2
- package/dist/NotificationServicesPushController/services/push/index.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/services/push/index.d.mts +6 -0
- package/dist/NotificationServicesPushController/services/push/index.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/services/push/index.mjs +1 -0
- package/dist/NotificationServicesPushController/services/push/index.mjs.map +1 -1
- package/dist/NotificationServicesPushController/services/push/push-web.cjs +121 -0
- package/dist/NotificationServicesPushController/services/push/push-web.cjs.map +1 -0
- package/dist/{types/NotificationServicesPushController/services/push/push-web.d.ts → NotificationServicesPushController/services/push/push-web.d.cts} +3 -3
- package/dist/NotificationServicesPushController/services/push/push-web.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/services/push/push-web.d.mts +32 -0
- package/dist/NotificationServicesPushController/services/push/push-web.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/services/push/push-web.mjs +116 -38
- package/dist/NotificationServicesPushController/services/push/push-web.mjs.map +1 -1
- package/dist/NotificationServicesPushController/services/services.cjs +197 -0
- package/dist/NotificationServicesPushController/services/services.cjs.map +1 -0
- package/dist/{types/NotificationServicesPushController/services/services.d.ts → NotificationServicesPushController/services/services.d.cts} +4 -4
- package/dist/NotificationServicesPushController/services/services.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/services/services.d.mts +95 -0
- package/dist/NotificationServicesPushController/services/services.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/services/services.mjs +168 -45
- package/dist/NotificationServicesPushController/services/services.mjs.map +1 -1
- package/dist/NotificationServicesPushController/types/firebase.cjs +3 -0
- package/dist/NotificationServicesPushController/types/firebase.cjs.map +1 -0
- package/dist/{types/NotificationServicesPushController/types/firebase.d.ts → NotificationServicesPushController/types/firebase.d.cts} +1 -1
- package/dist/NotificationServicesPushController/types/firebase.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/types/firebase.d.mts +53 -0
- package/dist/NotificationServicesPushController/types/firebase.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/types/firebase.mjs +1 -1
- package/dist/NotificationServicesPushController/types/firebase.mjs.map +1 -1
- package/dist/NotificationServicesPushController/types/index.cjs +18 -0
- package/dist/NotificationServicesPushController/types/index.cjs.map +1 -0
- package/dist/NotificationServicesPushController/types/index.d.cts +2 -0
- package/dist/NotificationServicesPushController/types/index.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/types/index.d.mts +2 -0
- package/dist/NotificationServicesPushController/types/index.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/types/index.mjs +1 -2
- package/dist/NotificationServicesPushController/types/index.mjs.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-data.cjs +84 -0
- package/dist/NotificationServicesPushController/utils/get-notification-data.cjs.map +1 -0
- package/dist/{types/NotificationServicesPushController/utils/get-notification-data.d.ts → NotificationServicesPushController/utils/get-notification-data.d.cts} +2 -2
- package/dist/NotificationServicesPushController/utils/get-notification-data.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/utils/get-notification-data.d.mts +42 -0
- package/dist/NotificationServicesPushController/utils/get-notification-data.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/utils/get-notification-data.mjs +76 -12
- package/dist/NotificationServicesPushController/utils/get-notification-data.mjs.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.cjs +190 -0
- package/dist/NotificationServicesPushController/utils/get-notification-message.cjs.map +1 -0
- package/dist/{types/NotificationServicesPushController/utils/get-notification-message.d.ts → NotificationServicesPushController/utils/get-notification-message.d.cts} +3 -3
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts +67 -0
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/utils/get-notification-message.mjs +182 -37
- package/dist/NotificationServicesPushController/utils/get-notification-message.mjs.map +1 -1
- package/dist/NotificationServicesPushController/utils/index.cjs +19 -0
- package/dist/NotificationServicesPushController/utils/index.cjs.map +1 -0
- package/dist/NotificationServicesPushController/utils/index.d.cts +3 -0
- package/dist/NotificationServicesPushController/utils/index.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/utils/index.d.mts +3 -0
- package/dist/NotificationServicesPushController/utils/index.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/utils/index.mjs +2 -48
- package/dist/NotificationServicesPushController/utils/index.mjs.map +1 -1
- package/dist/index.cjs +29 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2 -45
- package/dist/index.mjs.map +1 -1
- package/dist/shared/to-raw-notification.cjs +19 -0
- package/dist/shared/to-raw-notification.cjs.map +1 -0
- package/dist/{types/shared/to-raw-notification.d.ts → shared/to-raw-notification.d.cts} +2 -2
- package/dist/shared/to-raw-notification.d.cts.map +1 -0
- package/dist/shared/to-raw-notification.d.mts +11 -0
- package/dist/shared/to-raw-notification.d.mts.map +1 -0
- package/dist/shared/to-raw-notification.mjs +14 -7
- package/dist/shared/to-raw-notification.mjs.map +1 -1
- package/package.json +12 -7
- package/dist/NotificationServicesController/NotificationServicesController.js +0 -19
- package/dist/NotificationServicesController/NotificationServicesController.js.map +0 -1
- package/dist/NotificationServicesController/constants/constants.js +0 -10
- package/dist/NotificationServicesController/constants/constants.js.map +0 -1
- package/dist/NotificationServicesController/constants/index.js +0 -29
- package/dist/NotificationServicesController/constants/index.js.map +0 -1
- package/dist/NotificationServicesController/constants/notification-schema.js +0 -22
- package/dist/NotificationServicesController/constants/notification-schema.js.map +0 -1
- package/dist/NotificationServicesController/index.js +0 -87
- package/dist/NotificationServicesController/index.js.map +0 -1
- package/dist/NotificationServicesController/processors/index.js +0 -22
- package/dist/NotificationServicesController/processors/index.js.map +0 -1
- package/dist/NotificationServicesController/processors/process-feature-announcement.js +0 -10
- package/dist/NotificationServicesController/processors/process-feature-announcement.js.map +0 -1
- package/dist/NotificationServicesController/processors/process-notifications.js +0 -13
- package/dist/NotificationServicesController/processors/process-notifications.js.map +0 -1
- package/dist/NotificationServicesController/processors/process-onchain-notifications.js +0 -8
- package/dist/NotificationServicesController/processors/process-onchain-notifications.js.map +0 -1
- package/dist/NotificationServicesController/services/feature-announcements.js +0 -14
- package/dist/NotificationServicesController/services/feature-announcements.js.map +0 -1
- package/dist/NotificationServicesController/services/onchain-notifications.js +0 -30
- package/dist/NotificationServicesController/services/onchain-notifications.js.map +0 -1
- package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.js +0 -2
- package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.js.map +0 -1
- package/dist/NotificationServicesController/types/feature-announcement/index.js +0 -5
- package/dist/NotificationServicesController/types/feature-announcement/index.js.map +0 -1
- package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.js +0 -2
- package/dist/NotificationServicesController/types/feature-announcement/type-feature-announcement.js.map +0 -1
- package/dist/NotificationServicesController/types/feature-announcement/type-links.js +0 -2
- package/dist/NotificationServicesController/types/feature-announcement/type-links.js.map +0 -1
- package/dist/NotificationServicesController/types/index.js +0 -12
- package/dist/NotificationServicesController/types/index.js.map +0 -1
- package/dist/NotificationServicesController/types/notification/index.js +0 -3
- package/dist/NotificationServicesController/types/notification/index.js.map +0 -1
- package/dist/NotificationServicesController/types/notification/notification.js +0 -2
- package/dist/NotificationServicesController/types/notification/notification.js.map +0 -1
- package/dist/NotificationServicesController/types/on-chain-notification/index.js +0 -3
- package/dist/NotificationServicesController/types/on-chain-notification/index.js.map +0 -1
- package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.js +0 -2
- package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.js.map +0 -1
- package/dist/NotificationServicesController/types/on-chain-notification/schema.js +0 -1
- package/dist/NotificationServicesController/types/on-chain-notification/schema.js.map +0 -1
- package/dist/NotificationServicesController/types/type-utils.js +0 -1
- package/dist/NotificationServicesController/types/type-utils.js.map +0 -1
- package/dist/NotificationServicesController/types/user-storage/index.js +0 -3
- package/dist/NotificationServicesController/types/user-storage/index.js.map +0 -1
- package/dist/NotificationServicesController/types/user-storage/user-storage.js +0 -2
- package/dist/NotificationServicesController/types/user-storage/user-storage.js.map +0 -1
- package/dist/NotificationServicesController/ui/constants.js +0 -16
- package/dist/NotificationServicesController/ui/constants.js.map +0 -1
- package/dist/NotificationServicesController/ui/index.js +0 -17
- package/dist/NotificationServicesController/ui/index.js.map +0 -1
- package/dist/NotificationServicesController/utils/utils.js +0 -32
- package/dist/NotificationServicesController/utils/utils.js.map +0 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.js +0 -39
- package/dist/NotificationServicesPushController/NotificationServicesPushController.js.map +0 -1
- package/dist/NotificationServicesPushController/constants.js +0 -26
- package/dist/NotificationServicesPushController/constants.js.map +0 -1
- package/dist/NotificationServicesPushController/index.js +0 -72
- package/dist/NotificationServicesPushController/index.js.map +0 -1
- package/dist/NotificationServicesPushController/services/endpoints.js +0 -8
- package/dist/NotificationServicesPushController/services/endpoints.js.map +0 -1
- package/dist/NotificationServicesPushController/services/push/index.js +0 -1
- package/dist/NotificationServicesPushController/services/push/index.js.map +0 -1
- package/dist/NotificationServicesPushController/services/push/push-web.js +0 -40
- package/dist/NotificationServicesPushController/services/push/push-web.js.map +0 -1
- package/dist/NotificationServicesPushController/services/services.js +0 -46
- package/dist/NotificationServicesPushController/services/services.js.map +0 -1
- package/dist/NotificationServicesPushController/types/firebase.js +0 -2
- package/dist/NotificationServicesPushController/types/firebase.js.map +0 -1
- package/dist/NotificationServicesPushController/types/index.js +0 -3
- package/dist/NotificationServicesPushController/types/index.js.map +0 -1
- package/dist/NotificationServicesPushController/utils/get-notification-data.js +0 -14
- package/dist/NotificationServicesPushController/utils/get-notification-data.js.map +0 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.js +0 -39
- package/dist/NotificationServicesPushController/utils/get-notification-message.js.map +0 -1
- package/dist/NotificationServicesPushController/utils/index.js +0 -49
- package/dist/NotificationServicesPushController/utils/index.js.map +0 -1
- package/dist/chunk-232HZSEV.js +0 -7
- package/dist/chunk-232HZSEV.js.map +0 -1
- package/dist/chunk-2P5WP5NT.mjs +0 -37
- package/dist/chunk-2P5WP5NT.mjs.map +0 -1
- package/dist/chunk-3ZS2HAEG.js +0 -1
- package/dist/chunk-3ZS2HAEG.js.map +0 -1
- package/dist/chunk-4BTNTREI.mjs +0 -1
- package/dist/chunk-4BTNTREI.mjs.map +0 -1
- package/dist/chunk-4QXAPVW3.mjs +0 -1
- package/dist/chunk-4QXAPVW3.mjs.map +0 -1
- package/dist/chunk-52CALMRA.js +0 -28
- package/dist/chunk-53F3SYYM.mjs +0 -178
- package/dist/chunk-53F3SYYM.mjs.map +0 -1
- package/dist/chunk-5FAAZCBK.mjs +0 -29
- package/dist/chunk-5FAAZCBK.mjs.map +0 -1
- package/dist/chunk-6FLC6CJD.js +0 -149
- package/dist/chunk-6FLC6CJD.js.map +0 -1
- package/dist/chunk-6ZDVTRRT.mjs +0 -9
- package/dist/chunk-6ZDVTRRT.mjs.map +0 -1
- package/dist/chunk-77QIITUL.mjs +0 -67
- package/dist/chunk-77QIITUL.mjs.map +0 -1
- package/dist/chunk-7LWR54U7.js +0 -7
- package/dist/chunk-7LWR54U7.js.map +0 -1
- package/dist/chunk-7PWKQSM2.mjs +0 -972
- package/dist/chunk-7PWKQSM2.mjs.map +0 -1
- package/dist/chunk-7RM3YNTD.mjs +0 -1
- package/dist/chunk-7RM3YNTD.mjs.map +0 -1
- package/dist/chunk-A2RPVX47.mjs +0 -1
- package/dist/chunk-A2RPVX47.mjs.map +0 -1
- package/dist/chunk-B25TJ7KS.js +0 -8
- package/dist/chunk-B25TJ7KS.js.map +0 -1
- package/dist/chunk-B4ECJJ5C.mjs +0 -7
- package/dist/chunk-B4ECJJ5C.mjs.map +0 -1
- package/dist/chunk-BONB66A2.mjs +0 -14
- package/dist/chunk-BONB66A2.mjs.map +0 -1
- package/dist/chunk-C62SK2KY.mjs +0 -92
- package/dist/chunk-C62SK2KY.mjs.map +0 -1
- package/dist/chunk-CGPMMFUQ.mjs +0 -96
- package/dist/chunk-CGPMMFUQ.mjs.map +0 -1
- package/dist/chunk-CWZQMK63.mjs +0 -118
- package/dist/chunk-CWZQMK63.mjs.map +0 -1
- package/dist/chunk-D42BBXBM.mjs +0 -28
- package/dist/chunk-D42BBXBM.mjs.map +0 -1
- package/dist/chunk-DINCLRZT.mjs +0 -12
- package/dist/chunk-DINCLRZT.mjs.map +0 -1
- package/dist/chunk-DMH4NSLF.js +0 -1
- package/dist/chunk-DMH4NSLF.js.map +0 -1
- package/dist/chunk-DT6SLUWJ.js +0 -12
- package/dist/chunk-DT6SLUWJ.js.map +0 -1
- package/dist/chunk-EJ52BDLB.js +0 -55
- package/dist/chunk-EJ52BDLB.js.map +0 -1
- package/dist/chunk-ER475D6V.mjs +0 -231
- package/dist/chunk-ER475D6V.mjs.map +0 -1
- package/dist/chunk-G52DNXFH.mjs +0 -1
- package/dist/chunk-G52DNXFH.mjs.map +0 -1
- package/dist/chunk-GETQWOTI.js +0 -1
- package/dist/chunk-GETQWOTI.js.map +0 -1
- package/dist/chunk-HCDICNYK.js +0 -207
- package/dist/chunk-HCDICNYK.js.map +0 -1
- package/dist/chunk-HE3P5RM7.js +0 -178
- package/dist/chunk-HE3P5RM7.js.map +0 -1
- package/dist/chunk-HPUQYDVC.js +0 -1
- package/dist/chunk-HPUQYDVC.js.map +0 -1
- package/dist/chunk-HT6T5R4U.js +0 -96
- package/dist/chunk-HT6T5R4U.js.map +0 -1
- package/dist/chunk-IDO4JFV5.mjs +0 -1
- package/dist/chunk-IDO4JFV5.mjs.map +0 -1
- package/dist/chunk-IGY2S5BC.js +0 -36
- package/dist/chunk-IGY2S5BC.js.map +0 -1
- package/dist/chunk-IKWNHNJQ.mjs +0 -8
- package/dist/chunk-IKWNHNJQ.mjs.map +0 -1
- package/dist/chunk-IOMDG67D.mjs +0 -7
- package/dist/chunk-IOMDG67D.mjs.map +0 -1
- package/dist/chunk-IPI7BAW3.js +0 -1
- package/dist/chunk-IPI7BAW3.js.map +0 -1
- package/dist/chunk-JIJXHO5V.js +0 -885
- package/dist/chunk-JIJXHO5V.js.map +0 -1
- package/dist/chunk-JQ7WKFCI.mjs +0 -1
- package/dist/chunk-JQ7WKFCI.mjs.map +0 -1
- package/dist/chunk-JW3TK3NU.js +0 -221
- package/dist/chunk-JW3TK3NU.js.map +0 -1
- package/dist/chunk-KGLHGLER.js +0 -231
- package/dist/chunk-KGLHGLER.js.map +0 -1
- package/dist/chunk-LGXHJ24K.js +0 -92
- package/dist/chunk-LGXHJ24K.js.map +0 -1
- package/dist/chunk-LYEXYTOI.js +0 -14
- package/dist/chunk-LYEXYTOI.js.map +0 -1
- package/dist/chunk-LZMC2QML.mjs +0 -25
- package/dist/chunk-LZMC2QML.mjs.map +0 -1
- package/dist/chunk-MG5QDUDI.mjs +0 -48
- package/dist/chunk-MG5QDUDI.mjs.map +0 -1
- package/dist/chunk-MNBV5FJI.mjs +0 -31
- package/dist/chunk-MNBV5FJI.mjs.map +0 -1
- package/dist/chunk-NIPCK74T.js +0 -185
- package/dist/chunk-NIPCK74T.js.map +0 -1
- package/dist/chunk-O45HYLIV.js +0 -67
- package/dist/chunk-O45HYLIV.js.map +0 -1
- package/dist/chunk-ODI2BTKS.mjs +0 -55
- package/dist/chunk-ODI2BTKS.mjs.map +0 -1
- package/dist/chunk-OHFX4S6R.mjs +0 -185
- package/dist/chunk-OHFX4S6R.mjs.map +0 -1
- package/dist/chunk-OMBFVTP2.js +0 -37
- package/dist/chunk-OMBFVTP2.js.map +0 -1
- package/dist/chunk-PJMQ2XEG.js +0 -29
- package/dist/chunk-PJMQ2XEG.js.map +0 -1
- package/dist/chunk-PNCS6GEX.mjs +0 -1
- package/dist/chunk-PNCS6GEX.mjs.map +0 -1
- package/dist/chunk-PROWNV4M.js +0 -1
- package/dist/chunk-PROWNV4M.js.map +0 -1
- package/dist/chunk-QAOZN4AX.js +0 -25
- package/dist/chunk-QAOZN4AX.js.map +0 -1
- package/dist/chunk-QB5IFRLA.mjs +0 -1
- package/dist/chunk-QB5IFRLA.mjs.map +0 -1
- package/dist/chunk-RAUV5UV4.mjs +0 -1
- package/dist/chunk-RAUV5UV4.mjs.map +0 -1
- package/dist/chunk-SGLVWM4N.js +0 -48
- package/dist/chunk-SGLVWM4N.js.map +0 -1
- package/dist/chunk-TLX5QQK5.js +0 -9
- package/dist/chunk-TLX5QQK5.js.map +0 -1
- package/dist/chunk-U5UIDVOO.mjs +0 -36
- package/dist/chunk-U5UIDVOO.mjs.map +0 -1
- package/dist/chunk-U74Q3BRP.mjs +0 -1
- package/dist/chunk-U74Q3BRP.mjs.map +0 -1
- package/dist/chunk-UQ6MTYIR.js +0 -972
- package/dist/chunk-UQ6MTYIR.js.map +0 -1
- package/dist/chunk-UZHUVXRM.js +0 -31
- package/dist/chunk-UZHUVXRM.js.map +0 -1
- package/dist/chunk-V5HMYDWE.js +0 -1
- package/dist/chunk-V5HMYDWE.js.map +0 -1
- package/dist/chunk-VZMQIJMK.mjs +0 -149
- package/dist/chunk-VZMQIJMK.mjs.map +0 -1
- package/dist/chunk-W7IP4LDB.js +0 -118
- package/dist/chunk-W7IP4LDB.js.map +0 -1
- package/dist/chunk-WE4RFGT7.mjs +0 -885
- package/dist/chunk-WE4RFGT7.mjs.map +0 -1
- package/dist/chunk-WGBEAP2F.mjs +0 -207
- package/dist/chunk-WGBEAP2F.mjs.map +0 -1
- package/dist/chunk-WRYFIWNK.js +0 -1
- package/dist/chunk-WRYFIWNK.js.map +0 -1
- package/dist/chunk-XZEVRYUE.js +0 -1
- package/dist/chunk-XZEVRYUE.js.map +0 -1
- package/dist/chunk-YUMIJSUD.mjs +0 -221
- package/dist/chunk-YUMIJSUD.mjs.map +0 -1
- package/dist/chunk-ZBNBZN5H.js +0 -1
- package/dist/chunk-ZBNBZN5H.js.map +0 -1
- package/dist/chunk-ZV3DFBO4.js +0 -1
- package/dist/chunk-ZV3DFBO4.js.map +0 -1
- package/dist/index.js +0 -46
- package/dist/index.js.map +0 -1
- package/dist/shared/to-raw-notification.js +0 -8
- package/dist/shared/to-raw-notification.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/types/NotificationServicesController/NotificationServicesController.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/__fixtures__/index.d.ts +0 -6
- package/dist/types/NotificationServicesController/__fixtures__/index.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/__fixtures__/mock-feature-announcements.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/__fixtures__/mock-notification-trigger.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/__fixtures__/mock-notification-user-storage.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/__fixtures__/mock-raw-notifications.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/__fixtures__/mockResponses.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/__fixtures__/mockServices.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/__fixtures__/test-utils.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/constants/constants.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/constants/index.d.ts +0 -3
- package/dist/types/NotificationServicesController/constants/index.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/constants/notification-schema.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/index.d.ts +0 -14
- package/dist/types/NotificationServicesController/index.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/processors/index.d.ts +0 -4
- package/dist/types/NotificationServicesController/processors/index.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/processors/process-feature-announcement.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/processors/process-notifications.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/processors/process-onchain-notifications.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/services/feature-announcements.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/services/onchain-notifications.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/types/feature-announcement/feature-announcement.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/types/feature-announcement/index.d.ts +0 -4
- package/dist/types/NotificationServicesController/types/feature-announcement/index.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/types/feature-announcement/type-feature-announcement.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/types/feature-announcement/type-links.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/types/index.d.ts +0 -5
- package/dist/types/NotificationServicesController/types/index.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/types/notification/index.d.ts +0 -2
- package/dist/types/NotificationServicesController/types/notification/index.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/types/notification/notification.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/types/on-chain-notification/index.d.ts +0 -2
- package/dist/types/NotificationServicesController/types/on-chain-notification/index.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/types/on-chain-notification/schema.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/types/type-utils.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/types/user-storage/index.d.ts +0 -2
- package/dist/types/NotificationServicesController/types/user-storage/index.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/types/user-storage/user-storage.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/ui/constants.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/ui/index.d.ts +0 -2
- package/dist/types/NotificationServicesController/ui/index.d.ts.map +0 -1
- package/dist/types/NotificationServicesController/utils/utils.d.ts.map +0 -1
- package/dist/types/NotificationServicesPushController/NotificationServicesPushController.d.ts.map +0 -1
- package/dist/types/NotificationServicesPushController/__fixtures__/index.d.ts +0 -2
- package/dist/types/NotificationServicesPushController/__fixtures__/index.d.ts.map +0 -1
- package/dist/types/NotificationServicesPushController/__fixtures__/mockResponse.d.ts.map +0 -1
- package/dist/types/NotificationServicesPushController/__fixtures__/mockServices.d.ts.map +0 -1
- package/dist/types/NotificationServicesPushController/constants.d.ts.map +0 -1
- package/dist/types/NotificationServicesPushController/index.d.ts +0 -11
- package/dist/types/NotificationServicesPushController/index.d.ts.map +0 -1
- package/dist/types/NotificationServicesPushController/services/endpoints.d.ts.map +0 -1
- package/dist/types/NotificationServicesPushController/services/push/index.d.ts.map +0 -1
- package/dist/types/NotificationServicesPushController/services/push/push-web.d.ts.map +0 -1
- package/dist/types/NotificationServicesPushController/services/services.d.ts.map +0 -1
- package/dist/types/NotificationServicesPushController/types/firebase.d.ts.map +0 -1
- package/dist/types/NotificationServicesPushController/types/index.d.ts +0 -2
- package/dist/types/NotificationServicesPushController/types/index.d.ts.map +0 -1
- package/dist/types/NotificationServicesPushController/utils/get-notification-data.d.ts.map +0 -1
- package/dist/types/NotificationServicesPushController/utils/get-notification-message.d.ts.map +0 -1
- package/dist/types/NotificationServicesPushController/utils/index.d.ts +0 -3
- package/dist/types/NotificationServicesPushController/utils/index.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -3
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/shared/to-raw-notification.d.ts.map +0 -1
|
@@ -1,14 +1,78 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import $bignumberjs from "bignumber.js";
|
|
2
|
+
const { BigNumber } = $bignumberjs;
|
|
3
|
+
const defaultFormatOptions = {
|
|
4
|
+
decimalPlaces: 4,
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Calculates the token amount based on the given value and decimals.
|
|
8
|
+
*
|
|
9
|
+
* @param value - The value to calculate the token amount from.
|
|
10
|
+
* @param decimals - The number of decimals to use for the calculation.
|
|
11
|
+
* @returns The calculated token amount.
|
|
12
|
+
*/
|
|
13
|
+
export function calcTokenAmount(value, decimals) {
|
|
14
|
+
const multiplier = Math.pow(10, Number(decimals || 0));
|
|
15
|
+
return new BigNumber(String(value)).div(multiplier);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Calculates the number of leading zeros in the fractional part of a number.
|
|
19
|
+
*
|
|
20
|
+
* This function converts a number or a string representation of a number into
|
|
21
|
+
* its decimal form and then counts the number of leading zeros present in the
|
|
22
|
+
* fractional part of the number. This is useful for determining the precision
|
|
23
|
+
* of very small numbers.
|
|
24
|
+
*
|
|
25
|
+
* @param num - The number to analyze, which can be in the form
|
|
26
|
+
* of a number or a string.
|
|
27
|
+
* @returns The count of leading zeros in the fractional part of the number.
|
|
28
|
+
*/
|
|
29
|
+
export const getLeadingZeroCount = (num) => {
|
|
30
|
+
const numToString = new BigNumber(num, 10).toString(10);
|
|
31
|
+
const fractionalPart = numToString.split('.')[1] ?? '';
|
|
32
|
+
return fractionalPart.match(/^0*/u)?.[0]?.length || 0;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* This formats a number using Intl
|
|
36
|
+
* It abbreviates large numbers (using K, M, B, T)
|
|
37
|
+
* And abbreviates small numbers in 2 ways:
|
|
38
|
+
* - Will format to the given number of decimal places
|
|
39
|
+
* - Will format up to 4 decimal places
|
|
40
|
+
* - Will ellipse the number if longer than given decimal places
|
|
41
|
+
*
|
|
42
|
+
* @param numericAmount - The number to format
|
|
43
|
+
* @param opts - The options to use when formatting
|
|
44
|
+
* @returns The formatted number
|
|
45
|
+
*/
|
|
46
|
+
export const formatAmount = (numericAmount, opts) => {
|
|
47
|
+
// create options with defaults
|
|
48
|
+
const options = { ...defaultFormatOptions, ...opts };
|
|
49
|
+
const leadingZeros = getLeadingZeroCount(numericAmount);
|
|
50
|
+
const isDecimal = numericAmount.toString().includes('.') || leadingZeros > 0;
|
|
51
|
+
const isLargeNumber = numericAmount > 999;
|
|
52
|
+
const handleShouldEllipse = (decimalPlaces) => Boolean(options?.shouldEllipse) && leadingZeros >= decimalPlaces;
|
|
53
|
+
if (isLargeNumber) {
|
|
54
|
+
return Intl.NumberFormat('en-US', {
|
|
55
|
+
notation: 'compact',
|
|
56
|
+
compactDisplay: 'short',
|
|
57
|
+
maximumFractionDigits: 2,
|
|
58
|
+
}).format(numericAmount);
|
|
59
|
+
}
|
|
60
|
+
if (isDecimal) {
|
|
61
|
+
const ellipse = handleShouldEllipse(options.decimalPlaces);
|
|
62
|
+
const formattedValue = Intl.NumberFormat('en-US', {
|
|
63
|
+
minimumFractionDigits: ellipse ? options.decimalPlaces : undefined,
|
|
64
|
+
maximumFractionDigits: options.decimalPlaces,
|
|
65
|
+
}).format(numericAmount);
|
|
66
|
+
return ellipse ? `${formattedValue}...` : formattedValue;
|
|
67
|
+
}
|
|
68
|
+
// Default to showing the raw amount
|
|
69
|
+
return numericAmount.toString();
|
|
70
|
+
};
|
|
71
|
+
export const getAmount = (amount, decimals, options) => {
|
|
72
|
+
if (!amount || !decimals) {
|
|
73
|
+
return '';
|
|
74
|
+
}
|
|
75
|
+
const numericAmount = calcTokenAmount(amount, parseFloat(decimals)).toNumber();
|
|
76
|
+
return formatAmount(numericAmount, options);
|
|
13
77
|
};
|
|
14
78
|
//# sourceMappingURL=get-notification-data.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"get-notification-data.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-data.ts"],"names":[],"mappings":";;AAMA,MAAM,oBAAoB,GAAG;IAC3B,aAAa,EAAE,CAAC;CACjB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa,EAAE,QAAgB;IAC7D,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC;IACvD,OAAO,IAAI,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AACtD,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAoB,EAAE,EAA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AAO,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;YAClE,qBAAqB,EAAE,OAAO,CAAC,aAAa;SAC7C,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QAEzB,OAAO,OAAO,CAAC,CAAC,CAAC,GAAG,cAAc,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC;KAC1D;IAED,oCAAoC;IACpC,OAAO,aAAa,CAAC,QAAQ,EAAE,CAAC;AAClC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,MAAc,EACd,QAAgB,EAChB,OAAuB,EACvB,EAAE;IACF,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE;QACxB,OAAO,EAAE,CAAC;KACX;IAED,MAAM,aAAa,GAAG,eAAe,CACnC,MAAM,EACN,UAAU,CAAC,QAAQ,CAAC,CACrB,CAAC,QAAQ,EAAE,CAAC;IAEb,OAAO,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC,CAAC","sourcesContent":["import { BigNumber } from 'bignumber.js';\n\ntype FormatOptions = {\n decimalPlaces?: number;\n shouldEllipse?: boolean;\n};\nconst defaultFormatOptions = {\n decimalPlaces: 4,\n};\n\n/**\n * Calculates the token amount based on the given value and decimals.\n *\n * @param value - The value to calculate the token amount from.\n * @param decimals - The number of decimals to use for the calculation.\n * @returns The calculated token amount.\n */\nexport function calcTokenAmount(value: string, decimals: number) {\n const multiplier = Math.pow(10, Number(decimals || 0));\n return new BigNumber(String(value)).div(multiplier);\n}\n\n/**\n * Calculates the number of leading zeros in the fractional part of a number.\n *\n * This function converts a number or a string representation of a number into\n * its decimal form and then counts the number of leading zeros present in the\n * fractional part of the number. This is useful for determining the precision\n * of very small numbers.\n *\n * @param num - The number to analyze, which can be in the form\n * of a number or a string.\n * @returns The count of leading zeros in the fractional part of the number.\n */\nexport const getLeadingZeroCount = (num: number | string) => {\n const numToString = new BigNumber(num, 10).toString(10);\n const fractionalPart = numToString.split('.')[1] ?? '';\n return fractionalPart.match(/^0*/u)?.[0]?.length || 0;\n};\n\n/**\n * This formats a number using Intl\n * It abbreviates large numbers (using K, M, B, T)\n * And abbreviates small numbers in 2 ways:\n * - Will format to the given number of decimal places\n * - Will format up to 4 decimal places\n * - Will ellipse the number if longer than given decimal places\n *\n * @param numericAmount - The number to format\n * @param opts - The options to use when formatting\n * @returns The formatted number\n */\nexport const formatAmount = (numericAmount: number, opts?: FormatOptions) => {\n // create options with defaults\n const options = { ...defaultFormatOptions, ...opts };\n\n const leadingZeros = getLeadingZeroCount(numericAmount);\n const isDecimal = numericAmount.toString().includes('.') || leadingZeros > 0;\n const isLargeNumber = numericAmount > 999;\n\n const handleShouldEllipse = (decimalPlaces: number) =>\n Boolean(options?.shouldEllipse) && leadingZeros >= decimalPlaces;\n\n if (isLargeNumber) {\n return Intl.NumberFormat('en-US', {\n notation: 'compact',\n compactDisplay: 'short',\n maximumFractionDigits: 2,\n }).format(numericAmount);\n }\n\n if (isDecimal) {\n const ellipse = handleShouldEllipse(options.decimalPlaces);\n const formattedValue = Intl.NumberFormat('en-US', {\n minimumFractionDigits: ellipse ? options.decimalPlaces : undefined,\n maximumFractionDigits: options.decimalPlaces,\n }).format(numericAmount);\n\n return ellipse ? `${formattedValue}...` : formattedValue;\n }\n\n // Default to showing the raw amount\n return numericAmount.toString();\n};\n\nexport const getAmount = (\n amount: string,\n decimals: string,\n options?: FormatOptions,\n) => {\n if (!amount || !decimals) {\n return '';\n }\n\n const numericAmount = calcTokenAmount(\n amount,\n parseFloat(decimals),\n ).toNumber();\n\n return formatAmount(numericAmount, options);\n};\n"]}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createOnChainPushNotificationMessage = exports.isOnChainNotification = exports.createOnChainPushNotificationMessages = void 0;
|
|
4
|
+
const NotificationServicesController_1 = require("../../NotificationServicesController/index.cjs");
|
|
5
|
+
const get_notification_data_1 = require("./get-notification-data.cjs");
|
|
6
|
+
/**
|
|
7
|
+
* On Chain Push Notification Messages.
|
|
8
|
+
* This is a list of all the push notifications we support. Update this for synced notifications on mobile and extension
|
|
9
|
+
*
|
|
10
|
+
* @param translationKeys - all translations supported
|
|
11
|
+
* @returns A translation push message object.
|
|
12
|
+
*/
|
|
13
|
+
const createOnChainPushNotificationMessages = (translationKeys) => {
|
|
14
|
+
const t = (...args) => {
|
|
15
|
+
const [key, ...otherArgs] = args;
|
|
16
|
+
// Coerce types for the translation function
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
const fn = translationKeys[key];
|
|
19
|
+
return fn(...otherArgs);
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
erc20_sent: {
|
|
23
|
+
title: t('pushPlatformNotificationsFundsSentTitle'),
|
|
24
|
+
defaultDescription: t('pushPlatformNotificationsFundsSentDescriptionDefault'),
|
|
25
|
+
getDescription: (n) => {
|
|
26
|
+
const symbol = n?.data?.token?.symbol;
|
|
27
|
+
const tokenAmount = n?.data?.token?.amount;
|
|
28
|
+
const tokenDecimals = n?.data?.token?.decimals;
|
|
29
|
+
if (!symbol || !tokenAmount || !tokenDecimals) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const amount = (0, get_notification_data_1.getAmount)(tokenAmount, tokenDecimals, {
|
|
33
|
+
shouldEllipse: true,
|
|
34
|
+
});
|
|
35
|
+
return t('pushPlatformNotificationsFundsSentDescription', amount, symbol);
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
eth_sent: {
|
|
39
|
+
title: t('pushPlatformNotificationsFundsSentTitle'),
|
|
40
|
+
defaultDescription: t('pushPlatformNotificationsFundsSentDescriptionDefault'),
|
|
41
|
+
getDescription: (n) => {
|
|
42
|
+
const symbol = getChainSymbol(n?.chain_id);
|
|
43
|
+
const tokenAmount = n?.data?.amount?.eth;
|
|
44
|
+
if (!symbol || !tokenAmount) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const amount = (0, get_notification_data_1.formatAmount)(parseFloat(tokenAmount), {
|
|
48
|
+
shouldEllipse: true,
|
|
49
|
+
});
|
|
50
|
+
return t('pushPlatformNotificationsFundsSentDescription', amount, symbol);
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
erc20_received: {
|
|
54
|
+
title: t('pushPlatformNotificationsFundsReceivedTitle'),
|
|
55
|
+
defaultDescription: t('pushPlatformNotificationsFundsReceivedDescriptionDefault'),
|
|
56
|
+
getDescription: (n) => {
|
|
57
|
+
const symbol = n?.data?.token?.symbol;
|
|
58
|
+
const tokenAmount = n?.data?.token?.amount;
|
|
59
|
+
const tokenDecimals = n?.data?.token?.decimals;
|
|
60
|
+
if (!symbol || !tokenAmount || !tokenDecimals) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const amount = (0, get_notification_data_1.getAmount)(tokenAmount, tokenDecimals, {
|
|
64
|
+
shouldEllipse: true,
|
|
65
|
+
});
|
|
66
|
+
return t('pushPlatformNotificationsFundsReceivedDescription', amount, symbol);
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
eth_received: {
|
|
70
|
+
title: t('pushPlatformNotificationsFundsReceivedTitle'),
|
|
71
|
+
defaultDescription: t('pushPlatformNotificationsFundsReceivedDescriptionDefault'),
|
|
72
|
+
getDescription: (n) => {
|
|
73
|
+
const symbol = getChainSymbol(n?.chain_id);
|
|
74
|
+
const tokenAmount = n?.data?.amount?.eth;
|
|
75
|
+
if (!symbol || !tokenAmount) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
const amount = (0, get_notification_data_1.formatAmount)(parseFloat(tokenAmount), {
|
|
79
|
+
shouldEllipse: true,
|
|
80
|
+
});
|
|
81
|
+
return t('pushPlatformNotificationsFundsReceivedDescription', amount, symbol);
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
metamask_swap_completed: {
|
|
85
|
+
title: t('pushPlatformNotificationsSwapCompletedTitle'),
|
|
86
|
+
defaultDescription: t('pushPlatformNotificationsSwapCompletedDescription'),
|
|
87
|
+
},
|
|
88
|
+
erc721_sent: {
|
|
89
|
+
title: t('pushPlatformNotificationsNftSentTitle'),
|
|
90
|
+
defaultDescription: t('pushPlatformNotificationsNftSentDescription'),
|
|
91
|
+
},
|
|
92
|
+
erc1155_sent: {
|
|
93
|
+
title: t('pushPlatformNotificationsNftSentTitle'),
|
|
94
|
+
defaultDescription: t('pushPlatformNotificationsNftSentDescription'),
|
|
95
|
+
},
|
|
96
|
+
erc721_received: {
|
|
97
|
+
title: t('pushPlatformNotificationsNftReceivedTitle'),
|
|
98
|
+
defaultDescription: t('pushPlatformNotificationsNftReceivedDescription'),
|
|
99
|
+
},
|
|
100
|
+
erc1155_received: {
|
|
101
|
+
title: t('pushPlatformNotificationsNftReceivedTitle'),
|
|
102
|
+
defaultDescription: t('pushPlatformNotificationsNftReceivedDescription'),
|
|
103
|
+
},
|
|
104
|
+
rocketpool_stake_completed: {
|
|
105
|
+
title: t('pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle'),
|
|
106
|
+
defaultDescription: t('pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription'),
|
|
107
|
+
},
|
|
108
|
+
rocketpool_unstake_completed: {
|
|
109
|
+
title: t('pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle'),
|
|
110
|
+
defaultDescription: t('pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription'),
|
|
111
|
+
},
|
|
112
|
+
lido_stake_completed: {
|
|
113
|
+
title: t('pushPlatformNotificationsStakingLidoStakeCompletedTitle'),
|
|
114
|
+
defaultDescription: t('pushPlatformNotificationsStakingLidoStakeCompletedDescription'),
|
|
115
|
+
},
|
|
116
|
+
lido_stake_ready_to_be_withdrawn: {
|
|
117
|
+
title: t('pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle'),
|
|
118
|
+
defaultDescription: t('pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription'),
|
|
119
|
+
},
|
|
120
|
+
lido_withdrawal_requested: {
|
|
121
|
+
title: t('pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle'),
|
|
122
|
+
defaultDescription: t('pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription'),
|
|
123
|
+
},
|
|
124
|
+
lido_withdrawal_completed: {
|
|
125
|
+
title: t('pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle'),
|
|
126
|
+
defaultDescription: t('pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription'),
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
exports.createOnChainPushNotificationMessages = createOnChainPushNotificationMessages;
|
|
131
|
+
/**
|
|
132
|
+
* Retrieves the symbol associated with a given chain ID.
|
|
133
|
+
*
|
|
134
|
+
* @param chainId - The ID of the chain.
|
|
135
|
+
* @returns The symbol associated with the chain ID, or null if not found.
|
|
136
|
+
*/
|
|
137
|
+
function getChainSymbol(chainId) {
|
|
138
|
+
return NotificationServicesController_1.Constants.CHAIN_SYMBOLS[chainId] ?? null;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Checks if the given value is an OnChainRawNotification object.
|
|
142
|
+
*
|
|
143
|
+
* @param n - The value to check.
|
|
144
|
+
* @returns True if the value is an OnChainRawNotification object, false otherwise.
|
|
145
|
+
*/
|
|
146
|
+
function isOnChainNotification(n) {
|
|
147
|
+
const assumed = n;
|
|
148
|
+
// We don't have a validation/parsing library to check all possible types of an on chain notification
|
|
149
|
+
// It is safe enough just to check "some" fields, and catch any errors down the line if the shape is bad.
|
|
150
|
+
const isValidEnoughToBeOnChainNotification = [
|
|
151
|
+
assumed?.id,
|
|
152
|
+
assumed?.data,
|
|
153
|
+
assumed?.trigger_id,
|
|
154
|
+
].every((field) => field !== undefined);
|
|
155
|
+
return isValidEnoughToBeOnChainNotification;
|
|
156
|
+
}
|
|
157
|
+
exports.isOnChainNotification = isOnChainNotification;
|
|
158
|
+
/**
|
|
159
|
+
* Creates a push notification message based on the given on-chain raw notification.
|
|
160
|
+
*
|
|
161
|
+
* @param n - processed notification.
|
|
162
|
+
* @param translations - translates keys into text
|
|
163
|
+
* @returns The push notification message object, or null if the notification is invalid.
|
|
164
|
+
*/
|
|
165
|
+
function createOnChainPushNotificationMessage(n, translations) {
|
|
166
|
+
if (!n?.type) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
const notificationMessage = (0, exports.createOnChainPushNotificationMessages)(translations)[n.type];
|
|
170
|
+
if (!notificationMessage) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
let description = null;
|
|
174
|
+
try {
|
|
175
|
+
description =
|
|
176
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
177
|
+
notificationMessage?.getDescription?.(n) ??
|
|
178
|
+
notificationMessage.defaultDescription ??
|
|
179
|
+
null;
|
|
180
|
+
}
|
|
181
|
+
catch (e) {
|
|
182
|
+
description = notificationMessage.defaultDescription ?? null;
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
title: notificationMessage.title ?? '',
|
|
186
|
+
description: description ?? '', // Fallback to empty string if null
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
exports.createOnChainPushNotificationMessage = createOnChainPushNotificationMessage;
|
|
190
|
+
//# sourceMappingURL=get-notification-message.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-notification-message.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-message.ts"],"names":[],"mappings":";;;AAEA,mGAAiE;AACjE,uEAAkE;AAkDlE;;;;;;GAMG;AACI,MAAM,qCAAqC,GAAG,CACnD,eAAgC,EACP,EAAE;IAI3B,MAAM,CAAC,GAAkB,CAAC,GAAG,IAAI,EAAE,EAAE;QACnC,MAAM,CAAC,GAAG,EAAE,GAAG,SAAS,C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AAI,CAAC;KACR;IAAC,OAAO,CAAC,EAAE;QACV,WAAW,GAAG,mBAAmB,CAAC,kBAAkB,IAAI,IAAI,CAAC;KAC9D;IAED,OAAO;QACL,KAAK,EAAE,mBAAmB,CAAC,KAAK,IAAI,EAAE;QACtC,WAAW,EAAE,WAAW,IAAI,EAAE,EAAE,mCAAmC;KACpE,CAAC;AACJ,CAAC;AA7BD,oFA6BC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport type { Types } from '../../NotificationServicesController';\nimport { Constants } from '../../NotificationServicesController';\nimport { getAmount, formatAmount } from './get-notification-data';\n\nexport type TranslationKeys = {\n pushPlatformNotificationsFundsSentTitle: () => string;\n pushPlatformNotificationsFundsSentDescriptionDefault: () => string;\n pushPlatformNotificationsFundsSentDescription: (\n ...args: [string, string]\n ) => string;\n pushPlatformNotificationsFundsReceivedTitle: () => string;\n pushPlatformNotificationsFundsReceivedDescriptionDefault: () => string;\n pushPlatformNotificationsFundsReceivedDescription: (\n ...args: [string, string]\n ) => string;\n pushPlatformNotificationsSwapCompletedTitle: () => string;\n pushPlatformNotificationsSwapCompletedDescription: () => string;\n pushPlatformNotificationsNftSentTitle: () => string;\n pushPlatformNotificationsNftSentDescription: () => string;\n pushPlatformNotificationsNftReceivedTitle: () => string;\n pushPlatformNotificationsNftReceivedDescription: () => string;\n pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle: () => string;\n pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription: () => string;\n pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle: () => string;\n pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription: () => string;\n pushPlatformNotificationsStakingLidoStakeCompletedTitle: () => string;\n pushPlatformNotificationsStakingLidoStakeCompletedDescription: () => string;\n pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle: () => string;\n pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription: () => string;\n pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle: () => string;\n pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription: () => string;\n pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle: () => string;\n pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription: () => string;\n};\n\ntype PushNotificationMessage = {\n title: string;\n description: string;\n};\n\ntype NotificationMessage<N extends Types.INotification> = {\n title: string | null;\n defaultDescription: string | null;\n getDescription?: (n: N) => string | null;\n};\n\ntype NotificationMessageDict = {\n [K in Constants.TRIGGER_TYPES]?: NotificationMessage<\n Extract<Types.INotification, { type: K }>\n >;\n};\n\n/**\n * On Chain Push Notification Messages.\n * This is a list of all the push notifications we support. Update this for synced notifications on mobile and extension\n *\n * @param translationKeys - all translations supported\n * @returns A translation push message object.\n */\nexport const createOnChainPushNotificationMessages = (\n translationKeys: TranslationKeys,\n): NotificationMessageDict => {\n type TranslationFn = <K extends keyof TranslationKeys>(\n ...args: [K, ...Parameters<TranslationKeys[K]>]\n ) => string;\n const t: TranslationFn = (...args) => {\n const [key, ...otherArgs] = args;\n\n // Coerce types for the translation function\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const fn: any = translationKeys[key];\n return fn(...otherArgs);\n };\n\n return {\n erc20_sent: {\n title: t('pushPlatformNotificationsFundsSentTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsFundsSentDescriptionDefault',\n ),\n getDescription: (n) => {\n const symbol = n?.data?.token?.symbol;\n const tokenAmount = n?.data?.token?.amount;\n const tokenDecimals = n?.data?.token?.decimals;\n if (!symbol || !tokenAmount || !tokenDecimals) {\n return null;\n }\n\n const amount = getAmount(tokenAmount, tokenDecimals, {\n shouldEllipse: true,\n });\n return t(\n 'pushPlatformNotificationsFundsSentDescription',\n amount,\n symbol,\n );\n },\n },\n eth_sent: {\n title: t('pushPlatformNotificationsFundsSentTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsFundsSentDescriptionDefault',\n ),\n getDescription: (n) => {\n const symbol = getChainSymbol(n?.chain_id);\n const tokenAmount = n?.data?.amount?.eth;\n if (!symbol || !tokenAmount) {\n return null;\n }\n\n const amount = formatAmount(parseFloat(tokenAmount), {\n shouldEllipse: true,\n });\n return t(\n 'pushPlatformNotificationsFundsSentDescription',\n amount,\n symbol,\n );\n },\n },\n erc20_received: {\n title: t('pushPlatformNotificationsFundsReceivedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsFundsReceivedDescriptionDefault',\n ),\n getDescription: (n) => {\n const symbol = n?.data?.token?.symbol;\n const tokenAmount = n?.data?.token?.amount;\n const tokenDecimals = n?.data?.token?.decimals;\n if (!symbol || !tokenAmount || !tokenDecimals) {\n return null;\n }\n\n const amount = getAmount(tokenAmount, tokenDecimals, {\n shouldEllipse: true,\n });\n return t(\n 'pushPlatformNotificationsFundsReceivedDescription',\n amount,\n symbol,\n );\n },\n },\n eth_received: {\n title: t('pushPlatformNotificationsFundsReceivedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsFundsReceivedDescriptionDefault',\n ),\n getDescription: (n) => {\n const symbol = getChainSymbol(n?.chain_id);\n const tokenAmount = n?.data?.amount?.eth;\n if (!symbol || !tokenAmount) {\n return null;\n }\n\n const amount = formatAmount(parseFloat(tokenAmount), {\n shouldEllipse: true,\n });\n return t(\n 'pushPlatformNotificationsFundsReceivedDescription',\n amount,\n symbol,\n );\n },\n },\n metamask_swap_completed: {\n title: t('pushPlatformNotificationsSwapCompletedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsSwapCompletedDescription',\n ),\n },\n erc721_sent: {\n title: t('pushPlatformNotificationsNftSentTitle'),\n defaultDescription: t('pushPlatformNotificationsNftSentDescription'),\n },\n erc1155_sent: {\n title: t('pushPlatformNotificationsNftSentTitle'),\n defaultDescription: t('pushPlatformNotificationsNftSentDescription'),\n },\n erc721_received: {\n title: t('pushPlatformNotificationsNftReceivedTitle'),\n defaultDescription: t('pushPlatformNotificationsNftReceivedDescription'),\n },\n erc1155_received: {\n title: t('pushPlatformNotificationsNftReceivedTitle'),\n defaultDescription: t('pushPlatformNotificationsNftReceivedDescription'),\n },\n rocketpool_stake_completed: {\n title: t('pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription',\n ),\n },\n rocketpool_unstake_completed: {\n title: t(\n 'pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle',\n ),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription',\n ),\n },\n lido_stake_completed: {\n title: t('pushPlatformNotificationsStakingLidoStakeCompletedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingLidoStakeCompletedDescription',\n ),\n },\n lido_stake_ready_to_be_withdrawn: {\n title: t(\n 'pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle',\n ),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription',\n ),\n },\n lido_withdrawal_requested: {\n title: t('pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription',\n ),\n },\n lido_withdrawal_completed: {\n title: t('pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle'),\n defaultDescription: t(\n 'pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription',\n ),\n },\n };\n};\n\n/**\n * Retrieves the symbol associated with a given chain ID.\n *\n * @param chainId - The ID of the chain.\n * @returns The symbol associated with the chain ID, or null if not found.\n */\nfunction getChainSymbol(chainId: number) {\n return Constants.CHAIN_SYMBOLS[chainId] ?? null;\n}\n\n/**\n * Checks if the given value is an OnChainRawNotification object.\n *\n * @param n - The value to check.\n * @returns True if the value is an OnChainRawNotification object, false otherwise.\n */\nexport function isOnChainNotification(\n n: unknown,\n): n is Types.OnChainRawNotification {\n const assumed = n as Types.OnChainRawNotification;\n\n // We don't have a validation/parsing library to check all possible types of an on chain notification\n // It is safe enough just to check \"some\" fields, and catch any errors down the line if the shape is bad.\n const isValidEnoughToBeOnChainNotification = [\n assumed?.id,\n assumed?.data,\n assumed?.trigger_id,\n ].every((field) => field !== undefined);\n return isValidEnoughToBeOnChainNotification;\n}\n\n/**\n * Creates a push notification message based on the given on-chain raw notification.\n *\n * @param n - processed notification.\n * @param translations - translates keys into text\n * @returns The push notification message object, or null if the notification is invalid.\n */\nexport function createOnChainPushNotificationMessage(\n n: Types.INotification,\n translations: TranslationKeys,\n): PushNotificationMessage | null {\n if (!n?.type) {\n return null;\n }\n const notificationMessage =\n createOnChainPushNotificationMessages(translations)[n.type];\n\n if (!notificationMessage) {\n return null;\n }\n\n let description: string | null = null;\n try {\n description =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n notificationMessage?.getDescription?.(n as any) ??\n notificationMessage.defaultDescription ??\n null;\n } catch (e) {\n description = notificationMessage.defaultDescription ?? null;\n }\n\n return {\n title: notificationMessage.title ?? '', // Ensure title is always a string\n description: description ?? '', // Fallback to empty string if null\n };\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Types } from
|
|
2
|
-
import { Constants } from
|
|
1
|
+
import type { Types } from "../../NotificationServicesController/index.cjs";
|
|
2
|
+
import { Constants } from "../../NotificationServicesController/index.cjs";
|
|
3
3
|
export type TranslationKeys = {
|
|
4
4
|
pushPlatformNotificationsFundsSentTitle: () => string;
|
|
5
5
|
pushPlatformNotificationsFundsSentDescriptionDefault: () => string;
|
|
@@ -64,4 +64,4 @@ export declare function isOnChainNotification(n: unknown): n is Types.OnChainRaw
|
|
|
64
64
|
*/
|
|
65
65
|
export declare function createOnChainPushNotificationMessage(n: Types.INotification, translations: TranslationKeys): PushNotificationMessage | null;
|
|
66
66
|
export {};
|
|
67
|
-
//# sourceMappingURL=get-notification-message.d.
|
|
67
|
+
//# sourceMappingURL=get-notification-message.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-notification-message.d.cts","sourceRoot":"","sources":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K,uBAAuB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,KAAK,mBAAmB,CAAC,CAAC,SAAS,KAAK,CAAC,aAAa,IAAI;IACxD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,GAAG,IAAI,CAAC;CAC1C,CAAC;AAEF,KAAK,uBAAuB,GAAG;KAC5B,CAAC,IAAI,SAAS,CAAC,aAAa,CAAC,CAAC,EAAE,mBAAmB,CAClD,OAAO,CAAC,KAAK,CAAC,aAAa,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,CAC1C;CACF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qCAAqC,oBAC/B,eAAe,KAC/B,uBAuKF,CAAC;AAYF;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,CAAC,EAAE,OAAO,GACT,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAWnC;AAED;;;;;;GAMG;AACH,wBAAgB,oCAAoC,CAClD,CAAC,EAAE,KAAK,CAAC,aAAa,EACtB,YAAY,EAAE,eAAe,GAC5B,uBAAuB,GAAG,IAAI,CA0BhC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Types } from "../../NotificationServicesController/index.mjs";
|
|
2
|
+
import { Constants } from "../../NotificationServicesController/index.mjs";
|
|
3
|
+
export type TranslationKeys = {
|
|
4
|
+
pushPlatformNotificationsFundsSentTitle: () => string;
|
|
5
|
+
pushPlatformNotificationsFundsSentDescriptionDefault: () => string;
|
|
6
|
+
pushPlatformNotificationsFundsSentDescription: (...args: [string, string]) => string;
|
|
7
|
+
pushPlatformNotificationsFundsReceivedTitle: () => string;
|
|
8
|
+
pushPlatformNotificationsFundsReceivedDescriptionDefault: () => string;
|
|
9
|
+
pushPlatformNotificationsFundsReceivedDescription: (...args: [string, string]) => string;
|
|
10
|
+
pushPlatformNotificationsSwapCompletedTitle: () => string;
|
|
11
|
+
pushPlatformNotificationsSwapCompletedDescription: () => string;
|
|
12
|
+
pushPlatformNotificationsNftSentTitle: () => string;
|
|
13
|
+
pushPlatformNotificationsNftSentDescription: () => string;
|
|
14
|
+
pushPlatformNotificationsNftReceivedTitle: () => string;
|
|
15
|
+
pushPlatformNotificationsNftReceivedDescription: () => string;
|
|
16
|
+
pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle: () => string;
|
|
17
|
+
pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription: () => string;
|
|
18
|
+
pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle: () => string;
|
|
19
|
+
pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription: () => string;
|
|
20
|
+
pushPlatformNotificationsStakingLidoStakeCompletedTitle: () => string;
|
|
21
|
+
pushPlatformNotificationsStakingLidoStakeCompletedDescription: () => string;
|
|
22
|
+
pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle: () => string;
|
|
23
|
+
pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription: () => string;
|
|
24
|
+
pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle: () => string;
|
|
25
|
+
pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription: () => string;
|
|
26
|
+
pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle: () => string;
|
|
27
|
+
pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription: () => string;
|
|
28
|
+
};
|
|
29
|
+
type PushNotificationMessage = {
|
|
30
|
+
title: string;
|
|
31
|
+
description: string;
|
|
32
|
+
};
|
|
33
|
+
type NotificationMessage<N extends Types.INotification> = {
|
|
34
|
+
title: string | null;
|
|
35
|
+
defaultDescription: string | null;
|
|
36
|
+
getDescription?: (n: N) => string | null;
|
|
37
|
+
};
|
|
38
|
+
type NotificationMessageDict = {
|
|
39
|
+
[K in Constants.TRIGGER_TYPES]?: NotificationMessage<Extract<Types.INotification, {
|
|
40
|
+
type: K;
|
|
41
|
+
}>>;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* On Chain Push Notification Messages.
|
|
45
|
+
* This is a list of all the push notifications we support. Update this for synced notifications on mobile and extension
|
|
46
|
+
*
|
|
47
|
+
* @param translationKeys - all translations supported
|
|
48
|
+
* @returns A translation push message object.
|
|
49
|
+
*/
|
|
50
|
+
export declare const createOnChainPushNotificationMessages: (translationKeys: TranslationKeys) => NotificationMessageDict;
|
|
51
|
+
/**
|
|
52
|
+
* Checks if the given value is an OnChainRawNotification object.
|
|
53
|
+
*
|
|
54
|
+
* @param n - The value to check.
|
|
55
|
+
* @returns True if the value is an OnChainRawNotification object, false otherwise.
|
|
56
|
+
*/
|
|
57
|
+
export declare function isOnChainNotification(n: unknown): n is Types.OnChainRawNotification;
|
|
58
|
+
/**
|
|
59
|
+
* Creates a push notification message based on the given on-chain raw notification.
|
|
60
|
+
*
|
|
61
|
+
* @param n - processed notification.
|
|
62
|
+
* @param translations - translates keys into text
|
|
63
|
+
* @returns The push notification message object, or null if the notification is invalid.
|
|
64
|
+
*/
|
|
65
|
+
export declare function createOnChainPushNotificationMessage(n: Types.INotification, translations: TranslationKeys): PushNotificationMessage | null;
|
|
66
|
+
export {};
|
|
67
|
+
//# sourceMappingURL=get-notification-message.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-notification-message.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-message.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,uDAA6C;AAClE,OAAO,EAAE,SAAS,EAAE,uDAA6C;AAGjE,MAAM,MAAM,eAAe,GAAG;IAC5B,uCAAuC,EAAE,MAAM,MAAM,CAAC;IACtD,oDAAoD,EAAE,MAAM,MAAM,CAAC;IACnE,6CAA6C,EAAE,CAC7C,GA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C,EAAE,CAAC,KAAK,MAAM,GAAG,IAAI,CAAC;CAC1C,CAAC;AAEF,KAAK,uBAAuB,GAAG;KAC5B,CAAC,IAAI,SAAS,CAAC,aAAa,CAAC,CAAC,EAAE,mBAAmB,CAClD,OAAO,CAAC,KAAK,CAAC,aAAa,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,CAC1C;CACF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qCAAqC,oBAC/B,eAAe,KAC/B,uBAuKF,CAAC;AAYF;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,CAAC,EAAE,OAAO,GACT,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAWnC;AAED;;;;;;GAMG;AACH,wBAAgB,oCAAoC,CAClD,CAAC,EAAE,KAAK,CAAC,aAAa,EACtB,YAAY,EAAE,eAAe,GAC5B,uBAAuB,GAAG,IAAI,CA0BhC"}
|
|
@@ -1,39 +1,184 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
import { Constants } from "../../NotificationServicesController/index.mjs";
|
|
2
|
+
import { getAmount, formatAmount } from "./get-notification-data.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* On Chain Push Notification Messages.
|
|
5
|
+
* This is a list of all the push notifications we support. Update this for synced notifications on mobile and extension
|
|
6
|
+
*
|
|
7
|
+
* @param translationKeys - all translations supported
|
|
8
|
+
* @returns A translation push message object.
|
|
9
|
+
*/
|
|
10
|
+
export const createOnChainPushNotificationMessages = (translationKeys) => {
|
|
11
|
+
const t = (...args) => {
|
|
12
|
+
const [key, ...otherArgs] = args;
|
|
13
|
+
// Coerce types for the translation function
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
const fn = translationKeys[key];
|
|
16
|
+
return fn(...otherArgs);
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
erc20_sent: {
|
|
20
|
+
title: t('pushPlatformNotificationsFundsSentTitle'),
|
|
21
|
+
defaultDescription: t('pushPlatformNotificationsFundsSentDescriptionDefault'),
|
|
22
|
+
getDescription: (n) => {
|
|
23
|
+
const symbol = n?.data?.token?.symbol;
|
|
24
|
+
const tokenAmount = n?.data?.token?.amount;
|
|
25
|
+
const tokenDecimals = n?.data?.token?.decimals;
|
|
26
|
+
if (!symbol || !tokenAmount || !tokenDecimals) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const amount = getAmount(tokenAmount, tokenDecimals, {
|
|
30
|
+
shouldEllipse: true,
|
|
31
|
+
});
|
|
32
|
+
return t('pushPlatformNotificationsFundsSentDescription', amount, symbol);
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
eth_sent: {
|
|
36
|
+
title: t('pushPlatformNotificationsFundsSentTitle'),
|
|
37
|
+
defaultDescription: t('pushPlatformNotificationsFundsSentDescriptionDefault'),
|
|
38
|
+
getDescription: (n) => {
|
|
39
|
+
const symbol = getChainSymbol(n?.chain_id);
|
|
40
|
+
const tokenAmount = n?.data?.amount?.eth;
|
|
41
|
+
if (!symbol || !tokenAmount) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const amount = formatAmount(parseFloat(tokenAmount), {
|
|
45
|
+
shouldEllipse: true,
|
|
46
|
+
});
|
|
47
|
+
return t('pushPlatformNotificationsFundsSentDescription', amount, symbol);
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
erc20_received: {
|
|
51
|
+
title: t('pushPlatformNotificationsFundsReceivedTitle'),
|
|
52
|
+
defaultDescription: t('pushPlatformNotificationsFundsReceivedDescriptionDefault'),
|
|
53
|
+
getDescription: (n) => {
|
|
54
|
+
const symbol = n?.data?.token?.symbol;
|
|
55
|
+
const tokenAmount = n?.data?.token?.amount;
|
|
56
|
+
const tokenDecimals = n?.data?.token?.decimals;
|
|
57
|
+
if (!symbol || !tokenAmount || !tokenDecimals) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
const amount = getAmount(tokenAmount, tokenDecimals, {
|
|
61
|
+
shouldEllipse: true,
|
|
62
|
+
});
|
|
63
|
+
return t('pushPlatformNotificationsFundsReceivedDescription', amount, symbol);
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
eth_received: {
|
|
67
|
+
title: t('pushPlatformNotificationsFundsReceivedTitle'),
|
|
68
|
+
defaultDescription: t('pushPlatformNotificationsFundsReceivedDescriptionDefault'),
|
|
69
|
+
getDescription: (n) => {
|
|
70
|
+
const symbol = getChainSymbol(n?.chain_id);
|
|
71
|
+
const tokenAmount = n?.data?.amount?.eth;
|
|
72
|
+
if (!symbol || !tokenAmount) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
const amount = formatAmount(parseFloat(tokenAmount), {
|
|
76
|
+
shouldEllipse: true,
|
|
77
|
+
});
|
|
78
|
+
return t('pushPlatformNotificationsFundsReceivedDescription', amount, symbol);
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
metamask_swap_completed: {
|
|
82
|
+
title: t('pushPlatformNotificationsSwapCompletedTitle'),
|
|
83
|
+
defaultDescription: t('pushPlatformNotificationsSwapCompletedDescription'),
|
|
84
|
+
},
|
|
85
|
+
erc721_sent: {
|
|
86
|
+
title: t('pushPlatformNotificationsNftSentTitle'),
|
|
87
|
+
defaultDescription: t('pushPlatformNotificationsNftSentDescription'),
|
|
88
|
+
},
|
|
89
|
+
erc1155_sent: {
|
|
90
|
+
title: t('pushPlatformNotificationsNftSentTitle'),
|
|
91
|
+
defaultDescription: t('pushPlatformNotificationsNftSentDescription'),
|
|
92
|
+
},
|
|
93
|
+
erc721_received: {
|
|
94
|
+
title: t('pushPlatformNotificationsNftReceivedTitle'),
|
|
95
|
+
defaultDescription: t('pushPlatformNotificationsNftReceivedDescription'),
|
|
96
|
+
},
|
|
97
|
+
erc1155_received: {
|
|
98
|
+
title: t('pushPlatformNotificationsNftReceivedTitle'),
|
|
99
|
+
defaultDescription: t('pushPlatformNotificationsNftReceivedDescription'),
|
|
100
|
+
},
|
|
101
|
+
rocketpool_stake_completed: {
|
|
102
|
+
title: t('pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle'),
|
|
103
|
+
defaultDescription: t('pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription'),
|
|
104
|
+
},
|
|
105
|
+
rocketpool_unstake_completed: {
|
|
106
|
+
title: t('pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle'),
|
|
107
|
+
defaultDescription: t('pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription'),
|
|
108
|
+
},
|
|
109
|
+
lido_stake_completed: {
|
|
110
|
+
title: t('pushPlatformNotificationsStakingLidoStakeCompletedTitle'),
|
|
111
|
+
defaultDescription: t('pushPlatformNotificationsStakingLidoStakeCompletedDescription'),
|
|
112
|
+
},
|
|
113
|
+
lido_stake_ready_to_be_withdrawn: {
|
|
114
|
+
title: t('pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle'),
|
|
115
|
+
defaultDescription: t('pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription'),
|
|
116
|
+
},
|
|
117
|
+
lido_withdrawal_requested: {
|
|
118
|
+
title: t('pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle'),
|
|
119
|
+
defaultDescription: t('pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription'),
|
|
120
|
+
},
|
|
121
|
+
lido_withdrawal_completed: {
|
|
122
|
+
title: t('pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle'),
|
|
123
|
+
defaultDescription: t('pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription'),
|
|
124
|
+
},
|
|
125
|
+
};
|
|
38
126
|
};
|
|
127
|
+
/**
|
|
128
|
+
* Retrieves the symbol associated with a given chain ID.
|
|
129
|
+
*
|
|
130
|
+
* @param chainId - The ID of the chain.
|
|
131
|
+
* @returns The symbol associated with the chain ID, or null if not found.
|
|
132
|
+
*/
|
|
133
|
+
function getChainSymbol(chainId) {
|
|
134
|
+
return Constants.CHAIN_SYMBOLS[chainId] ?? null;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Checks if the given value is an OnChainRawNotification object.
|
|
138
|
+
*
|
|
139
|
+
* @param n - The value to check.
|
|
140
|
+
* @returns True if the value is an OnChainRawNotification object, false otherwise.
|
|
141
|
+
*/
|
|
142
|
+
export function isOnChainNotification(n) {
|
|
143
|
+
const assumed = n;
|
|
144
|
+
// We don't have a validation/parsing library to check all possible types of an on chain notification
|
|
145
|
+
// It is safe enough just to check "some" fields, and catch any errors down the line if the shape is bad.
|
|
146
|
+
const isValidEnoughToBeOnChainNotification = [
|
|
147
|
+
assumed?.id,
|
|
148
|
+
assumed?.data,
|
|
149
|
+
assumed?.trigger_id,
|
|
150
|
+
].every((field) => field !== undefined);
|
|
151
|
+
return isValidEnoughToBeOnChainNotification;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Creates a push notification message based on the given on-chain raw notification.
|
|
155
|
+
*
|
|
156
|
+
* @param n - processed notification.
|
|
157
|
+
* @param translations - translates keys into text
|
|
158
|
+
* @returns The push notification message object, or null if the notification is invalid.
|
|
159
|
+
*/
|
|
160
|
+
export function createOnChainPushNotificationMessage(n, translations) {
|
|
161
|
+
if (!n?.type) {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
const notificationMessage = createOnChainPushNotificationMessages(translations)[n.type];
|
|
165
|
+
if (!notificationMessage) {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
let description = null;
|
|
169
|
+
try {
|
|
170
|
+
description =
|
|
171
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
172
|
+
notificationMessage?.getDescription?.(n) ??
|
|
173
|
+
notificationMessage.defaultDescription ??
|
|
174
|
+
null;
|
|
175
|
+
}
|
|
176
|
+
catch (e) {
|
|
177
|
+
description = notificationMessage.defaultDescription ?? null;
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
title: notificationMessage.title ?? '',
|
|
181
|
+
description: description ?? '', // Fallback to empty string if null
|
|
182
|
+
};
|
|
183
|
+
}
|
|
39
184
|
//# sourceMappingURL=get-notification-message.mjs.map
|