@lifi/widget 1.10.3 → 1.11.1

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 (201) hide show
  1. package/App.js +59 -11
  2. package/AppDrawer.js +1 -1
  3. package/AppDrawer.style.d.ts +1 -1
  4. package/AppDrawer.style.js +0 -1
  5. package/AppProvider.d.ts +1 -0
  6. package/AppProvider.js +5 -2
  7. package/components/AppContainer.d.ts +10 -0
  8. package/components/AppContainer.js +4 -7
  9. package/components/Card/Card.d.ts +11 -5
  10. package/components/Card/Card.js +29 -5
  11. package/components/Card/index.d.ts +0 -1
  12. package/components/Card/index.js +0 -1
  13. package/components/Dialog.d.ts +3 -0
  14. package/components/Dialog.js +23 -0
  15. package/components/GasSufficiencyMessage/GasSufficiencyMessage.d.ts +6 -0
  16. package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +41 -0
  17. package/components/{InsufficientGasOrFundsMessage/InsufficientGasOrFundsMessage.style.d.ts → GasSufficiencyMessage/GasSufficiencyMessage.style.d.ts} +0 -0
  18. package/components/{InsufficientGasOrFundsMessage/InsufficientGasOrFundsMessage.style.js → GasSufficiencyMessage/GasSufficiencyMessage.style.js} +1 -0
  19. package/components/GasSufficiencyMessage/index.d.ts +1 -0
  20. package/components/GasSufficiencyMessage/index.js +1 -0
  21. package/components/Header/Header.js +5 -6
  22. package/components/Header/Header.style.js +2 -1
  23. package/components/Header/NavigationHeader.js +28 -22
  24. package/components/Header/WalletHeader.js +4 -4
  25. package/components/Header/index.d.ts +1 -0
  26. package/components/Header/index.js +1 -0
  27. package/components/Header/types.d.ts +8 -0
  28. package/components/Header/types.js +1 -0
  29. package/components/Header/useHeaderActionStore.d.ts +6 -0
  30. package/components/Header/useHeaderActionStore.js +19 -0
  31. package/components/PoweredBy/PoweredBy.js +0 -1
  32. package/components/ProgressToNextUpdate/ProgressToNextUpdate.js +14 -2
  33. package/components/ReverseTokensButton/ReverseTokensButton.js +5 -7
  34. package/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +1 -1
  35. package/components/ReverseTokensButton/ReverseTokensButton.style.js +4 -2
  36. package/components/SelectTokenButton/SelectTokenButton.js +9 -7
  37. package/components/SelectTokenButton/SelectTokenButton.style.d.ts +3 -10
  38. package/components/SelectTokenButton/SelectTokenButton.style.js +0 -7
  39. package/components/SmallAvatar.d.ts +16 -0
  40. package/components/SmallAvatar.js +8 -0
  41. package/{pages/SwapPage → components/Step}/CircularProgress.d.ts +0 -0
  42. package/{pages/SwapPage → components/Step}/CircularProgress.js +0 -0
  43. package/{pages/SwapPage → components/Step}/CircularProgress.style.d.ts +0 -0
  44. package/{pages/SwapPage → components/Step}/CircularProgress.style.js +0 -0
  45. package/components/Step/Step.d.ts +7 -0
  46. package/{pages/SwapPage/StepItem.js → components/Step/Step.js} +6 -6
  47. package/{pages/SwapPage/ExecutionItem.d.ts → components/Step/StepProcess.d.ts} +1 -1
  48. package/{pages/SwapPage/ExecutionItem.js → components/Step/StepProcess.js} +2 -2
  49. package/{pages/SwapPage/ExecutionItem.style.d.ts → components/Step/StepProcess.style.d.ts} +1 -1
  50. package/{pages/SwapPage/ExecutionItem.style.js → components/Step/StepProcess.style.js} +0 -0
  51. package/{pages/SwapPage → components/Step}/StepTimer.d.ts +0 -0
  52. package/{pages/SwapPage → components/Step}/StepTimer.js +0 -0
  53. package/components/Step/index.d.ts +1 -0
  54. package/components/Step/index.js +1 -0
  55. package/components/Step/utils.d.ts +6 -0
  56. package/components/Step/utils.js +89 -0
  57. package/components/StepActions/StepActions.js +17 -7
  58. package/components/StepActions/StepActions.style.js +2 -2
  59. package/{pages/SwapPage → components/StepDivider}/StepDivider.d.ts +0 -0
  60. package/{pages/SwapPage → components/StepDivider}/StepDivider.js +0 -0
  61. package/{pages/SwapPage → components/StepDivider}/StepDivider.style.d.ts +0 -0
  62. package/{pages/SwapPage → components/StepDivider}/StepDivider.style.js +0 -0
  63. package/components/StepDivider/index.d.ts +1 -0
  64. package/components/StepDivider/index.js +1 -0
  65. package/components/SwapButton/SwapButton.js +9 -12
  66. package/components/SwapButton/SwapButton.style.d.ts +1 -1
  67. package/components/SwapButton/SwapButton.style.js +1 -5
  68. package/components/SwapButton/types.d.ts +2 -0
  69. package/components/SwapInProgress/SwapInProgress.js +9 -6
  70. package/components/SwapInProgress/SwapInProgress.style.d.ts +9 -21
  71. package/components/SwapInProgress/SwapInProgress.style.js +5 -6
  72. package/components/SwapInput/FormPriceHelperText.js +1 -1
  73. package/components/SwapInput/SwapInput.js +4 -5
  74. package/components/SwapInput/SwapInputAdornment.style.d.ts +1 -1
  75. package/components/SwapInput/SwapInputAdornment.style.js +0 -2
  76. package/components/SwapRouteCard/SwapRouteCard.js +15 -15
  77. package/components/SwapRouteCard/SwapRouteCard.style.d.ts +0 -20
  78. package/components/SwapRouteCard/SwapRouteCard.style.js +7 -54
  79. package/components/SwapRouteCard/SwapRouteCardSkeleton.js +6 -10
  80. package/components/SwapRouteCard/SwapRouteNotFoundCard.js +3 -3
  81. package/components/SwapRouteCard/types.d.ts +0 -3
  82. package/components/{StepToken.d.ts → Token/Token.d.ts} +2 -1
  83. package/components/Token/Token.js +31 -0
  84. package/components/Token/Token.style.d.ts +24 -0
  85. package/components/Token/Token.style.js +31 -0
  86. package/components/Token/index.d.ts +2 -0
  87. package/components/Token/index.js +2 -0
  88. package/components/TokenAvatar/TokenAvatar.d.ts +7 -0
  89. package/components/TokenAvatar/TokenAvatar.js +8 -0
  90. package/components/TokenAvatar/TokenAvatar.style.d.ts +1 -0
  91. package/components/TokenAvatar/TokenAvatar.style.js +16 -0
  92. package/components/TokenAvatar/index.d.ts +2 -0
  93. package/components/TokenAvatar/index.js +2 -0
  94. package/components/TokenList/TokenList.js +2 -2
  95. package/components/TokenList/TokenList.style.js +1 -1
  96. package/components/TokenList/TokenListItem.d.ts +1 -0
  97. package/components/TokenList/TokenListItem.js +13 -7
  98. package/components/TokenList/types.d.ts +1 -0
  99. package/config/queryClient.d.ts +1 -1
  100. package/config/queryClient.js +1 -1
  101. package/config/theme.js +14 -1
  102. package/config/version.d.ts +1 -1
  103. package/config/version.js +1 -1
  104. package/hooks/index.d.ts +1 -1
  105. package/hooks/index.js +1 -1
  106. package/hooks/useChains.d.ts +8 -8
  107. package/hooks/useChains.js +1 -1
  108. package/hooks/useContentHeight.js +1 -1
  109. package/hooks/useGasSufficiency.d.ts +15 -0
  110. package/hooks/useGasSufficiency.js +91 -0
  111. package/hooks/useRouteExecution.d.ts +3 -3
  112. package/hooks/useRouteExecution.js +23 -19
  113. package/hooks/useScrollableContainer.js +1 -1
  114. package/hooks/useSwapRoutes.d.ts +1 -1
  115. package/hooks/useSwapRoutes.js +2 -14
  116. package/hooks/useTelemetry.js +3 -1
  117. package/hooks/useTokenBalance.js +5 -5
  118. package/hooks/useTokenBalances.d.ts +2 -2
  119. package/hooks/useTokenBalances.js +8 -10
  120. package/hooks/useTokens.js +1 -1
  121. package/hooks/useTools.d.ts +10 -1
  122. package/hooks/useTools.js +13 -3
  123. package/i18n/en/translation.json +18 -9
  124. package/i18n/index.d.ts +12 -3
  125. package/icons/LiFiToolLogo.svg +6 -0
  126. package/package.json +9 -9
  127. package/pages/MainPage/MainPage.js +2 -3
  128. package/pages/MainPage/MainSwapButton.js +6 -7
  129. package/{components/SwapRoutes → pages/MainPage}/SwapRoutes.d.ts +0 -0
  130. package/pages/MainPage/SwapRoutes.js +36 -0
  131. package/{components/SwapRoutes → pages/MainPage}/SwapRoutes.style.d.ts +0 -0
  132. package/{components/SwapRoutes → pages/MainPage}/SwapRoutes.style.js +4 -0
  133. package/pages/SelectTokenPage/ChainSelect.js +2 -2
  134. package/pages/SelectTokenPage/SearchTokenInput.js +2 -2
  135. package/pages/SelectWalletPage/SelectWalletPage.js +4 -23
  136. package/pages/SelectWalletPage/SelectWalletPage.style.js +1 -1
  137. package/pages/SettingsPage/AdvancedPreferences.js +1 -1
  138. package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
  139. package/pages/SettingsPage/EnabledBridgesSelect.js +7 -4
  140. package/pages/SettingsPage/EnabledExchangesSelect.js +7 -4
  141. package/pages/SettingsPage/GasPriceSelect.js +2 -2
  142. package/pages/SettingsPage/RoutePrioritySelect.js +2 -2
  143. package/pages/SettingsPage/SlippageInput.js +3 -3
  144. package/pages/SwapDetailsPage/SwapDetailsPage.d.ts +2 -0
  145. package/pages/SwapDetailsPage/SwapDetailsPage.js +62 -0
  146. package/pages/SwapDetailsPage/SwapDetailsPage.style.d.ts +11 -0
  147. package/pages/SwapDetailsPage/SwapDetailsPage.style.js +5 -0
  148. package/pages/SwapDetailsPage/index.d.ts +1 -0
  149. package/pages/SwapDetailsPage/index.js +1 -0
  150. package/pages/SwapHistoryPage/SwapHistoryEmpty.d.ts +2 -0
  151. package/pages/SwapHistoryPage/SwapHistoryEmpty.js +14 -0
  152. package/pages/SwapHistoryPage/SwapHistoryItem.d.ts +5 -0
  153. package/pages/SwapHistoryPage/SwapHistoryItem.js +23 -0
  154. package/pages/SwapHistoryPage/SwapHistoryPage.d.ts +2 -0
  155. package/pages/SwapHistoryPage/SwapHistoryPage.js +14 -0
  156. package/pages/SwapHistoryPage/index.d.ts +1 -0
  157. package/pages/SwapHistoryPage/index.js +1 -0
  158. package/pages/SwapPage/StatusBottomSheet.js +4 -4
  159. package/pages/SwapPage/SwapPage.js +13 -10
  160. package/pages/SwapPage/SwapPage.style.d.ts +0 -33
  161. package/pages/SwapPage/SwapPage.style.js +2 -9
  162. package/pages/SwapPage/utils.js +1 -1
  163. package/pages/SwapRoutesPage/SwapRoutesPage.js +16 -8
  164. package/pages/SwapRoutesPage/SwapRoutesPage.style.js +1 -1
  165. package/providers/WalletProvider/WalletProvider.js +7 -26
  166. package/providers/WalletProvider/types.d.ts +0 -1
  167. package/providers/WidgetProvider/WidgetProvider.js +1 -1
  168. package/stores/route/index.d.ts +1 -1
  169. package/stores/route/index.js +1 -1
  170. package/stores/route/types.d.ts +2 -4
  171. package/stores/route/useExecutingRoutes.d.ts +2 -1
  172. package/stores/route/useExecutingRoutes.js +4 -2
  173. package/stores/route/useRouteStore.d.ts +4 -1
  174. package/stores/route/useRouteStore.js +23 -24
  175. package/stores/route/useSwapHistory.d.ts +2 -0
  176. package/stores/route/useSwapHistory.js +11 -0
  177. package/stores/settings/useSettingsStore.d.ts +13 -0
  178. package/types/widget.d.ts +3 -4
  179. package/utils/index.d.ts +6 -0
  180. package/utils/index.js +6 -0
  181. package/utils/navigationRoutes.d.ts +13 -0
  182. package/utils/navigationRoutes.js +12 -0
  183. package/components/Card/CardContainer.d.ts +0 -11
  184. package/components/Card/CardContainer.js +0 -16
  185. package/components/InsufficientGasOrFundsMessage/InsufficientGasOrFundsMessage.d.ts +0 -3
  186. package/components/InsufficientGasOrFundsMessage/InsufficientGasOrFundsMessage.js +0 -31
  187. package/components/InsufficientGasOrFundsMessage/index.d.ts +0 -1
  188. package/components/InsufficientGasOrFundsMessage/index.js +0 -1
  189. package/components/StepToken.js +0 -21
  190. package/components/SwapRoutes/SwapRoutes.js +0 -32
  191. package/components/SwapRoutes/SwapRoutesUpdateProgress.d.ts +0 -3
  192. package/components/SwapRoutes/SwapRoutesUpdateProgress.js +0 -24
  193. package/components/SwapRoutes/index.d.ts +0 -1
  194. package/components/SwapRoutes/index.js +0 -1
  195. package/hooks/useHasSufficientBalance.d.ts +0 -5
  196. package/hooks/useHasSufficientBalance.js +0 -72
  197. package/pages/SwapPage/StepItem.d.ts +0 -7
  198. package/stores/route/useCurrentRoute.d.ts +0 -2
  199. package/stores/route/useCurrentRoute.js +0 -5
  200. package/utils/routes.d.ts +0 -11
  201. package/utils/routes.js +0 -10
