@metamask-previews/notification-services-controller 19.0.0-preview-7b698bb → 19.0.0-preview-ba016213

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 (187) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/NotificationServicesController/NotificationServicesController.cjs +17 -38
  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 +17 -15
  9. package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
  10. package/dist/NotificationServicesController/constants/notification-schema.cjs +4 -14
  11. package/dist/NotificationServicesController/constants/notification-schema.cjs.map +1 -1
  12. package/dist/NotificationServicesController/constants/notification-schema.d.cts +3 -13
  13. package/dist/NotificationServicesController/constants/notification-schema.d.cts.map +1 -1
  14. package/dist/NotificationServicesController/constants/notification-schema.d.mts +3 -13
  15. package/dist/NotificationServicesController/constants/notification-schema.d.mts.map +1 -1
  16. package/dist/NotificationServicesController/constants/notification-schema.mjs +3 -13
  17. package/dist/NotificationServicesController/constants/notification-schema.mjs.map +1 -1
  18. package/dist/NotificationServicesController/mocks/mock-raw-notifications.cjs +428 -530
  19. package/dist/NotificationServicesController/mocks/mock-raw-notifications.cjs.map +1 -1
  20. package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.cts +20 -50
  21. package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.cts.map +1 -1
  22. package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.mts +20 -50
  23. package/dist/NotificationServicesController/mocks/mock-raw-notifications.d.mts.map +1 -1
  24. package/dist/NotificationServicesController/mocks/mock-raw-notifications.mjs +425 -522
  25. package/dist/NotificationServicesController/mocks/mock-raw-notifications.mjs.map +1 -1
  26. package/dist/NotificationServicesController/mocks/mockResponses.cjs +5 -5
  27. package/dist/NotificationServicesController/mocks/mockResponses.cjs.map +1 -1
  28. package/dist/NotificationServicesController/mocks/mockResponses.d.cts +2 -2
  29. package/dist/NotificationServicesController/mocks/mockResponses.d.cts.map +1 -1
  30. package/dist/NotificationServicesController/mocks/mockResponses.d.mts +2 -2
  31. package/dist/NotificationServicesController/mocks/mockResponses.d.mts.map +1 -1
  32. package/dist/NotificationServicesController/mocks/mockResponses.mjs +1 -1
  33. package/dist/NotificationServicesController/mocks/mockResponses.mjs.map +1 -1
  34. package/dist/NotificationServicesController/processors/index.cjs +1 -1
  35. package/dist/NotificationServicesController/processors/index.cjs.map +1 -1
  36. package/dist/NotificationServicesController/processors/index.d.cts +1 -1
  37. package/dist/NotificationServicesController/processors/index.d.cts.map +1 -1
  38. package/dist/NotificationServicesController/processors/index.d.mts +1 -1
  39. package/dist/NotificationServicesController/processors/index.d.mts.map +1 -1
  40. package/dist/NotificationServicesController/processors/index.mjs +1 -1
  41. package/dist/NotificationServicesController/processors/index.mjs.map +1 -1
  42. package/dist/NotificationServicesController/processors/process-api-notifications.cjs +22 -0
  43. package/dist/NotificationServicesController/processors/process-api-notifications.cjs.map +1 -0
  44. package/dist/NotificationServicesController/processors/process-api-notifications.d.cts +10 -0
  45. package/dist/NotificationServicesController/processors/process-api-notifications.d.cts.map +1 -0
  46. package/dist/NotificationServicesController/processors/process-api-notifications.d.mts +10 -0
  47. package/dist/NotificationServicesController/processors/process-api-notifications.d.mts.map +1 -0
  48. package/dist/NotificationServicesController/processors/process-api-notifications.mjs +18 -0
  49. package/dist/NotificationServicesController/processors/process-api-notifications.mjs.map +1 -0
  50. package/dist/NotificationServicesController/processors/process-feature-announcement.cjs +2 -7
  51. package/dist/NotificationServicesController/processors/process-feature-announcement.cjs.map +1 -1
  52. package/dist/NotificationServicesController/processors/process-feature-announcement.d.cts.map +1 -1
  53. package/dist/NotificationServicesController/processors/process-feature-announcement.d.mts.map +1 -1
  54. package/dist/NotificationServicesController/processors/process-feature-announcement.mjs +1 -6
  55. package/dist/NotificationServicesController/processors/process-feature-announcement.mjs.map +1 -1
  56. package/dist/NotificationServicesController/processors/process-notifications.cjs +3 -3
  57. package/dist/NotificationServicesController/processors/process-notifications.cjs.map +1 -1
  58. package/dist/NotificationServicesController/processors/process-notifications.d.cts +398 -458
  59. package/dist/NotificationServicesController/processors/process-notifications.d.cts.map +1 -1
  60. package/dist/NotificationServicesController/processors/process-notifications.d.mts +398 -458
  61. package/dist/NotificationServicesController/processors/process-notifications.d.mts.map +1 -1
  62. package/dist/NotificationServicesController/processors/process-notifications.mjs +4 -4
  63. package/dist/NotificationServicesController/processors/process-notifications.mjs.map +1 -1
  64. package/dist/NotificationServicesController/services/{onchain-notifications.cjs → api-notifications.cjs} +28 -15
  65. package/dist/NotificationServicesController/services/api-notifications.cjs.map +1 -0
  66. package/dist/NotificationServicesController/services/{onchain-notifications.d.cts → api-notifications.d.cts} +9 -7
  67. package/dist/NotificationServicesController/services/api-notifications.d.cts.map +1 -0
  68. package/dist/NotificationServicesController/services/{onchain-notifications.d.mts → api-notifications.d.mts} +9 -7
  69. package/dist/NotificationServicesController/services/api-notifications.d.mts.map +1 -0
  70. package/dist/NotificationServicesController/services/{onchain-notifications.mjs → api-notifications.mjs} +26 -13
  71. package/dist/NotificationServicesController/services/api-notifications.mjs.map +1 -0
  72. package/dist/NotificationServicesController/services/perp-notifications.cjs +0 -1
  73. package/dist/NotificationServicesController/services/perp-notifications.cjs.map +1 -1
  74. package/dist/NotificationServicesController/services/perp-notifications.d.cts.map +1 -1
  75. package/dist/NotificationServicesController/services/perp-notifications.d.mts.map +1 -1
  76. package/dist/NotificationServicesController/services/perp-notifications.mjs +0 -1
  77. package/dist/NotificationServicesController/services/perp-notifications.mjs.map +1 -1
  78. package/dist/NotificationServicesController/types/index.cjs.map +1 -1
  79. package/dist/NotificationServicesController/types/index.d.cts +1 -1
  80. package/dist/NotificationServicesController/types/index.d.cts.map +1 -1
  81. package/dist/NotificationServicesController/types/index.d.mts +1 -1
  82. package/dist/NotificationServicesController/types/index.d.mts.map +1 -1
  83. package/dist/NotificationServicesController/types/index.mjs.map +1 -1
  84. package/dist/NotificationServicesController/types/notification/notification.cjs.map +1 -1
  85. package/dist/NotificationServicesController/types/notification/notification.d.cts +3 -11
  86. package/dist/NotificationServicesController/types/notification/notification.d.cts.map +1 -1
  87. package/dist/NotificationServicesController/types/notification/notification.d.mts +3 -11
  88. package/dist/NotificationServicesController/types/notification/notification.d.mts.map +1 -1
  89. package/dist/NotificationServicesController/types/notification/notification.mjs.map +1 -1
  90. package/dist/NotificationServicesController/types/notification-api/index.cjs.map +1 -0
  91. package/dist/NotificationServicesController/types/notification-api/index.d.cts +3 -0
  92. package/dist/NotificationServicesController/types/notification-api/index.d.cts.map +1 -0
  93. package/dist/NotificationServicesController/types/notification-api/index.d.mts +3 -0
  94. package/dist/NotificationServicesController/types/notification-api/index.d.mts.map +1 -0
  95. package/dist/NotificationServicesController/types/notification-api/index.mjs.map +1 -0
  96. package/dist/NotificationServicesController/types/{on-chain-notification/on-chain-notification.cjs → notification-api/notification-api.cjs} +1 -1
  97. package/dist/NotificationServicesController/types/notification-api/notification-api.cjs.map +1 -0
  98. package/dist/NotificationServicesController/types/notification-api/notification-api.d.cts +64 -0
  99. package/dist/NotificationServicesController/types/notification-api/notification-api.d.cts.map +1 -0
  100. package/dist/NotificationServicesController/types/notification-api/notification-api.d.mts +64 -0
  101. package/dist/NotificationServicesController/types/notification-api/notification-api.d.mts.map +1 -0
  102. package/dist/NotificationServicesController/types/notification-api/notification-api.mjs +2 -0
  103. package/dist/NotificationServicesController/types/notification-api/notification-api.mjs.map +1 -0
  104. package/dist/NotificationServicesController/types/notification-api/schema.cjs.map +1 -0
  105. package/dist/NotificationServicesController/types/notification-api/schema.d.cts +365 -0
  106. package/dist/NotificationServicesController/types/notification-api/schema.d.cts.map +1 -0
  107. package/dist/NotificationServicesController/types/notification-api/schema.d.mts +365 -0
  108. package/dist/NotificationServicesController/types/notification-api/schema.d.mts.map +1 -0
  109. package/dist/NotificationServicesController/types/notification-api/schema.mjs.map +1 -0
  110. package/dist/NotificationServicesController/utils/should-auto-expire.cjs +12 -0
  111. package/dist/NotificationServicesController/utils/should-auto-expire.cjs.map +1 -0
  112. package/dist/NotificationServicesController/utils/should-auto-expire.d.cts +2 -0
  113. package/dist/NotificationServicesController/utils/should-auto-expire.d.cts.map +1 -0
  114. package/dist/NotificationServicesController/utils/should-auto-expire.d.mts +2 -0
  115. package/dist/NotificationServicesController/utils/should-auto-expire.d.mts.map +1 -0
  116. package/dist/NotificationServicesController/utils/should-auto-expire.mjs +8 -0
  117. package/dist/NotificationServicesController/utils/should-auto-expire.mjs.map +1 -0
  118. package/dist/NotificationServicesPushController/services/push/push-web.cjs +5 -2
  119. package/dist/NotificationServicesPushController/services/push/push-web.cjs.map +1 -1
  120. package/dist/NotificationServicesPushController/services/push/push-web.d.cts.map +1 -1
  121. package/dist/NotificationServicesPushController/services/push/push-web.d.mts.map +1 -1
  122. package/dist/NotificationServicesPushController/services/push/push-web.mjs +6 -3
  123. package/dist/NotificationServicesPushController/services/push/push-web.mjs.map +1 -1
  124. package/dist/NotificationServicesPushController/utils/get-notification-message.cjs +51 -43
  125. package/dist/NotificationServicesPushController/utils/get-notification-message.cjs.map +1 -1
  126. package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts +4 -2
  127. package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts.map +1 -1
  128. package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts +4 -2
  129. package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts.map +1 -1
  130. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs +51 -43
  131. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs.map +1 -1
  132. package/dist/NotificationServicesPushController/web/push-utils.cjs +5 -2
  133. package/dist/NotificationServicesPushController/web/push-utils.cjs.map +1 -1
  134. package/dist/NotificationServicesPushController/web/push-utils.d.cts.map +1 -1
  135. package/dist/NotificationServicesPushController/web/push-utils.d.mts.map +1 -1
  136. package/dist/NotificationServicesPushController/web/push-utils.mjs +6 -3
  137. package/dist/NotificationServicesPushController/web/push-utils.mjs.map +1 -1
  138. package/dist/shared/is-onchain-notification.cjs +1 -2
  139. package/dist/shared/is-onchain-notification.cjs.map +1 -1
  140. package/dist/shared/is-onchain-notification.d.cts.map +1 -1
  141. package/dist/shared/is-onchain-notification.d.mts.map +1 -1
  142. package/dist/shared/is-onchain-notification.mjs +1 -2
  143. package/dist/shared/is-onchain-notification.mjs.map +1 -1
  144. package/dist/shared/to-raw-notification.cjs +19 -6
  145. package/dist/shared/to-raw-notification.cjs.map +1 -1
  146. package/dist/shared/to-raw-notification.d.cts +2 -2
  147. package/dist/shared/to-raw-notification.d.cts.map +1 -1
  148. package/dist/shared/to-raw-notification.d.mts +2 -2
  149. package/dist/shared/to-raw-notification.d.mts.map +1 -1
  150. package/dist/shared/to-raw-notification.mjs +17 -4
  151. package/dist/shared/to-raw-notification.mjs.map +1 -1
  152. package/package.json +1 -1
  153. package/dist/NotificationServicesController/processors/process-onchain-notifications.cjs +0 -19
  154. package/dist/NotificationServicesController/processors/process-onchain-notifications.cjs.map +0 -1
  155. package/dist/NotificationServicesController/processors/process-onchain-notifications.d.cts +0 -10
  156. package/dist/NotificationServicesController/processors/process-onchain-notifications.d.cts.map +0 -1
  157. package/dist/NotificationServicesController/processors/process-onchain-notifications.d.mts +0 -10
  158. package/dist/NotificationServicesController/processors/process-onchain-notifications.d.mts.map +0 -1
  159. package/dist/NotificationServicesController/processors/process-onchain-notifications.mjs +0 -15
  160. package/dist/NotificationServicesController/processors/process-onchain-notifications.mjs.map +0 -1
  161. package/dist/NotificationServicesController/services/onchain-notifications.cjs.map +0 -1
  162. package/dist/NotificationServicesController/services/onchain-notifications.d.cts.map +0 -1
  163. package/dist/NotificationServicesController/services/onchain-notifications.d.mts.map +0 -1
  164. package/dist/NotificationServicesController/services/onchain-notifications.mjs.map +0 -1
  165. package/dist/NotificationServicesController/types/on-chain-notification/index.cjs.map +0 -1
  166. package/dist/NotificationServicesController/types/on-chain-notification/index.d.cts +0 -2
  167. package/dist/NotificationServicesController/types/on-chain-notification/index.d.cts.map +0 -1
  168. package/dist/NotificationServicesController/types/on-chain-notification/index.d.mts +0 -2
  169. package/dist/NotificationServicesController/types/on-chain-notification/index.d.mts.map +0 -1
  170. package/dist/NotificationServicesController/types/on-chain-notification/index.mjs.map +0 -1
  171. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.cjs.map +0 -1
  172. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.cts +0 -49
  173. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.cts.map +0 -1
  174. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.mts +0 -49
  175. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.mts.map +0 -1
  176. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.mjs +0 -2
  177. package/dist/NotificationServicesController/types/on-chain-notification/on-chain-notification.mjs.map +0 -1
  178. package/dist/NotificationServicesController/types/on-chain-notification/schema.cjs.map +0 -1
  179. package/dist/NotificationServicesController/types/on-chain-notification/schema.d.cts +0 -681
  180. package/dist/NotificationServicesController/types/on-chain-notification/schema.d.cts.map +0 -1
  181. package/dist/NotificationServicesController/types/on-chain-notification/schema.d.mts +0 -681
  182. package/dist/NotificationServicesController/types/on-chain-notification/schema.d.mts.map +0 -1
  183. package/dist/NotificationServicesController/types/on-chain-notification/schema.mjs.map +0 -1
  184. /package/dist/NotificationServicesController/types/{on-chain-notification → notification-api}/index.cjs +0 -0
  185. /package/dist/NotificationServicesController/types/{on-chain-notification → notification-api}/index.mjs +0 -0
  186. /package/dist/NotificationServicesController/types/{on-chain-notification → notification-api}/schema.cjs +0 -0
  187. /package/dist/NotificationServicesController/types/{on-chain-notification → notification-api}/schema.mjs +0 -0
