@lifi/widget 1.10.3 → 1.10.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 (37) hide show
  1. package/App.js +2 -2
  2. package/components/AppContainer.js +1 -1
  3. package/components/Header/Header.js +4 -5
  4. package/components/Header/NavigationHeader.js +16 -16
  5. package/components/Header/WalletHeader.js +3 -3
  6. package/components/SelectTokenButton/SelectTokenButton.js +4 -2
  7. package/components/StepActions/StepActions.js +3 -2
  8. package/components/StepToken.js +1 -1
  9. package/components/SwapButton/SwapButton.js +2 -2
  10. package/components/SwapButton/SwapButton.style.js +1 -1
  11. package/components/SwapInProgress/SwapInProgress.js +2 -2
  12. package/components/SwapInput/FormPriceHelperText.js +1 -1
  13. package/components/SwapInput/SwapInput.js +1 -2
  14. package/components/SwapRoutes/SwapRoutes.js +2 -2
  15. package/components/TokenList/TokenList.style.js +1 -1
  16. package/components/TokenList/TokenListItem.js +1 -1
  17. package/config/version.d.ts +1 -1
  18. package/config/version.js +1 -1
  19. package/hooks/useContentHeight.js +1 -1
  20. package/hooks/useRouteExecution.js +2 -2
  21. package/hooks/useScrollableContainer.js +1 -1
  22. package/hooks/useTelemetry.js +3 -1
  23. package/hooks/useTokenBalance.js +4 -4
  24. package/hooks/useTokenBalances.js +1 -1
  25. package/package.json +2 -2
  26. package/pages/MainPage/MainSwapButton.js +2 -2
  27. package/pages/SelectWalletPage/SelectWalletPage.style.js +1 -1
  28. package/pages/SettingsPage/SlippageInput.js +1 -1
  29. package/pages/SwapPage/StatusBottomSheet.js +2 -1
  30. package/pages/SwapPage/SwapPage.js +7 -4
  31. package/pages/SwapPage/utils.js +1 -1
  32. package/pages/SwapRoutesPage/SwapRoutesPage.js +6 -3
  33. package/utils/index.d.ts +6 -0
  34. package/utils/index.js +6 -0
  35. package/utils/navigationRoutes.d.ts +11 -0
  36. package/utils/{routes.js → navigationRoutes.js} +2 -2
  37. package/utils/routes.d.ts +0 -11
package/App.js CHANGED
@@ -13,7 +13,7 @@ import { SettingsPage } from './pages/SettingsPage';
13
13
  import { SwapPage } from './pages/SwapPage';
14
14
  import { SwapRoutesPage } from './pages/SwapRoutesPage';
15
15
  import { useWallet } from './providers/WalletProvider';
16
- import { routes } from './utils/routes';
16
+ import { navigationRoutes } from './utils';
17
17
  export const App = ({ config }) => {
18
18
  return (_jsx(AppProvider, Object.assign({ config: config }, { children: _jsx(AppDefault, {}) })));
19
19
  };
@@ -23,5 +23,5 @@ export const AppDefault = () => {
23
23
  attemptEagerConnect();
24
24
  // eslint-disable-next-line react-hooks/exhaustive-deps
25
25
  }, []);
26
- return (_jsxs(AppContainer, { children: [_jsx(Header, {}), _jsxs(Routes, { children: [_jsx(Route, { path: routes.home, element: _jsx(MainPage, {}) }), _jsx(Route, { path: routes.selectWallet, element: _jsx(SelectWalletPage, {}) }), _jsx(Route, { path: `${routes.swapRoutes}/${routes.swap}/${routes.selectWallet}`, element: _jsx(SelectWalletPage, {}) }), _jsx(Route, { path: routes.settings, element: _jsx(SettingsPage, {}) }), _jsx(Route, { path: routes.fromToken, element: _jsx(SelectTokenPage, { formType: "from" }) }), _jsx(Route, { path: routes.toToken, element: _jsx(SelectTokenPage, { formType: "to" }) }), _jsx(Route, { path: routes.swapRoutes, element: _jsx(SwapRoutesPage, {}) }), _jsx(Route, { path: `${routes.swapRoutes}/${routes.swap}`, element: _jsx(SwapPage, {}) }), _jsx(Route, { path: routes.swap, element: _jsx(SwapPage, {}) }), _jsx(Route, { path: "*", element: _jsx(NotFound, {}) })] }), _jsx(Initializer, {})] }));
26
+ return (_jsxs(AppContainer, { children: [_jsx(Header, {}), _jsxs(Routes, { children: [_jsx(Route, { path: navigationRoutes.home, element: _jsx(MainPage, {}) }), _jsx(Route, { path: navigationRoutes.selectWallet, element: _jsx(SelectWalletPage, {}) }), _jsx(Route, { path: `${navigationRoutes.swapRoutes}/${navigationRoutes.swap}/${navigationRoutes.selectWallet}`, element: _jsx(SelectWalletPage, {}) }), _jsx(Route, { path: navigationRoutes.settings, element: _jsx(SettingsPage, {}) }), _jsx(Route, { path: navigationRoutes.fromToken, element: _jsx(SelectTokenPage, { formType: "from" }) }), _jsx(Route, { path: navigationRoutes.toToken, element: _jsx(SelectTokenPage, { formType: "to" }) }), _jsx(Route, { path: navigationRoutes.swapRoutes, element: _jsx(SwapRoutesPage, {}) }), _jsx(Route, { path: `${navigationRoutes.swapRoutes}/${navigationRoutes.swap}`, element: _jsx(SwapPage, {}) }), _jsx(Route, { path: navigationRoutes.swap, element: _jsx(SwapPage, {}) }), _jsx(Route, { path: "*", element: _jsx(NotFound, {}) })] }), _jsx(Initializer, {})] }));
27
27
  };
