@rango-dev/widget-embedded 0.42.3-next.2 → 0.42.3-next.4

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 (99) hide show
  1. package/dist/components/NoResult/NoResult.d.ts.map +1 -1
  2. package/dist/components/NoResult/NoResult.types.d.ts +1 -0
  3. package/dist/components/NoResult/NoResult.types.d.ts.map +1 -1
  4. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts.map +1 -1
  5. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts +5 -3
  6. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +1 -1
  7. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts +440 -0
  8. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +1 -1
  9. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts +2 -0
  10. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts.map +1 -1
  11. package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts.map +1 -1
  12. package/dist/components/Slippage/Slippage.d.ts.map +1 -1
  13. package/dist/components/Slippage/Slippage.styles.d.ts +162 -0
  14. package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
  15. package/dist/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.d.ts +4 -0
  16. package/dist/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.d.ts.map +1 -0
  17. package/dist/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.helpers.d.ts +8 -0
  18. package/dist/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.helpers.d.ts.map +1 -0
  19. package/dist/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.types.d.ts +4 -0
  20. package/dist/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.types.d.ts.map +1 -0
  21. package/dist/components/SwapMetrics/SwapMetrics.constants.d.ts +5 -0
  22. package/dist/components/SwapMetrics/SwapMetrics.constants.d.ts.map +1 -0
  23. package/dist/components/SwapMetrics/SwapMetrics.d.ts +4 -0
  24. package/dist/components/SwapMetrics/SwapMetrics.d.ts.map +1 -0
  25. package/dist/components/SwapMetrics/SwapMetrics.helpers.d.ts +11 -0
  26. package/dist/components/SwapMetrics/SwapMetrics.helpers.d.ts.map +1 -0
  27. package/dist/components/SwapMetrics/SwapMetrics.styles.d.ts +482 -0
  28. package/dist/components/SwapMetrics/SwapMetrics.styles.d.ts.map +1 -0
  29. package/dist/components/SwapMetrics/SwapMetrics.types.d.ts +27 -0
  30. package/dist/components/SwapMetrics/SwapMetrics.types.d.ts.map +1 -0
  31. package/dist/components/SwapMetrics/index.d.ts +2 -0
  32. package/dist/components/SwapMetrics/index.d.ts.map +1 -0
  33. package/dist/containers/Inputs/Inputs.d.ts.map +1 -1
  34. package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.d.ts.map +1 -1
  35. package/dist/index.js +2 -2
  36. package/dist/index.js.map +4 -4
  37. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  38. package/dist/pages/Home.d.ts.map +1 -1
  39. package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
  40. package/dist/store/AppStore.d.ts +2 -0
  41. package/dist/store/AppStore.d.ts.map +1 -1
  42. package/dist/store/app.d.ts +2 -0
  43. package/dist/store/app.d.ts.map +1 -1
  44. package/dist/store/quote.d.ts +2 -0
  45. package/dist/store/quote.d.ts.map +1 -1
  46. package/dist/store/slices/settings.d.ts +3 -0
  47. package/dist/store/slices/settings.d.ts.map +1 -1
  48. package/dist/utils/colors.d.ts.map +1 -1
  49. package/dist/utils/numbers.d.ts +1 -0
  50. package/dist/utils/numbers.d.ts.map +1 -1
  51. package/dist/utils/sanitizers.d.ts +27 -0
  52. package/dist/utils/sanitizers.d.ts.map +1 -0
  53. package/dist/utils/sanitizers.test.d.ts +2 -0
  54. package/dist/utils/sanitizers.test.d.ts.map +1 -0
  55. package/dist/utils/settings.d.ts +2 -1
  56. package/dist/utils/settings.d.ts.map +1 -1
  57. package/dist/utils/validation.d.ts +26 -0
  58. package/dist/utils/validation.d.ts.map +1 -0
  59. package/dist/utils/validation.test.d.ts +2 -0
  60. package/dist/utils/validation.test.d.ts.map +1 -0
  61. package/dist/utils/wallets.d.ts.map +1 -1
  62. package/dist/widget-embedded.build.json +1 -1
  63. package/package.json +3 -3
  64. package/src/components/NoResult/NoResult.tsx +4 -1
  65. package/src/components/NoResult/NoResult.types.ts +1 -0
  66. package/src/components/Quote/Quote.tsx +1 -1
  67. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +29 -4
  68. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts +10 -1
  69. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.tsx +38 -7
  70. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.ts +2 -0
  71. package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +20 -21
  72. package/src/components/Slippage/Slippage.styles.ts +23 -0
  73. package/src/components/Slippage/Slippage.tsx +28 -22
  74. package/src/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.helpers.ts +33 -0
  75. package/src/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.tsx +48 -0
  76. package/src/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.types.ts +3 -0
  77. package/src/components/SwapMetrics/SwapMetrics.constants.ts +4 -0
  78. package/src/components/SwapMetrics/SwapMetrics.helpers.ts +76 -0
  79. package/src/components/SwapMetrics/SwapMetrics.styles.ts +32 -0
  80. package/src/components/SwapMetrics/SwapMetrics.tsx +134 -0
  81. package/src/components/SwapMetrics/SwapMetrics.types.ts +26 -0
  82. package/src/components/SwapMetrics/index.ts +1 -0
  83. package/src/containers/Inputs/Inputs.tsx +2 -0
  84. package/src/hooks/useSwapInput.ts +1 -1
  85. package/src/hooks/useSyncUrlAndStore/useSyncUrlAndStore.ts +2 -0
  86. package/src/pages/ConfirmSwapPage.tsx +6 -1
  87. package/src/pages/Home.tsx +61 -12
  88. package/src/pages/LiquiditySourcePage.tsx +5 -3
  89. package/src/store/app.ts +1 -0
  90. package/src/store/quote.ts +23 -4
  91. package/src/store/slices/settings.ts +11 -0
  92. package/src/utils/colors.ts +3 -10
  93. package/src/utils/numbers.ts +11 -0
  94. package/src/utils/sanitizers.test.ts +122 -0
  95. package/src/utils/sanitizers.ts +41 -0
  96. package/src/utils/settings.ts +11 -4
  97. package/src/utils/validation.test.ts +121 -0
  98. package/src/utils/validation.ts +45 -0
  99. package/src/utils/wallets.ts +2 -1
