@metamask-previews/notification-services-controller 21.0.0-preview-565dfca2 → 21.0.0-preview-3fa1672

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 (123) hide show
  1. package/dist/NotificationServicesController/NotificationServicesController.cjs +41 -37
  2. package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -1
  3. package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -1
  4. package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -1
  5. package/dist/NotificationServicesController/NotificationServicesController.mjs +41 -37
  6. package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
  7. package/dist/NotificationServicesController/constants/notification-schema.cjs +3 -0
  8. package/dist/NotificationServicesController/constants/notification-schema.cjs.map +1 -1
  9. package/dist/NotificationServicesController/constants/notification-schema.d.cts.map +1 -1
  10. package/dist/NotificationServicesController/constants/notification-schema.d.mts.map +1 -1
  11. package/dist/NotificationServicesController/constants/notification-schema.mjs +3 -0
  12. package/dist/NotificationServicesController/constants/notification-schema.mjs.map +1 -1
  13. package/dist/NotificationServicesController/mocks/mockResponses.cjs +6 -0
  14. package/dist/NotificationServicesController/mocks/mockResponses.cjs.map +1 -1
  15. package/dist/NotificationServicesController/mocks/mockResponses.d.cts.map +1 -1
  16. package/dist/NotificationServicesController/mocks/mockResponses.d.mts.map +1 -1
  17. package/dist/NotificationServicesController/mocks/mockResponses.mjs +6 -0
  18. package/dist/NotificationServicesController/mocks/mockResponses.mjs.map +1 -1
  19. package/dist/NotificationServicesController/processors/process-notifications.cjs +11 -9
  20. package/dist/NotificationServicesController/processors/process-notifications.cjs.map +1 -1
  21. package/dist/NotificationServicesController/processors/process-notifications.d.cts +1 -563
  22. package/dist/NotificationServicesController/processors/process-notifications.d.cts.map +1 -1
  23. package/dist/NotificationServicesController/processors/process-notifications.d.mts +1 -563
  24. package/dist/NotificationServicesController/processors/process-notifications.d.mts.map +1 -1
  25. package/dist/NotificationServicesController/processors/process-notifications.mjs +11 -9
  26. package/dist/NotificationServicesController/processors/process-notifications.mjs.map +1 -1
  27. package/dist/NotificationServicesController/services/api-notifications.cjs +21 -21
  28. package/dist/NotificationServicesController/services/api-notifications.cjs.map +1 -1
  29. package/dist/NotificationServicesController/services/api-notifications.d.cts.map +1 -1
  30. package/dist/NotificationServicesController/services/api-notifications.d.mts.map +1 -1
  31. package/dist/NotificationServicesController/services/api-notifications.mjs +21 -21
  32. package/dist/NotificationServicesController/services/api-notifications.mjs.map +1 -1
  33. package/dist/NotificationServicesController/services/feature-announcements.cjs +10 -10
  34. package/dist/NotificationServicesController/services/feature-announcements.cjs.map +1 -1
  35. package/dist/NotificationServicesController/services/feature-announcements.d.cts.map +1 -1
  36. package/dist/NotificationServicesController/services/feature-announcements.d.mts.map +1 -1
  37. package/dist/NotificationServicesController/services/feature-announcements.mjs +10 -10
  38. package/dist/NotificationServicesController/services/feature-announcements.mjs.map +1 -1
  39. package/dist/NotificationServicesController/services/notification-config-cache.cjs +4 -4
  40. package/dist/NotificationServicesController/services/notification-config-cache.cjs.map +1 -1
  41. package/dist/NotificationServicesController/services/notification-config-cache.mjs +4 -4
  42. package/dist/NotificationServicesController/services/notification-config-cache.mjs.map +1 -1
  43. package/dist/NotificationServicesController/services/perp-notifications.cjs +2 -2
  44. package/dist/NotificationServicesController/services/perp-notifications.cjs.map +1 -1
  45. package/dist/NotificationServicesController/services/perp-notifications.d.cts.map +1 -1
  46. package/dist/NotificationServicesController/services/perp-notifications.d.mts.map +1 -1
  47. package/dist/NotificationServicesController/services/perp-notifications.mjs +2 -2
  48. package/dist/NotificationServicesController/services/perp-notifications.mjs.map +1 -1
  49. package/dist/NotificationServicesController/types/notification-api/notification-api.cjs.map +1 -1
  50. package/dist/NotificationServicesController/types/notification-api/notification-api.d.cts.map +1 -1
  51. package/dist/NotificationServicesController/types/notification-api/notification-api.d.mts.map +1 -1
  52. package/dist/NotificationServicesController/types/notification-api/notification-api.mjs.map +1 -1
  53. package/dist/NotificationServicesController/types/notification-api/schema.cjs +2 -0
  54. package/dist/NotificationServicesController/types/notification-api/schema.cjs.map +1 -1
  55. package/dist/NotificationServicesController/types/notification-api/schema.d.cts.map +1 -1
  56. package/dist/NotificationServicesController/types/notification-api/schema.d.mts.map +1 -1
  57. package/dist/NotificationServicesController/types/notification-api/schema.mjs +2 -0
  58. package/dist/NotificationServicesController/types/notification-api/schema.mjs.map +1 -1
  59. package/dist/NotificationServicesController/types/perps/schema.cjs +2 -0
  60. package/dist/NotificationServicesController/types/perps/schema.cjs.map +1 -1
  61. package/dist/NotificationServicesController/types/perps/schema.d.cts.map +1 -1
  62. package/dist/NotificationServicesController/types/perps/schema.d.mts.map +1 -1
  63. package/dist/NotificationServicesController/types/perps/schema.mjs +2 -0
  64. package/dist/NotificationServicesController/types/perps/schema.mjs.map +1 -1
  65. package/dist/NotificationServicesController/utils/isVersionInBounds.cjs.map +1 -1
  66. package/dist/NotificationServicesController/utils/isVersionInBounds.d.cts.map +1 -1
  67. package/dist/NotificationServicesController/utils/isVersionInBounds.d.mts.map +1 -1
  68. package/dist/NotificationServicesController/utils/isVersionInBounds.mjs.map +1 -1
  69. package/dist/NotificationServicesController/utils/should-auto-expire.cjs.map +1 -1
  70. package/dist/NotificationServicesController/utils/should-auto-expire.d.cts.map +1 -1
  71. package/dist/NotificationServicesController/utils/should-auto-expire.d.mts.map +1 -1
  72. package/dist/NotificationServicesController/utils/should-auto-expire.mjs.map +1 -1
  73. package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -1
  74. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -1
  75. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -1
  76. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -1
  77. package/dist/NotificationServicesPushController/mocks/mockResponse.cjs.map +1 -1
  78. package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts +9 -24
  79. package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts.map +1 -1
  80. package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts +9 -24
  81. package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts.map +1 -1
  82. package/dist/NotificationServicesPushController/mocks/mockResponse.mjs.map +1 -1
  83. package/dist/NotificationServicesPushController/services/endpoints.cjs.map +1 -1
  84. package/dist/NotificationServicesPushController/services/endpoints.d.cts.map +1 -1
  85. package/dist/NotificationServicesPushController/services/endpoints.d.mts.map +1 -1
  86. package/dist/NotificationServicesPushController/services/endpoints.mjs.map +1 -1
  87. package/dist/NotificationServicesPushController/services/services.cjs.map +1 -1
  88. package/dist/NotificationServicesPushController/services/services.d.cts.map +1 -1
  89. package/dist/NotificationServicesPushController/services/services.d.mts.map +1 -1
  90. package/dist/NotificationServicesPushController/services/services.mjs.map +1 -1
  91. package/dist/NotificationServicesPushController/utils/get-notification-data.cjs +4 -4
  92. package/dist/NotificationServicesPushController/utils/get-notification-data.cjs.map +1 -1
  93. package/dist/NotificationServicesPushController/utils/get-notification-data.d.cts +2 -2
  94. package/dist/NotificationServicesPushController/utils/get-notification-data.d.cts.map +1 -1
  95. package/dist/NotificationServicesPushController/utils/get-notification-data.d.mts +2 -2
  96. package/dist/NotificationServicesPushController/utils/get-notification-data.d.mts.map +1 -1
  97. package/dist/NotificationServicesPushController/utils/get-notification-data.mjs +4 -4
  98. package/dist/NotificationServicesPushController/utils/get-notification-data.mjs.map +1 -1
  99. package/dist/NotificationServicesPushController/utils/get-notification-message.cjs +62 -61
  100. package/dist/NotificationServicesPushController/utils/get-notification-message.cjs.map +1 -1
  101. package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts +9 -9
  102. package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts.map +1 -1
  103. package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts +9 -9
  104. package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts.map +1 -1
  105. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs +62 -61
  106. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs.map +1 -1
  107. package/dist/NotificationServicesPushController/web/push-utils.cjs +3 -0
  108. package/dist/NotificationServicesPushController/web/push-utils.cjs.map +1 -1
  109. package/dist/NotificationServicesPushController/web/push-utils.d.cts.map +1 -1
  110. package/dist/NotificationServicesPushController/web/push-utils.d.mts.map +1 -1
  111. package/dist/NotificationServicesPushController/web/push-utils.mjs +3 -0
  112. package/dist/NotificationServicesPushController/web/push-utils.mjs.map +1 -1
  113. package/dist/shared/is-onchain-notification.cjs +3 -3
  114. package/dist/shared/is-onchain-notification.cjs.map +1 -1
  115. package/dist/shared/is-onchain-notification.d.cts +2 -2
  116. package/dist/shared/is-onchain-notification.d.cts.map +1 -1
  117. package/dist/shared/is-onchain-notification.d.mts +2 -2
  118. package/dist/shared/is-onchain-notification.d.mts.map +1 -1
  119. package/dist/shared/is-onchain-notification.mjs +3 -3
  120. package/dist/shared/is-onchain-notification.mjs.map +1 -1
  121. package/dist/shared/to-raw-notification.cjs.map +1 -1
  122. package/dist/shared/to-raw-notification.mjs.map +1 -1
  123. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"get-notification-data.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-data.ts"],"names":[],"mappings":";;;AAAA,+CAAyC;AAMzC,MAAM,oBAAoB,GAAG;IAC3B,aAAa,EAAE,CAAC;CACjB,CAAC;AAEF;;;;;;GAMG;AACH,SAAgB,eAAe,CAAC,KAAa,EAAE,QAAgB;IAC7D,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC;IACvD,OAAO,IAAI,wBAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AACtD,CAAC;AAHD,0CAGC;AAED;;;;;;;;;;;GAWG;AACI,MAAM,mBAAmB,GAAG,CAA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AG,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;YAChD,qBAAqB,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;YAClE,qBAAqB,EAAE,OAAO,CAAC,aAAa;SAC7C,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QAEzB,OAAO,OAAO,CAAC,CAAC,CAAC,GAAG,cAAc,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC;IAC3D,CAAC;IAED,oCAAoC;IACpC,OAAO,aAAa,CAAC,QAAQ,EAAE,CAAC;AAClC,CAAC,CAAC;AA/BW,QAAA,YAAY,gBA+BvB;AAEK,MAAM,SAAS,GAAG,CACvB,MAAc,EACd,QAAgB,EAChB,OAAuB,EACvB,EAAE;IACF,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,aAAa,GAAG,eAAe,CACnC,MAAM,EACN,UAAU,CAAC,QAAQ,CAAC,CACrB,CAAC,QAAQ,EAAE,CAAC;IAEb,OAAO,IAAA,oBAAY,EAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC,CAAC;AAfW,QAAA,SAAS,aAepB","sourcesContent":["import { BigNumber } from 'bignumber.js';\n\ntype FormatOptions = {\n decimalPlaces?: number;\n shouldEllipse?: boolean;\n};\nconst defaultFormatOptions = {\n decimalPlaces: 4,\n};\n\n/**\n * Calculates the token amount based on the given value and decimals.\n *\n * @param value - The value to calculate the token amount from.\n * @param decimals - The number of decimals to use for the calculation.\n * @returns The calculated token amount.\n */\nexport function calcTokenAmount(value: string, decimals: number) {\n const multiplier = Math.pow(10, Number(decimals || 0));\n return new BigNumber(String(value)).div(multiplier);\n}\n\n/**\n * Calculates the number of leading zeros in the fractional part of a number.\n *\n * This function converts a number or a string representation of a number into\n * its decimal form and then counts the number of leading zeros present in the\n * fractional part of the number. This is useful for determining the precision\n * of very small numbers.\n *\n * @param num - The number to analyze, which can be in the form\n * of a number or a string.\n * @returns The count of leading zeros in the fractional part of the number.\n */\nexport const getLeadingZeroCount = (num: number | string) => {\n const numToString = new BigNumber(num, 10).toString(10);\n const fractionalPart = numToString.split('.')[1] ?? '';\n return fractionalPart.match(/^0*/u)?.[0]?.length || 0;\n};\n\n/**\n * This formats a number using Intl\n * It abbreviates large numbers (using K, M, B, T)\n * And abbreviates small numbers in 2 ways:\n * - Will format to the given number of decimal places\n * - Will format up to 4 decimal places\n * - Will ellipse the number if longer than given decimal places\n *\n * @param numericAmount - The number to format\n * @param opts - The options to use when formatting\n * @returns The formatted number\n */\nexport const formatAmount = (numericAmount: number, opts?: FormatOptions) => {\n // create options with defaults\n const options = { ...defaultFormatOptions, ...opts };\n\n const leadingZeros = getLeadingZeroCount(numericAmount);\n const isDecimal = numericAmount.toString().includes('.') || leadingZeros > 0;\n const isLargeNumber = numericAmount > 999;\n\n const handleShouldEllipse = (decimalPlaces: number) =>\n Boolean(options?.shouldEllipse) && leadingZeros >= decimalPlaces;\n\n if (isLargeNumber) {\n return Intl.NumberFormat('en-US', {\n notation: 'compact',\n compactDisplay: 'short',\n maximumFractionDigits: 2,\n }).format(numericAmount);\n }\n\n if (isDecimal) {\n const ellipse = handleShouldEllipse(options.decimalPlaces);\n const formattedValue = Intl.NumberFormat('en-US', {\n minimumFractionDigits: ellipse ? options.decimalPlaces : undefined,\n maximumFractionDigits: options.decimalPlaces,\n }).format(numericAmount);\n\n return ellipse ? `${formattedValue}...` : formattedValue;\n }\n\n // Default to showing the raw amount\n return numericAmount.toString();\n};\n\nexport const getAmount = (\n amount: string,\n decimals: string,\n options?: FormatOptions,\n) => {\n if (!amount || !decimals) {\n return '';\n }\n\n const numericAmount = calcTokenAmount(\n amount,\n parseFloat(decimals),\n ).toNumber();\n\n return formatAmount(numericAmount, options);\n};\n"]}
