@lifi/widget 1.10.4 → 1.11.2
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 +58 -10
- 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 +3 -6
- 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 +1 -1
- package/components/Header/Header.style.js +2 -1
- package/components/Header/NavigationHeader.js +16 -10
- package/components/Header/WalletHeader.js +1 -1
- 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 +5 -5
- 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 +14 -5
- 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 +7 -10
- package/components/SwapButton/SwapButton.style.d.ts +1 -1
- package/components/SwapButton/SwapButton.style.js +0 -4
- package/components/SwapButton/types.d.ts +2 -0
- package/components/SwapInProgress/SwapInProgress.js +8 -5
- package/components/SwapInProgress/SwapInProgress.style.d.ts +9 -21
- package/components/SwapInProgress/SwapInProgress.style.js +5 -6
- package/components/SwapInput/SwapInput.js +3 -3
- 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/TokenListItem.d.ts +1 -0
- package/components/TokenList/TokenListItem.js +12 -6
- 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 +30 -3
- 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/useGasSufficiency.d.ts +15 -0
- package/hooks/useGasSufficiency.js +91 -0
- package/hooks/useRouteExecution.d.ts +3 -3
- package/hooks/useRouteExecution.js +22 -18
- package/hooks/useSwapRoutes.d.ts +1 -1
- package/hooks/useSwapRoutes.js +2 -14
- package/hooks/useTokenBalance.js +1 -1
- package/hooks/useTokenBalances.d.ts +2 -2
- package/hooks/useTokenBalances.js +7 -9
- 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 +8 -8
- package/pages/MainPage/MainPage.js +2 -3
- package/pages/MainPage/MainSwapButton.js +5 -6
- 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/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 +2 -2
- 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 +3 -4
- package/pages/SwapPage/SwapPage.js +9 -9
- package/pages/SwapPage/SwapPage.style.d.ts +0 -33
- package/pages/SwapPage/SwapPage.style.js +2 -9
- package/pages/SwapRoutesPage/SwapRoutesPage.js +13 -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/navigationRoutes.d.ts +3 -1
- package/utils/navigationRoutes.js +3 -1
- 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
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box } from '@mui/material';
|
|
3
|
-
import { InsufficientGasOrFundsMessage } from '../../components/InsufficientGasOrFundsMessage';
|
|
4
3
|
import { SelectChainAndToken } from '../../components/SelectChainAndToken';
|
|
5
4
|
import { SwapInProgress } from '../../components/SwapInProgress';
|
|
6
5
|
import { SwapInput } from '../../components/SwapInput';
|
|
7
|
-
import { SwapRoutes } from '../../components/SwapRoutes';
|
|
8
6
|
import { FormContainer } from './MainPage.style';
|
|
9
7
|
import { MainSwapButton } from './MainSwapButton';
|
|
8
|
+
import { SwapRoutes } from './SwapRoutes';
|
|
10
9
|
export const MainPage = () => {
|
|
11
|
-
return (_jsxs(FormContainer, Object.assign({ disableGutters: true }, { children: [_jsx(SwapInProgress, { mx: 3, mt:
|
|
10
|
+
return (_jsxs(FormContainer, Object.assign({ disableGutters: true }, { children: [_jsx(SwapInProgress, { mx: 3, mt: 1, mb: 2 }), _jsx(SelectChainAndToken, { mt: 1, mx: 3, mb: 3 }), _jsx(Box, Object.assign({ mx: 3, mb: 3 }, { children: _jsx(SwapInput, { formType: "from" }) })), _jsx(SwapRoutes, { mx: 3, mb: 3 }), _jsx(Box, Object.assign({ mx: 3, mb: 1 }, { children: _jsx(MainSwapButton, {}) }))] })));
|
|
12
11
|
};
|
|
@@ -11,21 +11,20 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
11
11
|
import { useNavigate } from 'react-router-dom';
|
|
12
12
|
import { SwapButton } from '../../components/SwapButton';
|
|
13
13
|
import { useSwapRoutes } from '../../hooks';
|
|
14
|
-
import {
|
|
14
|
+
import { useSetExecutableRoute } from '../../stores';
|
|
15
15
|
import { navigationRoutes } from '../../utils';
|
|
16
16
|
export const MainSwapButton = () => {
|
|
17
17
|
const navigate = useNavigate();
|
|
18
|
-
const [currentRoute] = useCurrentRoute();
|
|
19
18
|
const setExecutableRoute = useSetExecutableRoute();
|
|
20
19
|
const { routes: swapRoutes, isLoading, isFetching } = useSwapRoutes();
|
|
20
|
+
const currentRoute = swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes[0];
|
|
21
21
|
const handleClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
-
if (currentRoute
|
|
23
|
-
(swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.some((route) => route.id === currentRoute.id))) {
|
|
22
|
+
if (currentRoute) {
|
|
24
23
|
setExecutableRoute(currentRoute);
|
|
25
|
-
navigate(navigationRoutes.
|
|
24
|
+
navigate(navigationRoutes.swapExecution, {
|
|
26
25
|
state: { routeId: currentRoute.id },
|
|
27
26
|
});
|
|
28
27
|
}
|
|
29
28
|
});
|
|
30
|
-
return _jsx(SwapButton, { onClick: handleClick, loading: isLoading || isFetching });
|
|
29
|
+
return (_jsx(SwapButton, { onClick: handleClick, currentRoute: currentRoute, loading: isLoading || isFetching || !currentRoute }));
|
|
31
30
|
};
|
|
File without changes
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, 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 { Card, CardTitle } from '../../components/Card';
|
|
9
|
+
import { GasSufficiencyMessage } from '../../components/GasSufficiencyMessage';
|
|
10
|
+
import { ProgressToNextUpdate } from '../../components/ProgressToNextUpdate';
|
|
11
|
+
import { SwapRouteCard, SwapRouteCardSkeleton, SwapRouteNotFoundCard, } from '../../components/SwapRouteCard';
|
|
12
|
+
import { useSwapRoutes } from '../../hooks';
|
|
13
|
+
import { navigationRoutes } from '../../utils';
|
|
14
|
+
import { Stack } from './SwapRoutes.style';
|
|
15
|
+
export const SwapRoutes = (props) => {
|
|
16
|
+
const { t } = useTranslation();
|
|
17
|
+
const navigate = useNavigate();
|
|
18
|
+
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = useSwapRoutes();
|
|
19
|
+
const handleCardClick = useCallback(() => {
|
|
20
|
+
navigate(navigationRoutes.swapRoutes);
|
|
21
|
+
}, [navigate]);
|
|
22
|
+
const currentRoute = routes === null || routes === void 0 ? void 0 : routes[0];
|
|
23
|
+
if (!currentRoute && !isLoading && !isFetching && !isFetched) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const routeNotFound = !currentRoute && isFetched;
|
|
27
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Card, Object.assign({}, props, { children: [_jsx(CardTitle, { children: t('swap.routes') }), _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt, timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: {
|
|
28
|
+
position: 'absolute',
|
|
29
|
+
top: 8,
|
|
30
|
+
right: 8,
|
|
31
|
+
} }), _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: {
|
|
32
|
+
borderWidth: !routeNotFound && (isFetching || (routes && routes.length > 1))
|
|
33
|
+
? 1
|
|
34
|
+
: 0,
|
|
35
|
+
} }, { children: routeNotFound ? (_jsx(SwapRouteNotFoundCard, { minWidth: "100%", dense: true })) : isLoading || isFetching || !currentRoute ? (_jsxs(_Fragment, { children: [_jsx(SwapRouteCardSkeleton, { minWidth: "80%", dense: true }), _jsx(SwapRouteCardSkeleton, { minWidth: "80%", dense: true })] })) : (_jsxs(_Fragment, { children: [_jsx(SwapRouteCard, { minWidth: routes.length > 1 ? '80%' : '100%', route: currentRoute, active: true, dense: true }), routes.length > 1 ? (_jsx(SwapRouteCard, { minWidth: "80%", route: routes[1], dense: true })) : 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", "aria-label": "swap-routes" }, { children: _jsx(KeyboardArrowRightIcon, {}) })) }))) : null }))] }))] })), _jsx(GasSufficiencyMessage, Object.assign({ route: !isFetching ? currentRoute : undefined }, props))] }));
|
|
36
|
+
};
|
|
File without changes
|
|
@@ -3,7 +3,7 @@ import { KeyboardArrowDown as KeyboardArrowDownIcon } from '@mui/icons-material'
|
|
|
3
3
|
import { Avatar, FormControl, ListItemAvatar, MenuItem, Skeleton, } from '@mui/material';
|
|
4
4
|
import { useFormContext, useWatch } from 'react-hook-form';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
|
-
import {
|
|
6
|
+
import { Card, CardTitle } from '../../components/Card';
|
|
7
7
|
import { Select } from '../../components/Select';
|
|
8
8
|
import { useChains } from '../../hooks';
|
|
9
9
|
import { SwapFormKeyHelper, } from '../../providers/SwapFormProvider';
|
|
@@ -21,5 +21,5 @@ export const ChainSelect = ({ formType }) => {
|
|
|
21
21
|
setValue(SwapFormKeyHelper.getTokenKey(formType), '');
|
|
22
22
|
setValue(SwapFormKeyHelper.getAmountKey(formType), '');
|
|
23
23
|
};
|
|
24
|
-
return !isLoading ? (_jsxs(
|
|
24
|
+
return !isLoading ? (_jsxs(Card, { children: [_jsx(CardTitle, { children: t(`swap.selectChain`) }), _jsx(FormControl, Object.assign({ fullWidth: true }, { children: _jsx(Select, Object.assign({ labelId: "label", MenuProps: { elevation: 2 }, defaultValue: formType === 'from' ? fromChain : toChain, value: chainId, onChange: handleChain, IconComponent: KeyboardArrowDownIcon }, { children: chains === null || chains === void 0 ? void 0 : chains.map((chain) => (_jsxs(MenuItem, Object.assign({ value: chain.id }, { children: [_jsx(ListItemAvatar, { children: _jsx(Avatar, Object.assign({ src: chain.logoURI, alt: chain.key }, { children: chain.name[0] })) }), chain.name] }), chain.key))) })) }))] })) : (_jsx(Skeleton, { variant: "rectangular", width: "100%", height: 98, sx: { borderRadius: 1 } }));
|
|
25
25
|
};
|
|
@@ -4,7 +4,7 @@ import { FormControl, InputAdornment } from '@mui/material';
|
|
|
4
4
|
import { useEffect } from 'react';
|
|
5
5
|
import { useFormContext } from 'react-hook-form';
|
|
6
6
|
import { useTranslation } from 'react-i18next';
|
|
7
|
-
import {
|
|
7
|
+
import { Card } from '../../components/Card';
|
|
8
8
|
import { SwapFormKey } from '../../providers/SwapFormProvider';
|
|
9
9
|
import { Input } from './SearchTokenInput.style';
|
|
10
10
|
export const SearchTokenInput = () => {
|
|
@@ -13,5 +13,5 @@ export const SearchTokenInput = () => {
|
|
|
13
13
|
useEffect(() => () => {
|
|
14
14
|
setValue(SwapFormKey.SearchTokensFilter, '');
|
|
15
15
|
}, [setValue]);
|
|
16
|
-
return (_jsx(
|
|
16
|
+
return (_jsx(Card, { children: _jsx(FormControl, Object.assign({ fullWidth: true }, { children: _jsx(Input, { size: "small", placeholder: t(`swap.tokenSearch`), defaultValue: "", endAdornment: _jsx(InputAdornment, Object.assign({ position: "end" }, { children: _jsx(SearchIcon, {}) })), inputProps: Object.assign({ inputMode: 'search' }, register(SwapFormKey.SearchTokensFilter)), autoComplete: "off" }) })) }));
|
|
17
17
|
};
|
|
@@ -9,11 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { supportedWallets } from '@lifi/wallet-management';
|
|
12
|
-
import { Avatar, Button, Container,
|
|
12
|
+
import { Avatar, Button, Container, DialogActions, DialogContent, DialogContentText, List, ListItemAvatar, } from '@mui/material';
|
|
13
13
|
import { useCallback, useState } from 'react';
|
|
14
14
|
import { useTranslation } from 'react-i18next';
|
|
15
15
|
import { useNavigate } from 'react-router-dom';
|
|
16
|
-
import {
|
|
16
|
+
import { Dialog } from '../../components/Dialog';
|
|
17
17
|
import { useWallet } from '../../providers/WalletProvider';
|
|
18
18
|
import { WalletListItemButton, WalletListItemText, } from './SelectWalletPage.style';
|
|
19
19
|
export const SelectWalletPage = () => {
|
|
@@ -21,12 +21,9 @@ export const SelectWalletPage = () => {
|
|
|
21
21
|
const { t } = useTranslation();
|
|
22
22
|
const navigate = useNavigate();
|
|
23
23
|
const { connect } = useWallet();
|
|
24
|
-
const containerElement = useScrollableContainer();
|
|
25
24
|
const [walletIdentity, setWalletIdentity] = useState({ show: false });
|
|
26
25
|
const closeDialog = () => {
|
|
27
|
-
setWalletIdentity({
|
|
28
|
-
show: false,
|
|
29
|
-
});
|
|
26
|
+
setWalletIdentity((state) => (Object.assign(Object.assign({}, state), { show: false })));
|
|
30
27
|
};
|
|
31
28
|
const handleConnect = useCallback((event, wallet) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
29
|
const { ethereum } = window;
|
|
@@ -46,23 +43,7 @@ export const SelectWalletPage = () => {
|
|
|
46
43
|
return (_jsxs(Container, Object.assign({ disableGutters: true }, { children: [_jsx(List, Object.assign({ sx: {
|
|
47
44
|
paddingLeft: 2,
|
|
48
45
|
paddingRight: 2,
|
|
49
|
-
} }, { children: supportedWallets.map((wallet) => (_jsxs(WalletListItemButton, Object.assign({ onClick: (event) => handleConnect(event, wallet), disableRipple: true }, { children: [_jsx(ListItemAvatar, { children: _jsx(Avatar, Object.assign({ src: wallet.icon, alt: wallet.name }, { children: wallet.name[0] })) }), _jsx(WalletListItemText, { primary: wallet.name })] }), wallet.name))) })), _jsxs(Dialog, Object.assign({ open: walletIdentity.show, onClose: closeDialog,
|
|
50
|
-
position: 'absolute',
|
|
51
|
-
overflow: 'hidden',
|
|
52
|
-
}, PaperProps: {
|
|
53
|
-
sx: (theme) => ({
|
|
54
|
-
position: 'absolute',
|
|
55
|
-
backgroundImage: 'none',
|
|
56
|
-
borderTopLeftRadius: theme.shape.borderRadius,
|
|
57
|
-
borderTopRightRadius: theme.shape.borderRadius,
|
|
58
|
-
}),
|
|
59
|
-
}, BackdropProps: {
|
|
60
|
-
sx: {
|
|
61
|
-
position: 'absolute',
|
|
62
|
-
backgroundColor: 'rgb(0 0 0 / 48%)',
|
|
63
|
-
backdropFilter: 'blur(3px)',
|
|
64
|
-
},
|
|
65
|
-
} }, { children: [_jsx(DialogContent, { children: _jsx(DialogContentText, { children: t('wallet.extensionNotFound', {
|
|
46
|
+
} }, { children: supportedWallets.map((wallet) => (_jsxs(WalletListItemButton, Object.assign({ onClick: (event) => handleConnect(event, wallet), disableRipple: true }, { children: [_jsx(ListItemAvatar, { children: _jsx(Avatar, Object.assign({ src: wallet.icon, alt: wallet.name }, { children: wallet.name[0] })) }), _jsx(WalletListItemText, { primary: wallet.name })] }), wallet.name))) })), _jsxs(Dialog, Object.assign({ open: walletIdentity.show, onClose: closeDialog }, { children: [_jsx(DialogContent, { children: _jsx(DialogContentText, { children: t('wallet.extensionNotFound', {
|
|
66
47
|
name: (_a = walletIdentity.wallet) === null || _a === void 0 ? void 0 : _a.name,
|
|
67
48
|
}) }) }), _jsx(DialogActions, { children: _jsx(Button, Object.assign({ onClick: closeDialog, autoFocus: true }, { children: t('button.ok') })) })] }))] })));
|
|
68
49
|
};
|
|
@@ -12,7 +12,7 @@ export const AdvancedPreferences = () => {
|
|
|
12
12
|
const handleAdvancedPreferences = (_, checked) => {
|
|
13
13
|
setValue('advancedPreferences', checked);
|
|
14
14
|
};
|
|
15
|
-
return (_jsxs(Box, Object.assign({
|
|
15
|
+
return (_jsxs(Box, Object.assign({ px: 3, pt: 3 }, { children: [_jsxs(Box, Object.assign({ sx: {
|
|
16
16
|
display: 'flex',
|
|
17
17
|
justifyContent: 'space-between',
|
|
18
18
|
alignItems: 'center',
|
|
@@ -9,7 +9,7 @@ export declare const ToggleButton: import("@emotion/styled").StyledComponent<{
|
|
|
9
9
|
onChange?: ((event: import("react").MouseEvent<HTMLElement, MouseEvent>, value: any) => void) | undefined;
|
|
10
10
|
onClick?: ((event: import("react").MouseEvent<HTMLElement, MouseEvent>, value: any) => void) | undefined;
|
|
11
11
|
selected?: boolean | undefined;
|
|
12
|
-
size?: "small" | "
|
|
12
|
+
size?: "small" | "medium" | "large" | undefined;
|
|
13
13
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
14
14
|
value: unknown;
|
|
15
15
|
} & Omit<{
|
|
@@ -3,18 +3,21 @@ import { KeyboardArrowDown as KeyboardArrowDownIcon } from '@mui/icons-material'
|
|
|
3
3
|
import { Box, Chip, FormControl, MenuItem, Skeleton } from '@mui/material';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import shallow from 'zustand/shallow';
|
|
6
|
-
import {
|
|
6
|
+
import { Card, CardTitle } from '../../components/Card';
|
|
7
7
|
import { Select } from '../../components/Select';
|
|
8
8
|
import { useTools } from '../../hooks';
|
|
9
9
|
import { useSettingsStore } from '../../stores';
|
|
10
10
|
export const EnabledBridgesSelect = () => {
|
|
11
11
|
var _a;
|
|
12
12
|
const { t } = useTranslation();
|
|
13
|
-
const tools = useTools();
|
|
13
|
+
const { tools, formattedTools } = useTools();
|
|
14
14
|
const [enabledBridges, setTools] = useSettingsStore((state) => [state.enabledBridges, state.setTools], shallow);
|
|
15
|
-
return (tools === null || tools === void 0 ? void 0 : tools.bridges.length) ? (_jsxs(
|
|
15
|
+
return (tools === null || tools === void 0 ? void 0 : tools.bridges.length) ? (_jsxs(Card, { children: [_jsx(CardTitle, { children: t(`settings.enabledBridges`) }), _jsx(FormControl, Object.assign({ fullWidth: true }, { children: _jsx(Select, Object.assign({ multiple: true, placeholder: t(`settings.selectEnabledBridges`), MenuProps: { elevation: 2 }, IconComponent: KeyboardArrowDownIcon, value: enabledBridges !== null && enabledBridges !== void 0 ? enabledBridges : [], onChange: (event) => {
|
|
16
16
|
if (tools === null || tools === void 0 ? void 0 : tools.bridges) {
|
|
17
17
|
setTools('Bridges', event.target.value, tools.bridges);
|
|
18
18
|
}
|
|
19
|
-
}, renderValue: (selected) => (_jsx(Box, Object.assign({ sx: { display: 'flex', flexWrap: 'wrap', gap: 0.5 } }, { children: selected.map((value) =>
|
|
19
|
+
}, renderValue: (selected) => (_jsx(Box, Object.assign({ sx: { display: 'flex', flexWrap: 'wrap', gap: 0.5 } }, { children: selected.map((value) => {
|
|
20
|
+
var _a, _b, _c;
|
|
21
|
+
return (_jsx(Chip, { label: (_c = (_b = (_a = formattedTools.bridges) === null || _a === void 0 ? void 0 : _a[value]) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : value }, value));
|
|
22
|
+
}) }))) }, { children: (_a = tools === null || tools === void 0 ? void 0 : tools.bridges) === null || _a === void 0 ? void 0 : _a.map((bridge) => (_jsx(MenuItem, Object.assign({ value: bridge.key }, { children: bridge.name }), bridge.key))) })) }))] })) : (_jsx(Skeleton, { variant: "rectangular", width: "100%", height: 134, sx: { borderRadius: 1 } }));
|
|
20
23
|
};
|
|
@@ -3,17 +3,20 @@ import { KeyboardArrowDown as KeyboardArrowDownIcon } from '@mui/icons-material'
|
|
|
3
3
|
import { Box, Chip, FormControl, MenuItem, Skeleton } from '@mui/material';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import shallow from 'zustand/shallow';
|
|
6
|
-
import {
|
|
6
|
+
import { Card, CardTitle } from '../../components/Card';
|
|
7
7
|
import { Select } from '../../components/Select';
|
|
8
8
|
import { useTools } from '../../hooks';
|
|
9
9
|
import { useSettingsStore } from '../../stores';
|
|
10
10
|
export const EnabledExchangesSelect = () => {
|
|
11
11
|
const { t } = useTranslation();
|
|
12
|
-
const tools = useTools();
|
|
12
|
+
const { tools, formattedTools } = useTools();
|
|
13
13
|
const [enabledExchanges, setTools] = useSettingsStore((state) => [state.enabledExchanges, state.setTools], shallow);
|
|
14
|
-
return (tools === null || tools === void 0 ? void 0 : tools.exchanges.length) ? (_jsxs(
|
|
14
|
+
return (tools === null || tools === void 0 ? void 0 : tools.exchanges.length) ? (_jsxs(Card, { children: [_jsx(CardTitle, { children: t(`settings.enabledExchanges`) }), _jsx(FormControl, Object.assign({ fullWidth: true }, { children: _jsx(Select, Object.assign({ multiple: true, placeholder: t(`settings.selectEnabledExchanges`), value: enabledExchanges !== null && enabledExchanges !== void 0 ? enabledExchanges : [], onChange: (event) => {
|
|
15
15
|
if (tools === null || tools === void 0 ? void 0 : tools.exchanges) {
|
|
16
16
|
setTools('Exchanges', event.target.value, tools.exchanges);
|
|
17
17
|
}
|
|
18
|
-
}, MenuProps: { elevation: 2 }, IconComponent: KeyboardArrowDownIcon, renderValue: (selected) => (_jsx(Box, Object.assign({ sx: { display: 'flex', flexWrap: 'wrap', gap: 0.5 } }, { children: selected.map((value) =>
|
|
18
|
+
}, MenuProps: { elevation: 2 }, IconComponent: KeyboardArrowDownIcon, renderValue: (selected) => (_jsx(Box, Object.assign({ sx: { display: 'flex', flexWrap: 'wrap', gap: 0.5 } }, { children: selected.map((value) => {
|
|
19
|
+
var _a, _b, _c;
|
|
20
|
+
return (_jsx(Chip, { label: (_c = (_b = (_a = formattedTools.exchanges) === null || _a === void 0 ? void 0 : _a[value]) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : value }, value));
|
|
21
|
+
}) }))) }, { children: tools === null || tools === void 0 ? void 0 : tools.exchanges.map((exchange) => (_jsx(MenuItem, Object.assign({ value: exchange.key }, { children: exchange.key }), exchange.key))) })) }))] })) : (_jsx(Skeleton, { variant: "rectangular", width: "100%", height: 206, sx: { borderRadius: 1 } }));
|
|
19
22
|
};
|
|
@@ -2,12 +2,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { KeyboardArrowDown as KeyboardArrowDownIcon } from '@mui/icons-material';
|
|
3
3
|
import { FormControl, MenuItem } from '@mui/material';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import {
|
|
5
|
+
import { Card, CardTitle } from '../../components/Card';
|
|
6
6
|
import { Select } from '../../components/Select';
|
|
7
7
|
import { useSetSettings, useSettings } from '../../stores';
|
|
8
8
|
export const GasPriceSelect = () => {
|
|
9
9
|
const { t } = useTranslation();
|
|
10
10
|
const [setValue] = useSetSettings();
|
|
11
11
|
const { gasPrice } = useSettings(['gasPrice']);
|
|
12
|
-
return (_jsxs(
|
|
12
|
+
return (_jsxs(Card, Object.assign({ flex: 1 }, { children: [_jsx(CardTitle, { children: t(`settings.gasPrice.title`) }), _jsx(FormControl, Object.assign({ fullWidth: true }, { children: _jsxs(Select, Object.assign({ MenuProps: { elevation: 2 }, value: gasPrice, onChange: (event) => setValue('gasPrice', event.target.value), IconComponent: KeyboardArrowDownIcon, dense: true }, { children: [_jsx(MenuItem, Object.assign({ value: "slow" }, { children: t(`settings.gasPrice.slow`) })), _jsx(MenuItem, Object.assign({ value: "normal" }, { children: t(`settings.gasPrice.normal`) })), _jsx(MenuItem, Object.assign({ value: "fast" }, { children: t(`settings.gasPrice.fast`) }))] })) }))] })));
|
|
13
13
|
};
|
|
@@ -3,12 +3,12 @@ import { Orders } from '@lifi/sdk';
|
|
|
3
3
|
import { KeyboardArrowDown as KeyboardArrowDownIcon } from '@mui/icons-material';
|
|
4
4
|
import { FormControl, MenuItem } from '@mui/material';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
|
-
import {
|
|
6
|
+
import { Card, CardTitle } from '../../components/Card';
|
|
7
7
|
import { Select } from '../../components/Select';
|
|
8
8
|
import { useSetSettings, useSettings } from '../../stores';
|
|
9
9
|
export const RoutePrioritySelect = () => {
|
|
10
10
|
const { t } = useTranslation();
|
|
11
11
|
const [setValue] = useSetSettings();
|
|
12
12
|
const { routePriority } = useSettings(['routePriority']);
|
|
13
|
-
return (_jsxs(
|
|
13
|
+
return (_jsxs(Card, { children: [_jsx(CardTitle, { children: t(`settings.routePriority`) }), _jsx(FormControl, Object.assign({ fullWidth: true }, { children: _jsx(Select, Object.assign({ MenuProps: { elevation: 2 }, value: routePriority, onChange: (event) => setValue('routePriority', event.target.value), IconComponent: KeyboardArrowDownIcon, dense: true }, { children: Orders.map((order) => (_jsx(MenuItem, Object.assign({ value: order }, { children: t(`swap.tags.${order.toLowerCase()}`) }), order))) })) }))] }));
|
|
14
14
|
};
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { FormControl, InputAdornment } from '@mui/material';
|
|
3
3
|
import { useRef } from 'react';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import {
|
|
5
|
+
import { Card, CardTitle } from '../../components/Card';
|
|
6
6
|
import { Input } from '../../components/Input';
|
|
7
7
|
import { useSetSettings, useSettings } from '../../stores';
|
|
8
8
|
import { formatSlippage } from '../../utils';
|
|
@@ -19,7 +19,7 @@ export const SlippageInput = () => {
|
|
|
19
19
|
const { value } = event.target;
|
|
20
20
|
setValue('slippage', formatSlippage(value, defaultValue.current));
|
|
21
21
|
};
|
|
22
|
-
return (_jsxs(
|
|
22
|
+
return (_jsxs(Card, { children: [_jsx(CardTitle, { children: t(`settings.slippage`) }), _jsx(FormControl, Object.assign({ fullWidth: true }, { children: _jsx(Input, { size: "small", placeholder: t(`settings.slippage`), endAdornment: _jsx(InputAdornment, Object.assign({ position: "end" }, { children: "%" })), autoComplete: "off", inputProps: {
|
|
23
23
|
inputMode: 'decimal',
|
|
24
24
|
}, onChange: handleChange, onBlur: handleBlur, value: slippage }) }))] }));
|
|
25
25
|
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { ContentCopy as ContentCopyIcon, DeleteOutline as DeleteIcon, } from '@mui/icons-material';
|
|
12
|
+
import { Box, Button, DialogActions, DialogContent, DialogContentText, DialogTitle, IconButton, Typography, } from '@mui/material';
|
|
13
|
+
import { Fragment, useCallback, useEffect, useState } from 'react';
|
|
14
|
+
import { useTranslation } from 'react-i18next';
|
|
15
|
+
import { useLocation, useNavigate } from 'react-router-dom';
|
|
16
|
+
import shallow from 'zustand/shallow';
|
|
17
|
+
import { Card, CardTitle } from '../../components/Card';
|
|
18
|
+
import { Dialog } from '../../components/Dialog';
|
|
19
|
+
import { useSetHeaderAction } from '../../components/Header';
|
|
20
|
+
import { Step } from '../../components/Step';
|
|
21
|
+
import { StepDivider } from '../../components/StepDivider';
|
|
22
|
+
import { useRouteStore } from '../../stores';
|
|
23
|
+
import { Container } from './SwapDetailsPage.style';
|
|
24
|
+
export const SwapDetailsPage = () => {
|
|
25
|
+
var _a, _b;
|
|
26
|
+
const { t } = useTranslation();
|
|
27
|
+
const navigate = useNavigate();
|
|
28
|
+
const setHeaderAction = useSetHeaderAction();
|
|
29
|
+
const { state } = useLocation();
|
|
30
|
+
const [routeExecution, deleteRoute] = useRouteStore((store) => [store.routes[state === null || state === void 0 ? void 0 : state.routeId], store.deleteRoute], shallow);
|
|
31
|
+
const [open, setOpen] = useState(false);
|
|
32
|
+
const toggleDialog = useCallback(() => {
|
|
33
|
+
setOpen((open) => !open);
|
|
34
|
+
}, []);
|
|
35
|
+
const handleDeleteRoute = () => {
|
|
36
|
+
navigate(-1);
|
|
37
|
+
if (routeExecution) {
|
|
38
|
+
deleteRoute(routeExecution.route.id);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const copyRouteId = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
+
var _c;
|
|
43
|
+
yield navigator.clipboard.writeText((_c = routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route.id) !== null && _c !== void 0 ? _c : '');
|
|
44
|
+
});
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
return setHeaderAction(_jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "end", onClick: toggleDialog }, { children: _jsx(DeleteIcon, {}) })));
|
|
47
|
+
}, [setHeaderAction, toggleDialog]);
|
|
48
|
+
const startedAt = new Date((_b = (_a = routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route.steps[0].execution) === null || _a === void 0 ? void 0 : _a.process[0].startedAt) !== null && _b !== void 0 ? _b : 0);
|
|
49
|
+
return (_jsxs(Container, { children: [_jsxs(Box, Object.assign({ sx: {
|
|
50
|
+
display: 'flex',
|
|
51
|
+
flex: 1,
|
|
52
|
+
justifyContent: 'space-between',
|
|
53
|
+
}, pb: 1 }, { children: [_jsx(Typography, Object.assign({ fontSize: 12 }, { children: new Intl.DateTimeFormat(undefined, { dateStyle: 'long' }).format(startedAt) })), _jsx(Typography, Object.assign({ fontSize: 12 }, { children: new Intl.DateTimeFormat(undefined, { timeStyle: 'short' }).format(startedAt) }))] })), routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route.steps.map((step, index, steps) => {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
return (_jsxs(Fragment, { children: [_jsx(Step, { step: step, fromToken: index === 0
|
|
56
|
+
? Object.assign(Object.assign({}, step.action.fromToken), { amount: step.action.fromAmount }) : undefined, toToken: index === steps.length - 1
|
|
57
|
+
? 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));
|
|
58
|
+
}), _jsxs(Card, Object.assign({ mt: 2 }, { children: [_jsxs(Box, Object.assign({ sx: {
|
|
59
|
+
display: 'flex',
|
|
60
|
+
flex: 1,
|
|
61
|
+
} }, { children: [_jsx(CardTitle, Object.assign({ flex: 1 }, { children: t('swap.routeId') })), _jsx(Box, Object.assign({ mr: 1, mt: 1 }, { children: _jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", onClick: copyRouteId }, { children: _jsx(ContentCopyIcon, { fontSize: "small" }) })) }))] })), _jsx(Typography, Object.assign({ variant: "body2", pt: 1, pb: 2, px: 2, sx: { wordBreak: 'break-all' } }, { children: routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route.id }))] })), _jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "contained", href: "https://discord.com/channels/849912621360218112/863689862514343946", target: "_blank", rel: "nofollow noreferrer", fullWidth: true }, { children: t('button.contactSupport') })) })), _jsxs(Dialog, Object.assign({ open: open, onClose: toggleDialog }, { children: [_jsx(DialogTitle, { children: t('swap.warning.title.deleteSwap') }), _jsx(DialogContent, { children: _jsx(DialogContentText, { children: t('swap.warning.message.deleteSwap') }) }), _jsxs(DialogActions, { children: [_jsx(Button, Object.assign({ onClick: toggleDialog }, { children: t('button.cancel') })), _jsx(Button, Object.assign({ onClick: handleDeleteRoute, autoFocus: true }, { children: t('button.delete') }))] })] }))] }));
|
|
62
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const Container: import("@emotion/styled").StyledComponent<{
|
|
3
|
+
children?: import("react").ReactNode;
|
|
4
|
+
classes?: Partial<import("@mui/material").ContainerClasses> | undefined;
|
|
5
|
+
disableGutters?: boolean | undefined;
|
|
6
|
+
fixed?: boolean | undefined;
|
|
7
|
+
maxWidth?: false | import("@mui/material").Breakpoint | undefined;
|
|
8
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
9
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
10
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
11
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "maxWidth" | "fixed" | "disableGutters"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SwapDetailsPage';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SwapDetailsPage';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { History as HistoryIcon } from '@mui/icons-material';
|
|
3
|
+
import { Container, Typography } from '@mui/material';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
export const SwapHistoryEmpty = () => {
|
|
6
|
+
const { t } = useTranslation();
|
|
7
|
+
return (_jsxs(Container, Object.assign({ sx: {
|
|
8
|
+
display: 'flex',
|
|
9
|
+
flex: 1,
|
|
10
|
+
flexDirection: 'column',
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
justifyContent: 'center',
|
|
13
|
+
} }, { children: [_jsx(Typography, Object.assign({ fontSize: 48 }, { children: _jsx(HistoryIcon, { fontSize: "inherit" }) })), _jsx(Typography, Object.assign({ fontSize: 18, fontWeight: 700 }, { children: "No recent swaps" })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.secondary", textAlign: "center", mt: 2 }, { children: "Swap history is only stored locally and will be deleted if you clear your browser data." }))] })));
|
|
14
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Typography } from '@mui/material';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { useNavigate } from 'react-router-dom';
|
|
5
|
+
import { Card } from '../../components/Card';
|
|
6
|
+
import { Token, TokenDivider } from '../../components/Token';
|
|
7
|
+
import { navigationRoutes } from '../../utils';
|
|
8
|
+
export const SwapHistoryItem = ({ route }) => {
|
|
9
|
+
var _a, _b, _c, _d, _e;
|
|
10
|
+
const { t } = useTranslation();
|
|
11
|
+
const navigate = useNavigate();
|
|
12
|
+
const handleClick = () => {
|
|
13
|
+
navigate(navigationRoutes.swapDetails, {
|
|
14
|
+
state: { routeId: route.id },
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
const startedAt = new Date((_b = (_a = route.steps[0].execution) === null || _a === void 0 ? void 0 : _a.process[0].startedAt) !== null && _b !== void 0 ? _b : 0);
|
|
18
|
+
return (_jsxs(Card, Object.assign({ onClick: handleClick }, { children: [_jsxs(Box, Object.assign({ sx: {
|
|
19
|
+
display: 'flex',
|
|
20
|
+
flex: 1,
|
|
21
|
+
justifyContent: 'space-between',
|
|
22
|
+
}, pt: 1.75, px: 2 }, { children: [_jsx(Typography, Object.assign({ fontSize: 12 }, { children: new Intl.DateTimeFormat(undefined, { dateStyle: 'long' }).format(startedAt) })), _jsx(Typography, Object.assign({ fontSize: 12 }, { children: new Intl.DateTimeFormat(undefined, { timeStyle: 'short' }).format(startedAt) }))] })), _jsxs(Box, Object.assign({ py: 1 }, { children: [_jsx(Token, { token: Object.assign(Object.assign({}, route.fromToken), { amount: route.fromAmount }), px: 2, pt: 1, connected: true }), _jsx(TokenDivider, {}), _jsx(Token, { token: Object.assign(Object.assign({}, route.toToken), { amount: (_e = (_d = (_c = route.steps.at(-1)) === null || _c === void 0 ? void 0 : _c.execution) === null || _d === void 0 ? void 0 : _d.toAmount) !== null && _e !== void 0 ? _e : route.toAmount }), px: 2, pt: 0.5, pb: 1 })] }))] })));
|
|
23
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Container, Stack } from '@mui/material';
|
|
3
|
+
import { useWallet } from '../../providers/WalletProvider';
|
|
4
|
+
import { useSwapHistory } from '../../stores/route';
|
|
5
|
+
import { SwapHistoryEmpty } from './SwapHistoryEmpty';
|
|
6
|
+
import { SwapHistoryItem } from './SwapHistoryItem';
|
|
7
|
+
export const SwapHistoryPage = () => {
|
|
8
|
+
const { account } = useWallet();
|
|
9
|
+
const swaps = useSwapHistory(account.address);
|
|
10
|
+
if (!swaps.length) {
|
|
11
|
+
return _jsx(SwapHistoryEmpty, {});
|
|
12
|
+
}
|
|
13
|
+
return (_jsx(Container, { children: _jsx(Stack, Object.assign({ spacing: 2, mt: 1 }, { children: swaps.length ? (swaps.map(({ route }) => (_jsx(SwapHistoryItem, { route: route }, route.id)))) : (_jsx(SwapHistoryEmpty, {})) })) }));
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SwapHistoryPage';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SwapHistoryPage';
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Done as DoneIcon, Info as InfoIcon, Warning as WarningIcon, } from '@mui/icons-material';
|
|
3
|
-
import { Box, Typography } from '@mui/material';
|
|
3
|
+
import { Box, Button, Typography } from '@mui/material';
|
|
4
4
|
import { useEffect, useMemo, useRef } from 'react';
|
|
5
5
|
import { useFormContext } from 'react-hook-form';
|
|
6
6
|
import { useTranslation } from 'react-i18next';
|
|
7
7
|
import { useNavigate } from 'react-router-dom';
|
|
8
8
|
import { BottomSheet } from '../../components/BottomSheet';
|
|
9
|
-
import {
|
|
9
|
+
import { Token } from '../../components/Token';
|
|
10
10
|
import { useChains, useTokenBalance } from '../../hooks';
|
|
11
11
|
import { SwapFormKey } from '../../providers/SwapFormProvider';
|
|
12
12
|
import { IconCircle, IconContainer, iconStyles, } from './StatusBottomSheet.style';
|
|
13
|
-
import { Button } from './SwapPage.style';
|
|
14
13
|
import { getProcessMessage } from './utils';
|
|
15
14
|
export const StatusBottomSheet = ({ status, route, }) => {
|
|
16
15
|
var _a, _b, _c, _d, _e;
|
|
@@ -76,5 +75,5 @@ export const StatusBottomSheet = ({ status, route, }) => {
|
|
|
76
75
|
(_b = ref.current) === null || _b === void 0 ? void 0 : _b.openDrawer();
|
|
77
76
|
}
|
|
78
77
|
}, [refetchBalance, status]);
|
|
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(
|
|
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(Token, { 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 })), _jsx(Box, Object.assign({ mt: 2 }, { children: _jsxs(Button, Object.assign({ variant: "contained", 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(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "outlined", fullWidth: true, onClick: handleClose }, { children: t('button.seeDetails') })) }))) : null] })) })));
|
|
80
79
|
};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box } from '@mui/material';
|
|
2
|
+
import { Box, Button } from '@mui/material';
|
|
3
3
|
import { Fragment } from 'react';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { useLocation, useNavigate } from 'react-router-dom';
|
|
6
|
-
import {
|
|
6
|
+
import { GasSufficiencyMessage } from '../../components/GasSufficiencyMessage';
|
|
7
|
+
import { Step } from '../../components/Step';
|
|
8
|
+
import { StepDivider } from '../../components/StepDivider';
|
|
7
9
|
import { SwapButton } from '../../components/SwapButton';
|
|
8
10
|
import { useRouteExecution } from '../../hooks';
|
|
9
11
|
import { StatusBottomSheet } from './StatusBottomSheet';
|
|
10
|
-
import {
|
|
11
|
-
import { StepItem } from './StepItem';
|
|
12
|
-
import { Button, Container } from './SwapPage.style';
|
|
12
|
+
import { Container } from './SwapPage.style';
|
|
13
13
|
export const SwapPage = () => {
|
|
14
14
|
const { t } = useTranslation();
|
|
15
15
|
const { state } = useLocation();
|
|
16
16
|
const navigate = useNavigate();
|
|
17
|
-
const { route, status, executeRoute, restartRoute,
|
|
17
|
+
const { route, status, executeRoute, restartRoute, deleteRoute } = useRouteExecution(state === null || state === void 0 ? void 0 : state.routeId);
|
|
18
18
|
const handleRemoveRoute = () => {
|
|
19
|
-
removeRoute();
|
|
20
19
|
navigate(-1);
|
|
20
|
+
deleteRoute();
|
|
21
21
|
};
|
|
22
22
|
const handleSwapClick = () => {
|
|
23
23
|
if (status === 'idle') {
|
|
@@ -38,8 +38,8 @@ export const SwapPage = () => {
|
|
|
38
38
|
};
|
|
39
39
|
return (_jsxs(Container, { children: [route === null || route === void 0 ? void 0 : route.steps.map((step, index, steps) => {
|
|
40
40
|
var _a, _b;
|
|
41
|
-
return (_jsxs(Fragment, { children: [_jsx(
|
|
41
|
+
return (_jsxs(Fragment, { children: [_jsx(Step, { step: step, fromToken: index === 0
|
|
42
42
|
? Object.assign(Object.assign({}, step.action.fromToken), { amount: step.action.fromAmount }) : undefined, toToken: index === steps.length - 1
|
|
43
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(
|
|
44
|
+
}), status === 'idle' ? (_jsx(GasSufficiencyMessage, { route: route, mt: 2 })) : null, status === 'idle' || status === 'error' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(SwapButton, { onClick: handleSwapClick, text: getSwapButtonText() }) }))) : null, status === 'error' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "outlined", onClick: handleRemoveRoute, fullWidth: true }, { children: t('button.removeSwap') })) }))) : null, route && status ? (_jsx(StatusBottomSheet, { status: status, route: route })) : null] }));
|
|
45
45
|
};
|