@@ -4,7 +4,7 @@ import { styled } from '@mui/material/styles';
4
4
  import { useLayoutEffect, useRef } from 'react';
5
5
  import { useLocation } from 'react-router-dom';
6
6
  import { useWidgetConfig } from '../providers/WidgetProvider';
7
- import { ElementId } from '../utils/elements';
7
+ import { ElementId } from '../utils';
8
8
  import { PoweredBy } from './PoweredBy';
9
9
  const CssBaselineContainer = styled(ScopedCssBaseline)(({ theme }) => ({
10
10
  // height: '100%',
@@ -1,15 +1,14 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useLocation } from 'react-router-dom';
3
3
  import { useWidgetConfig } from '../../providers/WidgetProvider';
4
- import { ElementId } from '../../utils/elements';
5
- import { routes } from '../../utils/routes';
4
+ import { ElementId, navigationRoutes } from '../../utils';
6
5
  import { Container } from './Header.style';
7
6
  import { NavigationHeader } from './NavigationHeader';
8
7
  import { WalletHeader } from './WalletHeader';
9
8
  const stickyHeaderRoutes = [
10
- routes.selectWallet,
11
- routes.settings,
12
- routes.swapRoutes,
9
+ navigationRoutes.selectWallet,
10
+ navigationRoutes.settings,
11
+ navigationRoutes.swapRoutes,
13
12
  ];
14
13
  const HeaderContainer = ({ children }) => {
15
14
  const { pathname } = useLocation();
@@ -3,46 +3,46 @@ import { ArrowBack as ArrowBackIcon, Settings as SettingsIcon, } from '@mui/icon
3
3
  import { Box, IconButton, Typography } from '@mui/material';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { Route, Routes, useLocation, useNavigate } from 'react-router-dom';
6
- import { routes, routesValues } from '../../utils/routes';
6
+ import { navigationRoutes, navigationRoutesValues } from '../../utils';
7
7
  import { SwapRoutesUpdateProgress } from '../SwapRoutes/SwapRoutesUpdateProgress';
8
8
  import { HeaderAppBar } from './Header.style';
9
9
  const backButtonRoutes = [
10
- routes.selectWallet,
11
- routes.settings,
12
- routes.fromToken,
13
- routes.toToken,
14
- routes.swapRoutes,
15
- routes.swap,
10
+ navigationRoutes.selectWallet,
11
+ navigationRoutes.settings,
12
+ navigationRoutes.fromToken,
13
+ navigationRoutes.toToken,
14
+ navigationRoutes.swapRoutes,
15
+ navigationRoutes.swap,
16
16
  ];
17
17
  export const NavigationHeader = () => {
18
18
  const { t } = useTranslation();
19
19
  const { pathname } = useLocation();
20
20
  const path = pathname.substring(pathname.lastIndexOf('/') + 1);
21
- const hasPath = routesValues.includes(path);
21
+ const hasPath = navigationRoutesValues.includes(path);
22
22
  const navigate = useNavigate();
23
23
  const handleSettings = () => {
24
- navigate(routes.settings);
24
+ navigate(navigationRoutes.settings);
25
25
  };
26
26
  const handleBack = () => {
27
27
  navigate(-1);
28
28
  };
29
29
  const handleHeaderTitle = () => {
30
30
  switch (path) {
31
- case routes.selectWallet:
31
+ case navigationRoutes.selectWallet:
32
32
  return t(`header.selectWallet`);
33
- case routes.settings:
33
+ case navigationRoutes.settings:
34
34
  return t(`header.settings`);
35
- case routes.fromToken:
35
+ case navigationRoutes.fromToken:
36
36
  return t(`header.from`);
37
- case routes.toToken:
37
+ case navigationRoutes.toToken:
38
38
  return t(`header.to`);
39
- case routes.swapRoutes:
39
+ case navigationRoutes.swapRoutes:
40
40
  return t(`header.routes`);
41
- case routes.swap:
41
+ case navigationRoutes.swap:
42
42
  return t(`header.swap`);
43
43
  default:
44
44
  return t(`header.swap`);
45
45
  }
46
46
  };
47
- return (_jsxs(HeaderAppBar, Object.assign({ elevation: 0 }, { children: [backButtonRoutes.includes(path) ? (_jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "start", onClick: handleBack }, { children: _jsx(ArrowBackIcon, {}) }))) : null, _jsx(Typography, Object.assign({ fontSize: hasPath ? 24 : 32, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true }, { children: handleHeaderTitle() })), _jsxs(Routes, { children: [_jsx(Route, { path: routes.swapRoutes, element: _jsx(SwapRoutesUpdateProgress, { size: "medium", edge: "end", sx: { marginRight: -1 } }) }), _jsx(Route, { path: routes.home, element: _jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "end", onClick: handleSettings }, { children: _jsx(SettingsIcon, {}) })) }), _jsx(Route, { path: "*", element: _jsx(Box, { width: 28, height: 48 }) })] })] })));
47
+ return (_jsxs(HeaderAppBar, Object.assign({ elevation: 0 }, { children: [backButtonRoutes.includes(path) ? (_jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "start", onClick: handleBack }, { children: _jsx(ArrowBackIcon, {}) }))) : null, _jsx(Typography, Object.assign({ fontSize: hasPath ? 24 : 32, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true }, { children: handleHeaderTitle() })), _jsxs(Routes, { children: [_jsx(Route, { path: navigationRoutes.swapRoutes, element: _jsx(SwapRoutesUpdateProgress, { size: "medium", edge: "end", sx: { marginRight: -1 } }) }), _jsx(Route, { path: navigationRoutes.home, element: _jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "end", onClick: handleSettings }, { children: _jsx(SettingsIcon, {}) })) }), _jsx(Route, { path: "*", element: _jsx(Box, { width: 28, height: 48 }) })] })] })));
48
48
  };