1
+ {"version":3,"file":"get-notification-data.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get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,aAepB","sourcesContent":["import { BigNumber } from 'bignumber.js';\n\ntype FormatOptions = {\n decimalPlaces?: number;\n shouldEllipse?: boolean;\n};\nconst defaultFormatOptions = {\n decimalPlaces: 4,\n};\n\n/**\n * Calculates the token amount based on the given value and decimals.\n *\n * @param value - The value to calculate the token amount from.\n * @param decimals - The number of decimals to use for the calculation.\n * @returns The calculated token amount.\n */\nexport function calcTokenAmount(value: string, decimals: number): BigNumber {\n const multiplier = Math.pow(10, Number(decimals || 0));\n return new BigNumber(String(value)).div(multiplier);\n}\n\n/**\n * Calculates the number of leading zeros in the fractional part of a number.\n *\n * This function converts a number or a string representation of a number into\n * its decimal form and then counts the number of leading zeros present in the\n * fractional part of the number. This is useful for determining the precision\n * of very small numbers.\n *\n * @param numericValue - The number to analyze, which can be in the form\n * of a number or a string.\n * @returns The count of leading zeros in the fractional part of the number.\n */\nexport const getLeadingZeroCount = (numericValue: number | string): number => {\n const numToString = new BigNumber(numericValue, 10).toString(10);\n const fractionalPart = numToString.split('.')[1] ?? '';\n return fractionalPart.match(/^0*/u)?.[0]?.length ?? 0;\n};\n\n/**\n * This formats a number using Intl\n * It abbreviates large numbers (using K, M, B, T)\n * And abbreviates small numbers in 2 ways:\n * - Will format to the given number of decimal places\n * - Will format up to 4 decimal places\n * - Will ellipse the number if longer than given decimal places\n *\n * @param numericAmount - The number to format\n * @param opts - The options to use when formatting\n * @returns The formatted number\n */\nexport const formatAmount = (\n numericAmount: number,\n opts?: FormatOptions,\n): string => {\n // create options with defaults\n const options = { ...defaultFormatOptions, ...opts };\n\n const leadingZeros = getLeadingZeroCount(numericAmount);\n const isDecimal = numericAmount.toString().includes('.') || leadingZeros > 0;\n const isLargeNumber = numericAmount > 999;\n\n const handleShouldEllipse = (decimalPlaces: number): boolean =>\n Boolean(options?.shouldEllipse) && leadingZeros >= decimalPlaces;\n\n if (isLargeNumber) {\n return Intl.NumberFormat('en-US', {\n notation: 'compact',\n compactDisplay: 'short',\n maximumFractionDigits: 2,\n }).format(numericAmount);\n }\n\n if (isDecimal) {\n const ellipse = handleShouldEllipse(options.decimalPlaces);\n const formattedValue = Intl.NumberFormat('en-US', {\n minimumFractionDigits: ellipse ? options.decimalPlaces : undefined,\n maximumFractionDigits: options.decimalPlaces,\n }).format(numericAmount);\n\n return ellipse ? `${formattedValue}...` : formattedValue;\n }\n\n // Default to showing the raw amount\n return numericAmount.toString();\n};\n\nexport const getAmount = (\n amount: string,\n decimals: string,\n options?: FormatOptions,\n): string => {\n if (!amount || !decimals) {\n return '';\n }\n\n const numericAmount = calcTokenAmount(\n amount,\n parseFloat(decimals),\n ).toNumber();\n\n return formatAmount(numericAmount, options);\n};\n"]}
@@ -19,11 +19,11 @@ export declare function calcTokenAmount(value: string, decimals: number): BigNum
19
19
  * fractional part of the number. This is useful for determining the precision
