@rango-dev/widget-embedded 0.42.4-next.1 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +5 -2
  2. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
  3. package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
  4. package/dist/components/NoResult/NoResult.d.ts.map +1 -1
  5. package/dist/components/NoResult/NoResult.types.d.ts +0 -1
  6. package/dist/components/NoResult/NoResult.types.d.ts.map +1 -1
  7. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts.map +1 -1
  8. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts +3 -5
  9. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +1 -1
  10. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts +0 -440
  11. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +1 -1
  12. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts +0 -2
  13. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts.map +1 -1
  14. package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts.map +1 -1
  15. package/dist/components/Slippage/Slippage.d.ts.map +1 -1
  16. package/dist/components/Slippage/Slippage.styles.d.ts +0 -162
  17. package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
  18. package/dist/components/StatefulConnectModal/StatefulConnectModal.d.ts.map +1 -1
  19. package/dist/components/StatefulConnectModal/helpers.d.ts +0 -3
  20. package/dist/components/StatefulConnectModal/helpers.d.ts.map +1 -1
  21. package/dist/components/StatefulConnectModal/index.d.ts +1 -1
  22. package/dist/components/StatefulConnectModal/index.d.ts.map +1 -1
  23. package/dist/components/WalletStatefulConnect/NamespaceListItem.d.ts.map +1 -1
  24. package/dist/components/WalletStatefulConnect/Namespaces.d.ts.map +1 -1
  25. package/dist/components/WalletStatefulConnect/Namespaces.styles.d.ts +3 -805
  26. package/dist/components/WalletStatefulConnect/Namespaces.styles.d.ts.map +1 -1
  27. package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts +8 -11
  28. package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts.map +1 -1
  29. package/dist/components/WalletStatefulConnect/index.d.ts +0 -1
  30. package/dist/components/WalletStatefulConnect/index.d.ts.map +1 -1
  31. package/dist/constants/errors.d.ts.map +1 -1
  32. package/dist/containers/Inputs/Inputs.d.ts.map +1 -1
  33. package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
  34. package/dist/containers/Wallets/Wallets.types.d.ts +3 -5
  35. package/dist/containers/Wallets/Wallets.types.d.ts.map +1 -1
  36. package/dist/containers/Wallets/useUpdates.d.ts +3 -3
  37. package/dist/containers/Wallets/useUpdates.d.ts.map +1 -1
  38. package/dist/hooks/useBootstrap/useBootstrap.d.ts.map +1 -1
  39. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -1
  40. package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts.map +1 -1
  41. package/dist/hooks/useStatefulConnect/useStatefulConnect.state.d.ts +1 -3
  42. package/dist/hooks/useStatefulConnect/useStatefulConnect.state.d.ts.map +1 -1
  43. package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts +2 -11
  44. package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts.map +1 -1
  45. package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.d.ts.map +1 -1
  46. package/dist/hooks/useWalletList.d.ts +2 -2
  47. package/dist/hooks/useWalletList.d.ts.map +1 -1
  48. package/dist/index.d.ts +2 -4
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +2 -2
  51. package/dist/index.js.map +4 -4
  52. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  53. package/dist/pages/Home.d.ts.map +1 -1
  54. package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
  55. package/dist/pages/WalletsPage.d.ts.map +1 -1
  56. package/dist/store/AppStore.d.ts +0 -2
  57. package/dist/store/AppStore.d.ts.map +1 -1
  58. package/dist/store/app.d.ts +0 -2
  59. package/dist/store/app.d.ts.map +1 -1
  60. package/dist/store/quote.d.ts +0 -2
  61. package/dist/store/quote.d.ts.map +1 -1
  62. package/dist/store/slices/settings.d.ts +0 -3
  63. package/dist/store/slices/settings.d.ts.map +1 -1
  64. package/dist/types/quote.d.ts +0 -1
  65. package/dist/types/quote.d.ts.map +1 -1
  66. package/dist/utils/colors.d.ts.map +1 -1
  67. package/dist/utils/numbers.d.ts +0 -1
  68. package/dist/utils/numbers.d.ts.map +1 -1
  69. package/dist/utils/settings.d.ts +1 -2
  70. package/dist/utils/settings.d.ts.map +1 -1
  71. package/dist/utils/wallets.d.ts +1 -9
  72. package/dist/utils/wallets.d.ts.map +1 -1
  73. package/dist/widget-embedded.build.json +1 -1
  74. package/package.json +8 -8
  75. package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +47 -4
  76. package/src/components/ConfirmWalletsModal/WalletList.tsx +19 -35
  77. package/src/components/NoResult/NoResult.tsx +1 -4
  78. package/src/components/NoResult/NoResult.types.ts +0 -1
  79. package/src/components/Quote/Quote.tsx +1 -1
  80. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +4 -29
  81. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts +1 -10
  82. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.tsx +7 -38
  83. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.ts +0 -2
  84. package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +21 -20
  85. package/src/components/Slippage/Slippage.styles.ts +0 -23
  86. package/src/components/Slippage/Slippage.tsx +22 -28
  87. package/src/components/StatefulConnectModal/StatefulConnectModal.tsx +1 -19
  88. package/src/components/StatefulConnectModal/helpers.ts +0 -6
  89. package/src/components/StatefulConnectModal/index.ts +1 -1
  90. package/src/components/WalletStatefulConnect/NamespaceListItem.tsx +33 -14
  91. package/src/components/WalletStatefulConnect/Namespaces.styles.ts +6 -44
  92. package/src/components/WalletStatefulConnect/Namespaces.tsx +7 -12
  93. package/src/components/WalletStatefulConnect/Namespaces.types.tsx +11 -13
  94. package/src/components/WalletStatefulConnect/index.ts +0 -1
  95. package/src/constants/errors.ts +7 -6
  96. package/src/containers/Inputs/Inputs.tsx +0 -2
  97. package/src/containers/Wallets/Wallets.tsx +5 -6
  98. package/src/containers/Wallets/Wallets.types.ts +3 -5
  99. package/src/containers/Wallets/useUpdates.ts +32 -40
  100. package/src/hooks/useBootstrap/useBootstrap.ts +10 -33
  101. package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +0 -1
  102. package/src/hooks/useConfirmSwap/useConfirmSwap.ts +1 -1
  103. package/src/hooks/useStatefulConnect/useStatefulConnect.state.ts +1 -11
  104. package/src/hooks/useStatefulConnect/useStatefulConnect.ts +4 -33
  105. package/src/hooks/useStatefulConnect/useStatefulConnect.types.ts +1 -13
  106. package/src/hooks/useSwapInput.ts +1 -1
  107. package/src/hooks/useSyncUrlAndStore/useSyncUrlAndStore.ts +0 -2
  108. package/src/hooks/useWalletList.ts +3 -3
  109. package/src/index.ts +1 -8
  110. package/src/pages/ConfirmSwapPage.tsx +1 -6
  111. package/src/pages/Home.tsx +12 -61
  112. package/src/pages/LiquiditySourcePage.tsx +3 -5
  113. package/src/pages/WalletsPage.tsx +1 -17
  114. package/src/store/app.ts +0 -1
  115. package/src/store/quote.ts +4 -23
  116. package/src/store/slices/settings.ts +0 -11
  117. package/src/types/quote.ts +1 -4
  118. package/src/utils/colors.ts +10 -3
  119. package/src/utils/numbers.ts +0 -11
  120. package/src/utils/settings.ts +4 -11
  121. package/src/utils/wallets.ts +14 -59
  122. package/dist/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.d.ts +0 -4
  123. package/dist/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.d.ts.map +0 -1
  124. package/dist/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.helpers.d.ts +0 -8
  125. package/dist/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.helpers.d.ts.map +0 -1
  126. package/dist/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.types.d.ts +0 -4
  127. package/dist/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.types.d.ts.map +0 -1
  128. package/dist/components/SwapMetrics/SwapMetrics.constants.d.ts +0 -5
  129. package/dist/components/SwapMetrics/SwapMetrics.constants.d.ts.map +0 -1
  130. package/dist/components/SwapMetrics/SwapMetrics.d.ts +0 -4
  131. package/dist/components/SwapMetrics/SwapMetrics.d.ts.map +0 -1
  132. package/dist/components/SwapMetrics/SwapMetrics.helpers.d.ts +0 -11
  133. package/dist/components/SwapMetrics/SwapMetrics.helpers.d.ts.map +0 -1
  134. package/dist/components/SwapMetrics/SwapMetrics.styles.d.ts +0 -482
  135. package/dist/components/SwapMetrics/SwapMetrics.styles.d.ts.map +0 -1
  136. package/dist/components/SwapMetrics/SwapMetrics.types.d.ts +0 -27
  137. package/dist/components/SwapMetrics/SwapMetrics.types.d.ts.map +0 -1
  138. package/dist/components/SwapMetrics/index.d.ts +0 -2
  139. package/dist/components/SwapMetrics/index.d.ts.map +0 -1
  140. package/dist/components/WalletStatefulConnect/Detached.d.ts +0 -4
  141. package/dist/components/WalletStatefulConnect/Detached.d.ts.map +0 -1
  142. package/dist/components/WalletStatefulConnect/Detached.types.d.ts +0 -8
  143. package/dist/components/WalletStatefulConnect/Detached.types.d.ts.map +0 -1
  144. package/dist/components/WalletStatefulConnect/NamespaceDetachedItem.d.ts +0 -4
  145. package/dist/components/WalletStatefulConnect/NamespaceDetachedItem.d.ts.map +0 -1
  146. package/dist/components/WalletStatefulConnect/NamespaceUnsupportedItem.d.ts +0 -4
  147. package/dist/components/WalletStatefulConnect/NamespaceUnsupportedItem.d.ts.map +0 -1
  148. package/dist/utils/sanitizers.d.ts +0 -27
  149. package/dist/utils/sanitizers.d.ts.map +0 -1
  150. package/dist/utils/sanitizers.test.d.ts +0 -2
  151. package/dist/utils/sanitizers.test.d.ts.map +0 -1
  152. package/dist/utils/validation.d.ts +0 -26
  153. package/dist/utils/validation.d.ts.map +0 -1
  154. package/dist/utils/validation.test.d.ts +0 -2
  155. package/dist/utils/validation.test.d.ts.map +0 -1
  156. package/src/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.helpers.ts +0 -33
  157. package/src/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.tsx +0 -48
  158. package/src/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.types.ts +0 -3
  159. package/src/components/SwapMetrics/SwapMetrics.constants.ts +0 -4
  160. package/src/components/SwapMetrics/SwapMetrics.helpers.ts +0 -76
  161. package/src/components/SwapMetrics/SwapMetrics.styles.ts +0 -32
  162. package/src/components/SwapMetrics/SwapMetrics.tsx +0 -134
  163. package/src/components/SwapMetrics/SwapMetrics.types.ts +0 -26
  164. package/src/components/SwapMetrics/index.ts +0 -1
  165. package/src/components/WalletStatefulConnect/Detached.tsx +0 -53
  166. package/src/components/WalletStatefulConnect/Detached.types.ts +0 -8
  167. package/src/components/WalletStatefulConnect/NamespaceDetachedItem.tsx +0 -177
  168. package/src/components/WalletStatefulConnect/NamespaceUnsupportedItem.tsx +0 -42
  169. package/src/utils/sanitizers.test.ts +0 -122
  170. package/src/utils/sanitizers.ts +0 -41
  171. package/src/utils/validation.test.ts +0 -121
  172. package/src/utils/validation.ts +0 -45