@@ -14,7 +14,7 @@ import { useTranslation } from 'react-i18next';
14
14
  import { useLocation, useNavigate } from 'react-router-dom';
15
15
  import { useWallet } from '../../providers/WalletProvider';
16
16
  import { useWidgetConfig } from '../../providers/WidgetProvider';
17
- import { routes } from '../../utils/routes';
17
+ import { navigationRoutes } from '../../utils';
18
18
  import { HeaderAppBar } from './Header.style';
19
19
  export const WalletHeader = () => {
20
20
  const { t } = useTranslation();
@@ -38,7 +38,7 @@ const ConnectButton = () => {
38
38
  yield walletConnect();
39
39
  return;
40
40
  }
41
- navigate(routes.selectWallet);
41
+ navigate(navigationRoutes.selectWallet);
42
42
  });
43
- return (_jsx(IconButton, Object.assign({ size: "medium", "aria-label": "disconnect", edge: "end", onClick: !pathname.includes(routes.selectWallet) ? connect : undefined }, { children: _jsx(AccountBalanceWalletIcon, {}) })));
43
+ return (_jsx(IconButton, Object.assign({ size: "medium", "aria-label": "disconnect", edge: "end", onClick: !pathname.includes(navigationRoutes.selectWallet) ? connect : undefined }, { children: _jsx(AccountBalanceWalletIcon, {}) })));
44
44
  };
@@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next';
6
6
  import { useNavigate } from 'react-router-dom';
7
7
  import { useChain, useToken } from '../../hooks';
8
8
  import { SwapFormKeyHelper, } from '../../providers/SwapFormProvider';
9
- import { routes } from '../../utils/routes';
9
+ import { navigationRoutes } from '../../utils';
10
10
  import { CardTitle } from '../Card';
11
11
  import { CardContainer } from '../Card/CardContainer';
12
12
  import { Card, SelectTokenCardHeader } from './SelectTokenButton.style';
@@ -22,7 +22,9 @@ export const SelectTokenButton = ({ formType, compact }) => {
22
22
  const { chain, isLoading: isChainLoading } = useChain(chainId);
23
23
  const { token, isLoading: isTokenLoading } = useToken(chainId, tokenAddress);
24
24
  const handleClick = () => {
25
- navigate(formType === 'from' ? routes.fromToken : routes.toToken);
25
+ navigate(formType === 'from'
26
+ ? navigationRoutes.fromToken
27
+ : navigationRoutes.toToken);
26
28
  };
27
29
  const isSelected = !!(chain && token);
28
30
  return (_jsx(CardContainer, Object.assign({ flex: 1 }, { children: _jsxs(Card, Object.assign({ onClick: handleClick, elevation: 0 }, { children: [_jsx(CardTitle, { children: t(`swap.${formType}`) }), chainId && tokenAddress && (isChainLoading || isTokenLoading) ? (_jsx(SelectTokenCardHeader, { avatar: _jsx(Skeleton, { variant: "circular", width: 32, height: 32 }), title: _jsx(Skeleton, { variant: "text", width: 64, height: 24 }), subheader: _jsx(Skeleton, { variant: "text", width: 64, height: 16 }), compact: compact })) : (_jsx(SelectTokenCardHeader, { avatar: isSelected ? (_jsx(Avatar, Object.assign({ src: token.logoURI, alt: token.symbol }, { children: token.symbol[0] }))) : null, action: !compact ? _jsx(KeyboardArrowRightIcon, {}) : null, title: isSelected ? token.symbol : t(`swap.selectChainAndToken`), subheader: isSelected ? `on ${chain.name}` : null, selected: isSelected, compact: compact }))] })) })));
@@ -14,7 +14,7 @@ import { ArrowForward as ArrowForwardIcon } from '@mui/icons-material';
14
14
  import { Box, Step as MuiStep, Stepper, Typography } from '@mui/material';
15
15
  import { useTranslation } from 'react-i18next';
16
16
  import { useChains } from '../../hooks';
17
- import { formatTokenAmount } from '../../utils/format';
17
+ import { formatTokenAmount } from '../../utils';
18
18
  import { LiFiLogo } from '../LiFiLogo';
19
19
  import { StepAvatar, StepConnector, StepContent, StepIcon, StepLabel, } from './StepActions.style';
20
20
  export const StepActions = (_a) => {
@@ -29,7 +29,8 @@ export const StepActions = (_a) => {
29
29
  : step.toolDetails.name }))] })), isFullView ? (_jsx(Stepper, Object.assign({ orientation: "vertical", connector: _jsx(StepConnector, {}), activeStep: -1 }, { children: step.includedSteps.map((step) => (_jsxs(MuiStep, Object.assign({ expanded: true }, { children: [_jsx(StepLabel, Object.assign({ StepIconComponent: StepIcon }, { children: step.type === 'cross' || step.type === 'lifi' ? (_jsx(CrossStepDetailsLabel, { step: step })) : (_jsx(SwapStepDetailsLabel, { step: step })) })), _jsx(StepContent, { children: _jsx(StepDetailsContent, { step: step }) })] }), step.id))) }))) : (_jsxs(Box, Object.assign({ ml: 6 }, { children: [_jsx(StepDetailsLabel, { step: step }), _jsx(StepDetailsContent, { step: step })] })))] })));