20
20
  * of very small numbers.
21
21
  *
22
- * @param num - The number to analyze, which can be in the form
22
+ * @param numericValue - The number to analyze, which can be in the form
23
23
  * of a number or a string.
24
24
  * @returns The count of leading zeros in the fractional part of the number.
25
25
  */
26
- export declare const getLeadingZeroCount: (num: number | string) => number;
26
+ export declare const getLeadingZeroCount: (numericValue: number | string) => number;
27
27
  /**
28
28
  * This formats a number using Intl
29
29
  * It abbreviates large numbers (using K, M, B, T)
@@ -1 +1 @@
1
- {"version":3,"file":"get-notification-data.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAEzC,KAAK,aAAa,GAAG;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAKF;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAG9D;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,QAAS,MAAM,GAAG,MAAM,WAIvD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,kBAAmB,MAAM,SAAS,aAAa,WA+BvE,CAAC;AAEF,eAAO,MAAM,SAAS,WACZ,MAAM,YACJ,MAAM,YACN,aAAa,WAYxB,CAAC"}
1
+ {"version":3,"file":"get-notification-data.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAEzC,KAAK,aAAa,GAAG;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAKF;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,CAG1E;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,iBAAkB,MAAM,GAAG,MAAM,KAAG,MAInE,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,kBACR,MAAM,SACd,aAAa,KACnB,MA+BF,CAAC;AAEF,eAAO,MAAM,SAAS,WACZ,MAAM,YACJ,MAAM,YACN,aAAa,KACtB,MAWF,CAAC"}
@@ -19,11 +19,11 @@ export declare function calcTokenAmount(value: string, decimals: number): BigNum
19
19
  * fractional part of the number. This is useful for determining the precision
20
20
  * of very small numbers.
21
21
  *
22
- * @param num - The number to analyze, which can be in the form
22
+ * @param numericValue - The number to analyze, which can be in the form
23
23
  * of a number or a string.
24
24
  * @returns The count of leading zeros in the fractional part of the number.
25
25
  */
