@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.
- package/App.js +59 -11
- package/AppDrawer.js +1 -1
- package/AppDrawer.style.d.ts +1 -1
- package/AppDrawer.style.js +0 -1
- package/AppProvider.d.ts +1 -0
- package/AppProvider.js +5 -2
- package/components/AppContainer.d.ts +10 -0
- package/components/AppContainer.js +4 -7
- package/components/Card/Card.d.ts +11 -5
- package/components/Card/Card.js +29 -5
- package/components/Card/index.d.ts +0 -1
- package/components/Card/index.js +0 -1
- package/components/Dialog.d.ts +3 -0
- package/components/Dialog.js +23 -0
- package/components/GasSufficiencyMessage/GasSufficiencyMessage.d.ts +6 -0
- package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +41 -0
- package/components/{InsufficientGasOrFundsMessage/InsufficientGasOrFundsMessage.style.d.ts → GasSufficiencyMessage/GasSufficiencyMessage.style.d.ts} +0 -0
- package/components/{InsufficientGasOrFundsMessage/InsufficientGasOrFundsMessage.style.js → GasSufficiencyMessage/GasSufficiencyMessage.style.js} +1 -0
- package/components/GasSufficiencyMessage/index.d.ts +1 -0
- package/components/GasSufficiencyMessage/index.js +1 -0
- package/components/Header/Header.js +5 -6
- package/components/Header/Header.style.js +2 -1
- package/components/Header/NavigationHeader.js +28 -22
- package/components/Header/WalletHeader.js +4 -4
- package/components/Header/index.d.ts +1 -0
- package/components/Header/index.js +1 -0
- package/components/Header/types.d.ts +8 -0
- package/components/Header/types.js +1 -0
- package/components/Header/useHeaderActionStore.d.ts +6 -0
- package/components/Header/useHeaderActionStore.js +19 -0
- package/components/PoweredBy/PoweredBy.js +0 -1
- package/components/ProgressToNextUpdate/ProgressToNextUpdate.js +14 -2
- package/components/ReverseTokensButton/ReverseTokensButton.js +5 -7
- package/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +1 -1
- package/components/ReverseTokensButton/ReverseTokensButton.style.js +4 -2
- package/components/SelectTokenButton/SelectTokenButton.js +9 -7
- package/components/SelectTokenButton/SelectTokenButton.style.d.ts +3 -10
- package/components/SelectTokenButton/SelectTokenButton.style.js +0 -7
- package/components/SmallAvatar.d.ts +16 -0
- package/components/SmallAvatar.js +8 -0
- package/{pages/SwapPage → components/Step}/CircularProgress.d.ts +0 -0
- package/{pages/SwapPage → components/Step}/CircularProgress.js +0 -0
- package/{pages/SwapPage → components/Step}/CircularProgress.style.d.ts +0 -0
- package/{pages/SwapPage → components/Step}/CircularProgress.style.js +0 -0
- package/components/Step/Step.d.ts +7 -0
- package/{pages/SwapPage/StepItem.js → components/Step/Step.js} +6 -6
- package/{pages/SwapPage/ExecutionItem.d.ts → components/Step/StepProcess.d.ts} +1 -1
- package/{pages/SwapPage/ExecutionItem.js → components/Step/StepProcess.js} +2 -2
- package/{pages/SwapPage/ExecutionItem.style.d.ts → components/Step/StepProcess.style.d.ts} +1 -1
- package/{pages/SwapPage/ExecutionItem.style.js → components/Step/StepProcess.style.js} +0 -0
- package/{pages/SwapPage → components/Step}/StepTimer.d.ts +0 -0
- package/{pages/SwapPage → components/Step}/StepTimer.js +0 -0
- package/components/Step/index.d.ts +1 -0
- package/components/Step/index.js +1 -0
- package/components/Step/utils.d.ts +6 -0
- package/components/Step/utils.js +89 -0
- package/components/StepActions/StepActions.js +17 -7
- package/components/StepActions/StepActions.style.js +2 -2
- package/{pages/SwapPage → components/StepDivider}/StepDivider.d.ts +0 -0
- package/{pages/SwapPage → components/StepDivider}/StepDivider.js +0 -0
- package/{pages/SwapPage → components/StepDivider}/StepDivider.style.d.ts +0 -0
- package/{pages/SwapPage → components/StepDivider}/StepDivider.style.js +0 -0
- package/components/StepDivider/index.d.ts +1 -0
- package/components/StepDivider/index.js +1 -0
- package/components/SwapButton/SwapButton.js +9 -12
- package/components/SwapButton/SwapButton.style.d.ts +1 -1
- package/components/SwapButton/SwapButton.style.js +1 -5
- package/components/SwapButton/types.d.ts +2 -0
- package/components/SwapInProgress/SwapInProgress.js +9 -6
- package/components/SwapInProgress/SwapInProgress.style.d.ts +9 -21
- package/components/SwapInProgress/SwapInProgress.style.js +5 -6
- package/components/SwapInput/FormPriceHelperText.js +1 -1
- package/components/SwapInput/SwapInput.js +4 -5
- package/components/SwapInput/SwapInputAdornment.style.d.ts +1 -1
- package/components/SwapInput/SwapInputAdornment.style.js +0 -2
- package/components/SwapRouteCard/SwapRouteCard.js +15 -15
- package/components/SwapRouteCard/SwapRouteCard.style.d.ts +0 -20
- package/components/SwapRouteCard/SwapRouteCard.style.js +7 -54
- package/components/SwapRouteCard/SwapRouteCardSkeleton.js +6 -10
- package/components/SwapRouteCard/SwapRouteNotFoundCard.js +3 -3
- package/components/SwapRouteCard/types.d.ts +0 -3
- package/components/{StepToken.d.ts → Token/Token.d.ts} +2 -1
- package/components/Token/Token.js +31 -0
- package/components/Token/Token.style.d.ts +24 -0
- package/components/Token/Token.style.js +31 -0
- package/components/Token/index.d.ts +2 -0
- package/components/Token/index.js +2 -0
- package/components/TokenAvatar/TokenAvatar.d.ts +7 -0
- package/components/TokenAvatar/TokenAvatar.js +8 -0
- package/components/TokenAvatar/TokenAvatar.style.d.ts +1 -0
- package/components/TokenAvatar/TokenAvatar.style.js +16 -0
- package/components/TokenAvatar/index.d.ts +2 -0
- package/components/TokenAvatar/index.js +2 -0
- package/components/TokenList/TokenList.js +2 -2
- package/components/TokenList/TokenList.style.js +1 -1
- package/components/TokenList/TokenListItem.d.ts +1 -0
- package/components/TokenList/TokenListItem.js +13 -7
- package/components/TokenList/types.d.ts +1 -0
- package/config/queryClient.d.ts +1 -1
- package/config/queryClient.js +1 -1
- package/config/theme.js +14 -1
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/index.d.ts +1 -1
- package/hooks/index.js +1 -1
- package/hooks/useChains.d.ts +8 -8
- package/hooks/useChains.js +1 -1
- package/hooks/useContentHeight.js +1 -1
- package/hooks/useGasSufficiency.d.ts +15 -0
- package/hooks/useGasSufficiency.js +91 -0
- package/hooks/useRouteExecution.d.ts +3 -3
- package/hooks/useRouteExecution.js +23 -19
- package/hooks/useScrollableContainer.js +1 -1
- package/hooks/useSwapRoutes.d.ts +1 -1
- package/hooks/useSwapRoutes.js +2 -14
- package/hooks/useTelemetry.js +3 -1
- package/hooks/useTokenBalance.js +5 -5
- package/hooks/useTokenBalances.d.ts +2 -2
- package/hooks/useTokenBalances.js +8 -10
- package/hooks/useTokens.js +1 -1
- package/hooks/useTools.d.ts +10 -1
- package/hooks/useTools.js +13 -3
- package/i18n/en/translation.json +18 -9
- package/i18n/index.d.ts +12 -3
- package/icons/LiFiToolLogo.svg +6 -0
- package/package.json +9 -9
- package/pages/MainPage/MainPage.js +2 -3
- package/pages/MainPage/MainSwapButton.js +6 -7
- package/{components/SwapRoutes → pages/MainPage}/SwapRoutes.d.ts +0 -0
- package/pages/MainPage/SwapRoutes.js +36 -0
- package/{components/SwapRoutes → pages/MainPage}/SwapRoutes.style.d.ts +0 -0
- package/{components/SwapRoutes → pages/MainPage}/SwapRoutes.style.js +4 -0
- package/pages/SelectTokenPage/ChainSelect.js +2 -2
- package/pages/SelectTokenPage/SearchTokenInput.js +2 -2
- package/pages/SelectWalletPage/SelectWalletPage.js +4 -23
- package/pages/SelectWalletPage/SelectWalletPage.style.js +1 -1
- package/pages/SettingsPage/AdvancedPreferences.js +1 -1
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
- package/pages/SettingsPage/EnabledBridgesSelect.js +7 -4
- package/pages/SettingsPage/EnabledExchangesSelect.js +7 -4
- package/pages/SettingsPage/GasPriceSelect.js +2 -2
- package/pages/SettingsPage/RoutePrioritySelect.js +2 -2
- package/pages/SettingsPage/SlippageInput.js +3 -3
- package/pages/SwapDetailsPage/SwapDetailsPage.d.ts +2 -0
- package/pages/SwapDetailsPage/SwapDetailsPage.js +62 -0
- package/pages/SwapDetailsPage/SwapDetailsPage.style.d.ts +11 -0
- package/pages/SwapDetailsPage/SwapDetailsPage.style.js +5 -0
- package/pages/SwapDetailsPage/index.d.ts +1 -0
- package/pages/SwapDetailsPage/index.js +1 -0
- package/pages/SwapHistoryPage/SwapHistoryEmpty.d.ts +2 -0
- package/pages/SwapHistoryPage/SwapHistoryEmpty.js +14 -0
- package/pages/SwapHistoryPage/SwapHistoryItem.d.ts +5 -0
- package/pages/SwapHistoryPage/SwapHistoryItem.js +23 -0
- package/pages/SwapHistoryPage/SwapHistoryPage.d.ts +2 -0
- package/pages/SwapHistoryPage/SwapHistoryPage.js +14 -0
- package/pages/SwapHistoryPage/index.d.ts +1 -0
- package/pages/SwapHistoryPage/index.js +1 -0
- package/pages/SwapPage/StatusBottomSheet.js +4 -4
- package/pages/SwapPage/SwapPage.js +13 -10
- package/pages/SwapPage/SwapPage.style.d.ts +0 -33
- package/pages/SwapPage/SwapPage.style.js +2 -9
- package/pages/SwapPage/utils.js +1 -1
- package/pages/SwapRoutesPage/SwapRoutesPage.js +16 -8
- package/pages/SwapRoutesPage/SwapRoutesPage.style.js +1 -1
- package/providers/WalletProvider/WalletProvider.js +7 -26
- package/providers/WalletProvider/types.d.ts +0 -1
- package/providers/WidgetProvider/WidgetProvider.js +1 -1
- package/stores/route/index.d.ts +1 -1
- package/stores/route/index.js +1 -1
- package/stores/route/types.d.ts +2 -4
- package/stores/route/useExecutingRoutes.d.ts +2 -1
- package/stores/route/useExecutingRoutes.js +4 -2
- package/stores/route/useRouteStore.d.ts +4 -1
- package/stores/route/useRouteStore.js +23 -24
- package/stores/route/useSwapHistory.d.ts +2 -0
- package/stores/route/useSwapHistory.js +11 -0
- package/stores/settings/useSettingsStore.d.ts +13 -0
- package/types/widget.d.ts +3 -4
- package/utils/index.d.ts +6 -0
- package/utils/index.js +6 -0
- package/utils/navigationRoutes.d.ts +13 -0
- package/utils/navigationRoutes.js +12 -0
- package/components/Card/CardContainer.d.ts +0 -11
- package/components/Card/CardContainer.js +0 -16
- package/components/InsufficientGasOrFundsMessage/InsufficientGasOrFundsMessage.d.ts +0 -3
- package/components/InsufficientGasOrFundsMessage/InsufficientGasOrFundsMessage.js +0 -31
- package/components/InsufficientGasOrFundsMessage/index.d.ts +0 -1
- package/components/InsufficientGasOrFundsMessage/index.js +0 -1
- package/components/StepToken.js +0 -21
- package/components/SwapRoutes/SwapRoutes.js +0 -32
- package/components/SwapRoutes/SwapRoutesUpdateProgress.d.ts +0 -3
- package/components/SwapRoutes/SwapRoutesUpdateProgress.js +0 -24
- package/components/SwapRoutes/index.d.ts +0 -1
- package/components/SwapRoutes/index.js +0 -1
- package/hooks/useHasSufficientBalance.d.ts +0 -5
- package/hooks/useHasSufficientBalance.js +0 -72
- package/pages/SwapPage/StepItem.d.ts +0 -7
- package/stores/route/useCurrentRoute.d.ts +0 -2
- package/stores/route/useCurrentRoute.js +0 -5
- package/utils/routes.d.ts +0 -11
- 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,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';
|
package/components/StepToken.js
DELETED
|
@@ -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,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,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
|
-
};
|
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);
|