@@ -1,11 +0,0 @@
1
- /// <reference types="react" />
2
- export declare const CardContainer: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
3
- children?: import("react").ReactNode;
4
- component?: import("react").ElementType<any> | undefined;
5
- ref?: import("react").Ref<unknown> | undefined;
6
- sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
7
- } & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
8
- ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
9
- }, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "component"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
10
- isError?: boolean | undefined;
11
- }, {}, {}>;
@@ -1,16 +0,0 @@
1
- import { Box } from '@mui/material';
2
- import { styled } from '@mui/material/styles';
3
- export const CardContainer = styled(Box, {
4
- shouldForwardProp: (prop) => prop !== 'isError',
5
- })(({ theme, isError }) => ({
6
- backgroundColor: theme.palette.background.paper,
7
- border: `1px solid`,
8
- borderColor: isError
9
- ? theme.palette.error.main
10
- : theme.palette.mode === 'light'
11
- ? theme.palette.grey[300]
12
- : theme.palette.grey[800],
13
- borderRadius: theme.shape.borderRadius,
14
- overflow: 'hidden',
15
- position: 'relative',
16
- }));
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import { BoxProps } from '@mui/material';
3
- export declare const InsufficientGasOrFundsMessage: React.FC<BoxProps>;
@@ -1,31 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Warning as WarningIcon } from '@mui/icons-material';
3
- import { Box, Typography } from '@mui/material';
4
- import { useTranslation } from 'react-i18next';
5
- import { CardTitle } from '../../components/Card';
6
- import { useHasSufficientBalance } from '../../hooks';
7
- import { MessageCard } from './InsufficientGasOrFundsMessage.style';
8
- export const InsufficientGasOrFundsMessage = (props) => {
9
- const { t } = useTranslation();
10
- const { hasGasOnStartChain, hasGasOnCrossChain, hasSufficientBalance } = useHasSufficientBalance();
11
- if (hasSufficientBalance && hasGasOnStartChain && hasGasOnCrossChain) {
12
- return null;
13
- }
14
- let title;
15
- let message;
16
- if (!hasSufficientBalance) {
17
- message = t(`swap.warning.message.insufficientFunds`);
18
- }
19
- if (!hasGasOnStartChain) {
20
- title = t(`swap.warning.title.insufficientGas`);
21
- message = t(`swap.warning.message.insufficientGasOnStartChain`);
22
- }
23
- if (!hasGasOnCrossChain) {
24
- title = t(`swap.warning.title.insufficientGas`);
25
- message = t(`swap.warning.message.insufficientGasOnDestinationChain`);
26
- }
27
- return (_jsxs(MessageCard, Object.assign({}, props, { children: [_jsx(WarningIcon, { sx: {
28
- marginTop: 2,
29
- marginLeft: 2,
30
- } }), _jsxs(Box, { children: [title ? _jsx(CardTitle, { children: title }) : null, _jsx(Typography, Object.assign({ variant: "body2", px: 2, pb: 2, pt: title ? 1 : 2 }, { children: message }))] })] })));
31
- };
@@ -1 +0,0 @@
1
- export * from './InsufficientGasOrFundsMessage';
@@ -1 +0,0 @@
1
- export * from './InsufficientGasOrFundsMessage';
@@ -1,21 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- import { Avatar, Box, Typography } from '@mui/material';
14
- import { formatTokenAmount } from '../utils/format';
15
- import { TextFitter } from './TextFitter';
16
- export const StepToken = (_a) => {
17
- var { token } = _a, other = __rest(_a, ["token"]);
18
- return (_jsxs(Box, Object.assign({ flex: 1 }, other, { children: [_jsxs(Box, Object.assign({ display: "flex", flex: 1 }, { children: [_jsx(Avatar, Object.assign({ src: token.logoURI, alt: token.symbol, sx: { marginRight: 2 } }, { children: token.symbol[0] })), _jsx(TextFitter, Object.assign({ height: 32, textStyle: {
19
- fontWeight: 700,
20
- } }, { children: formatTokenAmount(token.amount, token.decimals) }))] })), _jsx(Typography, Object.assign({ fontSize: 14, lineHeight: 1, fontWeight: "500", color: "text.secondary", mr: 1, ml: 6 }, { children: token.symbol }))] })));
21
- };
@@ -1,32 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- /* eslint-disable react/no-array-index-key */
3
- import { KeyboardArrowRight as KeyboardArrowRightIcon } from '@mui/icons-material';
4
- import { Box, IconButton } from '@mui/material';
5
- import { useCallback } from 'react';
6
- import { useTranslation } from 'react-i18next';
7
- import { useNavigate } from 'react-router-dom';
8
- import { useSwapRoutes } from '../../hooks';
9
- import { useCurrentRoute } from '../../stores';
10
- import { routes } from '../../utils/routes';
11
- import { CardContainer, CardTitle } from '../Card';
12
- import { SwapRouteCard, SwapRouteCardSkeleton, SwapRouteNotFoundCard, } from '../SwapRouteCard';
13
- import { Stack } from './SwapRoutes.style';
14
- import { SwapRoutesUpdateProgress } from './SwapRoutesUpdateProgress';
15
- export const SwapRoutes = (props) => {
16
- const { t } = useTranslation();
17
- const navigate = useNavigate();
18
- const [currentRoute] = useCurrentRoute();
19
- const { routes: swapRoutes, isLoading, isFetching, isFetched, } = useSwapRoutes();
20
- const handleCardClick = useCallback(() => {
21
- navigate(routes.swapRoutes);
22
- }, [navigate]);
23
- if (!(swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.length) && !isLoading && !isFetching && !isFetched) {
24
- return null;
25
- }
26
- const routeNotFound = !(swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.length) && isFetched;
27
- return (_jsxs(CardContainer, Object.assign({}, props, { children: [_jsx(CardTitle, { children: t('swap.routes') }), !routeNotFound ? (_jsx(SwapRoutesUpdateProgress, { sx: {
28
- position: 'absolute',
29
- top: 8,
30
- right: 8,
31
- } })) : null, _jsxs(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: [_jsx(Stack, Object.assign({ direction: "row", py: 2, pl: 2, pr: routeNotFound ? 2 : 1 }, { children: routeNotFound ? (_jsx(SwapRouteNotFoundCard, { minWidth: "100%", dense: true })) : isLoading || isFetching || !currentRoute ? (_jsx(SwapRouteCardSkeleton, { minWidth: "100%", active: true, dense: true })) : (_jsx(SwapRouteCard, { minWidth: "100%", route: currentRoute, active: true, dense: true })) })), !routeNotFound ? (_jsx(Box, Object.assign({ py: 1, pr: 1 }, { children: _jsx(IconButton, Object.assign({ onClick: handleCardClick, size: "medium", "aria-label": "swap-routes" }, { children: _jsx(KeyboardArrowRightIcon, {}) })) }))) : null] }))] })));
32
- };
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import { IconButtonProps } from '@mui/material';
3
- export declare const SwapRoutesUpdateProgress: React.FC<IconButtonProps>;
@@ -1,24 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- /* eslint-disable react/no-array-index-key */
14
- import { Box } from '@mui/material';
15
- import { useSwapRoutes } from '../../hooks';
16
- import { ProgressToNextUpdate } from '../ProgressToNextUpdate';
17
- export const SwapRoutesUpdateProgress = (_a) => {
18
- var { sx } = _a, other = __rest(_a, ["sx"]);
19
- const { isLoading, isFetching, dataUpdatedAt, refetchTime, refetch } = useSwapRoutes();
20
- if (isLoading) {
21
- return _jsx(Box, { width: 24, height: 24, sx: sx });
22
- }
23
- return (_jsx(ProgressToNextUpdate, Object.assign({ updatedAt: dataUpdatedAt, timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: sx }, other)));
24
- };
@@ -1 +0,0 @@
1
- export * from './SwapRoutes';
@@ -1 +0,0 @@
1
- export * from './SwapRoutes';
@@ -1,5 +0,0 @@
1
- export declare const useHasSufficientBalance: () => {
2
- hasGasOnStartChain: boolean;
3
- hasGasOnCrossChain: boolean;
4
- hasSufficientBalance: boolean;
5
- };
@@ -1,72 +0,0 @@
1
- import { isSwapStep } from '@lifi/sdk';
2
- import Big from 'big.js';
3
- import { useMemo } from 'react';
4
- import { useWatch } from 'react-hook-form';
5
- import { useDebouncedWatch } from '.';
6
- import { SwapFormKey, SwapFormKeyHelper } from '../providers/SwapFormProvider';
7
- import { useWallet } from '../providers/WalletProvider';
8
- import { useCurrentRoute } from '../stores';
9
- import { useTokenBalances } from './useTokenBalances';
10
- export const useHasSufficientBalance = () => {
11
- var _a;
12
- const { account } = useWallet();
13
- const [route] = useCurrentRoute();
14
- const [fromChainId, toChainId, fromToken] = useWatch({
15
- name: [
16
- SwapFormKeyHelper.getChainKey('from'),
17
- SwapFormKeyHelper.getChainKey('to'),
18
- SwapFormKey.FromToken,
19
- ],
20
- });
21
- const fromAmount = useDebouncedWatch(SwapFormKey.FromAmount, 250);
22
- const lastStep = route === null || route === void 0 ? void 0 : route.steps.at(-1);
23
- const { tokens: fromChainTokenBalances } = useTokenBalances(fromChainId);
24
- const { tokens: toChainTokenBalances } = useTokenBalances((_a = lastStep === null || lastStep === void 0 ? void 0 : lastStep.action.fromChainId) !== null && _a !== void 0 ? _a : toChainId);
25
- const hasGasOnStartChain = useMemo(() => {
26
- var _a, _b, _c;
27
- const gasToken = (_a = route === null || route === void 0 ? void 0 : route.steps[0].estimate.gasCosts) === null || _a === void 0 ? void 0 : _a[0].token;
28
- if (!account.isActive || !gasToken || !fromAmount) {
29
- return true;
30
- }
31
- const gasTokenBalance = Big((_c = (_b = fromChainTokenBalances === null || fromChainTokenBalances === void 0 ? void 0 : fromChainTokenBalances.find((t) => t.address === gasToken.address)) === null || _b === void 0 ? void 0 : _b.amount) !== null && _c !== void 0 ? _c : 0);
32
- let requiredAmount = route.steps
33
- .filter((step) => step.action.fromChainId === route.fromChainId)
34
- .reduce((big, step) => { var _a; return big.plus(Big(((_a = step.estimate.gasCosts) === null || _a === void 0 ? void 0 : _a[0].amount) || 0)); }, Big(0))
35
- .div(Math.pow(10, gasToken.decimals));
36
- if (route.fromToken.address === gasToken.address) {
37
- requiredAmount = requiredAmount.plus(Big(fromAmount));
38
- }
39
- return gasTokenBalance.gt(0) && gasTokenBalance.gte(requiredAmount);
40
- }, [
41
- account.isActive,
42
- fromAmount,
43
- fromChainTokenBalances,
44
- route === null || route === void 0 ? void 0 : route.fromChainId,
45
- route === null || route === void 0 ? void 0 : route.fromToken.address,
46
- route === null || route === void 0 ? void 0 : route.steps,
47
- ]);
48
- const hasGasOnCrossChain = useMemo(() => {
49
- var _a, _b, _c, _d, _e, _f;
50
- const gasToken = (_a = lastStep === null || lastStep === void 0 ? void 0 : lastStep.estimate.gasCosts) === null || _a === void 0 ? void 0 : _a[0].token;
51
- if (!account.isActive || !gasToken || !isSwapStep(lastStep)) {
52
- return true;
53
- }
54
- const balance = Big((_c = (_b = toChainTokenBalances === null || toChainTokenBalances === void 0 ? void 0 : toChainTokenBalances.find((t) => t.address === gasToken.address)) === null || _b === void 0 ? void 0 : _b.amount) !== null && _c !== void 0 ? _c : 0);
55
- const gasEstimate = (_d = lastStep.estimate.gasCosts) === null || _d === void 0 ? void 0 : _d[0].amount;
56
- const requiredAmount = Big(gasEstimate || 0).div(Math.pow(10, ((_f = (_e = lastStep.estimate.gasCosts) === null || _e === void 0 ? void 0 : _e[0].token.decimals) !== null && _f !== void 0 ? _f : 0)));
57
- return balance.gt(0) && balance.gte(requiredAmount);
58
- }, [account.isActive, lastStep, toChainTokenBalances]);
59
- const hasSufficientBalance = useMemo(() => {
60
- var _a, _b;
61
- if (!account.isActive || !fromToken || !fromAmount) {
62
- return true;
63
- }
64
- const balance = Big((_b = (_a = fromChainTokenBalances === null || fromChainTokenBalances === void 0 ? void 0 : fromChainTokenBalances.find((t) => t.address === fromToken)) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0);
65
- return Big(fromAmount).lte(balance);
66
- }, [account.isActive, fromAmount, fromChainTokenBalances, fromToken]);
67
- return {
68
- hasGasOnStartChain,
69
- hasGasOnCrossChain,
70
- hasSufficientBalance,
71
- };
72
- };
@@ -1,7 +0,0 @@
1
- /// <reference types="react" />
2
- import { Step, TokenAmount } from '@lifi/sdk';
3
- export declare const StepItem: React.FC<{
4
- step: Step;
5
- fromToken?: TokenAmount;
6
- toToken?: TokenAmount;
7
- }>;
@@ -1,2 +0,0 @@
1
- import { Route } from '@lifi/sdk';
2
- export declare const useCurrentRoute: () => [Route | undefined, (route?: Route) => void];
@@ -1,5 +0,0 @@
1
- import shallow from 'zustand/shallow';
2
- import { useRouteStore } from './useRouteStore';
3
- export const useCurrentRoute = () => {
4
- return useRouteStore((state) => [state.currentRoute, state.setCurrentRoute], shallow);
5
- };
package/utils/routes.d.ts DELETED
@@ -1,11 +0,0 @@
1
- export declare const routes: {
2
- home: string;
3
- selectWallet: string;
4
- settings: string;
5
- fromToken: string;
6
- toToken: string;
7
- swapRoutes: string;
8
- swap: string;
9
- };
10
- export declare const routesValues: string[];
11
- export declare type RouteType = keyof typeof routes;
package/utils/routes.js DELETED
@@ -1,10 +0,0 @@
1
- export const routes = {
2
- home: '/',
3
- selectWallet: 'select-wallet',
4
- settings: 'settings',
5
- fromToken: 'select-from-token',
6
- toToken: 'select-to-token',
7
- swapRoutes: 'swap-routes',
8
- swap: 'swap',
9
- };
10
- export const routesValues = Object.values(routes);