30
30
  };
31
31
  export const StepDetailsContent = ({ step }) => {
32
- return (_jsxs(Typography, Object.assign({ fontSize: 12, fontWeight: "500", color: "text.secondary", alignItems: "center", display: "flex" }, { children: [formatTokenAmount(step.estimate.fromAmount, step.action.fromToken.decimals), ' ', step.action.fromToken.symbol, _jsx(ArrowForwardIcon, { sx: { fontSize: 18, paddingX: 0.5 } }), formatTokenAmount(step.estimate.toAmount, step.action.toToken.decimals), ' ', step.action.toToken.symbol] })));
32
+ var _a, _b;
33
+ return (_jsxs(Typography, Object.assign({ fontSize: 12, fontWeight: "500", color: "text.secondary", alignItems: "center", display: "flex" }, { children: [formatTokenAmount(step.estimate.fromAmount, step.action.fromToken.decimals), ' ', step.action.fromToken.symbol, _jsx(ArrowForwardIcon, { sx: { fontSize: 18, paddingX: 0.5 } }), formatTokenAmount((_b = (_a = step.execution) === null || _a === void 0 ? void 0 : _a.toAmount) !== null && _b !== void 0 ? _b : step.estimate.toAmount, step.action.toToken.decimals), ' ', step.action.toToken.symbol] })));
33
34
  };