@@ -0,0 +1,122 @@
1
+ import { faker } from '@faker-js/faker';
2
+ import { describe, expect, test } from 'vitest';
3
+
4
+ import {
5
+ ensureLeadingZeroForDecimal,
6
+ formatThousandsWithCommas,
7
+ removeLeadingZeros,
8
+ replaceSpacesWithDash,
9
+ stripTrailingZeros,
10
+ } from './sanitizers';
11
+
12
+ const WORD_COUNT = 5;
13
+ const FAKER_SEED = 12;
14
+ const LONG_NUMBER_LENGTH = 50;
15
+ faker.seed(FAKER_SEED);
16
+
17
+ describe('check sanitization behaviors', () => {
18
+ describe('check leading zero removal', () => {
19
+ test('should remove zeros at start before digits', () => {
20
+ expect(removeLeadingZeros('000123')).toBe('123');
21
+ expect(removeLeadingZeros('00123')).toBe('123');
22
+ });
23
+
24
+ test('should preserve lone zero or non-digit prefixes', () => {
25
+ expect(removeLeadingZeros('0')).toBe('0');
26
+ expect(removeLeadingZeros('0000')).toBe('0');
27
+ expect(removeLeadingZeros('00.1')).toBe('0.1');
28
+ expect(removeLeadingZeros('00a')).toBe('0a');
29
+ });
30
+
31
+ test('should leave strings with no leading zeros unchanged', () => {
32
+ const val = faker.number.int({ min: 1, max: 999 }).toString();
33
+ expect(removeLeadingZeros(val)).toBe(val);
34
+ });
35
+ });
36
+
37
+ describe('check decimal leading zero insertion', () => {
38
+ test('should add a zero before lone decimal points', () => {
39
+ expect(ensureLeadingZeroForDecimal('.5')).toBe('0.5');
40
+ expect(ensureLeadingZeroForDecimal('.000')).toBe('0.000');
41
+ expect(ensureLeadingZeroForDecimal('0.001')).toBe('0.001');
42
+ expect(ensureLeadingZeroForDecimal('000.000')).toBe('000.000');
43
+ });
44
+
45
+ test('should not alter other inputs', () => {
46
+ expect(ensureLeadingZeroForDecimal('0.5')).toBe('0.5');
47
+ expect(ensureLeadingZeroForDecimal('2.')).toBe('2.');
48
+ expect(ensureLeadingZeroForDecimal('')).toBe('');
49
+ });
50
+ });
51
+
52
+ describe('check thousand separator formatting', () => {
53
+ test('should insert commas every three digits for 4–6 digit numbers', () => {
54
+ expect(formatThousandsWithCommas('1000')).toBe('1,000');
55
+ expect(formatThousandsWithCommas('12345')).toBe('12,345');
56
+ expect(formatThousandsWithCommas('123456')).toBe('123,456');
57
+ });
58
+
59
+ test('should handle large numbers correctly', () => {
60
+ expect(formatThousandsWithCommas('1234567')).toBe('1,234,567');
61
+ expect(formatThousandsWithCommas('1234567890')).toBe('1,234,567,890');
62
+ });
63
+
64
+ test('should not add commas for numbers below 1000', () => {
65
+ expect(formatThousandsWithCommas('0')).toBe('0');
66
+ expect(formatThousandsWithCommas('999')).toBe('999');
67
+ });
68
+ });
69
+
70
+ describe('check space-to-dash replacement', () => {
71
+ test('should convert any spaces to a single dash', () => {
72
+ const words = faker.lorem.words(WORD_COUNT).split(' ');
73
+ const spaced = words.join(' ');
74
+ expect(replaceSpacesWithDash(spaced)).toBe(words.join('-'));
75
+ });
76
+
77
+ test('should convert tabs and newlines into dashes', () => {
78
+ const words = faker.lorem.words(WORD_COUNT).split(' ');
79
+ expect(replaceSpacesWithDash(words.join('\t'))).toBe(words.join('-'));
80
+ expect(replaceSpacesWithDash(words.join('\n'))).toBe(words.join('-'));
81
+ });
82
+
83
+ test('should handle empty or single-word strings', () => {
84
+ expect(replaceSpacesWithDash('')).toBe('');
85
+ expect(replaceSpacesWithDash('nospace')).toBe('nospace');
86
+ });
87
+ });
88
+
89
+ describe('check trailing zero stripping', () => {
90
+ test('should trim only zeros after last non-zero digit', () => {
91
+ expect(stripTrailingZeros('0.0010000')).toBe('0.001');
92
+ expect(stripTrailingZeros('123.45000')).toBe('123.45');
93
+ expect(stripTrailingZeros('5.1000')).toBe('5.1');
94
+ });
95
+
96
+ test('should remove entire fractional part if all zeros', () => {
97
+ expect(stripTrailingZeros('10.000')).toBe('10');
98
+ expect(stripTrailingZeros('0.000')).toBe('0');
99
+ });
100
+
101
+ test('should leave inputs without trailing zeros untouched', () => {
102
+ expect(stripTrailingZeros('42')).toBe('42');
103
+ expect(stripTrailingZeros('7.89')).toBe('7.89');
104
+ expect(stripTrailingZeros('0.123')).toBe('0.123');
105
+ });
106
+
107
+ test('edge: very long fractional zeros', () => {
108
+ const long =
109
+ '0.' +
110
+ '0'.repeat(LONG_NUMBER_LENGTH) +
111
+ '1' +
112
+ '0'.repeat(LONG_NUMBER_LENGTH);
113
+ expect(stripTrailingZeros(long)).toBe(
114
+ '0.' + '0'.repeat(LONG_NUMBER_LENGTH) + '1'
115
+ );
116
+ });
117
+
118
+ test('edge: no decimal point', () => {
119
+ expect(stripTrailingZeros('1000')).toBe('1000');
120
+ });
121
+ });
122
+ });
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Remove leading zeros when followed by another digit.
3
+ * @example "000123" → "123"
4
+ */
5
+ export function removeLeadingZeros(input: string): string {
6
+ return input.replace(/^0+(?=\d)/g, '');
7
+ }
8
+
9
+ /**
10
+ * Ensure a leading zero before a decimal point.
11
+ * @example ".45" → "0.45"
12
+ */
13
+ export function ensureLeadingZeroForDecimal(input: string): string {
14
+ return input.replace(/^\.(\d+)/, '0.$1');
15
+ }
16
+
17
+ /**
18
+ * Insert commas as thousand separators.
19
+ * @example "1234567" → "1,234,567"
20
+ */
21
+ export function formatThousandsWithCommas(input: string): string {
22
+ return input.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
23
+ }
24
+
25
+ /**
26
+ * Replace spaces (one or more) with a single dash.
27
+ * @example "a b c" → "a-b-c"
28
+ */
29
+ export function replaceSpacesWithDash(input: string): string {
30
+ return input.replace(/\s+/g, '-');
31
+ }
32
+
33
+ /**
34
+ * Strip any trailing zeros in the fractional part, and remove a dangling decimal point.
35
+ * @example "0.0010000" → "0.001"
36
+ * @example "10.000" → "10"
37
+ */
38
+ export function stripTrailingZeros(input: string): string {
39
+ const s = input.replace(/(\.\d*?[1-9])0+$/, '$1');
40
+ return s.replace(/\.0+$/, '');
41
+ }
@@ -1,4 +1,4 @@
1
- import type { Features, Routing } from '../types';
1
+ import type { Features, HighSlippageWarning, Routing } from '../types';
2
2
  import type { SwapperMeta, SwapperType, Token } from 'rango-sdk';