@@ -1,4 +0,0 @@
1
- import type { PropTypes } from './Detached.types';
2
- import React from 'react';
3
- export declare function Detached(props: PropTypes): React.JSX.Element;
4
- //# sourceMappingURL=Detached.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Detached.d.ts","sourceRoot":"","sources":["../../../src/components/WalletStatefulConnect/Detached.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAIlD,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,qBA0CxC"}
@@ -1,8 +0,0 @@
1
- import type { NeedsNamespacesState } from '../../hooks/useStatefulConnect';
2
- import type { Namespace } from '@rango-dev/wallets-core/namespaces/common';
3
- export interface PropTypes {
4
- value: NeedsNamespacesState;
5
- onConfirm: () => void;
6
- selectedNamespaces: Namespace[] | null;
7
- }
8
- //# sourceMappingURL=Detached.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Detached.types.d.ts","sourceRoot":"","sources":["../../../src/components/WalletStatefulConnect/Detached.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAC;AAE3E,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,oBAAoB,CAAC;IAC5B,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,kBAAkB,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;CACxC"}
@@ -1,4 +0,0 @@
1
- import type { NamespaceDetachedItemPropTypes } from './Namespaces.types';
2
- import React from 'react';
3
- export declare const NamespaceDetachedItem: (props: NamespaceDetachedItemPropTypes) => React.JSX.Element;
4
- //# sourceMappingURL=NamespaceDetachedItem.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NamespaceDetachedItem.d.ts","sourceRoot":"","sources":["../../../src/components/WalletStatefulConnect/NamespaceDetachedItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AAczE,OAAO,KAA+C,MAAM,OAAO,CAAC;AAkBpE,eAAO,MAAM,qBAAqB,UACzB,8BAA8B,sBA+ItC,CAAC"}
@@ -1,4 +0,0 @@
1
- import type { NamespaceUnsupportedItemPropTypes } from './Namespaces.types';
2
- import React from 'react';
3
- export declare function NamespaceUnsupportedItem(props: NamespaceUnsupportedItemPropTypes): React.JSX.Element;
4
- //# sourceMappingURL=NamespaceUnsupportedItem.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NamespaceUnsupportedItem.d.ts","sourceRoot":"","sources":["../../../src/components/WalletStatefulConnect/NamespaceUnsupportedItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,oBAAoB,CAAC;AAI5E,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,iCAAiC,qBAwBzC"}
@@ -1,27 +0,0 @@
1
- /**
2
- * Remove leading zeros when followed by another digit.
3
- * @example "000123" → "123"
4
- */
5
- export declare function removeLeadingZeros(input: string): string;
6
- /**
7
- * Ensure a leading zero before a decimal point.
8
- * @example ".45" → "0.45"
9
- */
10
- export declare function ensureLeadingZeroForDecimal(input: string): string;
11
- /**
12
- * Insert commas as thousand separators.
13
- * @example "1234567" → "1,234,567"
14
- */
15
- export declare function formatThousandsWithCommas(input: string): string;
16
- /**
17
- * Replace spaces (one or more) with a single dash.
18
- * @example "a b c" → "a-b-c"
19
- */
20
- export declare function replaceSpacesWithDash(input: string): string;
21
- /**
22
- * Strip any trailing zeros in the fractional part, and remove a dangling decimal point.
23
- * @example "0.0010000" → "0.001"
24
- * @example "10.000" → "10"
25
- */
26
- export declare function stripTrailingZeros(input: string): string;
27
- //# sourceMappingURL=sanitizers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sanitizers.d.ts","sourceRoot":"","sources":["../../src/utils/sanitizers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGxD"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=sanitizers.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sanitizers.test.d.ts","sourceRoot":"","sources":["../../src/utils/sanitizers.test.ts"],"names":[],"mappings":""}
@@ -1,26 +0,0 @@
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 declare function isZeroValue(input: string): boolean;
7
- /**
8
- * Validate currency-style input: up to `maxDecimals` places after the decimal point.
9
- * @param input - string to test, e.g. "0", "10.25"
10
- * @param maxDecimals - maximum digits allowed after the decimal (default: 2)
11
- * @returns true for valid money formats, false otherwise
12
- */
13
- export declare function isValidCurrencyFormat(input: string, maxDecimals?: number): boolean;
14
- /**
15
- * Test if a string is a numeric literal (integers or decimals), allows leading zeros.
16
- * @param input - string to test, e.g. "00.5", "123"
17
- * @returns true when string is numeric, false otherwise
18
- */
19
- export declare function isNumeric(input: string): boolean;
20
- /**
21
- * Detect if a color key name ends with digits (overriding default shades).
22
- * @param key - color key, e.g. "primary", "secondary100"
23
- * @returns true when key has numeric suffix, false otherwise
24
- */
25
- export declare function isColorKeyOverridden(key: string): boolean;
26
- //# sourceMappingURL=validation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,WAGxC;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,WAAW,GAAE,MAAU,GACtB,OAAO,CAKT;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGhD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAGzD"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=validation.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validation.test.d.ts","sourceRoot":"","sources":["../../src/utils/validation.test.ts"],"names":[],"mappings":""}
@@ -1,33 +0,0 @@
1
- import type { AlertInfo } from '../QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers';
2
-
3
- import { i18n } from '@lingui/core';
4
-
5
- import { HIGH_SLIPPAGE, MIN_SLIPPAGE } from '../../constants/swapSettings';
6
-
7
- export type ActionType = AlertInfo['action'] | 'reset-slippage';
8
-
9
- type Alert = Omit<AlertInfo, 'action'> & {
10
- action: ActionType;
11
- };
12
-
13
- export function makeAlerts(slippage: number): Alert | null {
14
- let alertInfo: Alert | null = null;
15
- if (slippage === MIN_SLIPPAGE) {
16
- alertInfo = {
17
- alertType: 'error',
18
- action: 'reset-slippage',
19
- actionButtonTitle: i18n.t('Reset'),
20
- title: i18n.t('Slippage cannot be set lower than 0.01%.'),
21
- };
22
- return alertInfo;
23
- } else if (slippage > HIGH_SLIPPAGE) {
24
- alertInfo = {
25
- alertType: 'warning',
26
- action: 'change-settings',
27
- actionButtonTitle: i18n.t('Change'),
28
- title: i18n.t('Caution, your slippage is high!'),
29
- };
30
- return alertInfo;
31
- }
32
- return null;
33
- }
@@ -1,48 +0,0 @@
1
- import type { ActionType } from './SlippageWarningsAndErrors.helpers';
2
- import type { PropTypes } from './SlippageWarningsAndErrors.types';
3
-
4
- import { Alert, Button } from '@rango-dev/ui';
5
- import React from 'react';
6
-
7
- import { DEFAULT_SLIPPAGE } from '../../constants/swapSettings';
8
- import { useAppStore } from '../../store/AppStore';
9
-
10
- import { makeAlerts } from './SlippageWarningsAndErrors.helpers';
11
-
12
- export function SlippageWarningsAndErrors(props: PropTypes) {
13
- const { slippage, customSlippage, setSlippage, setCustomSlippage } =
14
- useAppStore();
15
- const { onChangeSettings } = props;
16
- const currentSlippage = customSlippage !== null ? customSlippage : slippage;
17
-
18
- const alertInfo = makeAlerts(currentSlippage);
19
-
20
- const onClickActionButton = (action: ActionType) => {
21
- if (action === 'reset-slippage') {
22
- setSlippage(DEFAULT_SLIPPAGE);
23
- setCustomSlippage(null);
24
- } else if (action === 'change-settings') {
25
- onChangeSettings();
26
- }
27
- };
28
-
29
- if (!alertInfo) {
30
- return null;
31
- }
32
- return (
33
- <Alert
34
- title={alertInfo.title}
35
- type={alertInfo.alertType}
36
- variant="alarm"
37
- action={
38
- <Button
39
- id="widget-slippage-warning-error-change-settings-or-reset-slippage-btn"
40
- size="xxsmall"
41
- type={alertInfo.alertType}
42
- onClick={() => onClickActionButton(alertInfo.action)}>
43
- {alertInfo.actionButtonTitle}
44
- </Button>
45
- }
46
- />
47
- );
48
- }
@@ -1,3 +0,0 @@
1
- export interface PropTypes {
2
- onChangeSettings: () => void;
3
- }
@@ -1,4 +0,0 @@
1
- export const USD_FORMAT_DECIMALS = 2;
2
- export const USD_EXCHANGE_MINIMUM = 0.001;
3
- export const SMALL_VALUE_DECIMALS = 14;
4
- export const LARGE_VALUE_MAX_DIGITS = 10;
@@ -1,76 +0,0 @@
1
- import type { SlippageColorParams } from './SwapMetrics.types';
2
-
3
- import BigNumber from 'bignumber.js';
4
-
5
- import { QuoteErrorType, QuoteWarningType } from '../../types';
6
-
7
- import {
8
- LARGE_VALUE_MAX_DIGITS,
9
- SMALL_VALUE_DECIMALS,
10
- USD_EXCHANGE_MINIMUM,
11
- USD_FORMAT_DECIMALS,
12
- } from './SwapMetrics.constants';
13
-
14
- export function getSlippageColor(params: SlippageColorParams) {
15
- const { error, isDarkTheme, warning } = params;
16
- const { quoteError, slippageError } = error;
17
- const { quoteWarning, slippageWarning } = warning;
18
- const hasSlippageError =
19
- !!slippageError ||
20
- quoteError?.type === QuoteErrorType.INSUFFICIENT_SLIPPAGE;
21
- const hasSlippageWarning =
22
- !!slippageWarning ||
23
- quoteWarning?.type === QuoteWarningType.INSUFFICIENT_SLIPPAGE;
24
-
25
- if (hasSlippageError) {
26
- return '$error500';
27
- } else if (hasSlippageWarning) {
28
- return '$warning500';
29
- }
30
- if (isDarkTheme) {
31
- return '$neutral600';
32
- }
33
- return '$neutral700';
34
- }
35
-
36
- export function getUsdExchangeRate(params: {
37
- toTokenUsdPrice: number | null;
38
- fromTokenUsdPrice: number | null;
39
- }) {
40
- const { toTokenUsdPrice, fromTokenUsdPrice } = params;
41
- if (!toTokenUsdPrice || !fromTokenUsdPrice) {
42
- return { rawValue: '0', displayValue: '0' };
43
- }
44
-
45
- const toPrice = new BigNumber(toTokenUsdPrice);
46
- const fromPrice = new BigNumber(fromTokenUsdPrice);
47
- const rawValue = toPrice.dividedBy(fromPrice);
48
- let displayValue: string;
49
-
50
- if (rawValue.isLessThan(1)) {
51
- displayValue = rawValue.toFixed(SMALL_VALUE_DECIMALS);
52
- } else if (rawValue.toFixed(0).length > LARGE_VALUE_MAX_DIGITS) {
53
- displayValue = rawValue.toFixed(0).slice(0, LARGE_VALUE_MAX_DIGITS);
54
- } else {
55
- displayValue = rawValue.toFixed(USD_FORMAT_DECIMALS);
56
- }
57
- return {
58
- displayValue,
59
- rawValue: rawValue.toFixed(),
60
- };
61
- }
62
-
63
- export function formatTokenValueInUsd(
64
- usdExchangeRate: number,
65
- tokenUsdPrice: number
66
- ): string {
67
- const value = new BigNumber(usdExchangeRate).multipliedBy(tokenUsdPrice);
68
- if (value.isLessThan(USD_EXCHANGE_MINIMUM)) {
69
- return '$0';
70
- }
71
- const result = value
72
- .decimalPlaces(USD_FORMAT_DECIMALS, BigNumber.ROUND_DOWN)
73
- .toFormat(USD_FORMAT_DECIMALS);
74
-
75
- return `$${result}`;
76
- }
@@ -1,32 +0,0 @@
1
- import { darkTheme, styled, Typography } from '@rango-dev/ui';
2
-
3
- export const Container = styled('div', {
4
- display: 'flex',
5
- padding: '$4',
6
- justifyContent: 'space-between',
7
- alignItems: 'center',
8
- });
9
-
10
- export const Rate = styled('div', {
11
- display: 'flex',
12
- alignItems: 'center',
13
- gap: '$2',
14
- '& .rate-text': {
15
- color: '$neutral700',
16
- [`.${darkTheme} &`]: {
17
- color: '$neutral700',
18
- },
19
- },
20
- '& ._icon-button': {
21
- transform: 'rotate(90deg)',
22
- width: '$16',
23
- height: '$16',
24
- },
25
- });
26
-
27
- export const TokenName = styled(Typography, {
28
- maxWidth: '$32',
29
- overflow: 'hidden',
30
- textOverflow: 'ellipsis',
31
- whiteSpace: 'nowrap',
32
- });
@@ -1,134 +0,0 @@
1
- import type { PropTypes } from './SwapMetrics.types';
2
-
3
- import { i18n } from '@lingui/core';
4
- import {
5
- IconButton,
6
- ReverseIcon,
7
- Skeleton,
8
- Tooltip,
9
- Typography,
10
- } from '@rango-dev/ui';
11
- import React from 'react';
12
-
13
- import { useTheme } from '../../hooks/useTheme';
14
- import { useAppStore } from '../../store/AppStore';
15
- import { getContainer } from '../../utils/common';
16
- import { getSlippageValidation } from '../../utils/settings';
17
-
18
- import {
19
- formatTokenValueInUsd,
20
- getSlippageColor,
21
- getUsdExchangeRate,
22
- } from './SwapMetrics.helpers';
23
- import { Container, Rate, TokenName } from './SwapMetrics.styles';
24
-
25
- export function SwapMetrics(props: PropTypes) {
26
- const { slippage, customSlippage, quoteTokensRate, changeQuoteTokensRate } =
27
- useAppStore();
28
- const {
29
- quoteError,
30
- quoteWarning,
31
- fromToken: initialFromToken,
32
- toToken: initialToToken,
33
- quote,
34
- loading,
35
- } = props;
36
- const currentSlippage = customSlippage !== null ? customSlippage : slippage;
37
- const { mode } = useTheme({});
38
- const slippageValidation = getSlippageValidation(currentSlippage);
39
- const isDarkTheme = mode === 'dark';
40
- const isDefaultRate = quoteTokensRate === 'default';
41
-
42
- const error = {
43
- quoteError,
44
- slippageError:
45
- slippageValidation?.type === 'error' ? slippageValidation.message : null,
46
- };
47
- const warning = {
48
- quoteWarning,
49
- slippageWarning:
50
- slippageValidation?.type === 'warning'
51
- ? slippageValidation.message
52
- : null,
53
- };
54
-
55
- const sourceToken = quote?.swaps[0].from || initialFromToken;
56
- const destinationToken =
57
- quote?.swaps[quote?.swaps.length - 1].to || initialToToken;
58
-
59
- const fromToken = isDefaultRate ? sourceToken : destinationToken;
60
- const toToken = isDefaultRate ? destinationToken : sourceToken;
61
-
62
- const fromAmount = Number(
63
- isDefaultRate ? quote?.outputAmount : quote?.requestAmount
64
- );
65
- const toAmount = Number(
66
- isDefaultRate ? quote?.requestAmount : quote?.outputAmount
67
- );
68
-
69
- const fromTokenUsdPrice = fromAmount || fromToken.usdPrice;
70
- const toTokenUsdPrice = toAmount || toToken.usdPrice;
71
-
72
- const { rawValue: rawExchangeRate, displayValue: displayExchangeRate } =
73
- getUsdExchangeRate({
74
- toTokenUsdPrice,
75
- fromTokenUsdPrice,
76
- });
77
-
78
- return (
79
- <Container>
80
- <Typography
81
- variant={!!error || !!warning ? 'label' : 'body'}
82
- size={!!error || !!warning ? 'medium' : 'small'}
83
- color={getSlippageColor({ error, warning, isDarkTheme })}>
84
- {i18n.t('Slippage:')} {currentSlippage}%
85
- </Typography>
86
- {loading ? (
87
- <Skeleton height={16} width={104} variant="rounded" />
88
- ) : (
89
- fromTokenUsdPrice &&
90
- toTokenUsdPrice && (
91
- <Rate>
92
- <Typography className="rate-text" variant="body" size="small">
93
- 1
94
- </Typography>
95
- <TokenName className="rate-text" variant="body" size="small">
96
- {toToken.symbol}
97
- </TokenName>
98
- <IconButton
99
- id="widget-home-page-change-rate-button"
100
- onClick={changeQuoteTokensRate}>
101
- <ReverseIcon size={14} color="secondary" />
102
- </IconButton>
103
- <Tooltip
104
- container={getContainer()}
105
- side="top"
106
- sideOffset={4}
107
- content={
108
- <Typography className="rate-text" variant="body" size="small">
109
- {rawExchangeRate}
110
- </Typography>
111
- }>
112
- <Typography className="rate-text" variant="body" size="small">
113
- {displayExchangeRate}
114
- </Typography>
115
- </Tooltip>
116
-
117
- <TokenName className="rate-text" variant="body" size="small">
118
- {fromToken.symbol}
119
- </TokenName>
120
- {fromToken.usdPrice && (
121
- <Typography color="neutral600" variant="body" size="small">
122
- ~
123
- {formatTokenValueInUsd(
124
- Number(rawExchangeRate),
125
- fromToken.usdPrice
126
- )}
127
- </Typography>
128
- )}
129
- </Rate>
130
- )
131
- )}
132
- </Container>
133
- );
134
- }
@@ -1,26 +0,0 @@
1
- import type { QuoteError, QuoteWarning, SelectedQuote } from '../../types';
2
- import type { TokenData } from '../TokenList/TokenList.types';
3
- import type { SwapResultAsset } from 'rango-sdk';
4
-
5
- export interface PropTypes {
6
- quoteError: QuoteError | null;
7
- quoteWarning: QuoteWarning | null;
8
- fromToken: TokenData;
9
- toToken: TokenData;
10
- quote: SelectedQuote | null;
11
- loading: boolean;
12
- }
13
-
14
- export type Tokens = {
15
- to: TokenData | SwapResultAsset;
16
- from: TokenData | SwapResultAsset;
17
- };
18
-
19
- export type SlippageColorParams = {
20
- error: { quoteError: QuoteError | null; slippageError: string | null };
21
- warning: {
22
- quoteWarning: QuoteWarning | null;
23
- slippageWarning: string | null;
24
- };
25
- isDarkTheme: boolean;
26
- };
@@ -1 +0,0 @@
1
- export { SwapMetrics } from './SwapMetrics';
@@ -1,53 +0,0 @@
1
- import type { PropTypes } from './Detached.types';
2
-
3
- import { i18n } from '@lingui/core';
4
- import { Divider, Image, MessageBox } from '@rango-dev/ui';
5
- import React from 'react';
6
-
7
- import { NamespaceDetachedItem } from './NamespaceDetachedItem';
8
- import { NamespaceList, StyledButton } from './Namespaces.styles';
9
- import { NamespaceUnsupportedItem } from './NamespaceUnsupportedItem';
10
-
11
- export function Detached(props: PropTypes) {
12
- const { selectedNamespaces, value } = props;
13
- const { targetWallet } = value;
14
-
15
- return (
16
- <>
17
- <MessageBox
18
- type="info"
19
- title={i18n.t(`Connect {wallet}`, {
20
- wallet: targetWallet.type,
21
- })}
22
- description={i18n.t(
23
- 'This wallet supports multiple chains. Choose which chains you’d like to connect or disconnect.'
24
- )}
25
- icon={<Image src={targetWallet.image} size={45} />}
26
- />
27
- <Divider size={20} />
28
- <NamespaceList>
29
- {targetWallet.needsNamespace?.data.map((namespace, index, array) => (
30
- <React.Fragment key={namespace.id}>
31
- {namespace.unsupported ? (
32
- <NamespaceUnsupportedItem namespace={namespace} />
33
- ) : (
34
- <NamespaceDetachedItem
35
- walletType={targetWallet.type}
36
- namespace={namespace}
37
- initialConnect={selectedNamespaces?.includes(namespace.value)}
38
- />
39
- )}
40
- {index !== array.length - 1 && <Divider size={10} />}
41
- </React.Fragment>
42
- ))}
43
- </NamespaceList>
44
- <Divider size={20} />
45
- <StyledButton
46
- id="widget-name-space-confirm-btn"
47
- type="primary"
48
- onClick={props.onConfirm}>
49
- {i18n.t('Done')}
50
- </StyledButton>
51
- </>
52
- );
53
- }
@@ -1,8 +0,0 @@
1
- import type { NeedsNamespacesState } from '../../hooks/useStatefulConnect';
2
- import type { Namespace } from '@rango-dev/wallets-core/namespaces/common';
3
-
4
- export interface PropTypes {
5
- value: NeedsNamespacesState;
6
- onConfirm: () => void;
7
- selectedNamespaces: Namespace[] | null;
8
- }