@lifi/widget 1.18.9 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/App.js +3 -3
- package/cjs/App.js +3 -3
- package/cjs/components/ActiveSwaps/ActiveSwaps.js +1 -1
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +0 -14
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.js +1 -9
- package/cjs/components/AppContainer.d.ts +11 -1
- package/cjs/components/AppContainer.js +2 -6
- package/cjs/components/BottomSheet/BottomSheet.js +9 -31
- package/cjs/components/BottomSheet/types.d.ts +2 -2
- package/cjs/components/Card/Card.js +1 -1
- package/cjs/components/Card/CardHeader.d.ts +1 -1
- package/cjs/components/ChainSelect/ChainSelect.js +1 -1
- package/cjs/components/ChainSelect/useChainSelect.js +2 -4
- package/cjs/components/Dialog.d.ts +22 -1
- package/cjs/components/Dialog.js +23 -19
- package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.js +19 -22
- package/cjs/components/Header/NavigationHeader.js +1 -1
- package/cjs/components/Header/WalletHeader.js +2 -2
- package/cjs/components/PoweredBy/PoweredBy.js +1 -1
- package/cjs/components/ProgressToNextUpdate/ProgressToNextUpdate.js +1 -1
- package/cjs/components/ReverseTokensButton/ReverseTokensButton.js +6 -6
- package/cjs/components/SelectTokenButton/SelectTokenButton.style.d.ts +1 -1
- package/cjs/components/SendToWallet/SendToWallet.d.ts +1 -0
- package/cjs/components/SendToWallet/SendToWallet.js +10 -5
- package/cjs/components/SendToWallet/SendToWalletButton.js +2 -2
- package/cjs/components/Step/StepProcess.js +1 -1
- package/cjs/components/SwapButton/SwapButton.js +4 -4
- package/cjs/components/SwapButton/types.d.ts +2 -0
- package/cjs/components/SwapInput/SwapInput.js +6 -2
- package/cjs/components/SwapInput/SwapInputAdornment.js +4 -2
- package/cjs/components/SwapInput/SwapInputAdornment.style.js +2 -14
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +7 -6
- package/cjs/components/SwapRoutes/SwapRoutes.js +4 -4
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.d.ts +1 -0
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +17 -12
- package/cjs/components/SwapRoutes/useSetRecommendedRoute.d.ts +2 -0
- package/cjs/components/SwapRoutes/useSetRecommendedRoute.js +13 -0
- package/cjs/components/TokenList/TokenList.js +9 -6
- package/cjs/config/theme.js +22 -8
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/index.d.ts +1 -0
- package/cjs/hooks/index.js +1 -0
- package/cjs/hooks/useContentHeight.d.ts +2 -0
- package/cjs/hooks/useContentHeight.js +18 -1
- package/cjs/hooks/useExpandableVariant.d.ts +1 -0
- package/cjs/hooks/useExpandableVariant.js +14 -0
- package/cjs/hooks/useGasSufficiency.d.ts +3 -2
- package/cjs/hooks/useGasSufficiency.js +50 -26
- package/cjs/hooks/useSwapRoutes.js +4 -2
- package/cjs/hooks/useTokenBalance.js +2 -2
- package/cjs/i18n/en/translation.json +15 -7
- package/cjs/i18n/index.d.ts +13 -5
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.js +21 -4
- package/cjs/pages/MainPage/MainPage.js +3 -3
- package/cjs/pages/SelectWalletPage/SelectWalletPage.js +1 -1
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +2 -2
- package/cjs/pages/SwapHistoryPage/SwapHistoryPage.js +2 -2
- package/cjs/pages/SwapPage/StatusBottomSheet.js +4 -4
- package/cjs/pages/SwapPage/StatusBottomSheet.style.d.ts +0 -4
- package/cjs/pages/SwapPage/StatusBottomSheet.style.js +23 -17
- package/cjs/pages/SwapPage/SwapPage.js +38 -17
- package/cjs/pages/SwapPage/TokenValueBottomSheet.d.ts +11 -0
- package/cjs/pages/SwapPage/TokenValueBottomSheet.js +42 -0
- package/cjs/providers/SwapFormProvider/SwapFormProvider.js +3 -2
- package/cjs/providers/SwapFormProvider/URLSearchParamsBuilder.d.ts +1 -0
- package/cjs/providers/SwapFormProvider/URLSearchParamsBuilder.js +46 -0
- package/cjs/providers/SwapFormProvider/types.d.ts +4 -4
- package/cjs/providers/SwapFormProvider/types.js +2 -2
- package/cjs/providers/WalletProvider/WalletFormUpdate.d.ts +5 -0
- package/cjs/providers/WalletProvider/WalletFormUpdate.js +64 -0
- package/cjs/providers/WalletProvider/WalletProvider.js +3 -58
- package/cjs/providers/WidgetProvider/WidgetProvider.js +12 -5
- package/cjs/stores/routes/index.d.ts +1 -1
- package/cjs/stores/routes/index.js +1 -1
- package/cjs/stores/routes/types.d.ts +5 -5
- package/cjs/stores/routes/useRecommendedRouteStore.d.ts +4 -0
- package/cjs/stores/routes/{useSelectedRouteStore.js → useRecommendedRouteStore.js} +4 -4
- package/cjs/stores/routes/useRouteExecutionStore.js +9 -2
- package/cjs/types/widget.d.ts +1 -0
- package/components/ActiveSwaps/ActiveSwaps.js +3 -3
- package/components/ActiveSwaps/ActiveSwaps.style.d.ts +0 -14
- package/components/ActiveSwaps/ActiveSwaps.style.js +1 -9
- package/components/AppContainer.d.ts +11 -1
- package/components/AppContainer.js +1 -4
- package/components/BottomSheet/BottomSheet.js +10 -32
- package/components/BottomSheet/types.d.ts +2 -2
- package/components/Card/Card.js +1 -1
- package/components/Card/CardHeader.d.ts +1 -1
- package/components/ChainSelect/ChainSelect.js +1 -1
- package/components/ChainSelect/useChainSelect.js +2 -4
- package/components/Dialog.d.ts +22 -1
- package/components/Dialog.js +23 -19
- package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +21 -24
- package/components/Header/NavigationHeader.js +2 -2
- package/components/Header/WalletHeader.js +2 -2
- package/components/PoweredBy/PoweredBy.js +1 -1
- package/components/ProgressToNextUpdate/ProgressToNextUpdate.js +1 -1
- package/components/ReverseTokensButton/ReverseTokensButton.js +6 -6
- package/components/SelectTokenButton/SelectTokenButton.style.d.ts +1 -1
- package/components/SendToWallet/SendToWallet.d.ts +1 -0
- package/components/SendToWallet/SendToWallet.js +9 -5
- package/components/SendToWallet/SendToWalletButton.js +2 -2
- package/components/Step/StepProcess.js +1 -1
- package/components/SwapButton/SwapButton.js +4 -4
- package/components/SwapButton/types.d.ts +2 -0
- package/components/SwapInput/SwapInput.js +6 -2
- package/components/SwapInput/SwapInputAdornment.js +4 -2
- package/components/SwapInput/SwapInputAdornment.style.js +3 -15
- package/components/SwapRouteCard/SwapRouteCard.js +8 -7
- package/components/SwapRoutes/SwapRoutes.js +4 -4
- package/components/SwapRoutes/SwapRoutesExpanded.d.ts +1 -0
- package/components/SwapRoutes/SwapRoutesExpanded.js +16 -12
- package/components/SwapRoutes/useSetRecommendedRoute.d.ts +2 -0
- package/components/SwapRoutes/useSetRecommendedRoute.js +9 -0
- package/components/TokenList/TokenList.js +9 -6
- package/config/theme.js +22 -8
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +1 -0
- package/hooks/useContentHeight.d.ts +2 -0
- package/hooks/useContentHeight.js +16 -0
- package/hooks/useExpandableVariant.d.ts +1 -0
- package/hooks/useExpandableVariant.js +10 -0
- package/hooks/useGasSufficiency.d.ts +3 -2
- package/hooks/useGasSufficiency.js +50 -26
- package/hooks/useSwapRoutes.js +4 -2
- package/hooks/useTokenBalance.js +2 -2
- package/i18n/en/translation.json +15 -7
- package/i18n/index.d.ts +13 -5
- package/package.json +11 -11
- package/pages/ActiveSwapsPage/ActiveSwapsPage.js +24 -7
- package/pages/MainPage/MainPage.js +3 -3
- package/pages/SelectWalletPage/SelectWalletPage.js +1 -1
- package/pages/SwapDetailsPage/SwapDetailsPage.js +2 -2
- package/pages/SwapHistoryPage/SwapHistoryPage.js +2 -2
- package/pages/SwapPage/StatusBottomSheet.js +5 -5
- package/pages/SwapPage/StatusBottomSheet.style.d.ts +0 -4
- package/pages/SwapPage/StatusBottomSheet.style.js +23 -17
- package/pages/SwapPage/SwapPage.js +41 -20
- package/pages/SwapPage/TokenValueBottomSheet.d.ts +11 -0
- package/pages/SwapPage/TokenValueBottomSheet.js +38 -0
- package/providers/SwapFormProvider/SwapFormProvider.js +4 -3
- package/providers/SwapFormProvider/URLSearchParamsBuilder.d.ts +1 -0
- package/providers/SwapFormProvider/URLSearchParamsBuilder.js +42 -0
- package/providers/SwapFormProvider/types.d.ts +4 -4
- package/providers/SwapFormProvider/types.js +2 -2
- package/providers/WalletProvider/WalletFormUpdate.d.ts +5 -0
- package/providers/WalletProvider/WalletFormUpdate.js +60 -0
- package/providers/WalletProvider/WalletProvider.js +5 -60
- package/providers/WidgetProvider/WidgetProvider.js +12 -5
- package/stores/routes/index.d.ts +1 -1
- package/stores/routes/index.js +1 -1
- package/stores/routes/types.d.ts +5 -5
- package/stores/routes/useRecommendedRouteStore.d.ts +4 -0
- package/stores/routes/useRecommendedRouteStore.js +9 -0
- package/stores/routes/useRouteExecutionStore.js +9 -2
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/widget.d.ts +1 -0
- package/cjs/components/SwapRoutes/useSetSelectedRoute.d.ts +0 -2
- package/cjs/components/SwapRoutes/useSetSelectedRoute.js +0 -13
- package/cjs/stores/routes/useSelectedRouteStore.d.ts +0 -4
- package/components/SwapRoutes/useSetSelectedRoute.d.ts +0 -2
- package/components/SwapRoutes/useSetSelectedRoute.js +0 -9
- package/stores/routes/useSelectedRouteStore.d.ts +0 -4
- package/stores/routes/useSelectedRouteStore.js +0 -9
|
@@ -11,35 +11,32 @@ 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 { WarningAmber as WarningIcon } from '@mui/icons-material';
|
|
14
|
-
import { Box, Typography } from '@mui/material';
|
|
14
|
+
import { Box, Collapse, Typography } from '@mui/material';
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
16
|
import { useGasSufficiency } from '../../hooks';
|
|
17
|
-
import {
|
|
17
|
+
import { useRecommendedRouteStore } from '../../stores';
|
|
18
18
|
import { CardTitle } from '../Card';
|
|
19
19
|
import { MessageCard } from './GasSufficiencyMessage.style';
|
|
20
20
|
export const GasSufficiencyMessage = (_a) => {
|
|
21
21
|
var { route } = _a, props = __rest(_a, ["route"]);
|
|
22
22
|
const { t } = useTranslation();
|
|
23
|
-
const
|
|
24
|
-
const { insufficientFunds, insufficientGas } = useGasSufficiency(route !== null && route !== void 0 ? route :
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}) }), index));
|
|
43
|
-
})
|
|
44
|
-
: null] })] })));
|
|
23
|
+
const recommendedRoute = useRecommendedRouteStore((state) => state.recommendedRoute);
|
|
24
|
+
const { insufficientFunds, insufficientGas } = useGasSufficiency(route !== null && route !== void 0 ? route : recommendedRoute);
|
|
25
|
+
return (_jsx(Collapse, Object.assign({ timeout: 225, in: Boolean(insufficientFunds || (insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length)), unmountOnExit: true, mountOnEnter: true, appear: true }, { children: _jsx(Box, Object.assign({}, props, { children: _jsxs(MessageCard, { children: [_jsx(WarningIcon, { sx: {
|
|
26
|
+
marginTop: 2,
|
|
27
|
+
marginLeft: 2,
|
|
28
|
+
} }), _jsxs(Box, { children: [(insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) ? (_jsx(CardTitle, { children: t(`swap.warning.title.insufficientGas`) })) : null, insufficientFunds ? (_jsx(Typography, Object.assign({ variant: "body2", px: 2, pb: (insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) ? 0 : 2, pt: (insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) ? 1 : 2 }, { children: insufficientFunds
|
|
29
|
+
? t(`swap.warning.message.insufficientFunds`)
|
|
30
|
+
: null }))) : null, (insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) ? (_jsx(Typography, Object.assign({ variant: "body2", px: 2, pt: 1 }, { children: t(`swap.warning.message.insufficientGas`) }))) : null, (insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length)
|
|
31
|
+
? insufficientGas.map((item, index) => {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
return (_jsx(Typography
|
|
34
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
35
|
+
, Object.assign({ variant: "body2", px: 2, pb: insufficientGas.length - 1 === index ? 2 : 0, pt: 0.5 }, { children: t(`swap.tokenOnChainAmount`, {
|
|
36
|
+
amount: (_a = item.insufficientAmount) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
37
|
+
tokenSymbol: item.token.symbol,
|
|
38
|
+
chainName: (_b = item.chain) === null || _b === void 0 ? void 0 : _b.name,
|
|
39
|
+
}) }), index));
|
|
40
|
+
})
|
|
41
|
+
: null] })] }) })) })));
|
|
45
42
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ArrowBack as ArrowBackIcon, History as HistoryIcon, SettingsOutlined as SettingsIcon, } from '@mui/icons-material';
|
|
3
|
-
import { Box, IconButton, Typography } from '@mui/material';
|
|
3
|
+
import { Box, IconButton, Tooltip, Typography } from '@mui/material';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { Route, Routes, useLocation } from 'react-router-dom';
|
|
6
6
|
import { useNavigateBack } from '../../hooks';
|
|
@@ -46,5 +46,5 @@ export const NavigationHeader = () => {
|
|
|
46
46
|
return t(`header.swap`);
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
return (_jsxs(HeaderAppBar, Object.assign({ elevation: 0 }, { children: [backButtonRoutes.includes(path) ? (_jsx(IconButton, Object.assign({ size: "medium",
|
|
49
|
+
return (_jsxs(HeaderAppBar, Object.assign({ elevation: 0 }, { children: [backButtonRoutes.includes(path) ? (_jsx(IconButton, Object.assign({ size: "medium", edge: "start", onClick: navigateBack }, { children: _jsx(ArrowBackIcon, {}) }))) : null, _jsx(Typography, Object.assign({ fontSize: hasPath ? 18 : 24, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true }, { children: handleHeaderTitle() })), _jsxs(Routes, { children: [_jsx(Route, { path: navigationRoutes.home, element: _jsxs(_Fragment, { children: [account.isActive ? (_jsx(Tooltip, Object.assign({ title: t(`header.swapHistory`), enterDelay: 400, arrow: true }, { children: _jsx(IconButton, Object.assign({ size: "medium", edge: "start", onClick: () => navigate(navigationRoutes.swapHistory) }, { children: _jsx(HistoryIcon, {}) })) }))) : null, _jsx(Tooltip, Object.assign({ title: t(`header.settings`), enterDelay: 400, arrow: true }, { children: _jsx(IconButton, Object.assign({ size: "medium", edge: "end", onClick: () => navigate(navigationRoutes.settings) }, { children: _jsx(SettingsIcon, {}) })) }))] }) }), _jsx(Route, { path: "*", element: element || _jsx(Box, { width: 28, height: 40 }) })] })] })));
|
|
50
50
|
};
|
|
@@ -23,7 +23,7 @@ export const WalletHeader = () => {
|
|
|
23
23
|
display: 'flex',
|
|
24
24
|
flex: 1,
|
|
25
25
|
flexDirection: 'column',
|
|
26
|
-
}, mr: 0.5 }, { children: [_jsx(Typography, Object.assign({ variant: "caption", align: "right" }, { children: t(`header.walletConnected`) })), _jsx(Typography, Object.assign({ variant: "body2", align: "right", fontWeight: "600" }, { children: walletAddress }))] })), _jsx(IconButton, Object.assign({ size: "medium",
|
|
26
|
+
}, mr: 0.5 }, { children: [_jsx(Typography, Object.assign({ variant: "caption", align: "right" }, { children: t(`header.walletConnected`) })), _jsx(Typography, Object.assign({ variant: "body2", align: "right", fontWeight: "600" }, { children: walletAddress }))] })), _jsx(IconButton, Object.assign({ size: "medium", edge: "end", onClick: disconnect }, { children: _jsx(LogoutIcon, {}) }))] })) : (_jsxs(_Fragment, { children: [_jsx(Typography, Object.assign({ variant: "body2", align: "right", fontWeight: "600", flex: 1, mr: 0.5 }, { children: t(`header.connectWallet`) })), _jsx(ConnectButton, {})] })) })));
|
|
27
27
|
};
|
|
28
28
|
const ConnectButton = () => {
|
|
29
29
|
const { pathname } = useLocation();
|
|
@@ -37,5 +37,5 @@ const ConnectButton = () => {
|
|
|
37
37
|
}
|
|
38
38
|
navigate(navigationRoutes.selectWallet);
|
|
39
39
|
});
|
|
40
|
-
return (_jsx(IconButton, Object.assign({ size: "medium",
|
|
40
|
+
return (_jsx(IconButton, Object.assign({ size: "medium", edge: "end", onClick: !pathname.includes(navigationRoutes.selectWallet) ? connect : undefined }, { children: _jsx(WalletOutlinedIcon, {}) })));
|
|
41
41
|
};
|
|
@@ -15,5 +15,5 @@ export const PoweredBy = () => {
|
|
|
15
15
|
display: 'flex',
|
|
16
16
|
alignItems: 'flex-end',
|
|
17
17
|
justifyContent: 'flex-end',
|
|
18
|
-
} }, { children: _jsx(Tooltip, Object.assign({ title: `v${version}`, placement: "top", enterDelay:
|
|
18
|
+
} }, { children: _jsx(Tooltip, Object.assign({ title: `v${version}`, placement: "top", enterDelay: 3000, arrow: true }, { children: _jsxs(Link, Object.assign({ href: "https://li.fi", target: "_blank", underline: "none", color: "text.primary" }, { children: [_jsx(Typography, Object.assign({ color: "text.secondary", fontSize: 12, px: 0.5 }, { children: "Powered by" })), _jsx(LiFiLogo, { variant: "full", style: { height: 16, width: 42 } })] })) })) })));
|
|
19
19
|
};
|
|
@@ -39,7 +39,7 @@ export const ProgressToNextUpdate = (_a) => {
|
|
|
39
39
|
}, [isLoading]);
|
|
40
40
|
return (_jsx(IconButton, Object.assign({ onClick: onClick, disabled: isLoading }, other, { children: _jsx(Tooltip, Object.assign({ title: t('tooltip.progressToNextUpdate', {
|
|
41
41
|
value: getSecondsToUpdate(updatedAt, timeToUpdate),
|
|
42
|
-
}), placement: "top", enterDelay:
|
|
42
|
+
}), placement: "top", enterDelay: 400, arrow: true }, { children: _jsxs(Box, Object.assign({ sx: {
|
|
43
43
|
display: 'grid',
|
|
44
44
|
position: 'relative',
|
|
45
45
|
placeItems: 'center',
|
|
@@ -12,11 +12,11 @@ export const ReverseTokensButton = ({ vertical, }) => {
|
|
|
12
12
|
SwapFormKey.ToChain,
|
|
13
13
|
SwapFormKey.ToToken,
|
|
14
14
|
]);
|
|
15
|
-
setValue(SwapFormKey.FromAmount, '');
|
|
16
|
-
setValue(SwapFormKey.FromChain, toChain);
|
|
17
|
-
setValue(SwapFormKey.FromToken, toToken);
|
|
18
|
-
setValue(SwapFormKey.ToChain, fromChain);
|
|
19
|
-
setValue(SwapFormKey.ToToken, fromToken);
|
|
15
|
+
setValue(SwapFormKey.FromAmount, '', { shouldTouch: true });
|
|
16
|
+
setValue(SwapFormKey.FromChain, toChain, { shouldTouch: true });
|
|
17
|
+
setValue(SwapFormKey.FromToken, toToken, { shouldTouch: true });
|
|
18
|
+
setValue(SwapFormKey.ToChain, fromChain, { shouldTouch: true });
|
|
19
|
+
setValue(SwapFormKey.ToToken, fromToken, { shouldTouch: true });
|
|
20
20
|
};
|
|
21
|
-
return (_jsx(IconButton, Object.assign({ onClick: handleClick, size: "small"
|
|
21
|
+
return (_jsx(IconButton, Object.assign({ onClick: handleClick, size: "small" }, { children: vertical ? _jsx(SwapVertIcon, {}) : _jsx(SwapHorizIcon, {}) })));
|
|
22
22
|
};
|
|
@@ -15,7 +15,7 @@ export declare const SelectTokenCardHeader: import("@emotion/styled").StyledComp
|
|
|
15
15
|
}> | undefined;
|
|
16
16
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
17
17
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
18
|
-
}, keyof import("@mui/material/OverridableComponent").CommonProps | "title" | "action" | "sx" | "
|
|
18
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "title" | "action" | "sx" | "disableTypography" | "avatar" | "subheader" | "subheaderTypographyProps" | "titleTypographyProps"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
19
19
|
selected?: boolean | undefined;
|
|
20
20
|
compact?: boolean | undefined;
|
|
21
21
|
}, {}, {}>;
|
|
@@ -11,18 +11,17 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
11
11
|
import { isAddress } from '@ethersproject/address';
|
|
12
12
|
import { Collapse, FormHelperText } from '@mui/material';
|
|
13
13
|
import { forwardRef, useEffect } from 'react';
|
|
14
|
-
import { useFormContext } from 'react-hook-form';
|
|
14
|
+
import { useFormContext, useFormState } from 'react-hook-form';
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
16
|
import { SwapFormKey, useWallet } from '../../providers';
|
|
17
17
|
import { Card, CardTitle } from '../Card';
|
|
18
18
|
import { FormControl, Input } from './SendToWallet.style';
|
|
19
19
|
import { useSendToWalletStore } from './store';
|
|
20
20
|
export const SendToWallet = forwardRef((props, ref) => {
|
|
21
|
-
var _a;
|
|
22
21
|
const { t } = useTranslation();
|
|
23
22
|
const showSendToWallet = useSendToWalletStore((state) => state.showSendToWallet);
|
|
24
23
|
const { account, provider } = useWallet();
|
|
25
|
-
const { register, trigger
|
|
24
|
+
const { register, trigger } = useFormContext();
|
|
26
25
|
useEffect(() => {
|
|
27
26
|
trigger(SwapFormKey.ToAddress);
|
|
28
27
|
}, [account.chainId, trigger]);
|
|
@@ -36,11 +35,16 @@ export const SendToWallet = forwardRef((props, ref) => {
|
|
|
36
35
|
return (isAddress(address || value) ||
|
|
37
36
|
t('swap.error.title.walletAddressInvalid'));
|
|
38
37
|
}
|
|
39
|
-
catch (
|
|
38
|
+
catch (_a) {
|
|
40
39
|
return t('swap.error.title.walletEnsAddressInvalid');
|
|
41
40
|
}
|
|
42
41
|
}),
|
|
43
42
|
onBlur: () => trigger(SwapFormKey.ToAddress),
|
|
44
43
|
});
|
|
45
|
-
return (_jsx(Collapse, Object.assign({ timeout: 225,
|
|
44
|
+
return (_jsx(Collapse, Object.assign({ timeout: 225, in: showSendToWallet, mountOnEnter: true, unmountOnExit: true }, { children: _jsxs(Card, Object.assign({}, props, { ref: ref }, { children: [_jsx(CardTitle, { children: t('swap.sendToWallet') }), _jsxs(FormControl, Object.assign({ fullWidth: true, sx: { paddingTop: '6px', paddingBottom: '5px' } }, { children: [_jsx(Input, { ref: inputRef, size: "small", autoComplete: "off", autoCorrect: "off", autoCapitalize: "off", spellCheck: "false", onChange: onChange, onBlur: onBlur, name: name, placeholder: t('swap.walletAddressOrEns'), autoFocus: true }), _jsx(SendToWalletFormHelperText, {})] }))] })) })));
|
|
46
45
|
});
|
|
46
|
+
export const SendToWalletFormHelperText = () => {
|
|
47
|
+
var _a;
|
|
48
|
+
const { errors } = useFormState();
|
|
49
|
+
return (_jsx(FormHelperText, Object.assign({ error: !!errors.toAddress }, { children: (_a = errors.toAddress) === null || _a === void 0 ? void 0 : _a.message })));
|
|
50
|
+
};
|
|
@@ -17,11 +17,11 @@ export const SendToWalletButton = () => {
|
|
|
17
17
|
}
|
|
18
18
|
const handleClick = () => {
|
|
19
19
|
if (showSendToWallet) {
|
|
20
|
-
setValue(SwapFormKey.ToAddress, '');
|
|
20
|
+
setValue(SwapFormKey.ToAddress, '', { shouldTouch: true });
|
|
21
21
|
}
|
|
22
22
|
toggleSendToWallet();
|
|
23
23
|
};
|
|
24
|
-
return (_jsx(Tooltip, Object.assign({ title: t('swap.sendToWallet'), placement: "bottom-end", enterDelay:
|
|
24
|
+
return (_jsx(Tooltip, Object.assign({ title: t('swap.sendToWallet'), placement: "bottom-end", enterDelay: 400, arrow: true }, { children: _jsx(Button, Object.assign({ variant: showSendToWallet ? 'contained' : 'text', onClick: handleClick, sx: {
|
|
25
25
|
minWidth: 48,
|
|
26
26
|
marginLeft: 1,
|
|
27
27
|
} }, { children: _jsx(WalletOutlinedIcon, {}) })) })));
|
|
@@ -13,5 +13,5 @@ export const StepProcess = ({ step, process }) => {
|
|
|
13
13
|
display: 'flex',
|
|
14
14
|
flex: 1,
|
|
15
15
|
justifyContent: 'flex-end',
|
|
16
|
-
} }, { children: _jsx(LinkButton, Object.assign({ size: "small",
|
|
16
|
+
} }, { children: _jsx(LinkButton, Object.assign({ size: "small", edge: "end", LinkComponent: Link, href: process.txLink, target: "_blank", rel: "nofollow noreferrer" }, { children: _jsx(LinkIcon, {}) })) }))) : null] })), message ? (_jsx(Typography, Object.assign({ ml: 6, fontSize: 14, fontWeight: 500, color: "text.secondary" }, { children: message }))) : null] })));
|
|
17
17
|
};
|
|
@@ -8,19 +8,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
import {
|
|
11
|
+
import { LoadingButton } from '@mui/lab';
|
|
12
12
|
import { forwardRef } from 'react';
|
|
13
13
|
import { useTranslation } from 'react-i18next';
|
|
14
14
|
import { useNavigate } from 'react-router-dom';
|
|
15
15
|
import { useGasSufficiency } from '../../hooks';
|
|
16
16
|
import { useWallet, useWidgetConfig } from '../../providers';
|
|
17
17
|
import { navigationRoutes } from '../../utils';
|
|
18
|
-
export const SwapButton = forwardRef(({ onClick, currentRoute, text, disable }, ref) => {
|
|
18
|
+
export const SwapButton = forwardRef(({ onClick, currentRoute, text, disable, enableLoading, loading }, ref) => {
|
|
19
19
|
const { t } = useTranslation();
|
|
20
20
|
const navigate = useNavigate();
|
|
21
21
|
const config = useWidgetConfig();
|
|
22
22
|
const { account, connect } = useWallet();
|
|
23
|
-
const { insufficientFunds, insufficientGas } = useGasSufficiency(currentRoute);
|
|
23
|
+
const { insufficientFunds, insufficientGas, isLoading: isGasSufficiencyLoading, } = useGasSufficiency(currentRoute);
|
|
24
24
|
const handleSwapButtonClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
25
|
if (!account.isActive) {
|
|
26
26
|
if (config.walletManagement) {
|
|
@@ -43,5 +43,5 @@ export const SwapButton = forwardRef(({ onClick, currentRoute, text, disable },
|
|
|
43
43
|
}
|
|
44
44
|
return t(`button.connectWallet`);
|
|
45
45
|
};
|
|
46
|
-
return (_jsx(
|
|
46
|
+
return (_jsx(LoadingButton, Object.assign({ variant: "contained", color: account.isActive ? 'primary' : 'success', onClick: handleSwapButtonClick, disabled: insufficientFunds || !!(insufficientGas === null || insufficientGas === void 0 ? void 0 : insufficientGas.length) || disable, loading: enableLoading && (loading || isGasSufficiencyLoading), loadingPosition: "center", fullWidth: true, ref: ref }, { children: getButtonText() })));
|
|
47
47
|
});
|
|
@@ -27,11 +27,15 @@ export const SwapInput = ({ formType }) => {
|
|
|
27
27
|
const isSelected = !!(chain && token);
|
|
28
28
|
const handleChange = (event) => {
|
|
29
29
|
const { value } = event.target;
|
|
30
|
-
|
|
30
|
+
const formattedAmount = formatAmount(value, true);
|
|
31
|
+
setValue(amountKey, formattedAmount, {
|
|
32
|
+
shouldTouch: true,
|
|
33
|
+
});
|
|
31
34
|
};
|
|
32
35
|
const handleBlur = (event) => {
|
|
33
36
|
const { value } = event.target;
|
|
34
|
-
|
|
37
|
+
const formattedAmount = formatAmount(value);
|
|
38
|
+
setValue(amountKey, formattedAmount);
|
|
35
39
|
};
|
|
36
40
|
useLayoutEffect(() => {
|
|
37
41
|
fitInputText(maxInputFontSize, minInputFontSize, ref.current);
|
|
@@ -17,7 +17,9 @@ export const SwapInputAdornment = ({ formType }) => {
|
|
|
17
17
|
const { token, isLoading } = useTokenAddressBalance(chainId, tokenAddress);
|
|
18
18
|
const handleMax = () => {
|
|
19
19
|
var _a;
|
|
20
|
-
setValue(SwapFormKeyHelper.getAmountKey(formType), (_a = token === null || token === void 0 ? void 0 : token.amount) !== null && _a !== void 0 ? _a : ''
|
|
20
|
+
setValue(SwapFormKeyHelper.getAmountKey(formType), (_a = token === null || token === void 0 ? void 0 : token.amount) !== null && _a !== void 0 ? _a : '', {
|
|
21
|
+
shouldTouch: true,
|
|
22
|
+
});
|
|
21
23
|
};
|
|
22
|
-
return (_jsx(InputAdornment, Object.assign({ position: "end" }, { children: isLoading && tokenAddress ? (_jsx(Skeleton, { variant: "rectangular", width: 46, height:
|
|
24
|
+
return (_jsx(InputAdornment, Object.assign({ position: "end" }, { children: isLoading && tokenAddress ? (_jsx(Skeleton, { variant: "rectangular", width: 46, height: 24, sx: { borderRadius: 0.5 } })) : formType === 'from' && (token === null || token === void 0 ? void 0 : token.amount) ? (_jsx(Button, Object.assign({ onClick: handleMax }, { children: t('button.max') }))) : null })));
|
|
23
25
|
};
|
|
@@ -1,20 +1,8 @@
|
|
|
1
1
|
import { Button as MuiButton } from '@mui/material';
|
|
2
|
-
import {
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
3
3
|
export const Button = styled(MuiButton)(({ theme }) => ({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
: theme.palette.grey[800],
|
|
7
|
-
color: theme.palette.text.secondary,
|
|
8
|
-
padding: theme.spacing(0.125, 1, 0.375, 1),
|
|
9
|
-
lineHeight: 1,
|
|
4
|
+
padding: theme.spacing(0.5, 1, 0.625, 1),
|
|
5
|
+
lineHeight: 1.0715,
|
|
10
6
|
fontSize: '0.875rem',
|
|
11
7
|
minWidth: 'unset',
|
|
12
|
-
'&:hover': {
|
|
13
|
-
color: theme.palette.mode === 'light'
|
|
14
|
-
? theme.palette.primary.main
|
|
15
|
-
: theme.palette.text.primary,
|
|
16
|
-
borderColor: theme.palette.mode === 'light'
|
|
17
|
-
? lighten(theme.palette.primary.main, 0.5)
|
|
18
|
-
: theme.palette.text.secondary,
|
|
19
|
-
},
|
|
20
8
|
}));
|
|
@@ -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 { AccessTime as AccessTimeIcon, EvStationOutlined as EvStationIcon, ExpandLess as ExpandLessIcon, ExpandMore as ExpandMoreIcon, LayersOutlined as LayersIcon, } from '@mui/icons-material';
|
|
14
|
-
import { Box, Collapse, Typography } from '@mui/material';
|
|
14
|
+
import { Box, Collapse, Tooltip, Typography } from '@mui/material';
|
|
15
15
|
import { useState } from 'react';
|
|
16
16
|
import { useTranslation } from 'react-i18next';
|
|
17
17
|
import { Card } from '../Card';
|
|
@@ -31,15 +31,16 @@ export const SwapRouteCard = (_a) => {
|
|
|
31
31
|
e.stopPropagation();
|
|
32
32
|
setCardExpanded((expanded) => !expanded);
|
|
33
33
|
};
|
|
34
|
-
return (_jsxs(Card, Object.assign({ dense: variant === 'dense', variant: active ? 'selected' : 'default', selectionColor: "secondary", indented: true }, other, { children: [_jsxs(Box, Object.assign({ display: "flex", justifyContent: "space-between", alignItems: "center", mb: 2 }, { children: [_jsx(Label, Object.assign({ active: active !== null && active !== void 0 ? active : label !== alternativeTag }, { children: label })), variant === 'stretched' ? (_jsx(SwapRouteCardEssentials, { route: route })) : null] })), _jsxs(Box, Object.assign({ display: "flex", justifyContent: "space-between", alignItems: "center" }, { children: [_jsx(Token, { token: Object.assign(Object.assign({}, route.toToken), { amount: route.toAmount }), step: variant === 'stretched' ? route.steps[0] : undefined }), variant === 'stretched' && !expanded ? (_jsx(IconButton, Object.assign({ onClick: handleExpand, size: "small" }, { children: cardExpanded ? _jsx(ExpandLessIcon, {}) : _jsx(ExpandMoreIcon, {}) }))) : null] })), _jsx(Collapse, Object.assign({
|
|
34
|
+
return (_jsxs(Card, Object.assign({ dense: variant === 'dense', variant: active ? 'selected' : 'default', selectionColor: "secondary", indented: true }, other, { children: [_jsxs(Box, Object.assign({ display: "flex", justifyContent: "space-between", alignItems: "center", mb: 2 }, { children: [_jsx(Label, Object.assign({ active: active !== null && active !== void 0 ? active : label !== alternativeTag }, { children: label })), variant === 'stretched' ? (_jsx(SwapRouteCardEssentials, { route: route })) : null] })), _jsxs(Box, Object.assign({ display: "flex", justifyContent: "space-between", alignItems: "center" }, { children: [_jsx(Token, { token: Object.assign(Object.assign({}, route.toToken), { amount: route.toAmount }), step: variant === 'stretched' ? route.steps[0] : undefined }), variant === 'stretched' && !expanded ? (_jsx(IconButton, Object.assign({ onClick: handleExpand, size: "small" }, { children: cardExpanded ? _jsx(ExpandLessIcon, {}) : _jsx(ExpandMoreIcon, {}) }))) : null] })), _jsx(Collapse, Object.assign({ timeout: 225, in: cardExpanded, mountOnEnter: true, unmountOnExit: true }, { children: route.steps.map((step) => (_jsx(StepActions, { step: step, mt: 2 }, step.id))) })), variant !== 'stretched' ? (_jsx(SwapRouteCardEssentials, { route: route, dense: true })) : null] })));
|
|
35
35
|
};
|
|
36
36
|
export const SwapRouteCardEssentials = ({ route, dense }) => {
|
|
37
37
|
var _a;
|
|
38
38
|
const { t } = useTranslation();
|
|
39
|
-
const
|
|
39
|
+
const executionTimeMinutes = Math.ceil(route.steps
|
|
40
40
|
.map((step) => step.estimate.executionDuration)
|
|
41
|
-
.reduce((duration, x) => duration + x) / 60)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
.reduce((duration, x) => duration + x, 0) / 60);
|
|
42
|
+
const gasCostUSD = parseFloat((_a = route.gasCostUSD) !== null && _a !== void 0 ? _a : '') || 0.01;
|
|
43
|
+
return (_jsxs(Box, Object.assign({ display: "flex", justifyContent: dense ? 'space-between' : 'flex-end', flex: 1, pl: dense ? 0 : 2, mt: dense ? 2 : 0 }, { children: [_jsx(Tooltip, Object.assign({ title: t(`tooltip.estimatedNetworkFee`), placement: "top", enterDelay: 400, arrow: true }, { children: _jsxs(Box, Object.assign({ display: "flex", alignItems: "center", mr: dense ? 0 : 2 }, { children: [_jsx(Typography, Object.assign({ lineHeight: 0, mr: 0.5, color: "grey.500" }, { children: _jsx(EvStationIcon, { fontSize: dense ? 'medium' : 'small' }) })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1 }, { children: t(`swap.currency`, { value: gasCostUSD }) }))] })) })), _jsx(Tooltip, Object.assign({ title: t(`tooltip.estimatedTime`), placement: "top", enterDelay: 400, arrow: true }, { children: _jsxs(Box, Object.assign({ display: "flex", alignItems: "center", mr: dense ? 0 : 2 }, { children: [_jsx(Typography, Object.assign({ lineHeight: 0, mr: 0.5, color: "grey.500" }, { children: _jsx(AccessTimeIcon, { fontSize: dense ? 'medium' : 'small' }) })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1 }, { children: t('swap.estimatedTime', {
|
|
44
|
+
value: executionTimeMinutes,
|
|
45
|
+
}) }))] })) })), !dense ? (_jsx(Tooltip, Object.assign({ title: t(`tooltip.numberOfSteps`), placement: "top", enterDelay: 400, arrow: true }, { children: _jsxs(Box, Object.assign({ display: "flex", alignItems: "center" }, { children: [_jsx(Typography, Object.assign({ lineHeight: 0, mr: 0.5, color: "grey.500" }, { children: _jsx(LayersIcon, { fontSize: dense ? 'medium' : 'small' }) })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1 }, { children: route.steps.length }))] })) }))) : null] })));
|
|
45
46
|
};
|
|
@@ -10,14 +10,14 @@ import { SwapRouteCard, SwapRouteCardSkeleton, SwapRouteNotFoundCard, } from '..
|
|
|
10
10
|
import { useSwapRoutes } from '../../hooks';
|
|
11
11
|
import { navigationRoutes } from '../../utils';
|
|
12
12
|
import { Stack } from './SwapRoutes.style';
|
|
13
|
-
import {
|
|
13
|
+
import { useSetRecommendedRoute } from './useSetRecommendedRoute';
|
|
14
14
|
export const SwapRoutes = (props) => {
|
|
15
15
|
const { t } = useTranslation();
|
|
16
16
|
const navigate = useNavigate();
|
|
17
17
|
const { isValid, isValidating } = useFormState();
|
|
18
18
|
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = useSwapRoutes();
|
|
19
19
|
const currentRoute = routes === null || routes === void 0 ? void 0 : routes[0];
|
|
20
|
-
|
|
20
|
+
useSetRecommendedRoute(currentRoute, isFetching);
|
|
21
21
|
if (!currentRoute && !isLoading && !isFetching && !isFetched) {
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
@@ -30,8 +30,8 @@ export const SwapRoutes = (props) => {
|
|
|
30
30
|
top: 8,
|
|
31
31
|
right: 8,
|
|
32
32
|
} }), _jsxs(Box, Object.assign({ sx: { display: 'flex' } }, { children: [_jsx(Stack, Object.assign({ direction: "row", spacing: 2, my: 2, ml: 2, mr: routeNotFound ? 2 : 1, sx: {
|
|
33
|
-
|
|
33
|
+
borderRightWidth: !routeNotFound && (isFetching || (routes && routes.length > 1))
|
|
34
34
|
? 1
|
|
35
35
|
: 0,
|
|
36
|
-
} }, { children: isLoading || isFetching ? (_jsxs(_Fragment, { children: [_jsx(SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" }), _jsx(SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" })] })) : !currentRoute ? (_jsx(SwapRouteNotFoundCard, {})) : (_jsxs(_Fragment, { children: [_jsx(SwapRouteCard, { minWidth: routes.length > 1 ? '80%' : '100%', route: currentRoute, variant: "dense", active: true }), routes.length > 1 ? (_jsx(SwapRouteCard, { minWidth: "80%", route: routes[1], variant: "dense" })) : null] })) })), _jsx(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: !routeNotFound ? (_jsx(Box, Object.assign({ py: 1, pr: 1 }, { children: _jsx(IconButton, Object.assign({ onClick: handleCardClick, size: "medium",
|
|
36
|
+
} }, { children: isLoading || isFetching ? (_jsxs(_Fragment, { children: [_jsx(SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" }), _jsx(SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" })] })) : !currentRoute ? (_jsx(SwapRouteNotFoundCard, {})) : (_jsxs(_Fragment, { children: [_jsx(SwapRouteCard, { minWidth: routes.length > 1 ? '80%' : '100%', route: currentRoute, variant: "dense", active: true }), routes.length > 1 ? (_jsx(SwapRouteCard, { minWidth: "80%", route: routes[1], variant: "dense" })) : null] })) })), _jsx(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: !routeNotFound ? (_jsx(Box, Object.assign({ py: 1, pr: 1 }, { children: _jsx(IconButton, Object.assign({ onClick: handleCardClick, size: "medium", disabled: isValidating || !isValid }, { children: _jsx(KeyboardArrowRightIcon, {}) })) }))) : null }))] }))] })));
|
|
37
37
|
};
|
|
@@ -2,16 +2,26 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Collapse, Grow, Stack, Typography } from '@mui/material';
|
|
3
3
|
import { useFormState } from 'react-hook-form';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import {
|
|
5
|
+
import { useNavigate, useRoutes } from 'react-router-dom';
|
|
6
6
|
import { useSwapRoutes } from '../../hooks';
|
|
7
7
|
import { useWidgetConfig } from '../../providers';
|
|
8
8
|
import { useSetExecutableRoute } from '../../stores';
|
|
9
|
-
import { navigationRoutes
|
|
9
|
+
import { navigationRoutes } from '../../utils';
|
|
10
10
|
import { ProgressToNextUpdate } from '../ProgressToNextUpdate';
|
|
11
11
|
import { SwapRouteCard, SwapRouteCardSkeleton, SwapRouteNotFoundCard, } from '../SwapRouteCard';
|
|
12
12
|
import { CollapseContainer, Container, Header, ScrollableContainer, } from './SwapRoutes.style';
|
|
13
|
-
import {
|
|
13
|
+
import { useSetRecommendedRoute } from './useSetRecommendedRoute';
|
|
14
|
+
const timeout = { enter: 225, exit: 225, appear: 0 };
|
|
14
15
|
export const SwapRoutesExpanded = () => {
|
|
16
|
+
const element = useRoutes([
|
|
17
|
+
{
|
|
18
|
+
path: '/',
|
|
19
|
+
element: null,
|
|
20
|
+
},
|
|
21
|
+
]);
|
|
22
|
+
return (_jsx(CollapseContainer, { children: _jsx(Collapse, Object.assign({ timeout: timeout, in: !!element, orientation: "horizontal" }, { children: _jsx(Grow, Object.assign({ timeout: timeout, in: !!element, mountOnEnter: true, unmountOnExit: true }, { children: _jsx("div", { children: _jsx(SwapRoutesExpandedElement, {}) }) })) })) }));
|
|
23
|
+
};
|
|
24
|
+
export const SwapRoutesExpandedElement = () => {
|
|
15
25
|
const { t } = useTranslation();
|
|
16
26
|
const navigate = useNavigate();
|
|
17
27
|
const setExecutableRoute = useSetExecutableRoute();
|
|
@@ -19,13 +29,7 @@ export const SwapRoutesExpanded = () => {
|
|
|
19
29
|
const { isValid, isValidating } = useFormState();
|
|
20
30
|
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = useSwapRoutes();
|
|
21
31
|
const currentRoute = routes === null || routes === void 0 ? void 0 : routes[0];
|
|
22
|
-
|
|
23
|
-
const { pathname } = useLocation();
|
|
24
|
-
const cleanedPathname = pathname.endsWith('/')
|
|
25
|
-
? pathname.slice(0, -1)
|
|
26
|
-
: pathname;
|
|
27
|
-
const path = cleanedPathname.substring(cleanedPathname.lastIndexOf('/') + 1);
|
|
28
|
-
const hasPath = navigationRoutesValues.includes(path);
|
|
32
|
+
useSetRecommendedRoute(currentRoute, isFetching);
|
|
29
33
|
const handleRouteClick = (route) => {
|
|
30
34
|
if (isValid && !isValidating) {
|
|
31
35
|
setExecutableRoute(route);
|
|
@@ -34,7 +38,7 @@ export const SwapRoutesExpanded = () => {
|
|
|
34
38
|
});
|
|
35
39
|
}
|
|
36
40
|
};
|
|
37
|
-
const expanded = Boolean(currentRoute || isLoading || isFetching || isFetched)
|
|
41
|
+
const expanded = Boolean(currentRoute || isLoading || isFetching || isFetched);
|
|
38
42
|
const routeNotFound = !currentRoute && !isLoading && !isFetching && expanded;
|
|
39
|
-
return (_jsx(
|
|
43
|
+
return (_jsx(Collapse, Object.assign({ timeout: timeout.enter, in: expanded, orientation: "horizontal" }, { children: _jsx(Grow, Object.assign({ timeout: timeout.enter, in: expanded, mountOnEnter: true, unmountOnExit: true }, { children: _jsx(Container, Object.assign({ sx: containerStyle, enableColorScheme: true }, { children: _jsxs(ScrollableContainer, { children: [_jsxs(Header, { children: [_jsx(Typography, Object.assign({ fontSize: 18, fontWeight: "700", flex: 1, noWrap: true }, { children: t('swap.routes') })), _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 } })] }), _jsx(Stack, Object.assign({ direction: "column", spacing: 2, flex: 1, paddingX: 3, paddingBottom: 3 }, { children: routeNotFound ? (_jsx(SwapRouteNotFoundCard, {})) : isLoading || isFetching ? (Array.from({ length: 3 }).map((_, index) => (_jsx(SwapRouteCardSkeleton, { variant: "stretched" }, index)))) : (routes === null || routes === void 0 ? void 0 : routes.map((route, index) => (_jsx(SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, variant: "stretched", expanded: (routes === null || routes === void 0 ? void 0 : routes.length) <= 2 }, route.id)))) }))] }) })) })) })));
|
|
40
44
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useRecommendedRouteStore } from '../../stores';
|
|
3
|
+
export const useSetRecommendedRoute = (currentRoute, isFetching) => {
|
|
4
|
+
const setRecommendedRoute = useRecommendedRouteStore((state) => state.setRecommendedRoute);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
setRecommendedRoute(!isFetching ? currentRoute : undefined);
|
|
7
|
+
return () => setRecommendedRoute(undefined);
|
|
8
|
+
}, [currentRoute, isFetching, setRecommendedRoute]);
|
|
9
|
+
};
|
|
@@ -36,22 +36,25 @@ export const TokenList = ({ formType, height, onClick, }) => {
|
|
|
36
36
|
: filteredTokens;
|
|
37
37
|
const handleTokenClick = useCallback((tokenAddress) => {
|
|
38
38
|
setValue(SwapFormKeyHelper.getTokenKey(formType), tokenAddress, {
|
|
39
|
-
|
|
39
|
+
shouldTouch: true,
|
|
40
|
+
});
|
|
41
|
+
// Set chain again to trigger URL builder update
|
|
42
|
+
setValue(SwapFormKeyHelper.getChainKey(formType), selectedChainId, {
|
|
43
|
+
shouldTouch: true,
|
|
40
44
|
});
|
|
41
45
|
setValue(SwapFormKeyHelper.getAmountKey(formType), '');
|
|
42
46
|
const oppositeFormType = formType === 'from' ? 'to' : 'from';
|
|
43
|
-
const [selectedOppositeToken,
|
|
47
|
+
const [selectedOppositeToken, selectedOppositeChainId] = getValues([
|
|
44
48
|
SwapFormKeyHelper.getTokenKey(oppositeFormType),
|
|
45
49
|
SwapFormKeyHelper.getChainKey(oppositeFormType),
|
|
46
|
-
SwapFormKeyHelper.getChainKey(formType),
|
|
47
50
|
]);
|
|
48
51
|
if (selectedOppositeToken === tokenAddress &&
|
|
49
|
-
|
|
52
|
+
selectedOppositeChainId === selectedChainId) {
|
|
50
53
|
setValue(SwapFormKeyHelper.getTokenKey(oppositeFormType), '', {
|
|
51
|
-
|
|
54
|
+
shouldTouch: true,
|
|
52
55
|
});
|
|
53
56
|
}
|
|
54
57
|
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
55
|
-
}, [formType, getValues, onClick, setValue]);
|
|
58
|
+
}, [formType, getValues, onClick, selectedChainId, setValue]);
|
|
56
59
|
return (_jsxs(Box, Object.assign({ ref: parentRef, style: { height, overflow: 'auto' } }, { children: [!tokens.length && !isLoading ? (_jsx(TokenNotFound, { formType: formType })) : null, _jsx(VirtualizedTokenList, { tokens: tokens, featuredTokensLength: featuredTokens === null || featuredTokens === void 0 ? void 0 : featuredTokens.length, scrollElementRef: parentRef, chainId: selectedChainId, isLoading: isLoading, isBalanceLoading: isBalanceLoading, showBalance: account.isActive, showFeatured: !tokenSearchFilter, onClick: handleTokenClick })] })));
|
|
57
60
|
};
|
package/config/theme.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { loadingButtonClasses } from '@mui/lab/LoadingButton';
|
|
1
2
|
import { common } from '@mui/material/colors';
|
|
2
3
|
import { dialogActionsClasses } from '@mui/material/DialogActions';
|
|
3
4
|
import { alpha, createTheme as createMuiTheme, darken, getContrastRatio, lighten, } from '@mui/material/styles';
|
|
@@ -45,6 +46,9 @@ export const createTheme = (mode, theme = {}) => {
|
|
|
45
46
|
const primaryMainColor = (_c = (_b = (_a = theme.palette) === null || _a === void 0 ? void 0 : _a.primary) === null || _b === void 0 ? void 0 : _b.main) !== null && _c !== void 0 ? _c : palette.primary.main;
|
|
46
47
|
const primaryLightColor = lighten((_f = (_e = (_d = theme.palette) === null || _d === void 0 ? void 0 : _d.primary) === null || _e === void 0 ? void 0 : _e.main) !== null && _f !== void 0 ? _f : palette.primary.main, 0.5);
|
|
47
48
|
const primaryDarkColor = darken((_j = (_h = (_g = theme.palette) === null || _g === void 0 ? void 0 : _g.primary) === null || _h === void 0 ? void 0 : _h.main) !== null && _j !== void 0 ? _j : palette.primary.main, 0.2);
|
|
49
|
+
const contrastButtonColor = getContrastRatio(common.white, primaryMainColor) >= 3
|
|
50
|
+
? common.white
|
|
51
|
+
: common.black;
|
|
48
52
|
return createMuiTheme({
|
|
49
53
|
typography: Object.assign({ fontFamily: 'Inter var, Inter, sans-serif' }, theme.typography),
|
|
50
54
|
palette: Object.assign(Object.assign(Object.assign({ mode }, palette), { primary: {
|
|
@@ -80,13 +84,25 @@ export const createTheme = (mode, theme = {}) => {
|
|
|
80
84
|
borderRadius: (_v = (_u = theme.shape) === null || _u === void 0 ? void 0 : _u.borderRadiusSecondary) !== null && _v !== void 0 ? _v : shape.borderRadiusSecondary,
|
|
81
85
|
textTransform: 'none',
|
|
82
86
|
fontSize: '1rem',
|
|
83
|
-
|
|
87
|
+
[`&.Mui-disabled, &.Mui-disabled:hover`]: {
|
|
84
88
|
color: mode === 'light'
|
|
85
|
-
? 'rgb(0 0 0 /
|
|
86
|
-
: 'rgb(255 255 255 /
|
|
89
|
+
? 'rgb(0 0 0 / 56%)'
|
|
90
|
+
: 'rgb(255 255 255 / 56%)',
|
|
87
91
|
cursor: 'not-allowed',
|
|
88
92
|
pointerEvents: 'auto',
|
|
89
93
|
},
|
|
94
|
+
[`&.${loadingButtonClasses.loading}.Mui-disabled`]: {
|
|
95
|
+
backgroundColor: primaryMainColor,
|
|
96
|
+
color: contrastButtonColor,
|
|
97
|
+
cursor: 'auto',
|
|
98
|
+
pointerEvents: 'auto',
|
|
99
|
+
},
|
|
100
|
+
[`.${loadingButtonClasses.loadingIndicator}`]: {
|
|
101
|
+
color: contrastButtonColor,
|
|
102
|
+
},
|
|
103
|
+
[`&.${loadingButtonClasses.root}.${loadingButtonClasses.loading}`]: {
|
|
104
|
+
color: 'transparent',
|
|
105
|
+
},
|
|
90
106
|
}, text: {
|
|
91
107
|
backgroundColor: alpha(primaryMainColor, 0.08),
|
|
92
108
|
'&:hover': {
|
|
@@ -94,9 +110,7 @@ export const createTheme = (mode, theme = {}) => {
|
|
|
94
110
|
},
|
|
95
111
|
}, contained: {
|
|
96
112
|
'&:hover': {
|
|
97
|
-
color:
|
|
98
|
-
? common.white
|
|
99
|
-
: common.black,
|
|
113
|
+
color: contrastButtonColor,
|
|
100
114
|
},
|
|
101
115
|
}, sizeMedium: {
|
|
102
116
|
padding: '10px 16px',
|
|
@@ -114,10 +128,10 @@ export const createTheme = (mode, theme = {}) => {
|
|
|
114
128
|
},
|
|
115
129
|
},
|
|
116
130
|
text: {
|
|
117
|
-
backgroundColor: paletteDark.background.paper,
|
|
131
|
+
backgroundColor: lighten(paletteDark.background.paper, 0.08),
|
|
118
132
|
color: common.white,
|
|
119
133
|
'&:hover': {
|
|
120
|
-
backgroundColor: lighten(paletteDark.background.paper, 0.
|
|
134
|
+
backgroundColor: lighten(paletteDark.background.paper, 0.12),
|
|
121
135
|
},
|
|
122
136
|
},
|
|
123
137
|
}
|
package/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "1.
|
|
2
|
+
export declare const version = "1.20.0";
|
package/config/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '1.
|
|
2
|
+
export const version = '1.20.0';
|
package/hooks/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './useChain';
|
|
|
2
2
|
export * from './useChains';
|
|
3
3
|
export * from './useContentHeight';
|
|
4
4
|
export * from './useDebouncedWatch';
|
|
5
|
+
export * from './useExpandableVariant';
|
|
5
6
|
export * from './useFeaturedTokens';
|
|
6
7
|
export * from './useGasSufficiency';
|
|
7
8
|
export * from './useInitializer';
|