@metamask/notification-services-controller 23.0.1 → 23.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/dist/NotificationServicesController/NotificationServicesController.cjs +9 -0
  3. package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -1
  4. package/dist/NotificationServicesController/NotificationServicesController.d.cts +2 -2
  5. package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -1
  6. package/dist/NotificationServicesController/NotificationServicesController.d.mts +2 -2
  7. package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -1
  8. package/dist/NotificationServicesController/NotificationServicesController.mjs +9 -0
  9. package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
  10. package/dist/NotificationServicesController/mocks/mockResponses.cjs +2 -2
  11. package/dist/NotificationServicesController/mocks/mockResponses.cjs.map +1 -1
  12. package/dist/NotificationServicesController/mocks/mockResponses.mjs +2 -2
  13. package/dist/NotificationServicesController/mocks/mockResponses.mjs.map +1 -1
  14. package/dist/NotificationServicesController/processors/process-api-notifications.cjs.map +1 -1
  15. package/dist/NotificationServicesController/processors/process-api-notifications.d.cts +1 -1
  16. package/dist/NotificationServicesController/processors/process-api-notifications.d.cts.map +1 -1
  17. package/dist/NotificationServicesController/processors/process-api-notifications.d.mts +1 -1
  18. package/dist/NotificationServicesController/processors/process-api-notifications.d.mts.map +1 -1
  19. package/dist/NotificationServicesController/processors/process-api-notifications.mjs.map +1 -1
  20. package/dist/NotificationServicesController/processors/process-notifications.cjs +1 -1
  21. package/dist/NotificationServicesController/processors/process-notifications.cjs.map +1 -1
  22. package/dist/NotificationServicesController/processors/process-notifications.d.cts.map +1 -1
  23. package/dist/NotificationServicesController/processors/process-notifications.d.mts.map +1 -1
  24. package/dist/NotificationServicesController/processors/process-notifications.mjs +1 -1
  25. package/dist/NotificationServicesController/processors/process-notifications.mjs.map +1 -1
  26. package/dist/NotificationServicesController/services/api-notifications.cjs +1 -1
  27. package/dist/NotificationServicesController/services/api-notifications.cjs.map +1 -1
  28. package/dist/NotificationServicesController/services/api-notifications.d.cts.map +1 -1
  29. package/dist/NotificationServicesController/services/api-notifications.d.mts.map +1 -1
  30. package/dist/NotificationServicesController/services/api-notifications.mjs +1 -1
  31. package/dist/NotificationServicesController/services/api-notifications.mjs.map +1 -1
  32. package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.cjs.map +1 -1
  33. package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.d.cts +1 -1
  34. package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.d.cts.map +1 -1
  35. package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.d.mts +1 -1
  36. package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.d.mts.map +1 -1
  37. package/dist/NotificationServicesController/types/feature-announcement/feature-announcement.mjs.map +1 -1
  38. package/dist/NotificationServicesController/types/notification-api/notification-api.cjs.map +1 -1
  39. package/dist/NotificationServicesController/types/notification-api/notification-api.d.cts +1 -1
  40. package/dist/NotificationServicesController/types/notification-api/notification-api.d.cts.map +1 -1
  41. package/dist/NotificationServicesController/types/notification-api/notification-api.d.mts +1 -1
  42. package/dist/NotificationServicesController/types/notification-api/notification-api.d.mts.map +1 -1
  43. package/dist/NotificationServicesController/types/notification-api/notification-api.mjs.map +1 -1
  44. package/dist/NotificationServicesPushController/NotificationServicesPushController-method-action-types.cjs.map +1 -1
  45. package/dist/NotificationServicesPushController/NotificationServicesPushController-method-action-types.d.cts +13 -1
  46. package/dist/NotificationServicesPushController/NotificationServicesPushController-method-action-types.d.cts.map +1 -1
  47. package/dist/NotificationServicesPushController/NotificationServicesPushController-method-action-types.d.mts +13 -1
  48. package/dist/NotificationServicesPushController/NotificationServicesPushController-method-action-types.d.mts.map +1 -1
  49. package/dist/NotificationServicesPushController/NotificationServicesPushController-method-action-types.mjs.map +1 -1
  50. package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs +32 -0
  51. package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -1
  52. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts +10 -1
  53. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -1
  54. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts +10 -1
  55. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -1
  56. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +33 -1
  57. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -1
  58. package/dist/NotificationServicesPushController/index.cjs.map +1 -1
  59. package/dist/NotificationServicesPushController/index.d.cts +1 -1
  60. package/dist/NotificationServicesPushController/index.d.cts.map +1 -1
  61. package/dist/NotificationServicesPushController/index.d.mts +1 -1
  62. package/dist/NotificationServicesPushController/index.d.mts.map +1 -1
  63. package/dist/NotificationServicesPushController/index.mjs.map +1 -1
  64. package/dist/NotificationServicesPushController/services/services.cjs.map +1 -1
  65. package/dist/NotificationServicesPushController/services/services.d.cts +1 -1
  66. package/dist/NotificationServicesPushController/services/services.d.cts.map +1 -1
  67. package/dist/NotificationServicesPushController/services/services.d.mts +1 -1
  68. package/dist/NotificationServicesPushController/services/services.d.mts.map +1 -1
  69. package/dist/NotificationServicesPushController/services/services.mjs.map +1 -1
  70. package/dist/NotificationServicesPushController/utils/get-notification-message.cjs.map +1 -1
  71. package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts.map +1 -1
  72. package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts.map +1 -1
  73. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs.map +1 -1
  74. package/package.json +22 -23