26
- export declare const getLeadingZeroCount: (num: number | string) => number;
26
+ export declare const getLeadingZeroCount: (numericValue: number | string) => number;
27
27
  /**
28
28
  * This formats a number using Intl
29
29
  * It abbreviates large numbers (using K, M, B, T)
@@ -1 +1 @@
1
- {"version":3,"file":"get-notification-data.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAEzC,KAAK,aAAa,GAAG;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAKF;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAG9D;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,QAAS,MAAM,GAAG,MAAM,WAIvD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,kBAAmB,MAAM,SAAS,aAAa,WA+BvE,CAAC;AAEF,eAAO,MAAM,SAAS,WACZ,MAAM,YACJ,MAAM,YACN,aAAa,WAYxB,CAAC"}
1
+ {"version":3,"file":"get-notification-data.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAEzC,KAAK,aAAa,GAAG;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAKF;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,CAG1E;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,iBAAkB,MAAM,GAAG,MAAM,KAAG,MAInE,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,kBACR,MAAM,SACd,aAAa,KACnB,MA+BF,CAAC;AAEF,eAAO,MAAM,SAAS,WACZ,MAAM,YACJ,MAAM,YACN,aAAa,KACtB,MAWF,CAAC"}
@@ -21,14 +21,14 @@ export function calcTokenAmount(value, decimals) {
21
21
  * fractional part of the number. This is useful for determining the precision
22
22
  * of very small numbers.
23
23
  *
24
- * @param num - The number to analyze, which can be in the form
24
+ * @param numericValue - The number to analyze, which can be in the form
25
25
  * of a number or a string.
26
26
  * @returns The count of leading zeros in the fractional part of the number.
27
27
  */