3
3
 
4
4
  import { i18n } from '@lingui/core';
@@ -8,6 +8,7 @@ import {
8
8
  MAX_SLIPPAGE,
9
9
  MIN_SLIPPAGE,
10
10
  } from '../constants/swapSettings';
11
+ import { QuoteWarningType } from '../types';
11
12
 
12
13
  import { removeDuplicateFrom } from './common';
13
14
 
@@ -96,9 +97,11 @@ export const addCustomTokensToSupportedTokens = (
96
97
  : supportedTokens.concat(customTokens);
97
98
  };
98
99
 
99
- export function getSlippageValidation(
100
- slippage: number
101
- ): { type: 'error' | 'warning'; message: string } | null {
100
+ export function getSlippageValidation(slippage: number): {
101
+ type: 'error' | 'warning';
102
+ message: string;
103
+ quoteValidation?: HighSlippageWarning;
104
+ } | null {
102
105
  if (slippage == MIN_SLIPPAGE) {
103
106
  return {
104
107
  type: 'error',
@@ -110,6 +113,10 @@ export function getSlippageValidation(
110
113
  message: i18n.t(
111
114
  'Your transaction is at risk of being frontrun due to high slippage tolerance.'
112
115
  ),
116
+ quoteValidation: {
117
+ type: QuoteWarningType.HIGH_SLIPPAGE,
118
+ slippage: slippage.toString(),
119
+ },
113
120
  };
114
121
  }
115
122
 
@@ -0,0 +1,121 @@
1
+ import { faker } from '@faker-js/faker';
2
+ import { describe, expect, test } from 'vitest';
3
+
4
+ import {
5
+ isColorKeyOverridden,
6
+ isNumeric,
7
+ isValidCurrencyFormat,
8
+ isZeroValue,
9
+ } from './validation';
10
+
11
+ const FAKER_SEED = 14;
12
+ const THREE_MAX_DECIMAL = 3;
13
+ const FOUR_MAX_DECIMAL = 4;
14
+ const SMALL_INT = { min: 1, max: 9 };
15
+ const FLOAT_OPTS = { min: 0, max: 100, precision: 0.01 };
16
+ faker.seed(FAKER_SEED);
17
+
18
+ describe('check validation behaviors', () => {
19
+ describe('check zero-value detection', () => {
20
+ test('should detect strings of zeros', () => {
21
+ expect(isZeroValue('0')).toBe(true);
22
+ expect(isZeroValue('000')).toBe(true);
23
+ expect(isZeroValue('000.00')).toBe(true);
24
+ });
25
+ test('should reject non-zero or fractional values', () => {
26
+ expect(isZeroValue('0.0001')).toBe(false);
27
+ expect(isZeroValue('000.0001')).toBe(false);
28
+ expect(isZeroValue(faker.number.int(SMALL_INT).toString())).toBe(false);
29
+ });
30
+ test('should return false for empty or non-numeric', () => {
31
+ expect(isZeroValue('')).toBe(false);
32
+ expect(isZeroValue('abc')).toBe(false);
33
+ });
34
+ });
35
+
36
+ describe('check currency format validation', () => {
37
+ // Default behavior (maxDecimals = 2)
38
+ test('should accepts integers and up to 2 decimals', () => {
39
+ expect(isValidCurrencyFormat('0')).toBe(true);
40
+ expect(isValidCurrencyFormat('10.2')).toBe(true);
41
+ expect(isValidCurrencyFormat('10.25')).toBe(true);
42
+ });
43
+
44
+ test('should rejects more than 2 decimals', () => {
45
+ expect(isValidCurrencyFormat('1.234')).toBe(false);
46
+ expect(isValidCurrencyFormat('0.001')).toBe(false);
47
+ });
48
+
49
+ test('should rejects leading zero on non-zero integer', () => {
50
+ expect(isValidCurrencyFormat('01')).toBe(false);
51
+ expect(isValidCurrencyFormat('00.5')).toBe(false);
52
+ });
53
+
54
+ test('should rejects non-numeric and malformed strings', () => {
55
+ expect(isValidCurrencyFormat('')).toBe(false);
56
+ expect(isValidCurrencyFormat('.5')).toBe(false);
57
+ expect(isValidCurrencyFormat('1.2.3')).toBe(false);
58
+ expect(isValidCurrencyFormat('abc')).toBe(false);
59
+ expect(isValidCurrencyFormat('0.1a')).toBe(false);
60
+ });
61
+
62
+ test('should allows up to specified decimals', () => {
63
+ expect(isValidCurrencyFormat('1.234', THREE_MAX_DECIMAL)).toBe(true);
64
+ expect(isValidCurrencyFormat('0.1234', FOUR_MAX_DECIMAL)).toBe(true);
65
+ });
66
+
67
+ test('should rejects if decimals exceed custom limit', () => {
68
+ expect(isValidCurrencyFormat('2.1234', THREE_MAX_DECIMAL)).toBe(false);
69
+ expect(isValidCurrencyFormat('0.12345', FOUR_MAX_DECIMAL)).toBe(false);
70
+ });
71
+
72
+ test('should rejects trailing dot', () => {
73
+ expect(isValidCurrencyFormat('10.')).toBe(false);
74
+ });
75
+
76
+ test('should handles zero with custom decimals edge', () => {
77
+ expect(isValidCurrencyFormat('0.0', 1)).toBe(true);
78
+ expect(isValidCurrencyFormat('0.00', 1)).toBe(false);
79
+ });
80
+
81
+ test('check large values within limits', () => {
82
+ expect(isValidCurrencyFormat('1234567890.12')).toBe(true);
83
+ expect(isValidCurrencyFormat('1234567890.123')).toBe(false);
84
+ });
85
+ });
86
+
87
+ describe('check numeric string validation', () => {
88
+ test('should accept integers and decimals', () => {
89
+ expect(isNumeric('0')).toBe(true);
90
+ expect(isNumeric('00.1')).toBe(true);
91
+ expect(isNumeric('123.456')).toBe(true);
92
+ expect(isNumeric(faker.number.float(FLOAT_OPTS).toString())).toBe(true);
93
+ });
94
+ test('should reject leading dot or letters', () => {
95
+ expect(isNumeric('.5')).toBe(false);
96
+ expect(isNumeric('abc')).toBe(false);
97
+ expect(isNumeric('1.2.3')).toBe(false);
98
+ });
99
+ test('should reject empty string', () => {
100
+ expect(isNumeric('')).toBe(false);
101
+ });
102
+ });
103
+
104
+ describe('check color key override detection', () => {
105
+ test('should detect numeric suffix keys', () => {
106
+ expect(isColorKeyOverridden('primary550')).toBe(true);
107
+ expect(isColorKeyOverridden('secondary100')).toBe(true);
108
+ expect(
109
+ isColorKeyOverridden(
110
+ faker.word.sample() +
111
+ faker.number.int({ min: 1, max: 999 }).toString()
112
+ )
113
+ ).toBe(true);
114
+ });
115
+ test('should reject keys without digits', () => {
116
+ expect(isColorKeyOverridden('primary')).toBe(false);
117
+ expect(isColorKeyOverridden('colorKey')).toBe(false);
118
+ expect(isColorKeyOverridden('')).toBe(false);
119
+ });
120
+ });
121
+ });
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Check if a string is composed only of zeros, optionally with decimal zeros.
3
+ * @param input - string to test, e.g. "0", "000.00"
4
+ * @returns true when input represents zero, otherwise false
5
+ */
6
+ export function isZeroValue(input: string) {
7
+ const zeroPattern = /^0+(?:\.0+)?$/;
8
+ return zeroPattern.test(input);
9
+ }
10
+
11
+ /**
12
+ * Validate currency-style input: up to `maxDecimals` places after the decimal point.
13
+ * @param input - string to test, e.g. "0", "10.25"
14
+ * @param maxDecimals - maximum digits allowed after the decimal (default: 2)
15
+ * @returns true for valid money formats, false otherwise
16
+ */
17
+ export function isValidCurrencyFormat(
18
+ input: string,
19
+ maxDecimals: number = 2
20
+ ): boolean {
21
+ // construct pattern like ^(?:0|[1-9]\d*)(?:\.\d{1,2})?$
22
+ const pattern = `^(?:0|[1-9]\\d*)(?:\\.\\d{1,${maxDecimals}})?$`;
23
+ const regex = new RegExp(pattern);
24
+ return regex.test(input);
25
+ }
26
+
27
+ /**
28
+ * Test if a string is a numeric literal (integers or decimals), allows leading zeros.
29
+ * @param input - string to test, e.g. "00.5", "123"
30
+ * @returns true when string is numeric, false otherwise
31
+ */
32
+ export function isNumeric(input: string): boolean {
33
+ const numericPattern = /^\d+(?:\.\d+)?$/;
34
+ return numericPattern.test(input);
35
+ }
36
+
37
+ /**
38
+ * Detect if a color key name ends with digits (overriding default shades).
39
+ * @param key - color key, e.g. "primary", "secondary100"
40
+ * @returns true when key has numeric suffix, false otherwise
41
+ */
42
+ export function isColorKeyOverridden(key: string): boolean {
43
+ const overridePattern = /\d+$/;
44
+ return overridePattern.test(key);
45
+ }
@@ -41,6 +41,7 @@ import { EXCLUDED_WALLETS } from '../constants/wallets';
41
41
 
42
42
  import { isBlockchainTypeInCategory, removeDuplicateFrom } from './common';
43
43
  import { numberToString } from './numbers';
44
+ import { formatThousandsWithCommas } from './sanitizers';
44
45
 
45
46
  export type ExtendedModalWalletInfo = WalletInfoWithExtra &
46
47
  Pick<ExtendedWalletInfo, 'properties' | 'isHub'>;
@@ -295,7 +296,7 @@ export const calculateWalletUsdValue = (balances: BalanceState) => {
295
296
 
296
297
  function numberWithThousandSeparator(number: string | number): string {
297
298
  const parts = number.toString().split('.');
298
- parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
299
+ parts[0] = formatThousandsWithCommas(parts[0]);
299
300
  return parts.join('.');
300
301
  }
301
302