34
35
  export const CrossStepDetailsLabel = ({ step }) => {
35
36
  var _a, _b;
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { Avatar, Box, Typography } from '@mui/material';
14
- import { formatTokenAmount } from '../utils/format';
14
+ import { formatTokenAmount } from '../utils';
15
15
  import { TextFitter } from './TextFitter';
16
16
  export const StepToken = (_a) => {
17
17
  var { token } = _a, other = __rest(_a, ["token"]);
@@ -16,7 +16,7 @@ import { useChains, useHasSufficientBalance } from '../../hooks';
16
16
  import { SwapFormKeyHelper } from '../../providers/SwapFormProvider';
17
17
  import { useWallet } from '../../providers/WalletProvider';
18
18
  import { useWidgetConfig } from '../../providers/WidgetProvider';
19
- import { routes } from '../../utils/routes';
19
+ import { navigationRoutes } from '../../utils';
20
20
  import { Button } from './SwapButton.style';
21
21
  export const SwapButton = ({ onClick, text, loading, }) => {
22
22
  var _a;
@@ -36,7 +36,7 @@ export const SwapButton = ({ onClick, text, loading, }) => {
36
36
  yield walletConnect();
37
37
  }
38
38
  else {
39
- navigate(routes.selectWallet);
39
+ navigate(navigationRoutes.selectWallet);
40
40
  }
41
41
  }
42
42
  else if (!isCurrentChainMatch) {
@@ -1,7 +1,7 @@
1
1
  import { LoadingButton } from '@mui/lab';
2
2
  import { loadingButtonClasses } from '@mui/lab/LoadingButton';
3
3
  import { styled } from '@mui/material/styles';
4
- import { getContrastAlphaColor } from '../../utils/colors';
4
+ import { getContrastAlphaColor } from '../../utils';
5
5
  export const Button = styled(LoadingButton)(({ theme }) => ({
6
6
  textTransform: 'none',
7
7
  borderRadius: theme.shape.borderRadiusSecondary,
@@ -5,7 +5,7 @@ import { useCallback } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import { useNavigate } from 'react-router-dom';
7
7
  import { useExecutingRoutes } from '../../stores';
8
- import { routes } from '../../utils/routes';
8
+ import { navigationRoutes } from '../../utils';
9
9
  import { CardTitle } from '../Card';
10
10
  import { Card, RouteAvatar, RouteCard } from './SwapInProgress.style';
11
11
  export const SwapInProgress = (props) => {
@@ -13,7 +13,7 @@ export const SwapInProgress = (props) => {
13
13
  const navigate = useNavigate();
14
14
  const executingRoutes = useExecutingRoutes();
15
15
  const handleCardClick = useCallback((routeId) => {
16
- navigate(routes.swap, { state: { routeId } });
16
+ navigate(navigationRoutes.swap, { state: { routeId } });
17
17
  }, [navigate]);
18
18
  if (!(executingRoutes === null || executingRoutes === void 0 ? void 0 : executingRoutes.length)) {
19
19
  return null;
@@ -4,7 +4,7 @@ import { useWatch } from 'react-hook-form';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { useTokenBalance } from '../../hooks';
6
6
  import { SwapFormKeyHelper, } from '../../providers/SwapFormProvider';
7
- import { formatTokenPrice } from '../../utils/format';
7
+ import { formatTokenPrice } from '../../utils';
8
8
  export const FormPriceHelperText = ({ formType, selected }) => {
9
9
  const { t } = useTranslation();
10
10
  const [amount, chainId, tokenAddress] = useWatch({
@@ -5,8 +5,7 @@ import { useFormContext, useWatch } from 'react-hook-form';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import { useChain, useToken } from '../../hooks';
7
7
  import { SwapFormKeyHelper, } from '../../providers/SwapFormProvider';
8
- import { formatAmount } from '../../utils/format';
9
- import { fitInputText } from '../../utils/input';
8
+ import { fitInputText, formatAmount } from '../../utils';
10
9
  import { CardContainer, CardTitle } from '../Card';
11
10
  import { FormPriceHelperText } from './FormPriceHelperText';
12
11
  import { FormControl, Input, maxInputFontSize, minInputFontSize, } from './SwapInput.style';
@@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next';
7
7
  import { useNavigate } from 'react-router-dom';
8
8
  import { useSwapRoutes } from '../../hooks';
9
9
  import { useCurrentRoute } from '../../stores';
10
- import { routes } from '../../utils/routes';
10
+ import { navigationRoutes } from '../../utils';
11
11
  import { CardContainer, CardTitle } from '../Card';
12
12
  import { SwapRouteCard, SwapRouteCardSkeleton, SwapRouteNotFoundCard, } from '../SwapRouteCard';
13
13
  import { Stack } from './SwapRoutes.style';
@@ -18,7 +18,7 @@ export const SwapRoutes = (props) => {
18
18
  const [currentRoute] = useCurrentRoute();
19
19
  const { routes: swapRoutes, isLoading, isFetching, isFetched, } = useSwapRoutes();
20
20
  const handleCardClick = useCallback(() => {
21
- navigate(routes.swapRoutes);
21
+ navigate(navigationRoutes.swapRoutes);
22
22
  }, [navigate]);
23
23
  if (!(swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.length) && !isLoading && !isFetching && !isFetched) {
24
24
  return null;
@@ -1,7 +1,7 @@
1
1
  import { ListItem as MuiListItem, ListItemButton as MuiListItemButton, } from '@mui/material';
2
2
  import { listItemSecondaryActionClasses } from '@mui/material/ListItemSecondaryAction';
3
3
  import { styled } from '@mui/material/styles';
4
- import { getContrastAlphaColor } from '../../utils/colors';
4
+ import { getContrastAlphaColor } from '../../utils';
5
5
  export const ListItemButton = styled(MuiListItemButton)(({ theme }) => ({
6
6
  borderRadius: theme.shape.borderRadiusSecondary,
7
7
  paddingLeft: theme.spacing(2),
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Avatar, Box, ListItemAvatar, ListItemText, Skeleton, Typography, } from '@mui/material';
3
3
  import { memo } from 'react';
4
4
  import { useTranslation } from 'react-i18next';
5
- import { formatTokenPrice } from '../../utils/format';
5
+ import { formatTokenPrice } from '../../utils';
6
6
  import { ListItem, ListItemButton } from './TokenList.style';
7
7
  export const TokenListItem = memo(({ onClick, size, start, token, showBalance }) => {
8
8
  var _a;
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "1.10.3";
2
+ export declare const version = "1.10.4";
package/config/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/widget';
2
- export const version = '1.10.3';
2
+ export const version = '1.10.4';
@@ -1,5 +1,5 @@
1
1
  import { useLayoutEffect, useState } from 'react';
2
- import { ElementId } from '../utils/elements';
2
+ import { ElementId } from '../utils';
3
3
  const getContentHeight = () => {
4
4
  const headerElement = document.getElementById(ElementId.Header);
5
5
  const containerElement = document.getElementById(ElementId.ScrollableContainer);
@@ -13,11 +13,11 @@ import shallow from 'zustand/shallow';
13
13
  import { LiFi } from '../config/lifi';
14
14
  import { useWallet } from '../providers/WalletProvider';
15
15
  import { useRouteStore } from '../stores';
16
- import { deepClone } from '../utils/deepClone';
16
+ import { deepClone } from '../utils';
17
17
  export const useRouteExecution = (routeId) => {
18
18
  const { account, switchChain } = useWallet();
19
19
  const resumedAfterMount = useRef(false);
20
- const { route, status } = useRouteStore((state) => { var _a; return (_a = state.routes[routeId]) !== null && _a !== void 0 ? _a : {}; });
20
+ const { route, status } = useRouteStore((state) => state.routes[routeId]);
21
21
  const [updateRoute, restartRoute, removeRoute] = useRouteStore((state) => [state.updateRoute, state.restartRoute, state.removeRoute], shallow);
22
22
  const updateCallback = (updatedRoute) => {
23
23
  console.log('Route updated.', updatedRoute);
@@ -1,5 +1,5 @@
1
1
  import { useLayoutEffect, useState } from 'react';
2
- import { ElementId } from '../utils/elements';
2
+ import { ElementId } from '../utils';
3
3
  export const useScrollableContainer = () => {
4
4
  const [containerElement, setContainerElement] = useState(() => document.getElementById(ElementId.ScrollableContainer));
5
5
  useLayoutEffect(() => {
@@ -4,7 +4,9 @@ import { initSentry } from '../config/sentry';
4
4
  export const useTelemetry = (disabled) => {
5
5
  useEffect(() => {
6
6
  if (disabled) {
7
- console.warn('Enable crash reports and diagnostic data to be collected. This helps us to better understand how the widget is performing and where improvements need to be made.');
7
+ if (process.env.NODE_ENV === 'production') {
8
+ console.warn('Enable crash reports and diagnostic data to be collected. This helps us to better understand how the widget is performing and where improvements need to be made.');
9
+ }
8
10
  }
9
11
  else {
10
12
  initSentry(true);
@@ -11,7 +11,7 @@ import { useCallback } from 'react';
11
11
  import { useQuery, useQueryClient } from 'react-query';
12
12
  import { LiFi } from '../config/lifi';
13
13
  import { useWallet } from '../providers/WalletProvider';
14
- import { formatTokenAmount } from '../utils/format';
14
+ import { formatTokenAmount } from '../utils';
15
15
  import { useToken } from './useToken';
16
16
  export const useTokenBalance = (chainId, tokenAddress) => {
17
17
  const { account } = useWallet();
@@ -26,9 +26,9 @@ export const useTokenBalance = (chainId, tokenAddress) => {
26
26
  }), {
27
27
  enabled: Boolean(account.address) && Boolean(token),
28
28
  refetchIntervalInBackground: true,
29
- refetchInterval: 60000,
30
- staleTime: 60000,
31
- cacheTime: 60000,
29
+ refetchInterval: 30000,
30
+ staleTime: 30000,
31
+ cacheTime: 30000,
32
32
  });
33
33
  const refetchBalance = useCallback((chainId, tokenAddress) => __awaiter(void 0, void 0, void 0, function* () {
34
34
  if (!chainId && !tokenAddress) {
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { useQuery } from 'react-query';
11
11
  import { LiFi } from '../config/lifi';
12
12
  import { useWallet } from '../providers/WalletProvider';
13
- import { formatTokenAmount } from '../utils/format';
13
+ import { formatTokenAmount } from '../utils';
14
14
  import { useChains } from './useChains';
15
15
  import { useTokens } from './useTokens';
16
16
  export const useTokenBalances = (selectedChainId) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/widget",
3
- "version": "1.10.3",
3
+ "version": "1.10.4",
4
4
  "description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
5
5
  "sideEffects": false,
6
6
  "main": "./index.js",
@@ -42,7 +42,7 @@
42
42
  "@ethersproject/experimental": "^5.6.3",
43
43
  "@ethersproject/providers": "^5.6.8",
44
44
  "@lifi/sdk": "^1.0.2",
45
- "@lifi/wallet-management": "^1.1.1",
45
+ "@lifi/wallet-management": "^1.1.2",
46
46
  "@mui/icons-material": "^5.8.4",
47
47
  "@mui/lab": "^5.0.0-alpha.90",
48
48
  "@mui/material": "^5.9.0",
@@ -12,7 +12,7 @@ import { useNavigate } from 'react-router-dom';
12
12
  import { SwapButton } from '../../components/SwapButton';
13
13
  import { useSwapRoutes } from '../../hooks';
14
14
  import { useCurrentRoute, useSetExecutableRoute } from '../../stores';
15
- import { routes } from '../../utils/routes';
15
+ import { navigationRoutes } from '../../utils';
16
16
  export const MainSwapButton = () => {
17
17
  const navigate = useNavigate();
18
18
  const [currentRoute] = useCurrentRoute();
@@ -22,7 +22,7 @@ export const MainSwapButton = () => {
22
22
  if (currentRoute &&
23
23
  (swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.some((route) => route.id === currentRoute.id))) {
24
24
  setExecutableRoute(currentRoute);
25
- navigate(routes.swap, {
25
+ navigate(navigationRoutes.swap, {
26
26
  state: { routeId: currentRoute.id },
27
27
  });
28
28
  }
@@ -2,7 +2,7 @@ import { ListItem, ListItemButton, ListItemText, Typography, } from '@mui/materi
2
2
  import { listItemSecondaryActionClasses } from '@mui/material/ListItemSecondaryAction';
3
3
  import { listItemTextClasses } from '@mui/material/ListItemText';
4
4
  import { styled } from '@mui/material/styles';
5
- import { getContrastAlphaColor } from '../../utils/colors';
5
+ import { getContrastAlphaColor } from '../../utils';
6
6
  export const WalletListItemButton = styled(ListItemButton)(({ theme }) => ({
7
7
  borderRadius: theme.shape.borderRadiusSecondary,
8
8
  paddingLeft: theme.spacing(1.5),
@@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next';
5
5
  import { CardContainer, CardTitle } from '../../components/Card';
6
6
  import { Input } from '../../components/Input';
7
7
  import { useSetSettings, useSettings } from '../../stores';
8
- import { formatSlippage } from '../../utils/format';
8
+ import { formatSlippage } from '../../utils';
9
9
  export const SlippageInput = () => {
10
10
  const { t } = useTranslation();
11
11
  const [setValue] = useSetSettings();
@@ -13,6 +13,7 @@ import { IconCircle, IconContainer, iconStyles, } from './StatusBottomSheet.styl
13
13
  import { Button } from './SwapPage.style';
14
14
  import { getProcessMessage } from './utils';
15
15
  export const StatusBottomSheet = ({ status, route, }) => {
16
+ var _a, _b, _c, _d, _e;
16
17
  const { t } = useTranslation();
17
18
  const navigate = useNavigate();
18
19
  const ref = useRef(null);
@@ -75,5 +76,5 @@ export const StatusBottomSheet = ({ status, route, }) => {
75
76
  (_b = ref.current) === null || _b === void 0 ? void 0 : _b.openDrawer();
76
77
  }
77
78
  }, [refetchBalance, status]);
78
- return (_jsx(BottomSheet, Object.assign({ ref: ref }, { children: _jsxs(Box, Object.assign({ p: 3 }, { children: [_jsxs(IconContainer, { children: [_jsxs(IconCircle, Object.assign({ status: status, mb: 1 }, { children: [status === 'idle' ? (_jsx(InfoIcon, { color: "primary", sx: iconStyles })) : null, status === 'success' ? (_jsx(DoneIcon, { color: "success", sx: iconStyles })) : null, status === 'error' ? (_jsx(WarningIcon, { color: "error", sx: iconStyles })) : null] })), _jsx(Typography, Object.assign({ py: 1, fontSize: 18, fontWeight: 700 }, { children: title })), status === 'success' ? (_jsx(StepToken, { token: Object.assign(Object.assign({}, route.toToken), { amount: route.toAmount }), py: 1 })) : null] }), _jsx(Typography, Object.assign({ pt: 2, pb: 1 }, { children: message })), _jsxs(Button, Object.assign({ variant: "contained", disableElevation: true, fullWidth: true, onClick: status === 'success' ? handleDone : handleClose }, { children: [status === 'idle' ? t('button.okay') : null, status === 'success' ? t('button.done') : null, status === 'error' ? t('button.tryAgain') : null] })), status === 'success' ? (_jsx(Button, Object.assign({ variant: "outlined", disableElevation: true, fullWidth: true, onClick: handleClose }, { children: t('button.seeDetails') }))) : null] })) })));
79
+ return (_jsx(BottomSheet, Object.assign({ ref: ref }, { children: _jsxs(Box, Object.assign({ p: 3 }, { children: [_jsxs(IconContainer, { children: [_jsxs(IconCircle, Object.assign({ status: status, mb: 1 }, { children: [status === 'idle' ? (_jsx(InfoIcon, { color: "primary", sx: iconStyles })) : null, status === 'success' ? (_jsx(DoneIcon, { color: "success", sx: iconStyles })) : null, status === 'error' ? (_jsx(WarningIcon, { color: "error", sx: iconStyles })) : null] })), _jsx(Typography, Object.assign({ py: 1, fontSize: 18, fontWeight: 700 }, { children: title })), status === 'success' ? (_jsx(StepToken, { token: Object.assign(Object.assign({}, route.toToken), { amount: (_e = (_c = (_b = (_a = route.steps.at(-1)) === null || _a === void 0 ? void 0 : _a.execution) === null || _b === void 0 ? void 0 : _b.toAmount) !== null && _c !== void 0 ? _c : (_d = route.steps.at(-1)) === null || _d === void 0 ? void 0 : _d.estimate.toAmount) !== null && _e !== void 0 ? _e : route.toAmount }), py: 1 })) : null] }), _jsx(Typography, Object.assign({ pt: 2, pb: 1 }, { children: message })), _jsxs(Button, Object.assign({ variant: "contained", disableElevation: true, fullWidth: true, onClick: status === 'success' ? handleDone : handleClose }, { children: [status === 'idle' ? t('button.okay') : null, status === 'success' ? t('button.done') : null, status === 'error' ? t('button.tryAgain') : null] })), status === 'success' ? (_jsx(Button, Object.assign({ variant: "outlined", disableElevation: true, fullWidth: true, onClick: handleClose }, { children: t('button.seeDetails') }))) : null] })) })));
79
80
  };
@@ -14,7 +14,7 @@ export const SwapPage = () => {
14
14
  const { t } = useTranslation();
15
15
  const { state } = useLocation();
16
16
  const navigate = useNavigate();
17
- const { route, status, executeRoute, restartRoute, removeRoute } = useRouteExecution(state.routeId);
17
+ const { route, status, executeRoute, restartRoute, removeRoute } = useRouteExecution(state === null || state === void 0 ? void 0 : state.routeId);
18
18
  const handleRemoveRoute = () => {
19
19
  removeRoute();
20
20
  navigate(-1);
@@ -36,7 +36,10 @@ export const SwapPage = () => {
36
36
  return t('button.restartSwap');
37
37
  }
38
38
  };
39
- return (_jsxs(Container, { children: [route === null || route === void 0 ? void 0 : route.steps.map((step, index, steps) => (_jsxs(Fragment, { children: [_jsx(StepItem, { step: step, fromToken: index === 0
40
- ? Object.assign(Object.assign({}, route.fromToken), { amount: route.fromAmount }) : undefined, toToken: index === steps.length - 1
41
- ? Object.assign(Object.assign({}, route.toToken), { amount: route.toAmount }) : undefined }), steps.length > 1 && index !== steps.length - 1 ? (_jsx(StepDivider, {})) : null] }, step.id))), status === 'idle' ? _jsx(InsufficientGasOrFundsMessage, { mt: 2 }) : null, status === 'idle' || status === 'error' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(SwapButton, { onClick: handleSwapClick, text: getSwapButtonText() }) }))) : null, status === 'error' ? (_jsx(Button, Object.assign({ variant: "outlined", disableElevation: true, fullWidth: true, onClick: handleRemoveRoute }, { children: t('button.removeSwap') }))) : null, _jsx(StatusBottomSheet, { status: status, route: route })] }));
39
+ return (_jsxs(Container, { children: [route === null || route === void 0 ? void 0 : route.steps.map((step, index, steps) => {
40
+ var _a, _b;
41
+ return (_jsxs(Fragment, { children: [_jsx(StepItem, { step: step, fromToken: index === 0
42
+ ? Object.assign(Object.assign({}, step.action.fromToken), { amount: step.action.fromAmount }) : undefined, toToken: index === steps.length - 1
43
+ ? Object.assign(Object.assign({}, step.action.toToken), { amount: (_b = (_a = step.execution) === null || _a === void 0 ? void 0 : _a.toAmount) !== null && _b !== void 0 ? _b : step.estimate.toAmount }) : undefined }), steps.length > 1 && index !== steps.length - 1 ? (_jsx(StepDivider, {})) : null] }, step.id));
44
+ }), status === 'idle' ? _jsx(InsufficientGasOrFundsMessage, { mt: 2 }) : null, status === 'idle' || status === 'error' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(SwapButton, { onClick: handleSwapClick, text: getSwapButtonText() }) }))) : null, status === 'error' ? (_jsx(Button, Object.assign({ variant: "outlined", disableElevation: true, fullWidth: true, onClick: handleRemoveRoute }, { children: t('button.removeSwap') }))) : null, _jsx(StatusBottomSheet, { status: status, route: route })] }));
42
45
  };
@@ -1,5 +1,5 @@
1
1
  import { LifiErrorCode, MetaMaskProviderErrorCode, } from '@lifi/sdk';
2
- import { formatTokenAmount } from '../../utils/format';
2
+ import { formatTokenAmount } from '../../utils';
3
3
  const formatProcessMessage = (initialMessage, args = {}) => {
4
4
  return Object.keys(args).reduce((message, key) => {
5
5
  return message.replace(`{${key}}`, args[key]);
@@ -4,7 +4,7 @@ import { useNavigate } from 'react-router-dom';
4
4
  import { SwapRouteCard, SwapRouteCardSkeleton, SwapRouteNotFoundCard, } from '../../components/SwapRouteCard';
5
5
  import { useSwapRoutes } from '../../hooks';
6
6
  import { useCurrentRoute, useSetExecutableRoute } from '../../stores';
7
- import { routes } from '../../utils/routes';
7
+ import { navigationRoutes } from '../../utils';
8
8
  import { Stack } from './SwapRoutesPage.style';
9
9
  export const SwapRoutesPage = () => {
10
10
  const navigate = useNavigate();
@@ -13,11 +13,14 @@ export const SwapRoutesPage = () => {
13
13
  const setExecutableRoute = useSetExecutableRoute();
14
14
  const handleRouteClick = (route) => {
15
15
  setExecutableRoute(route);
16
- navigate(routes.swap, { state: { routeId: route.id }, replace: true });
16
+ navigate(navigationRoutes.swap, {
17
+ state: { routeId: route.id },
18
+ replace: true,
19
+ });
17
20
  };
18
21
  useEffect(() => {
19
22
  if (!(swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.length) && !isLoading && !isFetching) {
20
- navigate(routes.home);
23
+ navigate(navigationRoutes.home);
21
24
  }
22
25
  // redirect to the home page if no routes are found on page reload
23
26
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -0,0 +1,6 @@
1
+ export * from './colors';
2
+ export * from './deepClone';
3
+ export * from './elements';
4
+ export * from './format';
5
+ export * from './input';
6
+ export * from './navigationRoutes';
package/utils/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export * from './colors';
2
+ export * from './deepClone';
3
+ export * from './elements';
4
+ export * from './format';
5
+ export * from './input';
6
+ export * from './navigationRoutes';
@@ -0,0 +1,11 @@
1
+ export declare const navigationRoutes: {
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 navigationRoutesValues: string[];
11
+ export declare type NavigationRouteType = keyof typeof navigationRoutes;
@@ -1,4 +1,4 @@
1
- export const routes = {
1
+ export const navigationRoutes = {
2
2
  home: '/',
3
3
  selectWallet: 'select-wallet',
4
4
  settings: 'settings',
@@ -7,4 +7,4 @@ export const routes = {
7
7
  swapRoutes: 'swap-routes',
8
8
  swap: 'swap',
9
9
  };
10
- export const routesValues = Object.values(routes);
10
+ export const navigationRoutesValues = Object.values(navigationRoutes);
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;