28
- export const getLeadingZeroCount = (num) => {
29
- const numToString = new BigNumber(num, 10).toString(10);
28
+ export const getLeadingZeroCount = (numericValue) => {
29
+ const numToString = new BigNumber(numericValue, 10).toString(10);
30
30
  const fractionalPart = numToString.split('.')[1] ?? '';
31
- return fractionalPart.match(/^0*/u)?.[0]?.length || 0;
31
+ return fractionalPart.match(/^0*/u)?.[0]?.length ?? 0;
32
32
  };
33
33
  /**
34
34
  * This formats a number using Intl
@@ -1 +1 @@
1
- {"version":3,"file":"get-notification-data.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAMzC,MAAM,oBAAoB,GAAG;IAC3B,aAAa,EAAE,CAAC;CACjB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa,EAAE,QAAgB;IAC7D,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC;IACvD,OAAO,IAAI,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AACtD,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAoB,EAAE,EAAE;IAC1D,MAAM,WAAW,GAAG,IAAI,SAAS,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACxD,MAAM,cAAc,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACvD,OAAO,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI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O,aAAa,CAAC,QAAQ,EAAE,CAAC;AAClC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,MAAc,EACd,QAAgB,EAChB,OAAuB,EACvB,EAAE;IACF,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,aAAa,GAAG,eAAe,CACnC,MAAM,EACN,UAAU,CAAC,QAAQ,CAAC,CACrB,CAAC,QAAQ,EAAE,CAAC;IAEb,OAAO,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC,CAAC","sourcesContent":["import { BigNumber } from 'bignumber.js';\n\ntype FormatOptions = {\n decimalPlaces?: number;\n shouldEllipse?: boolean;\n};\nconst defaultFormatOptions = {\n decimalPlaces: 4,\n};\n\n/**\n * Calculates the token amount based on the given value and decimals.\n *\n * @param value - The value to calculate the token amount from.\n * @param decimals - The number of decimals to use for the calculation.\n * @returns The calculated token amount.\n */\nexport function calcTokenAmount(value: string, decimals: number) {\n const multiplier = Math.pow(10, Number(decimals || 0));\n return new BigNumber(String(value)).div(multiplier);\n}\n\n/**\n * Calculates the number of leading zeros in the fractional part of a number.\n *\n * This function converts a number or a string representation of a number into\n * its decimal form and then counts the number of leading zeros present in the\n * fractional part of the number. This is useful for determining the precision\n * of very small numbers.\n *\n * @param num - The number to analyze, which can be in the form\n * of a number or a string.\n * @returns The count of leading zeros in the fractional part of the number.\n */\nexport const getLeadingZeroCount = (num: number | string) => {\n const numToString = new BigNumber(num, 10).toString(10);\n const fractionalPart = numToString.split('.')[1] ?? '';\n return fractionalPart.match(/^0*/u)?.[0]?.length || 0;\n};\n\n/**\n * This formats a number using Intl\n * It abbreviates large numbers (using K, M, B, T)\n * And abbreviates small numbers in 2 ways:\n * - Will format to the given number of decimal places\n * - Will format up to 4 decimal places\n * - Will ellipse the number if longer than given decimal places\n *\n * @param numericAmount - The number to format\n * @param opts - The options to use when formatting\n * @returns The formatted number\n */\nexport const formatAmount = (numericAmount: number, opts?: FormatOptions) => {\n // create options with defaults\n const options = { ...defaultFormatOptions, ...opts };\n\n const leadingZeros = getLeadingZeroCount(numericAmount);\n const isDecimal = numericAmount.toString().includes('.') || leadingZeros > 0;\n const isLargeNumber = numericAmount > 999;\n\n const handleShouldEllipse = (decimalPlaces: number) =>\n Boolean(options?.shouldEllipse) && leadingZeros >= decimalPlaces;\n\n if (isLargeNumber) {\n return Intl.NumberFormat('en-US', {\n notation: 'compact',\n compactDisplay: 'short',\n maximumFractionDigits: 2,\n }).format(numericAmount);\n }\n\n if (isDecimal) {\n const ellipse = handleShouldEllipse(options.decimalPlaces);\n const formattedValue = Intl.NumberFormat('en-US', {\n minimumFractionDigits: ellipse ? options.decimalPlaces : undefined,\n maximumFractionDigits: options.decimalPlaces,\n }).format(numericAmount);\n\n return ellipse ? `${formattedValue}...` : formattedValue;\n }\n\n // Default to showing the raw amount\n return numericAmount.toString();\n};\n\nexport const getAmount = (\n amount: string,\n decimals: string,\n options?: FormatOptions,\n) => {\n if (!amount || !decimals) {\n return '';\n }\n\n const numericAmount = calcTokenAmount(\n amount,\n parseFloat(decimals),\n ).toNumber();\n\n return formatAmount(numericAmount, options);\n};\n"]}
1
+ {"version":3,"file":"get-notification-data.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAMzC,MAAM,oBAAoB,GAAG;IAC3B,aAAa,EAAE,CAAC;CACjB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa,EAAE,QAAgB;IAC7D,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC;IACvD,OAAO,IAAI,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,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AG,mBAAmB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QAC3D,MAAM,cAAc,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;YAChD,qBAAqB,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;YAClE,qBAAqB,EAAE,OAAO,CAAC,aAAa;SAC7C,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QAEzB,OAAO,OAAO,CAAC,CAAC,CAAC,GAAG,cAAc,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC;IAC3D,CAAC;IAED,oCAAoC;IACpC,OAAO,aAAa,CAAC,QAAQ,EAAE,CAAC;AAClC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,MAAc,EACd,QAAgB,EAChB,OAAuB,EACf,EAAE;IACV,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,aAAa,GAAG,eAAe,CACnC,MAAM,EACN,UAAU,CAAC,QAAQ,CAAC,CACrB,CAAC,QAAQ,EAAE,CAAC;IAEb,OAAO,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC,CAAC","sourcesContent":["import { BigNumber } from 'bignumber.js';\n\ntype FormatOptions = {\n decimalPlaces?: number;\n shouldEllipse?: boolean;\n};\nconst defaultFormatOptions = {\n decimalPlaces: 4,\n};\n\n/**\n * Calculates the token amount based on the given value and decimals.\n *\n * @param value - The value to calculate the token amount from.\n * @param decimals - The number of decimals to use for the calculation.\n * @returns The calculated token amount.\n */\nexport function calcTokenAmount(value: string, decimals: number): BigNumber {\n const multiplier = Math.pow(10, Number(decimals || 0));\n return new BigNumber(String(value)).div(multiplier);\n}\n\n/**\n * Calculates the number of leading zeros in the fractional part of a number.\n *\n * This function converts a number or a string representation of a number into\n * its decimal form and then counts the number of leading zeros present in the\n * fractional part of the number. This is useful for determining the precision\n * of very small numbers.\n *\n * @param numericValue - The number to analyze, which can be in the form\n * of a number or a string.\n * @returns The count of leading zeros in the fractional part of the number.\n */\nexport const getLeadingZeroCount = (numericValue: number | string): number => {\n const numToString = new BigNumber(numericValue, 10).toString(10);\n const fractionalPart = numToString.split('.')[1] ?? '';\n return fractionalPart.match(/^0*/u)?.[0]?.length ?? 0;\n};\n\n/**\n * This formats a number using Intl\n * It abbreviates large numbers (using K, M, B, T)\n * And abbreviates small numbers in 2 ways:\n * - Will format to the given number of decimal places\n * - Will format up to 4 decimal places\n * - Will ellipse the number if longer than given decimal places\n *\n * @param numericAmount - The number to format\n * @param opts - The options to use when formatting\n * @returns The formatted number\n */\nexport const formatAmount = (\n numericAmount: number,\n opts?: FormatOptions,\n): string => {\n // create options with defaults\n const options = { ...defaultFormatOptions, ...opts };\n\n const leadingZeros = getLeadingZeroCount(numericAmount);\n const isDecimal = numericAmount.toString().includes('.') || leadingZeros > 0;\n const isLargeNumber = numericAmount > 999;\n\n const handleShouldEllipse = (decimalPlaces: number): boolean =>\n Boolean(options?.shouldEllipse) && leadingZeros >= decimalPlaces;\n\n if (isLargeNumber) {\n return Intl.NumberFormat('en-US', {\n notation: 'compact',\n compactDisplay: 'short',\n maximumFractionDigits: 2,\n }).format(numericAmount);\n }\n\n if (isDecimal) {\n const ellipse = handleShouldEllipse(options.decimalPlaces);\n const formattedValue = Intl.NumberFormat('en-US', {\n minimumFractionDigits: ellipse ? options.decimalPlaces : undefined,\n maximumFractionDigits: options.decimalPlaces,\n }).format(numericAmount);\n\n return ellipse ? `${formattedValue}...` : formattedValue;\n }\n\n // Default to showing the raw amount\n return numericAmount.toString();\n};\n\nexport const getAmount = (\n amount: string,\n decimals: string,\n options?: FormatOptions,\n): string => {\n if (!amount || !decimals) {\n return '';\n }\n\n const numericAmount = calcTokenAmount(\n amount,\n parseFloat(decimals),\n ).toNumber();\n\n return formatAmount(numericAmount, options);\n};\n"]}
@@ -11,7 +11,7 @@ const ui_1 = require("../../NotificationServicesController/ui/index.cjs");
11
11
  * @returns A translation push message object.
12
12
  */
13
13
  const createOnChainPushNotificationMessages = (translationKeys) => {
14
- const t = (...args) => {
14
+ const translate = (...args) => {
15
15
  const [key, ...otherArgs] = args;
16
16
  // Coerce types for the translation function
17
17
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -20,115 +20,115 @@ const createOnChainPushNotificationMessages = (translationKeys) => {
20
20
  };
21
21
  return {
22
22
  erc20_sent: {
23
- title: () => t('pushPlatformNotificationsFundsSentTitle'),
24
- defaultDescription: () => t('pushPlatformNotificationsFundsSentDescriptionDefault'),
25
- getDescription: (n) => {
26
- const symbol = n?.payload?.data?.token?.symbol;
27
- const tokenAmount = n?.payload?.data?.token?.amount;
28
- const tokenDecimals = n?.payload?.data?.token?.decimals;
23
+ title: () => translate('pushPlatformNotificationsFundsSentTitle'),
24
+ defaultDescription: () => translate('pushPlatformNotificationsFundsSentDescriptionDefault'),
25
+ getDescription: (notification) => {
26
+ const symbol = notification?.payload?.data?.token?.symbol;
27
+ const tokenAmount = notification?.payload?.data?.token?.amount;
28
+ const tokenDecimals = notification?.payload?.data?.token?.decimals;
29
29
  if (!symbol || !tokenAmount || !tokenDecimals) {
30
30
  return null;
31
31
  }
32
32
  const amount = (0, get_notification_data_1.getAmount)(tokenAmount, tokenDecimals, {
33
33
  shouldEllipse: true,
34
34
  });
35
- return t('pushPlatformNotificationsFundsSentDescription', amount, symbol);
35
+ return translate('pushPlatformNotificationsFundsSentDescription', amount, symbol);
36
36
  },
37
37
  },
38
38
  eth_sent: {
39
- title: () => t('pushPlatformNotificationsFundsSentTitle'),
40
- defaultDescription: () => t('pushPlatformNotificationsFundsSentDescriptionDefault'),
41
- getDescription: (n) => {
42
- const symbol = getChainSymbol(n?.payload?.chain_id);
43
- const tokenAmount = n?.payload?.data?.amount?.eth;
39
+ title: () => translate('pushPlatformNotificationsFundsSentTitle'),
40
+ defaultDescription: () => translate('pushPlatformNotificationsFundsSentDescriptionDefault'),
41
+ getDescription: (notification) => {
42
+ const symbol = getChainSymbol(notification?.payload?.chain_id);
43
+ const tokenAmount = notification?.payload?.data?.amount?.eth;
44
44
  if (!symbol || !tokenAmount) {
45
45
  return null;
46
46
  }
47
47
  const amount = (0, get_notification_data_1.formatAmount)(parseFloat(tokenAmount), {
48
48
  shouldEllipse: true,
49
49
  });
50
- return t('pushPlatformNotificationsFundsSentDescription', amount, symbol);
50
+ return translate('pushPlatformNotificationsFundsSentDescription', amount, symbol);
51
51
  },
52
52
  },
53
53
  erc20_received: {
54
- title: () => t('pushPlatformNotificationsFundsReceivedTitle'),
55
- defaultDescription: () => t('pushPlatformNotificationsFundsReceivedDescriptionDefault'),
56
- getDescription: (n) => {
57
- const symbol = n?.payload?.data?.token?.symbol;
58
- const tokenAmount = n?.payload?.data?.token?.amount;
59
- const tokenDecimals = n?.payload?.data?.token?.decimals;
54
+ title: () => translate('pushPlatformNotificationsFundsReceivedTitle'),
55
+ defaultDescription: () => translate('pushPlatformNotificationsFundsReceivedDescriptionDefault'),
56
+ getDescription: (notification) => {
57
+ const symbol = notification?.payload?.data?.token?.symbol;
58
+ const tokenAmount = notification?.payload?.data?.token?.amount;
59
+ const tokenDecimals = notification?.payload?.data?.token?.decimals;
60
60
  if (!symbol || !tokenAmount || !tokenDecimals) {
61
61
  return null;
62
62
  }
63
63
  const amount = (0, get_notification_data_1.getAmount)(tokenAmount, tokenDecimals, {
64
64
  shouldEllipse: true,
65
65
  });
66
- return t('pushPlatformNotificationsFundsReceivedDescription', amount, symbol);
66
+ return translate('pushPlatformNotificationsFundsReceivedDescription', amount, symbol);
67
67
  },
68
68
  },
69
69
  eth_received: {
70
- title: () => t('pushPlatformNotificationsFundsReceivedTitle'),
71
- defaultDescription: () => t('pushPlatformNotificationsFundsReceivedDescriptionDefault'),
72
- getDescription: (n) => {
73
- const symbol = getChainSymbol(n?.payload?.chain_id);
74
- const tokenAmount = n?.payload?.data?.amount?.eth;
70
+ title: () => translate('pushPlatformNotificationsFundsReceivedTitle'),
71
+ defaultDescription: () => translate('pushPlatformNotificationsFundsReceivedDescriptionDefault'),
72
+ getDescription: (notification) => {
73
+ const symbol = getChainSymbol(notification?.payload?.chain_id);
74
+ const tokenAmount = notification?.payload?.data?.amount?.eth;
75
75
  if (!symbol || !tokenAmount) {
76
76
  return null;
77
77
  }
78
78
  const amount = (0, get_notification_data_1.formatAmount)(parseFloat(tokenAmount), {
79
79
  shouldEllipse: true,
80
80
  });
81
- return t('pushPlatformNotificationsFundsReceivedDescription', amount, symbol);
81
+ return translate('pushPlatformNotificationsFundsReceivedDescription', amount, symbol);
82
82
  },
83
83
  },
84
84
  metamask_swap_completed: {
85
- title: () => t('pushPlatformNotificationsSwapCompletedTitle'),
86
- defaultDescription: () => t('pushPlatformNotificationsSwapCompletedDescription'),
85
+ title: () => translate('pushPlatformNotificationsSwapCompletedTitle'),
86
+ defaultDescription: () => translate('pushPlatformNotificationsSwapCompletedDescription'),
87
87
  },
88
88
  erc721_sent: {
89
- title: () => t('pushPlatformNotificationsNftSentTitle'),
90
- defaultDescription: () => t('pushPlatformNotificationsNftSentDescription'),
89
+ title: () => translate('pushPlatformNotificationsNftSentTitle'),
90
+ defaultDescription: () => translate('pushPlatformNotificationsNftSentDescription'),
91
91
  },
92
92
  erc1155_sent: {
93
- title: () => t('pushPlatformNotificationsNftSentTitle'),
94
- defaultDescription: () => t('pushPlatformNotificationsNftSentDescription'),
93
+ title: () => translate('pushPlatformNotificationsNftSentTitle'),
94
+ defaultDescription: () => translate('pushPlatformNotificationsNftSentDescription'),
95
95
  },
96
96
  erc721_received: {
97
- title: () => t('pushPlatformNotificationsNftReceivedTitle'),
98
- defaultDescription: () => t('pushPlatformNotificationsNftReceivedDescription'),
97
+ title: () => translate('pushPlatformNotificationsNftReceivedTitle'),
98
+ defaultDescription: () => translate('pushPlatformNotificationsNftReceivedDescription'),
99
99
  },
100
100
  erc1155_received: {
101
- title: () => t('pushPlatformNotificationsNftReceivedTitle'),
102
- defaultDescription: () => t('pushPlatformNotificationsNftReceivedDescription'),
101
+ title: () => translate('pushPlatformNotificationsNftReceivedTitle'),
102
+ defaultDescription: () => translate('pushPlatformNotificationsNftReceivedDescription'),
103
103
  },
104
104
  rocketpool_stake_completed: {
105
- title: () => t('pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle'),
106
- defaultDescription: () => t('pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription'),
105
+ title: () => translate('pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle'),
106
+ defaultDescription: () => translate('pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription'),
107
107
  },
108
108
  rocketpool_unstake_completed: {
109
- title: () => t('pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle'),
110
- defaultDescription: () => t('pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription'),
109
+ title: () => translate('pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle'),
110
+ defaultDescription: () => translate('pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription'),
111
111
  },
112
112
  lido_stake_completed: {
113
- title: () => t('pushPlatformNotificationsStakingLidoStakeCompletedTitle'),
114
- defaultDescription: () => t('pushPlatformNotificationsStakingLidoStakeCompletedDescription'),
113
+ title: () => translate('pushPlatformNotificationsStakingLidoStakeCompletedTitle'),
114
+ defaultDescription: () => translate('pushPlatformNotificationsStakingLidoStakeCompletedDescription'),
115
115
  },
116
116
  lido_stake_ready_to_be_withdrawn: {
117
- title: () => t('pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle'),
118
- defaultDescription: () => t('pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription'),
117
+ title: () => translate('pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle'),
118
+ defaultDescription: () => translate('pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription'),
119
119
  },
120
120
  lido_withdrawal_requested: {
121
- title: () => t('pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle'),
122
- defaultDescription: () => t('pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription'),
121
+ title: () => translate('pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle'),
122
+ defaultDescription: () => translate('pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription'),
123
123
  },
124
124
  lido_withdrawal_completed: {
125
- title: () => t('pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle'),
126
- defaultDescription: () => t('pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription'),
125
+ title: () => translate('pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle'),
126
+ defaultDescription: () => translate('pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription'),
127
127
  },
128
128
  platform: {
129
- title: (n) => n.template.title,
130
- defaultDescription: (n) => n.template.body,
131
- getDescription: (n) => n.template.body,
129
+ title: (notification) => notification.template.title,
130
+ defaultDescription: (notification) => notification.template.body,
131
+ getDescription: (notification) => notification.template.body,
132
132
  },
133
133
  };
134
134
  };
@@ -145,15 +145,15 @@ function getChainSymbol(chainId) {
145
145
  /**
146
146
  * Creates a push notification message based on the given on-chain raw notification.
147
147
  *
148
- * @param n - processed notification.
148
+ * @param notification - processed notification.
149
149
  * @param translations - translates keys into text
150
150
  * @returns The push notification message object, or null if the notification is invalid.
151
151
  */
152
- function createOnChainPushNotificationMessage(n, translations) {
153
- if (!n?.type) {
152
+ function createOnChainPushNotificationMessage(notification, translations) {
153
+ if (!notification?.type) {
154
154
  return null;
155
155
  }
156
- const notificationMessage = (0, exports.createOnChainPushNotificationMessages)(translations)[n.type];
156
+ const notificationMessage = (0, exports.createOnChainPushNotificationMessages)(translations)[notification.type];
157
157
  if (!notificationMessage) {
158
158
  return null;
159
159
  }
@@ -161,18 +161,19 @@ function createOnChainPushNotificationMessage(n, translations) {
161
161
  try {
162
162
  description =
163
163
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
164
- notificationMessage?.getDescription?.(n) ??
164
+ notificationMessage?.getDescription?.(notification) ??
165
165
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
166
- notificationMessage.defaultDescription?.(n) ??
166
+ notificationMessage.defaultDescription?.(notification) ??
167
167
  null;
168
168
  }
169
169
  catch {
170
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
171
- description = notificationMessage.defaultDescription?.(n) ?? null;
170
+ description =
171
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
172
+ notificationMessage.defaultDescription?.(notification) ?? null;
172
173
  }
173
174
  return {
174
175
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
175
- title: notificationMessage?.title?.(n) ?? '', // Ensure title is always a string
176
+ title: notificationMessage?.title?.(notification) ?? '', // Ensure title is always a string
176
177
  description: description ?? '', // Fallback to empty string if null
177
178
  };
178
179
  }
@@ -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;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,EAAE,GAAG,EAAE,CACvB,CAAC,CAAC,sDAAsD,CAAC;YAC3D,cAAc,EAAE,CAAC,CAAC,EAAE,EAAE;gBACpB,MAAM,MAAM,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,EAA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AC,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"]}
1
+ {"version":3,"file":"get-notification-message.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/utils/get-notification-message.ts"],"names":[],"mappings":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AAE,EAAE,kCAAkC;QAClG,WAAW,EAAE,WAAW,IAAI,EAAE,EAAE,mCAAmC;KACpE,CAAC;AACJ,CAAC;AAjCD,oFAiCC","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<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 = getChainSymbol(notification?.payload?.chain_id);\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 = getChainSymbol(notification?.payload?.chain_id);\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 * 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): string | null {\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 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"]}
@@ -31,15 +31,15 @@ type PushNotificationMessage = {
31
31
  description: string;
32
32
  ctaLink?: string;
33
33
  };
34
- type NotificationMessage<N extends Types.INotification> = {
35
- title: (n: N) => string | null;
36
- defaultDescription: (n: N) => string | null;
37
- getDescription?: (n: N) => string | null;
38
- link?: (n: N) => string | null;
34
+ type NotificationMessage<TNotification extends Types.INotification> = {
35
+ title: (notification: TNotification) => string | null;
36
+ defaultDescription: (notification: TNotification) => string | null;
37
+ getDescription?: (notification: TNotification) => string | null;
38
+ link?: (notification: TNotification) => string | null;
39
39
  };
40
40
  type NotificationMessageDict = {
41
- [K in Constants.TRIGGER_TYPES]?: NotificationMessage<Extract<Types.INotification, {
42
- type: K;
41
+ [TriggerType in Constants.TRIGGER_TYPES]?: NotificationMessage<Extract<Types.INotification, {
42
+ type: TriggerType;
43
43
  }>>;
44
44
  };
45
45
  /**
@@ -53,10 +53,10 @@ export declare const createOnChainPushNotificationMessages: (translationKeys: Tr
53
53
  /**
54
54
  * Creates a push notification message based on the given on-chain raw notification.
55
55
  *
56
- * @param n - processed notification.
56
+ * @param notification - processed notification.
57
57
  * @param translations - translates keys into text
58
58
  * @returns The push notification message object, or null if the notification is invalid.
59
59
  */
60
- export declare function createOnChainPushNotificationMessage(n: Types.INotification, translations: TranslationKeys): PushNotificationMessage | null;
60
+ export declare function createOnChainPushNotificationMessage(notification: Types.INotification, translations: TranslationKeys): PushNotificationMessage | null;
61
61
  export {};
62
62
  //# sourceMappingURL=get-notification-message.d.cts.map
@@ -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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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"}
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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oBAC/B,eAAe,KAC/B,uBAwMF,CAAC;AAgBF;;;;;;GAMG;AACH,wBAAgB,oCAAoC,CAClD,YAAY,EAAE,KAAK,CAAC,aAAa,EACjC,YAAY,EAAE,eAAe,GAC5B,uBAAuB,GAAG,IAAI,CA8BhC"}
@@ -31,15 +31,15 @@ type PushNotificationMessage = {
31
31
  description: string;
32
32
  ctaLink?: string;
33
33
  };
34
- type NotificationMessage<N extends Types.INotification> = {
35
- title: (n: N) => string | null;
36
- defaultDescription: (n: N) => string | null;
37
- getDescription?: (n: N) => string | null;
38
- link?: (n: N) => string | null;
34
+ type NotificationMessage<TNotification extends Types.INotification> = {
35
+ title: (notification: TNotification) => string | null;
36
+ defaultDescription: (notification: TNotification) => string | null;
37
+ getDescription?: (notification: TNotification) => string | null;
38
+ link?: (notification: TNotification) => string | null;
39
39
  };
40
40
  type NotificationMessageDict = {
41
- [K in Constants.TRIGGER_TYPES]?: NotificationMessage<Extract<Types.INotification, {
42
- type: K;
41
+ [TriggerType in Constants.TRIGGER_TYPES]?: NotificationMessage<Extract<Types.INotification, {
42
+ type: TriggerType;
43
43
  }>>;
44
44
  };
45
45
  /**
@@ -53,10 +53,10 @@ export declare const createOnChainPushNotificationMessages: (translationKeys: Tr
53
53
  /**
54
54
  * Creates a push notification message based on the given on-chain raw notification.
55
55
  *
56
- * @param n - processed notification.
56
+ * @param notification - processed notification.
57
57
  * @param translations - translates keys into text
58
58
  * @returns The push notification message object, or null if the notification is invalid.
59
59
  */
60
- export declare function createOnChainPushNotificationMessage(n: Types.INotification, translations: TranslationKeys): PushNotificationMessage | null;
60
+ export declare function createOnChainPushNotificationMessage(notification: Types.INotification, translations: TranslationKeys): PushNotificationMessage | null;
61
61
  export {};
62
62
  //# sourceMappingURL=get-notification-message.d.mts.map
@@ -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,E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E,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"}
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,MA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