@@ -1 +1 @@
1
- {"version":3,"file":"get-notification-message.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,oCAAgC;AAsDlE;;;;;;GAMG;AACH,MA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AE,CAAC,YAAY,EAAiB,EAAE,CAClD,YAAY,CAAC,QAAQ,CAAC,IAAI;YAC5B,cAAc,EAAE,CAAC,YAAY,EAAiB,EAAE,CAC9C,YAAY,CAAC,QAAQ,CAAC,IAAI;SAC7B;KACF,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,oCAAoC,CAClD,YAAiC,EACjC,YAA6B;IAE7B,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,mBAAmB,GACvB,qCAAqC,CAAC,YAAY,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAEzE,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,WAAW,GAAkB,IAAI,CAAC;IACtC,IAAI,CAAC;QACH,WAAW;YACT,8DAA8D;YAC9D,mBAAmB,EAAE,cAAc,EAAE,CAAC,YAAmB,CAAC;gBAC1D,8DAA8D;gBAC9D,mBAAmB,CAAC,kBAAkB,EAAE,CAAC,YAAmB,CAAC;gBAC7D,IAAI,CAAC;IACT,CAAC;IAAC,MAAM,CAAC;QACP,WAAW;YACT,8DAA8D;YAC9D,mBAAmB,CAAC,kBAAkB,EAAE,CAAC,YAAmB,CAAC,IAAI,IAAI,CAAC;IAC1E,CAAC;IAED,OAAO;QACL,8DAA8D;QAC9D,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,CAAC,YAAmB,CAAC,IAAI,EAAE,EAAE,kCAAkC;QAClG,WAAW,EAAE,WAAW,IAAI,EAAE,EAAE,mCAAmC;KACpE,CAAC;AACJ,CAAC","sourcesContent":["import { getAmount, formatAmount } from './get-notification-data';\nimport type { Types } from '../../NotificationServicesController';\nimport type { Constants } from '../../NotificationServicesController';\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 ctaLink?: string;\n};\n\ntype NotificationMessage<TNotification extends Types.INotification> = {\n title: (notification: TNotification) => string | null;\n defaultDescription: (notification: TNotification) => string | null;\n getDescription?: (notification: TNotification) => string | null;\n link?: (notification: TNotification) => string | null;\n};\n\ntype NotificationMessageDict = {\n [TriggerType in Constants.TRIGGER_TYPES]?: NotificationMessage<\n Extract<Types.INotification, { type: TriggerType }>\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 = <TKey extends keyof TranslationKeys>(\n ...args: [TKey, ...Parameters<TranslationKeys[TKey]>]\n ) => string;\n const translate: 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: (): string | null =>\n translate('pushPlatformNotificationsFundsSentTitle'),\n defaultDescription: (): string | null =>\n translate('pushPlatformNotificationsFundsSentDescriptionDefault'),\n getDescription: (notification): string | null => {\n const symbol = notification?.payload?.data?.token?.symbol;\n const tokenAmount = notification?.payload?.data?.token?.amount;\n const tokenDecimals = notification?.payload?.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 translate(\n 'pushPlatformNotificationsFundsSentDescription',\n amount,\n symbol,\n );\n },\n },\n eth_sent: {\n title: (): string | null =>\n translate('pushPlatformNotificationsFundsSentTitle'),\n defaultDescription: (): string | null =>\n translate('pushPlatformNotificationsFundsSentDescriptionDefault'),\n getDescription: (notification): string | null => {\n const symbol = notification?.payload?.network?.native_symbol;\n const tokenAmount = notification?.payload?.data?.amount?.eth;\n if (!symbol || !tokenAmount) {\n return null;\n }\n\n const amount = formatAmount(parseFloat(tokenAmount), {\n shouldEllipse: true,\n });\n return translate(\n 'pushPlatformNotificationsFundsSentDescription',\n amount,\n symbol,\n );\n },\n },\n erc20_received: {\n title: (): string | null =>\n translate('pushPlatformNotificationsFundsReceivedTitle'),\n defaultDescription: (): string | null =>\n translate('pushPlatformNotificationsFundsReceivedDescriptionDefault'),\n getDescription: (notification): string | null => {\n const symbol = notification?.payload?.data?.token?.symbol;\n const tokenAmount = notification?.payload?.data?.token?.amount;\n const tokenDecimals = notification?.payload?.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 translate(\n 'pushPlatformNotificationsFundsReceivedDescription',\n amount,\n symbol,\n );\n },\n },\n eth_received: {\n title: (): string | null =>\n translate('pushPlatformNotificationsFundsReceivedTitle'),\n defaultDescription: (): string | null =>\n translate('pushPlatformNotificationsFundsReceivedDescriptionDefault'),\n getDescription: (notification): string | null => {\n const symbol = notification?.payload?.network?.native_symbol;\n const tokenAmount = notification?.payload?.data?.amount?.eth;\n if (!symbol || !tokenAmount) {\n return null;\n }\n\n const amount = formatAmount(parseFloat(tokenAmount), {\n shouldEllipse: true,\n });\n return translate(\n 'pushPlatformNotificationsFundsReceivedDescription',\n amount,\n symbol,\n );\n },\n },\n metamask_swap_completed: {\n title: (): string | null =>\n translate('pushPlatformNotificationsSwapCompletedTitle'),\n defaultDescription: (): string | null =>\n translate('pushPlatformNotificationsSwapCompletedDescription'),\n },\n erc721_sent: {\n title: (): string | null =>\n translate('pushPlatformNotificationsNftSentTitle'),\n defaultDescription: (): string | null =>\n translate('pushPlatformNotificationsNftSentDescription'),\n },\n erc1155_sent: {\n title: (): string | null =>\n translate('pushPlatformNotificationsNftSentTitle'),\n defaultDescription: (): string | null =>\n translate('pushPlatformNotificationsNftSentDescription'),\n },\n erc721_received: {\n title: (): string | null =>\n translate('pushPlatformNotificationsNftReceivedTitle'),\n defaultDescription: (): string | null =>\n translate('pushPlatformNotificationsNftReceivedDescription'),\n },\n erc1155_received: {\n title: (): string | null =>\n translate('pushPlatformNotificationsNftReceivedTitle'),\n defaultDescription: (): string | null =>\n translate('pushPlatformNotificationsNftReceivedDescription'),\n },\n rocketpool_stake_completed: {\n title: (): string | null =>\n translate(\n 'pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle',\n ),\n defaultDescription: (): string | null =>\n translate(\n 'pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription',\n ),\n },\n rocketpool_unstake_completed: {\n title: (): string | null =>\n translate(\n 'pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle',\n ),\n defaultDescription: (): string | null =>\n translate(\n 'pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription',\n ),\n },\n lido_stake_completed: {\n title: (): string | null =>\n translate('pushPlatformNotificationsStakingLidoStakeCompletedTitle'),\n defaultDescription: (): string | null =>\n translate(\n 'pushPlatformNotificationsStakingLidoStakeCompletedDescription',\n ),\n },\n lido_stake_ready_to_be_withdrawn: {\n title: (): string | null =>\n translate(\n 'pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle',\n ),\n defaultDescription: (): string | null =>\n translate(\n 'pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription',\n ),\n },\n lido_withdrawal_requested: {\n title: (): string | null =>\n translate(\n 'pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle',\n ),\n defaultDescription: (): string | null =>\n translate(\n 'pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription',\n ),\n },\n lido_withdrawal_completed: {\n title: (): string | null =>\n translate(\n 'pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle',\n ),\n defaultDescription: (): string | null =>\n translate(\n 'pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription',\n ),\n },\n platform: {\n title: (notification): string | null => notification.template.title,\n defaultDescription: (notification): string | null =>\n notification.template.body,\n getDescription: (notification): string | null =>\n notification.template.body,\n },\n };\n};\n\n/**\n * Creates a push notification message based on the given on-chain raw notification.\n *\n * @param notification - 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 notification: Types.INotification,\n translations: TranslationKeys,\n): PushNotificationMessage | null {\n if (!notification?.type) {\n return null;\n }\n const notificationMessage =\n createOnChainPushNotificationMessages(translations)[notification.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?.(notification as any) ??\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n notificationMessage.defaultDescription?.(notification as any) ??\n null;\n } catch {\n description =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n notificationMessage.defaultDescription?.(notification as any) ?? null;\n }\n\n return {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n title: notificationMessage?.title?.(notification as any) ?? '', // Ensure title is always a string\n description: description ?? '', // Fallback to empty string if null\n };\n}\n"]}
1
+ {"version":3,"file":"get-notification-message.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-message.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,oCAAgC;AAoDlE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,CACnD,eAAgC,EACP,EAAE;IAI3B,MAAM,SAAS,GAAkB,CAAC,GAAG,IAAI,EAAE,EAAE;QAC3C,MAAM,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC;QAEjC,4CAA4C;QAC5C,8DAA8D;QAC9D,MAAM,EAAE,GAAQ,eAAe,CAAC,GAAG,CAAC,CAAC;QACrC,OAAO,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC;IAC1B,CAAC,CAAC;IAEF,OAAO;QACL,UAAU,EAAE;YACV,KAAK,EAAE,GAAkB,EAAE,CACzB,SAAS,CAAC,yCAAyC,CAAC;YACtD,kBAAkB,EAAE,GAAkB,EAAE,CACtC,SAAS,CAAC,sDAAsD,CAAC;YACnE,cAAc,EAAE,CAAC,YAAY,EAAiB,EAAE;gBAC9C,MAAM,MAAM,GAAG,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC;gBAC1D,MAAM,WAAW,GAAG,YAAY,EAAE,OA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AmB,CAAC,kBAAkB,EAAE,CAAC,YAAmB,CAAC;gBAC7D,IAAI,CAAC;IACT,CAAC;IAAC,MAAM,CAAC;QACP,WAAW;YACT,8DAA8D;YAC9D,mBAAmB,CAAC,kBAAkB,EAAE,CAAC,YAAmB,CAAC,IAAI,IAAI,CAAC;IAC1E,CAAC;IAED,OAAO;QACL,8DAA8D;QAC9D,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,CAAC,YAAmB,CAAC,IAAI,EAAE,EAAE,kCAAkC;QAClG,WAAW,EAAE,WAAW,IAAI,EAAE,EAAE,mCAAmC;KACpE,CAAC;AACJ,CAAC","sourcesContent":["import type { Types } from '../../NotificationServicesController';\nimport type { 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 ctaLink?: string;\n};\n\ntype NotificationMessage<TNotification extends Types.INotification> = {\n title: (notification: TNotification) => string | null;\n defaultDescription: (notification: TNotification) => string | null;\n getDescription?: (notification: TNotification) => string | null;\n link?: (notification: TNotification) => string | null;\n};\n\ntype NotificationMessageDict = {\n [TriggerType in Constants.TRIGGER_TYPES]?: NotificationMessage<\n Extract<Types.INotification, { type: TriggerType }>\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 = <TKey extends keyof TranslationKeys>(\n ...args: [TKey, ...Parameters<TranslationKeys[TKey]>]\n ) => string;\n const translate: 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: (): string | null =>\n translate('pushPlatformNotificationsFundsSentTitle'),\n defaultDescription: (): string | null =>\n translate('pushPlatformNotificationsFundsSentDescriptionDefault'),\n getDescription: (notification): string | null => {\n const symbol = notification?.payload?.data?.token?.symbol;\n const tokenAmount = notification?.payload?.data?.token?.amount;\n const tokenDecimals = notification?.payload?.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 translate(\n 'pushPlatformNotificationsFundsSentDescription',\n amount,\n symbol,\n );\n },\n },\n eth_sent: {\n title: (): string | null =>\n translate('pushPlatformNotificationsFundsSentTitle'),\n defaultDescription: (): string | null =>\n translate('pushPlatformNotificationsFundsSentDescriptionDefault'),\n getDescription: (notification): string | null => {\n const symbol = notification?.payload?.network?.native_symbol;\n const tokenAmount = notification?.payload?.data?.amount?.eth;\n if (!symbol || !tokenAmount) {\n return null;\n }\n\n const amount = formatAmount(parseFloat(tokenAmount), {\n shouldEllipse: true,\n });\n return translate(\n 'pushPlatformNotificationsFundsSentDescription',\n amount,\n symbol,\n );\n },\n },\n erc20_received: {\n title: (): string | null =>\n translate('pushPlatformNotificationsFundsReceivedTitle'),\n defaultDescription: (): string | null =>\n translate('pushPlatformNotificationsFundsReceivedDescriptionDefault'),\n getDescription: (notification): string | null => {\n const symbol = notification?.payload?.data?.token?.symbol;\n const tokenAmount = notification?.payload?.data?.token?.amount;\n const tokenDecimals = notification?.payload?.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 translate(\n 'pushPlatformNotificationsFundsReceivedDescription',\n amount,\n symbol,\n );\n },\n },\n eth_received: {\n title: (): string | null =>\n translate('pushPlatformNotificationsFundsReceivedTitle'),\n defaultDescription: (): string | null =>\n translate('pushPlatformNotificationsFundsReceivedDescriptionDefault'),\n getDescription: (notification): string | null => {\n const symbol = notification?.payload?.network?.native_symbol;\n const tokenAmount = notification?.payload?.data?.amount?.eth;\n if (!symbol || !tokenAmount) {\n return null;\n }\n\n const amount = formatAmount(parseFloat(tokenAmount), {\n shouldEllipse: true,\n });\n return translate(\n 'pushPlatformNotificationsFundsReceivedDescription',\n amount,\n symbol,\n );\n },\n },\n metamask_swap_completed: {\n title: (): string | null =>\n translate('pushPlatformNotificationsSwapCompletedTitle'),\n defaultDescription: (): string | null =>\n translate('pushPlatformNotificationsSwapCompletedDescription'),\n },\n erc721_sent: {\n title: (): string | null =>\n translate('pushPlatformNotificationsNftSentTitle'),\n defaultDescription: (): string | null =>\n translate('pushPlatformNotificationsNftSentDescription'),\n },\n erc1155_sent: {\n title: (): string | null =>\n translate('pushPlatformNotificationsNftSentTitle'),\n defaultDescription: (): string | null =>\n translate('pushPlatformNotificationsNftSentDescription'),\n },\n erc721_received: {\n title: (): string | null =>\n translate('pushPlatformNotificationsNftReceivedTitle'),\n defaultDescription: (): string | null =>\n translate('pushPlatformNotificationsNftReceivedDescription'),\n },\n erc1155_received: {\n title: (): string | null =>\n translate('pushPlatformNotificationsNftReceivedTitle'),\n defaultDescription: (): string | null =>\n translate('pushPlatformNotificationsNftReceivedDescription'),\n },\n rocketpool_stake_completed: {\n title: (): string | null =>\n translate(\n 'pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle',\n ),\n defaultDescription: (): string | null =>\n translate(\n 'pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription',\n ),\n },\n rocketpool_unstake_completed: {\n title: (): string | null =>\n translate(\n 'pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle',\n ),\n defaultDescription: (): string | null =>\n translate(\n 'pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription',\n ),\n },\n lido_stake_completed: {\n title: (): string | null =>\n translate('pushPlatformNotificationsStakingLidoStakeCompletedTitle'),\n defaultDescription: (): string | null =>\n translate(\n 'pushPlatformNotificationsStakingLidoStakeCompletedDescription',\n ),\n },\n lido_stake_ready_to_be_withdrawn: {\n title: (): string | null =>\n translate(\n 'pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle',\n ),\n defaultDescription: (): string | null =>\n translate(\n 'pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription',\n ),\n },\n lido_withdrawal_requested: {\n title: (): string | null =>\n translate(\n 'pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle',\n ),\n defaultDescription: (): string | null =>\n translate(\n 'pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription',\n ),\n },\n lido_withdrawal_completed: {\n title: (): string | null =>\n translate(\n 'pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle',\n ),\n defaultDescription: (): string | null =>\n translate(\n 'pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription',\n ),\n },\n platform: {\n title: (notification): string | null => notification.template.title,\n defaultDescription: (notification): string | null =>\n notification.template.body,\n getDescription: (notification): string | null =>\n notification.template.body,\n },\n };\n};\n\n/**\n * Creates a push notification message based on the given on-chain raw notification.\n *\n * @param notification - 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 notification: Types.INotification,\n translations: TranslationKeys,\n): PushNotificationMessage | null {\n if (!notification?.type) {\n return null;\n }\n const notificationMessage =\n createOnChainPushNotificationMessages(translations)[notification.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?.(notification as any) ??\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n notificationMessage.defaultDescription?.(notification as any) ??\n null;\n } catch {\n description =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n notificationMessage.defaultDescription?.(notification as any) ?? null;\n }\n\n return {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n title: notificationMessage?.title?.(notification as any) ?? '', // Ensure title is always a string\n description: description ?? '', // Fallback to empty string if null\n };\n}\n"]}
package/package.json CHANGED
@@ -1,21 +1,28 @@
1
1
  {
2
2
  "name": "@metamask/notification-services-controller",
3
- "version": "23.0.1",
3
+ "version": "23.1.0",
4
4
  "description": "Manages New MetaMask decentralized Notification system",
5
5
  "keywords": [
6
- "MetaMask",
7
- "Ethereum"
6
+ "Ethereum",
7
+ "MetaMask"
8
8
  ],
9
9
  "homepage": "https://github.com/MetaMask/core/tree/main/packages/notification-services-controller#readme",
10
10
  "bugs": {
11
11
  "url": "https://github.com/MetaMask/core/issues"
12
12
  },
13
+ "license": "MIT",
13
14
  "repository": {
14
15
  "type": "git",
15
16
  "url": "https://github.com/MetaMask/core.git"
16
17
  },
17
- "license": "MIT",
18
+ "files": [
19
+ "dist/",
20
+ "notification-services/",
21
+ "push-services/"
22
+ ],
18
23
  "sideEffects": false,
24
+ "main": "./dist/index.cjs",
25
+ "types": "./dist/index.d.cts",
19
26
  "exports": {
20
27
  ".": {
21
28
  "import": {
@@ -79,22 +86,18 @@
79
86
  },
80
87
  "./package.json": "./package.json"
81
88
  },
82
- "main": "./dist/index.cjs",
83
- "types": "./dist/index.d.cts",
84
- "files": [
85
- "dist/",
86
- "notification-services/",
87
- "push-services/"
88
- ],
89
+ "publishConfig": {
90
+ "access": "public",
91
+ "registry": "https://registry.npmjs.org/"
92
+ },
89
93
  "scripts": {
90
94
  "build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
91
95
  "build:all": "ts-bridge --project tsconfig.build.json --verbose --clean",
92
96
  "build:docs": "typedoc",
93
97
  "changelog:update": "../../scripts/update-changelog.sh @metamask/notification-services-controller",
94
98
  "changelog:validate": "../../scripts/validate-changelog.sh @metamask/notification-services-controller",
95
- "generate-method-action-types": "yarn generate-method-action-types:notifications-services-controller \"$@\" && yarn generate-method-action-types:notifications-services-push-controller \"$@\"",
96
- "generate-method-action-types:notifications-services-controller": "tsx ../../scripts/generate-method-action-types.ts src/NotificationServicesController",
97
- "generate-method-action-types:notifications-services-push-controller": "tsx ../../scripts/generate-method-action-types.ts src/NotificationServicesPushController",
99
+ "messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --check",
100
+ "messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --generate",
98
101
  "since-latest-release": "../../scripts/since-latest-release.sh",
99
102
  "test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
100
103
  "test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
@@ -104,10 +107,10 @@
104
107
  "dependencies": {
105
108
  "@contentful/rich-text-html-renderer": "^16.5.2",
106
109
  "@metamask/base-controller": "^9.0.1",
107
- "@metamask/controller-utils": "^11.19.0",
108
- "@metamask/keyring-controller": "^25.1.1",
109
- "@metamask/messenger": "^1.0.0",
110
- "@metamask/profile-sync-controller": "^28.0.1",
110
+ "@metamask/controller-utils": "^11.20.0",
111
+ "@metamask/keyring-controller": "^25.2.0",
112
+ "@metamask/messenger": "^1.1.1",
113
+ "@metamask/profile-sync-controller": "^28.0.2",
111
114
  "@metamask/utils": "^11.9.0",
112
115
  "bignumber.js": "^9.1.2",
113
116
  "firebase": "^11.2.0",
@@ -119,7 +122,7 @@
119
122
  "devDependencies": {
120
123
  "@lavamoat/allow-scripts": "^3.0.4",
121
124
  "@lavamoat/preinstall-always-fail": "^2.1.0",
122
- "@metamask/auto-changelog": "^3.4.4",
125
+ "@metamask/auto-changelog": "^6.0.0",
123
126
  "@ts-bridge/cli": "^0.6.4",
124
127
  "@types/jest": "^29.5.14",
125
128
  "@types/lodash": "^4.14.191",
@@ -138,9 +141,5 @@
138
141
  },
139
142
  "engines": {
140
143
  "node": "^18.18 || >=20"
141
- },
142
- "publishConfig": {
143
- "access": "public",
144
- "registry": "https://registry.npmjs.org/"
145
144
  }
146
145
  }