@@ -20,12 +20,12 @@ const createOnChainPushNotificationMessages = (translationKeys) => {
20
20
  };
21
21
  return {
22
22
  erc20_sent: {
23
- title: t('pushPlatformNotificationsFundsSentTitle'),
24
- defaultDescription: t('pushPlatformNotificationsFundsSentDescriptionDefault'),
23
+ title: () => t('pushPlatformNotificationsFundsSentTitle'),
24
+ defaultDescription: () => t('pushPlatformNotificationsFundsSentDescriptionDefault'),
25
25
  getDescription: (n) => {
26
- const symbol = n?.data?.token?.symbol;
27
- const tokenAmount = n?.data?.token?.amount;
28
- const tokenDecimals = n?.data?.token?.decimals;
26
+ const symbol = n?.payload?.data?.token?.symbol;
27
+ const tokenAmount = n?.payload?.data?.token?.amount;
28
+ const tokenDecimals = n?.payload?.data?.token?.decimals;
29
29
  if (!symbol || !tokenAmount || !tokenDecimals) {
30
30
  return null;
31
31
  }
@@ -36,11 +36,11 @@ const createOnChainPushNotificationMessages = (translationKeys) => {
36
36
  },
37
37
  },
38
38
  eth_sent: {
39
- title: t('pushPlatformNotificationsFundsSentTitle'),
40
- defaultDescription: t('pushPlatformNotificationsFundsSentDescriptionDefault'),
39
+ title: () => t('pushPlatformNotificationsFundsSentTitle'),
40
+ defaultDescription: () => t('pushPlatformNotificationsFundsSentDescriptionDefault'),
41
41
  getDescription: (n) => {
42
- const symbol = getChainSymbol(n?.chain_id);
43
- const tokenAmount = n?.data?.amount?.eth;
42
+ const symbol = getChainSymbol(n?.payload?.chain_id);
43
+ const tokenAmount = n?.payload?.data?.amount?.eth;
44
44
  if (!symbol || !tokenAmount) {
45
45
  return null;
46
46
  }
@@ -51,12 +51,12 @@ const createOnChainPushNotificationMessages = (translationKeys) => {
51
51
  },
52
52
  },
53
53
  erc20_received: {
54
- title: t('pushPlatformNotificationsFundsReceivedTitle'),
55
- defaultDescription: t('pushPlatformNotificationsFundsReceivedDescriptionDefault'),
54
+ title: () => t('pushPlatformNotificationsFundsReceivedTitle'),
55
+ defaultDescription: () => t('pushPlatformNotificationsFundsReceivedDescriptionDefault'),
56
56
  getDescription: (n) => {
57
- const symbol = n?.data?.token?.symbol;
58
- const tokenAmount = n?.data?.token?.amount;
59
- const tokenDecimals = n?.data?.token?.decimals;
57
+ const symbol = n?.payload?.data?.token?.symbol;
58
+ const tokenAmount = n?.payload?.data?.token?.amount;
59
+ const tokenDecimals = n?.payload?.data?.token?.decimals;
60
60
  if (!symbol || !tokenAmount || !tokenDecimals) {
61
61
  return null;
62
62
  }
@@ -67,11 +67,11 @@ const createOnChainPushNotificationMessages = (translationKeys) => {
67
67
  },
68
68
  },
69
69
  eth_received: {
70
- title: t('pushPlatformNotificationsFundsReceivedTitle'),
71
- defaultDescription: t('pushPlatformNotificationsFundsReceivedDescriptionDefault'),
70
+ title: () => t('pushPlatformNotificationsFundsReceivedTitle'),
71
+ defaultDescription: () => t('pushPlatformNotificationsFundsReceivedDescriptionDefault'),
72
72
  getDescription: (n) => {
73
- const symbol = getChainSymbol(n?.chain_id);
74
- const tokenAmount = n?.data?.amount?.eth;
73
+ const symbol = getChainSymbol(n?.payload?.chain_id);
74
+ const tokenAmount = n?.payload?.data?.amount?.eth;
75
75
  if (!symbol || !tokenAmount) {
76
76
  return null;
77
77
  }
@@ -82,48 +82,53 @@ const createOnChainPushNotificationMessages = (translationKeys) => {
82
82
  },
83
83
  },
84
84
  metamask_swap_completed: {
85
- title: t('pushPlatformNotificationsSwapCompletedTitle'),
86
- defaultDescription: t('pushPlatformNotificationsSwapCompletedDescription'),
85
+ title: () => t('pushPlatformNotificationsSwapCompletedTitle'),
86
+ defaultDescription: () => t('pushPlatformNotificationsSwapCompletedDescription'),
87
87
  },
88
88
  erc721_sent: {
89
- title: t('pushPlatformNotificationsNftSentTitle'),
90
- defaultDescription: t('pushPlatformNotificationsNftSentDescription'),
89
+ title: () => t('pushPlatformNotificationsNftSentTitle'),
90
+ defaultDescription: () => t('pushPlatformNotificationsNftSentDescription'),
91
91
  },
92
92
  erc1155_sent: {
93
- title: t('pushPlatformNotificationsNftSentTitle'),
94
- defaultDescription: t('pushPlatformNotificationsNftSentDescription'),
93
+ title: () => t('pushPlatformNotificationsNftSentTitle'),
94
+ defaultDescription: () => t('pushPlatformNotificationsNftSentDescription'),
95
95
  },
96
96
  erc721_received: {
97
- title: t('pushPlatformNotificationsNftReceivedTitle'),
98
- defaultDescription: t('pushPlatformNotificationsNftReceivedDescription'),
97
+ title: () => t('pushPlatformNotificationsNftReceivedTitle'),
98
+ defaultDescription: () => t('pushPlatformNotificationsNftReceivedDescription'),
99
99
  },
100
100
  erc1155_received: {
101
- title: t('pushPlatformNotificationsNftReceivedTitle'),
102
- defaultDescription: t('pushPlatformNotificationsNftReceivedDescription'),
101
+ title: () => t('pushPlatformNotificationsNftReceivedTitle'),
102
+ defaultDescription: () => t('pushPlatformNotificationsNftReceivedDescription'),
103
103
  },
104
104
  rocketpool_stake_completed: {
105
- title: t('pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle'),
106
- defaultDescription: t('pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription'),
105
+ title: () => t('pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle'),
106
+ defaultDescription: () => t('pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription'),
107
107
  },
108
108
  rocketpool_unstake_completed: {
109
- title: t('pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle'),
110
- defaultDescription: t('pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription'),
109
+ title: () => t('pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle'),
110
+ defaultDescription: () => t('pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription'),
111
111
  },
112
112
  lido_stake_completed: {
113
- title: t('pushPlatformNotificationsStakingLidoStakeCompletedTitle'),
114
- defaultDescription: t('pushPlatformNotificationsStakingLidoStakeCompletedDescription'),
113
+ title: () => t('pushPlatformNotificationsStakingLidoStakeCompletedTitle'),
114
+ defaultDescription: () => t('pushPlatformNotificationsStakingLidoStakeCompletedDescription'),
115
115
  },
116
116
  lido_stake_ready_to_be_withdrawn: {
117
- title: t('pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle'),
118
- defaultDescription: t('pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription'),
117
+ title: () => t('pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle'),
118
+ defaultDescription: () => t('pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription'),
119
119
  },
120
120
  lido_withdrawal_requested: {
121
- title: t('pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle'),
122
- defaultDescription: t('pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription'),
121
+ title: () => t('pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle'),
122
+ defaultDescription: () => t('pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription'),
123
123
  },
124
124
  lido_withdrawal_completed: {
125
- title: t('pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle'),
126
- defaultDescription: t('pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription'),
125
+ title: () => t('pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle'),
126
+ defaultDescription: () => t('pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription'),
127
+ },
128
+ platform: {
129
+ title: (n) => n.template.title,
130
+ defaultDescription: (n) => n.template.body,
131
+ getDescription: (n) => n.template.body,
127
132
  },
128
133
  };
129
134
  };
@@ -157,14 +162,17 @@ function createOnChainPushNotificationMessage(n, translations) {
157
162
  description =
158
163
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
159
164
  notificationMessage?.getDescription?.(n) ??
160
- notificationMessage.defaultDescription ??
165
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
166
+ notificationMessage.defaultDescription?.(n) ??
161
167
  null;
162
168
  }
163
169
  catch {
164
- description = notificationMessage.defaultDescription ?? null;
170
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
171
+ description = notificationMessage.defaultDescription?.(n) ?? null;
165
172
  }
166
173
  return {
167
- title: notificationMessage.title ?? '', // Ensure title is always a string
174
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
175
+ title: notificationMessage?.title?.(n) ?? '', // Ensure title is always a string
168
176
  description: description ?? '', // Fallback to empty string if null
169
177
  };
170
178
  }
@@ -1 +1 @@
1
- {"version":3,"file":"get-notification-message.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-message.ts"],"names":[],"mappings":";;;AAAA,uEAAkE;AAMlE,0EAA+F;AAkD/F;;;;;;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,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,CAAC,CAAC,yCAAyC,CAAC;YACnD,kBAAkB,EAAE,CAAC,CACnB,sDAAsD,CACvD;YACD,cAAc,EAAE,CAAC,CAAC,EAAE,EAAE;gBACpB,MAAM,MAAM,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC;gBACtC,MAAM,WAAW,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC;gBAC3C,MAAM,aAAa,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC;gBAC/C,IAAI,CAAC,MAAM,IAAI,CAAC,WAAW,IAAI,CAAC,aAAa,EAAE,CAAC;oBAC9C,OAAO,IAAI,CAAC;gBACd,CAAC;gBAED,MAAM,MAAM,GAAG,IAAA,iCAAS,EAAC,WAAW,EAAE,aAAa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;IAE9D,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,CAAQ,CAAC;gBAC/C,mBAAmB,CAAC,kBAAkB;gBACtC,IAAI,CAAC;IACT,CAAC;IAAC,MAAM,CAAC;QACP,WAAW,GAAG,mBAAmB,CAAC,kBAAkB,IAAI,IAAI,CAAC;IAC/D,CAAC;IAED,OAAO;QACL,KAAK,EAAE,mBAAmB,CAAC,KAAK,IAAI,EAAE,EAAE,kCAAkC;QAC1E,WAAW,EAAE,WAAW,IAAI,EAAE,EAAE,mCAAmC;KACpE,CAAC;AACJ,CAAC;AA7BD,oFA6BC","sourcesContent":["import { getAmount, formatAmount } from './get-notification-data';\nimport type {\n NOTIFICATION_CHAINS_IDS,\n Types,\n} from '../../NotificationServicesController';\nimport type { Constants } from '../../NotificationServicesController';\nimport { NOTIFICATION_NETWORK_CURRENCY_SYMBOL } from '../../NotificationServicesController/ui';\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 (\n NOTIFICATION_NETWORK_CURRENCY_SYMBOL[\n chainId.toString() as NOTIFICATION_CHAINS_IDS\n ] ?? null\n );\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 {\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
+ {"version":3,"file":"get-notification-message.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-message.ts"],"names":[],"mappings":";;;AAAA,uEAAkE;AAMlE,0EAA+F;AAoD/F;;;;;;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,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,GAAG,EAAE,CAAC,CAAC,CAAC,yCAAyC,CAAC;YACzD,kBAAkB,E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AC,CAAC,EAAE,IAAI,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,mBAAmB,GACvB,IAAA,6CAAqC,EAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAE9D,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,CAAQ,CAAC;gBAC/C,8DAA8D;gBAC9D,mBAAmB,CAAC,kBAAkB,EAAE,CAAC,CAAQ,CAAC;gBAClD,IAAI,CAAC;IACT,CAAC;IAAC,MAAM,CAAC;QACP,8DAA8D;QAC9D,WAAW,GAAG,mBAAmB,CAAC,kBAAkB,EAAE,CAAC,CAAQ,CAAC,IAAI,IAAI,CAAC;IAC3E,CAAC;IAED,OAAO;QACL,8DAA8D;QAC9D,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,CAAC,CAAQ,CAAC,IAAI,EAAE,EAAE,kCAAkC;QACvF,WAAW,EAAE,WAAW,IAAI,EAAE,EAAE,mCAAmC;KACpE,CAAC;AACJ,CAAC;AAhCD,oFAgCC","sourcesContent":["import { getAmount, formatAmount } from './get-notification-data';\nimport type {\n NOTIFICATION_CHAINS_IDS,\n Types,\n} from '../../NotificationServicesController';\nimport type { Constants } from '../../NotificationServicesController';\nimport { NOTIFICATION_NETWORK_CURRENCY_SYMBOL } from '../../NotificationServicesController/ui';\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<N extends Types.INotification> = {\n title: (n: N) => string | null;\n defaultDescription: (n: N) => string | null;\n getDescription?: (n: N) => string | null;\n link?: (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: () =>\n t('pushPlatformNotificationsFundsSentDescriptionDefault'),\n getDescription: (n) => {\n const symbol = n?.payload?.data?.token?.symbol;\n const tokenAmount = n?.payload?.data?.token?.amount;\n const tokenDecimals = n?.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 t(\n 'pushPlatformNotificationsFundsSentDescription',\n amount,\n symbol,\n );\n },\n },\n eth_sent: {\n title: () => t('pushPlatformNotificationsFundsSentTitle'),\n defaultDescription: () =>\n t('pushPlatformNotificationsFundsSentDescriptionDefault'),\n getDescription: (n) => {\n const symbol = getChainSymbol(n?.payload?.chain_id);\n const tokenAmount = n?.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 t(\n 'pushPlatformNotificationsFundsSentDescription',\n amount,\n symbol,\n );\n },\n },\n erc20_received: {\n title: () => t('pushPlatformNotificationsFundsReceivedTitle'),\n defaultDescription: () =>\n t('pushPlatformNotificationsFundsReceivedDescriptionDefault'),\n getDescription: (n) => {\n const symbol = n?.payload?.data?.token?.symbol;\n const tokenAmount = n?.payload?.data?.token?.amount;\n const tokenDecimals = n?.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 t(\n 'pushPlatformNotificationsFundsReceivedDescription',\n amount,\n symbol,\n );\n },\n },\n eth_received: {\n title: () => t('pushPlatformNotificationsFundsReceivedTitle'),\n defaultDescription: () =>\n t('pushPlatformNotificationsFundsReceivedDescriptionDefault'),\n getDescription: (n) => {\n const symbol = getChainSymbol(n?.payload?.chain_id);\n const tokenAmount = n?.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 t(\n 'pushPlatformNotificationsFundsReceivedDescription',\n amount,\n symbol,\n );\n },\n },\n metamask_swap_completed: {\n title: () => t('pushPlatformNotificationsSwapCompletedTitle'),\n defaultDescription: () =>\n t('pushPlatformNotificationsSwapCompletedDescription'),\n },\n erc721_sent: {\n title: () => t('pushPlatformNotificationsNftSentTitle'),\n defaultDescription: () =>\n t('pushPlatformNotificationsNftSentDescription'),\n },\n erc1155_sent: {\n title: () => t('pushPlatformNotificationsNftSentTitle'),\n defaultDescription: () =>\n t('pushPlatformNotificationsNftSentDescription'),\n },\n erc721_received: {\n title: () => t('pushPlatformNotificationsNftReceivedTitle'),\n defaultDescription: () =>\n t('pushPlatformNotificationsNftReceivedDescription'),\n },\n erc1155_received: {\n title: () => t('pushPlatformNotificationsNftReceivedTitle'),\n defaultDescription: () =>\n t('pushPlatformNotificationsNftReceivedDescription'),\n },\n rocketpool_stake_completed: {\n title: () =>\n t('pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle'),\n defaultDescription: () =>\n t(\n 'pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription',\n ),\n },\n rocketpool_unstake_completed: {\n title: () =>\n t('pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle'),\n defaultDescription: () =>\n t(\n 'pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription',\n ),\n },\n lido_stake_completed: {\n title: () => t('pushPlatformNotificationsStakingLidoStakeCompletedTitle'),\n defaultDescription: () =>\n t('pushPlatformNotificationsStakingLidoStakeCompletedDescription'),\n },\n lido_stake_ready_to_be_withdrawn: {\n title: () =>\n t('pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle'),\n defaultDescription: () =>\n t(\n 'pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription',\n ),\n },\n lido_withdrawal_requested: {\n title: () =>\n t('pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle'),\n defaultDescription: () =>\n t('pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription'),\n },\n lido_withdrawal_completed: {\n title: () =>\n t('pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle'),\n defaultDescription: () =>\n t('pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription'),\n },\n platform: {\n title: (n) => n.template.title,\n defaultDescription: (n) => n.template.body,\n getDescription: (n) => n.template.body,\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 (\n NOTIFICATION_NETWORK_CURRENCY_SYMBOL[\n chainId.toString() as NOTIFICATION_CHAINS_IDS\n ] ?? null\n );\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n notificationMessage.defaultDescription?.(n as any) ??\n null;\n } catch {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n description = notificationMessage.defaultDescription?.(n as any) ?? null;\n }\n\n return {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n title: notificationMessage?.title?.(n as any) ?? '', // Ensure title is always a string\n description: description ?? '', // Fallback to empty string if null\n };\n}\n"]}
@@ -29,11 +29,13 @@ export type TranslationKeys = {
29
29
  type PushNotificationMessage = {
30
30
  title: string;
31
31
  description: string;
32
+ ctaLink?: string;
32
33
  };
33
34
  type NotificationMessage<N extends Types.INotification> = {
34
- title: string | null;
35
- defaultDescription: string | null;
35
+ title: (n: N) => string | null;
36
+ defaultDescription: (n: N) => string | null;
36
37
  getDescription?: (n: N) => string | null;
38
+ link?: (n: N) => string | null;
37
39
  };
38
40
  type NotificationMessageDict = {
39
41
  [K in Constants.TRIGGER_TYPES]?: NotificationMessage<Extract<Types.INotification, {
@@ -1 +1 @@
1
- {"version":3,"file":"get-notification-message.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-message.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,KAAK,EACN,uDAA6C;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,uDAA6C;AAGtE,MAAM,MAAM,eAAe,GAAG;IAC5B,uCAAuC,EAAE,MAAM,MAAM,CAAC;IACtD,oDAAoD,EAAE,MAAM,MAAM,CAAC;IACnE,6CAA6C,EAAE,CAC7C,GAAG,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,KACtB,MAAM,CAAC;IACZ,2CAA2C,EAAE,MAAM,MAAM,CAAC;IAC1D,wDAAwD,EAAE,MAAM,MAAM,CAAC;IACvE,iDAAiD,EAAE,CACjD,GAAG,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,KACtB,MAAM,CAAC;IACZ,2CAA2C,EAAE,MAAM,MAAM,CAAC;IAC1D,iDAAiD,EAAE,MAAM,MAAM,CAAC;IAChE,qCAAqC,EAAE,MAAM,MAAM,CAAC;IACpD,2CAA2C,EAAE,MAAM,MAAM,CAAC;IAC1D,yCAAyC,EAAE,MAAM,MAAM,CAAC;IACxD,+CAA+C,EAAE,MAAM,MAAM,CAAC;IAC9D,6DAA6D,EAAE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notification-message.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-message.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,KAAK,EACN,uDAA6C;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,uDAA6C;AAGtE,MAAM,MAAM,eAAe,GAAG;IAC5B,uCAAuC,EAAE,MAAM,MAAM,CAAC;IACtD,oDAAoD,EAAE,MAAM,MAAM,CAAC;IACnE,6CAA6C,EAAE,CAC7C,GAAG,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,KACtB,MAAM,CAAC;IACZ,2CAA2C,EAAE,MAAM,MAAM,CAAC;IAC1D,wDAAwD,EAAE,MAAM,MAAM,CAAC;IACvE,iDAAiD,EAAE,CACjD,GAAG,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,KACtB,MAAM,CAAC;IACZ,2CAA2C,EAAE,MAAM,MAAM,CAAC;IAC1D,iDAAiD,EAAE,MAAM,MAAM,CAAC;IAChE,qCAAqC,EAAE,MAAM,MAAM,CAAC;IACpD,2CAA2C,EAAE,MAAM,MAAM,CAAC;IAC1D,yCAAyC,EAAE,MAAM,MAAM,CAAC;IACxD,+CAA+C,EAAE,MAAM,MAAM,CAAC;IAC9D,6DAA6D,EAAE,MAAM,MAAM,CAAC;IAC5E,mEAAmE,EAAE,MAAM,MAAM,CAAC;IAClF,+DAA+D,EAAE,MAAM,MAAM,CAAC;IAC9E,qEAAqE,EAAE,MAAM,MAAM,CAAC;IACpF,uDAAuD,EAAE,MAAM,MAAM,CAAC;IACtE,6DAA6D,EAAE,MAAM,MAAM,CAAC;IAC5E,gEAAgE,EAAE,MAAM,MAAM,CAAC;IAC/E,sEAAsE,EAAE,MAAM,MAAM,CAAC;IACrF,4DAA4D,EAAE,MAAM,MAAM,CAAC;IAC3E,kEAAkE,EAAE,MAAM,MAAM,CAAC;IACjF,4DAA4D,EAAE,MAAM,MAAM,CAAC;IAC3E,kEAAkE,EAAE,MAAM,MAAM,CAAC;CAClF,CAAC;AAEF,KAAK,uBAAuB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,mBAAmB,CAAC,CAAC,SAAS,KAAK,CAAC,aAAa,IAAI;IACxD,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,GAAG,IAAI,CAAC;IAC/B,kBAAkB,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,GAAG,IAAI,CAAC;IAC5C,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,GAAG,IAAI,CAAC;IACzC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,GAAG,IAAI,CAAC;CAChC,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,uBA4KF,CAAC;AAgBF;;;;;;GAMG;AACH,wBAAgB,oCAAoC,CAClD,CAAC,EAAE,KAAK,CAAC,aAAa,EACtB,YAAY,EAAE,eAAe,GAC5B,uBAAuB,GAAG,IAAI,CA6BhC"}
@@ -29,11 +29,13 @@ export type TranslationKeys = {
29
29
  type PushNotificationMessage = {
30
30
  title: string;
31
31
  description: string;
32
+ ctaLink?: string;
32
33
  };
33
34
  type NotificationMessage<N extends Types.INotification> = {
34
- title: string | null;
35
- defaultDescription: string | null;
35
+ title: (n: N) => string | null;
36
+ defaultDescription: (n: N) => string | null;
36
37
  getDescription?: (n: N) => string | null;
38
+ link?: (n: N) => string | null;
37
39
  };
38
40
  type NotificationMessageDict = {
39
41
  [K in Constants.TRIGGER_TYPES]?: NotificationMessage<Extract<Types.INotification, {
@@ -1 +1 @@
1
- {"version":3,"file":"get-notification-message.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-message.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,KAAK,EACN,uDAA6C;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,uDAA6C;AAGtE,MAAM,MAAM,eAAe,GAAG;IAC5B,uCAAuC,EAAE,MAAM,MAAM,CAAC;IACtD,oDAAoD,EAAE,MAAM,MAAM,CAAC;IACnE,6CAA6C,EAAE,CAC7C,GAAG,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,KACtB,MAAM,CAAC;IACZ,2CAA2C,EAAE,MAAM,MAAM,CAAC;IAC1D,wDAAwD,EAAE,MAAM,MAAM,CAAC;IACvE,iDAAiD,EAAE,CACjD,GAAG,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,KACtB,MAAM,CAAC;IACZ,2CAA2C,EAAE,MAAM,MAAM,CAAC;IAC1D,iDAAiD,EAAE,MAAM,MAAM,CAAC;IAChE,qCAAqC,EAAE,MAAM,MAAM,CAAC;IACpD,2CAA2C,EAAE,MAAM,MAAM,CAAC;IAC1D,yCAAyC,EAAE,MAAM,MAAM,CAAC;IACxD,+CAA+C,EAAE,MAAM,MAAM,CAAC;IAC9D,6DAA6D,EAAE,MAAM,MAAM,CAAC;IAC5E,mEAAmE,EAAE,MAAM,MAAM,CAAC;IAClF,+DAA+D,EAAE,MAAM,MAAM,CAAC;IAC9E,qEAAqE,EAAE,MAAM,MAAM,CAAC;IACpF,uDAAuD,EAAE,MAAM,MAAM,CAAC;IACtE,6DAA6D,EAAE,MAAM,MAAM,CAAC;IAC5E,gEAAgE,EAAE,MAAM,MAAM,CAAC;IAC/E,sEAAsE,EAAE,MAAM,MAAM,CAAC;IACrF,4DAA4D,EAAE,MAAM,MAAM,CAAC;IAC3E,kEAAkE,EAAE,MAAM,MAAM,CAAC;IACjF,4DAA4D,EAAE,MAAM,MAAM,CAAC;IAC3E,kEAAkE,EAAE,MAAM,MAAM,CAAC;CAClF,CAAC;AAEF,KAAK,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;AAgBF;;;;;;GAMG;AACH,wBAAgB,oCAAoC,CAClD,CAAC,EAAE,KAAK,CAAC,aAAa,EACtB,YAAY,EAAE,eAAe,GAC5B,uBAAuB,GAAG,IAAI,CA0BhC"}
1
+ {"version":3,"file":"get-notification-message.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-message.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,KAAK,EACN,uDAA6C;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,uDAA6C;AAGtE,MAAM,MAAM,eAAe,GAAG;IAC5B,uCAAuC,EAAE,MAAM,MAAM,CAAC;IACtD,oDAAoD,EAAE,MAAM,MAAM,CAAC;IACnE,6CAA6C,EAAE,CAC7C,GAAG,IAAI,EAAE,CAAC,MAAM,EAAE,MA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AK,MAAM,GAAG,IAAI,CAAC;IAC5C,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,GAAG,IAAI,CAAC;IACzC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,GAAG,IAAI,CAAC;CAChC,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,uBA4KF,CAAC;AAgBF;;;;;;GAMG;AACH,wBAAgB,oCAAoC,CAClD,CAAC,EAAE,KAAK,CAAC,aAAa,EACtB,YAAY,EAAE,eAAe,GAC5B,uBAAuB,GAAG,IAAI,CA6BhC"}
@@ -17,12 +17,12 @@ export const createOnChainPushNotificationMessages = (translationKeys) => {
17
17
  };
18
18
  return {
19
19
  erc20_sent: {
20
- title: t('pushPlatformNotificationsFundsSentTitle'),
21
- defaultDescription: t('pushPlatformNotificationsFundsSentDescriptionDefault'),
20
+ title: () => t('pushPlatformNotificationsFundsSentTitle'),
21
+ defaultDescription: () => t('pushPlatformNotificationsFundsSentDescriptionDefault'),
22
22
  getDescription: (n) => {
23
- const symbol = n?.data?.token?.symbol;
24
- const tokenAmount = n?.data?.token?.amount;
25
- const tokenDecimals = n?.data?.token?.decimals;
23
+ const symbol = n?.payload?.data?.token?.symbol;
24
+ const tokenAmount = n?.payload?.data?.token?.amount;
25
+ const tokenDecimals = n?.payload?.data?.token?.decimals;
26
26
  if (!symbol || !tokenAmount || !tokenDecimals) {
27
27
  return null;
28
28
  }
@@ -33,11 +33,11 @@ export const createOnChainPushNotificationMessages = (translationKeys) => {
33
33
  },
34
34
  },
35
35
  eth_sent: {
36
- title: t('pushPlatformNotificationsFundsSentTitle'),
37
- defaultDescription: t('pushPlatformNotificationsFundsSentDescriptionDefault'),
36
+ title: () => t('pushPlatformNotificationsFundsSentTitle'),
37
+ defaultDescription: () => t('pushPlatformNotificationsFundsSentDescriptionDefault'),
38
38
  getDescription: (n) => {
39
- const symbol = getChainSymbol(n?.chain_id);
40
- const tokenAmount = n?.data?.amount?.eth;
39
+ const symbol = getChainSymbol(n?.payload?.chain_id);
40
+ const tokenAmount = n?.payload?.data?.amount?.eth;
41
41
  if (!symbol || !tokenAmount) {
42
42
  return null;
43
43
  }
@@ -48,12 +48,12 @@ export const createOnChainPushNotificationMessages = (translationKeys) => {
48
48
  },
49
49
  },
50
50
  erc20_received: {
51
- title: t('pushPlatformNotificationsFundsReceivedTitle'),
52
- defaultDescription: t('pushPlatformNotificationsFundsReceivedDescriptionDefault'),
51
+ title: () => t('pushPlatformNotificationsFundsReceivedTitle'),
52
+ defaultDescription: () => t('pushPlatformNotificationsFundsReceivedDescriptionDefault'),
53
53
  getDescription: (n) => {
54
- const symbol = n?.data?.token?.symbol;
55
- const tokenAmount = n?.data?.token?.amount;
56
- const tokenDecimals = n?.data?.token?.decimals;
54
+ const symbol = n?.payload?.data?.token?.symbol;
55
+ const tokenAmount = n?.payload?.data?.token?.amount;
56
+ const tokenDecimals = n?.payload?.data?.token?.decimals;
57
57
  if (!symbol || !tokenAmount || !tokenDecimals) {
58
58
  return null;
59
59
  }
@@ -64,11 +64,11 @@ export const createOnChainPushNotificationMessages = (translationKeys) => {
64
64
  },
65
65
  },
66
66
  eth_received: {
67
- title: t('pushPlatformNotificationsFundsReceivedTitle'),
68
- defaultDescription: t('pushPlatformNotificationsFundsReceivedDescriptionDefault'),
67
+ title: () => t('pushPlatformNotificationsFundsReceivedTitle'),
68
+ defaultDescription: () => t('pushPlatformNotificationsFundsReceivedDescriptionDefault'),
69
69
  getDescription: (n) => {
70
- const symbol = getChainSymbol(n?.chain_id);
71
- const tokenAmount = n?.data?.amount?.eth;
70
+ const symbol = getChainSymbol(n?.payload?.chain_id);
71
+ const tokenAmount = n?.payload?.data?.amount?.eth;
72
72
  if (!symbol || !tokenAmount) {
73
73
  return null;
74
74
  }
@@ -79,48 +79,53 @@ export const createOnChainPushNotificationMessages = (translationKeys) => {
79
79
  },
80
80
  },
81
81
  metamask_swap_completed: {
82
- title: t('pushPlatformNotificationsSwapCompletedTitle'),
83
- defaultDescription: t('pushPlatformNotificationsSwapCompletedDescription'),
82
+ title: () => t('pushPlatformNotificationsSwapCompletedTitle'),
83
+ defaultDescription: () => t('pushPlatformNotificationsSwapCompletedDescription'),
84
84
  },
85
85
  erc721_sent: {
86
- title: t('pushPlatformNotificationsNftSentTitle'),
87
- defaultDescription: t('pushPlatformNotificationsNftSentDescription'),
86
+ title: () => t('pushPlatformNotificationsNftSentTitle'),
87
+ defaultDescription: () => t('pushPlatformNotificationsNftSentDescription'),
88
88
  },
89
89
  erc1155_sent: {
90
- title: t('pushPlatformNotificationsNftSentTitle'),
91
- defaultDescription: t('pushPlatformNotificationsNftSentDescription'),
90
+ title: () => t('pushPlatformNotificationsNftSentTitle'),
91
+ defaultDescription: () => t('pushPlatformNotificationsNftSentDescription'),
92
92
  },
93
93
  erc721_received: {
94
- title: t('pushPlatformNotificationsNftReceivedTitle'),
95
- defaultDescription: t('pushPlatformNotificationsNftReceivedDescription'),
94
+ title: () => t('pushPlatformNotificationsNftReceivedTitle'),
95
+ defaultDescription: () => t('pushPlatformNotificationsNftReceivedDescription'),
96
96
  },
97
97
  erc1155_received: {
98
- title: t('pushPlatformNotificationsNftReceivedTitle'),
99
- defaultDescription: t('pushPlatformNotificationsNftReceivedDescription'),
98
+ title: () => t('pushPlatformNotificationsNftReceivedTitle'),
99
+ defaultDescription: () => t('pushPlatformNotificationsNftReceivedDescription'),
100
100
  },
101
101
  rocketpool_stake_completed: {
102
- title: t('pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle'),
103
- defaultDescription: t('pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription'),
102
+ title: () => t('pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle'),
103
+ defaultDescription: () => t('pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription'),
104
104
  },
105
105
  rocketpool_unstake_completed: {
106
- title: t('pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle'),
107
- defaultDescription: t('pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription'),
106
+ title: () => t('pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle'),
107
+ defaultDescription: () => t('pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription'),
108
108
  },
109
109
  lido_stake_completed: {
110
- title: t('pushPlatformNotificationsStakingLidoStakeCompletedTitle'),
111
- defaultDescription: t('pushPlatformNotificationsStakingLidoStakeCompletedDescription'),
110
+ title: () => t('pushPlatformNotificationsStakingLidoStakeCompletedTitle'),
111
+ defaultDescription: () => t('pushPlatformNotificationsStakingLidoStakeCompletedDescription'),
112
112
  },
113
113
  lido_stake_ready_to_be_withdrawn: {
114
- title: t('pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle'),
115
- defaultDescription: t('pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription'),
114
+ title: () => t('pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle'),
115
+ defaultDescription: () => t('pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription'),
116
116
  },
117
117
  lido_withdrawal_requested: {
118
- title: t('pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle'),
119
- defaultDescription: t('pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription'),
118
+ title: () => t('pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle'),
119
+ defaultDescription: () => t('pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription'),
120
120
  },
121
121
  lido_withdrawal_completed: {
122
- title: t('pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle'),
123
- defaultDescription: t('pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription'),
122
+ title: () => t('pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle'),
123
+ defaultDescription: () => t('pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription'),
124
+ },
125
+ platform: {
126
+ title: (n) => n.template.title,
127
+ defaultDescription: (n) => n.template.body,
128
+ getDescription: (n) => n.template.body,
124
129
  },
125
130
  };
126
131
  };
@@ -153,14 +158,17 @@ export function createOnChainPushNotificationMessage(n, translations) {
153
158
  description =
154
159
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
155
160
  notificationMessage?.getDescription?.(n) ??
156
- notificationMessage.defaultDescription ??
161
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
162
+ notificationMessage.defaultDescription?.(n) ??
157
163
  null;
158
164
  }
159
165
  catch {
160
- description = notificationMessage.defaultDescription ?? null;
166
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
167
+ description = notificationMessage.defaultDescription?.(n) ?? null;
161
168
  }
162
169
  return {
163
- title: notificationMessage.title ?? '', // Ensure title is always a string
170
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
171
+ title: notificationMessage?.title?.(n) ?? '', // Ensure title is always a string
164
172
  description: description ?? '', // Fallback to empty string if null
165
173
  };
166
174
  }
@@ -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;AAMlE,OAAO,EAAE,oCAAoC,EAAE,0DAAgD;AAkD/F;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,CACnD,eAAgC,EACP,EAAE;IAI3B,MAAM,CAAC,GAAkB,CAAC,GAAG,IAAI,EAAE,EAAE;QACnC,MAAM,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC;QAEjC,4CAA4C;QAC5C,8DAA8D;QAC9D,MAAM,EAAE,G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AC,8DAA8D,CAAC;YACxE,kBAAkB,EAAE,CAAC,CACnB,oEAAoE,CACrE;SACF;QACD,yBAAyB,EAAE;YACzB,KAAK,EAAE,CAAC,CAAC,8DAA8D,CAAC;YACxE,kBAAkB,EAAE,CAAC,CACnB,oEAAoE,CACrE;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;GAKG;AACH,SAAS,cAAc,CAAC,OAAe;IACrC,OAAO,CACL,oCAAoC,CAClC,OAAO,CAAC,QAAQ,EAA6B,CAC9C,IAAI,IAAI,CACV,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oCAAoC,CAClD,CAAsB,EACtB,YAA6B;IAE7B,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,mBAAmB,GACvB,qCAAqC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAE9D,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,CAAQ,CAAC;gBAC/C,mBAAmB,CAAC,kBAAkB;gBACtC,IAAI,CAAC;IACT,CAAC;IAAC,MAAM,CAAC;QACP,WAAW,GAAG,mBAAmB,CAAC,kBAAkB,IAAI,IAAI,CAAC;IAC/D,CAAC;IAED,OAAO;QACL,KAAK,EAAE,mBAAmB,CAAC,KAAK,IAAI,EAAE,EAAE,kCAAkC;QAC1E,WAAW,EAAE,WAAW,IAAI,EAAE,EAAE,mCAAmC;KACpE,CAAC;AACJ,CAAC","sourcesContent":["import { getAmount, formatAmount } from './get-notification-data';\nimport type {\n NOTIFICATION_CHAINS_IDS,\n Types,\n} from '../../NotificationServicesController';\nimport type { Constants } from '../../NotificationServicesController';\nimport { NOTIFICATION_NETWORK_CURRENCY_SYMBOL } from '../../NotificationServicesController/ui';\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 (\n NOTIFICATION_NETWORK_CURRENCY_SYMBOL[\n chainId.toString() as NOTIFICATION_CHAINS_IDS\n ] ?? null\n );\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 {\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
+ {"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;AAMlE,OAAO,EAAE,oCAAoC,EAAE,0DAAgD;AAoD/F;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,CACnD,eAAgC,EACP,EAAE;IAI3B,MAAM,CAAC,GAAkB,CAAC,GAAG,IAAI,EAAE,EAAE;QACnC,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,GAAG,EAAE,CAAC,CAAC,CAAC,yCAAyC,CAAC;YACzD,kBAAkB,EAAE,GAAG,EAAE,CACvB,CAAC,CAAC,sDAAsD,CAAC;YAC3D,cAAc,EAAE,CAAC,CAAC,EAAE,EAAE;gBACpB,MAAM,MAAM,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC;gBAC/C,MAAM,WAAW,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC;gBACpD,MAAM,aAAa,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC;gBACxD,IAAI,CAAC,MAAM,IAAI,CAAC,WAAW,IAAI,CAAC,aAAa,EAAE,CAAC;oBAC9C,OAAO,IAAI,CAAC;gBACd,CAAC;gBAED,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,EAAE,aAAa,EAAE;oBACnD,aAAa,EAAE,IAAI;iBACpB,CAAC,CAAC;gBACH,OAA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AAE,mBAAmB,EAAE,KAAK,EAAE,CAAC,CAAQ,CAAC,IAAI,EAAE,EAAE,kCAAkC;QACvF,WAAW,EAAE,WAAW,IAAI,EAAE,EAAE,mCAAmC;KACpE,CAAC;AACJ,CAAC","sourcesContent":["import { getAmount, formatAmount } from './get-notification-data';\nimport type {\n NOTIFICATION_CHAINS_IDS,\n Types,\n} from '../../NotificationServicesController';\nimport type { Constants } from '../../NotificationServicesController';\nimport { NOTIFICATION_NETWORK_CURRENCY_SYMBOL } from '../../NotificationServicesController/ui';\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<N extends Types.INotification> = {\n title: (n: N) => string | null;\n defaultDescription: (n: N) => string | null;\n getDescription?: (n: N) => string | null;\n link?: (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: () =>\n t('pushPlatformNotificationsFundsSentDescriptionDefault'),\n getDescription: (n) => {\n const symbol = n?.payload?.data?.token?.symbol;\n const tokenAmount = n?.payload?.data?.token?.amount;\n const tokenDecimals = n?.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 t(\n 'pushPlatformNotificationsFundsSentDescription',\n amount,\n symbol,\n );\n },\n },\n eth_sent: {\n title: () => t('pushPlatformNotificationsFundsSentTitle'),\n defaultDescription: () =>\n t('pushPlatformNotificationsFundsSentDescriptionDefault'),\n getDescription: (n) => {\n const symbol = getChainSymbol(n?.payload?.chain_id);\n const tokenAmount = n?.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 t(\n 'pushPlatformNotificationsFundsSentDescription',\n amount,\n symbol,\n );\n },\n },\n erc20_received: {\n title: () => t('pushPlatformNotificationsFundsReceivedTitle'),\n defaultDescription: () =>\n t('pushPlatformNotificationsFundsReceivedDescriptionDefault'),\n getDescription: (n) => {\n const symbol = n?.payload?.data?.token?.symbol;\n const tokenAmount = n?.payload?.data?.token?.amount;\n const tokenDecimals = n?.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 t(\n 'pushPlatformNotificationsFundsReceivedDescription',\n amount,\n symbol,\n );\n },\n },\n eth_received: {\n title: () => t('pushPlatformNotificationsFundsReceivedTitle'),\n defaultDescription: () =>\n t('pushPlatformNotificationsFundsReceivedDescriptionDefault'),\n getDescription: (n) => {\n const symbol = getChainSymbol(n?.payload?.chain_id);\n const tokenAmount = n?.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 t(\n 'pushPlatformNotificationsFundsReceivedDescription',\n amount,\n symbol,\n );\n },\n },\n metamask_swap_completed: {\n title: () => t('pushPlatformNotificationsSwapCompletedTitle'),\n defaultDescription: () =>\n t('pushPlatformNotificationsSwapCompletedDescription'),\n },\n erc721_sent: {\n title: () => t('pushPlatformNotificationsNftSentTitle'),\n defaultDescription: () =>\n t('pushPlatformNotificationsNftSentDescription'),\n },\n erc1155_sent: {\n title: () => t('pushPlatformNotificationsNftSentTitle'),\n defaultDescription: () =>\n t('pushPlatformNotificationsNftSentDescription'),\n },\n erc721_received: {\n title: () => t('pushPlatformNotificationsNftReceivedTitle'),\n defaultDescription: () =>\n t('pushPlatformNotificationsNftReceivedDescription'),\n },\n erc1155_received: {\n title: () => t('pushPlatformNotificationsNftReceivedTitle'),\n defaultDescription: () =>\n t('pushPlatformNotificationsNftReceivedDescription'),\n },\n rocketpool_stake_completed: {\n title: () =>\n t('pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle'),\n defaultDescription: () =>\n t(\n 'pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription',\n ),\n },\n rocketpool_unstake_completed: {\n title: () =>\n t('pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle'),\n defaultDescription: () =>\n t(\n 'pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription',\n ),\n },\n lido_stake_completed: {\n title: () => t('pushPlatformNotificationsStakingLidoStakeCompletedTitle'),\n defaultDescription: () =>\n t('pushPlatformNotificationsStakingLidoStakeCompletedDescription'),\n },\n lido_stake_ready_to_be_withdrawn: {\n title: () =>\n t('pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle'),\n defaultDescription: () =>\n t(\n 'pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription',\n ),\n },\n lido_withdrawal_requested: {\n title: () =>\n t('pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle'),\n defaultDescription: () =>\n t('pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription'),\n },\n lido_withdrawal_completed: {\n title: () =>\n t('pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle'),\n defaultDescription: () =>\n t('pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription'),\n },\n platform: {\n title: (n) => n.template.title,\n defaultDescription: (n) => n.template.body,\n getDescription: (n) => n.template.body,\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 (\n NOTIFICATION_NETWORK_CURRENCY_SYMBOL[\n chainId.toString() as NOTIFICATION_CHAINS_IDS\n ] ?? null\n );\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n notificationMessage.defaultDescription?.(n as any) ??\n null;\n } catch {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n description = notificationMessage.defaultDescription?.(n as any) ?? null;\n }\n\n return {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n title: notificationMessage?.title?.(n as any) ?? '', // Ensure title is always a string\n description: description ?? '', // Fallback to empty string if null\n };\n}\n"]}
@@ -101,11 +101,14 @@ async function listenToPushNotificationsReceived(env, handler) {
101
101
  // eslint-disable-next-line @typescript-eslint/no-misused-promises
102
102
  async (payload) => {
103
103
  try {
104
- const data = payload?.data?.data ? JSON.parse(payload?.data?.data) : undefined;
104
+ const data = payload?.data
105
+ ?.data
106
+ ? JSON.parse(payload?.data?.data)
107
+ : undefined;
105
108
  if (!data) {
106
109
  return;
107
110
  }
108
- const notificationData = (0, to_raw_notification_1.toRawOnChainNotification)(data);
111
+ const notificationData = (0, to_raw_notification_1.toRawAPINotification)(data);
109
112
  const notification = NotificationServicesController_1.Processors.processNotification(notificationData);
110
113
  await handler(notification);
111
114
  }