@lifi/widget 1.8.1 → 1.9.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/AppDrawer.style.d.ts +1 -1
- package/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +1 -1
- package/components/SwapButton/SwapButton.style.d.ts +1 -1
- package/components/SwapInput/SwapInput.style.d.ts +1 -1
- package/components/SwapInput/SwapInputAdornment.style.d.ts +1 -1
- package/components/SwapRouteCard/SwapRouteCardSkeleton.d.ts +4 -0
- package/components/SwapRouteCard/SwapRouteCardSkeleton.js +32 -0
- package/components/SwapRouteCard/SwapRouteNotFoundCard.d.ts +4 -0
- package/components/SwapRouteCard/SwapRouteNotFoundCard.js +27 -0
- package/components/SwapRouteCard/index.d.ts +2 -0
- package/components/SwapRouteCard/index.js +2 -0
- package/components/SwapRouteCard/types.d.ts +5 -0
- package/components/SwapRoutes/SwapRoutes.js +7 -9
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/useSwapRoutes.d.ts +1 -0
- package/hooks/useSwapRoutes.js +4 -4
- package/i18n/en/translation.json +11 -3
- package/i18n/index.d.ts +8 -0
- package/package.json +4 -4
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
- package/pages/SwapPage/ExecutionItem.style.d.ts +1 -1
- package/pages/SwapPage/SwapPage.style.d.ts +1 -1
- package/pages/SwapRoutesPage/SwapRoutesPage.js +12 -13
- package/utils/format.js +3 -3
package/AppDrawer.style.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const DrawerButton: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").ButtonClasses> | undefined;
|
|
5
|
-
color?: "inherit" | "success" | "
|
|
5
|
+
color?: "inherit" | "success" | "info" | "warning" | "error" | "primary" | "secondary" | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableElevation?: boolean | undefined;
|
|
8
8
|
disableFocusRipple?: boolean | undefined;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const IconButton: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").IconButtonClasses> | undefined;
|
|
5
|
-
color?: "inherit" | "default" | "success" | "
|
|
5
|
+
color?: "inherit" | "default" | "success" | "info" | "warning" | "error" | "primary" | "secondary" | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableFocusRipple?: boolean | undefined;
|
|
8
8
|
edge?: false | "end" | "start" | undefined;
|
|
@@ -17,7 +17,7 @@ export declare const Button: import("@emotion/styled").StyledComponent<{
|
|
|
17
17
|
} & Omit<{
|
|
18
18
|
children?: import("react").ReactNode;
|
|
19
19
|
classes?: Partial<import("@mui/material").ButtonClasses> | undefined;
|
|
20
|
-
color?: "inherit" | "success" | "
|
|
20
|
+
color?: "inherit" | "success" | "info" | "warning" | "error" | "primary" | "secondary" | undefined;
|
|
21
21
|
disabled?: boolean | undefined;
|
|
22
22
|
disableElevation?: boolean | undefined;
|
|
23
23
|
disableFocusRipple?: boolean | undefined;
|
|
@@ -4,7 +4,7 @@ export declare const minInputFontSize = 14;
|
|
|
4
4
|
export declare const FormControl: import("@emotion/styled").StyledComponent<{
|
|
5
5
|
children?: import("react").ReactNode;
|
|
6
6
|
classes?: Partial<import("@mui/material").FormControlClasses> | undefined;
|
|
7
|
-
color?: "success" | "
|
|
7
|
+
color?: "success" | "info" | "warning" | "error" | "primary" | "secondary" | undefined;
|
|
8
8
|
disabled?: boolean | undefined;
|
|
9
9
|
error?: boolean | undefined;
|
|
10
10
|
fullWidth?: boolean | undefined;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const Button: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").ButtonClasses> | undefined;
|
|
5
|
-
color?: "inherit" | "success" | "
|
|
5
|
+
color?: "inherit" | "success" | "info" | "warning" | "error" | "primary" | "secondary" | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableElevation?: boolean | undefined;
|
|
8
8
|
disableFocusRipple?: boolean | undefined;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { Box, Skeleton } from '@mui/material';
|
|
14
|
+
import { Card } from './SwapRouteCard.style';
|
|
15
|
+
export const SwapRouteCardSkeleton = (_a) => {
|
|
16
|
+
var { active, dense } = _a, other = __rest(_a, ["active", "dense"]);
|
|
17
|
+
return (_jsxs(Card, Object.assign({ dense: dense }, other, { children: [_jsxs(Box, Object.assign({ sx: {
|
|
18
|
+
display: 'flex',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
justifyContent: 'space-between',
|
|
21
|
+
} }, { children: [_jsx(Skeleton, { variant: "rectangular", width: 120, height: 24, sx: { borderRadius: 0.5 } }), active ? _jsx(Skeleton, { variant: "circular", width: 24, height: 24 }) : null] })), _jsxs(Box, Object.assign({ my: 2 }, { children: [_jsxs(Box, Object.assign({ sx: {
|
|
22
|
+
display: 'flex',
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
} }, { children: [_jsx(Box, Object.assign({ mr: 2 }, { children: _jsx(Skeleton, { variant: "circular", width: 32, height: 32 }) })), _jsx(Skeleton, { variant: "text", width: 96, height: 32 })] })), _jsx(Box, Object.assign({ ml: 6 }, { children: _jsx(Skeleton, { variant: "text", width: 56, height: 22 }) }))] })), _jsxs(Box, Object.assign({ sx: {
|
|
25
|
+
display: 'flex',
|
|
26
|
+
justifyContent: 'space-between',
|
|
27
|
+
} }, { children: [_jsxs(Box, { children: [_jsx(Skeleton, { variant: "text", width: 56, height: 22 }), _jsx(Skeleton, { variant: "text", width: 52, height: 15 })] }), _jsxs(Box, Object.assign({ sx: {
|
|
28
|
+
display: 'flex',
|
|
29
|
+
alignItems: 'flex-end',
|
|
30
|
+
flexDirection: 'column',
|
|
31
|
+
} }, { children: [_jsx(Skeleton, { variant: "text", width: 40, height: 22 }), _jsx(Skeleton, { variant: "text", width: 48, height: 15 })] }))] }))] })));
|
|
32
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { Route as RouteIcon } from '@mui/icons-material';
|
|
14
|
+
import { Box, Typography } from '@mui/material';
|
|
15
|
+
import { useTranslation } from 'react-i18next';
|
|
16
|
+
import { Card } from './SwapRouteCard.style';
|
|
17
|
+
export const SwapRouteNotFoundCard = (_a) => {
|
|
18
|
+
var { active, dense } = _a, other = __rest(_a, ["active", "dense"]);
|
|
19
|
+
const { t } = useTranslation();
|
|
20
|
+
return (_jsx(Card, Object.assign({ active: active, dense: dense }, other, { children: _jsxs(Box, Object.assign({ sx: {
|
|
21
|
+
display: 'flex',
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
justifyContent: 'center',
|
|
24
|
+
flexDirection: 'column',
|
|
25
|
+
flex: 1,
|
|
26
|
+
}, py: 1.375 }, { children: [_jsx(RouteIcon, { fontSize: "large" }), _jsx(Typography, Object.assign({ fontSize: 16, fontWeight: "500", mt: 2 }, { children: t('swap.info.title.routeNotFound') })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.secondary", textAlign: "center", mt: 1 }, { children: t('swap.info.message.routeNotFound') }))] })) })));
|
|
27
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/* eslint-disable react/no-array-index-key */
|
|
3
3
|
import { KeyboardArrowRight as KeyboardArrowRightIcon } from '@mui/icons-material';
|
|
4
|
-
import { Box, IconButton
|
|
4
|
+
import { Box, IconButton } from '@mui/material';
|
|
5
5
|
import { useCallback } from 'react';
|
|
6
6
|
import { useTranslation } from 'react-i18next';
|
|
7
7
|
import { useNavigate } from 'react-router-dom';
|
|
@@ -9,26 +9,24 @@ import { useSwapRoutes } from '../../hooks';
|
|
|
9
9
|
import { useCurrentRoute } from '../../stores';
|
|
10
10
|
import { routes } from '../../utils/routes';
|
|
11
11
|
import { CardContainer, CardTitle } from '../Card';
|
|
12
|
-
import { SwapRouteCard } from '../SwapRouteCard';
|
|
12
|
+
import { SwapRouteCard, SwapRouteCardSkeleton, SwapRouteNotFoundCard, } from '../SwapRouteCard';
|
|
13
13
|
import { Stack } from './SwapRoutes.style';
|
|
14
14
|
import { SwapRoutesUpdateProgress } from './SwapRoutesUpdateProgress';
|
|
15
15
|
export const SwapRoutes = (props) => {
|
|
16
16
|
const { t } = useTranslation();
|
|
17
17
|
const navigate = useNavigate();
|
|
18
18
|
const [currentRoute] = useCurrentRoute();
|
|
19
|
-
const { routes: swapRoutes, isLoading, isFetching } = useSwapRoutes();
|
|
19
|
+
const { routes: swapRoutes, isLoading, isFetching, isFetched, } = useSwapRoutes();
|
|
20
20
|
const handleCardClick = useCallback(() => {
|
|
21
21
|
navigate(routes.swapRoutes);
|
|
22
22
|
}, [navigate]);
|
|
23
|
-
if (!(swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.length) && !isLoading && !isFetching) {
|
|
23
|
+
if (!(swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.length) && !isLoading && !isFetching && !isFetched) {
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
const routeNotFound = !(swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.length) && isFetched;
|
|
27
|
+
return (_jsxs(CardContainer, Object.assign({}, props, { children: [_jsx(CardTitle, { children: t('swap.routes') }), !routeNotFound ? (_jsx(SwapRoutesUpdateProgress, { sx: {
|
|
27
28
|
position: 'absolute',
|
|
28
29
|
top: 8,
|
|
29
30
|
right: 8,
|
|
30
|
-
} }), _jsxs(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: [_jsx(Stack, Object.assign({ direction: "row", py: 2, pl: 2, pr: 1 }, { children: isLoading || isFetching || !currentRoute ? (_jsx(
|
|
31
|
-
borderRadius: theme.shape.borderRadiusSecondary / theme.shape.borderRadius,
|
|
32
|
-
minWidth: '100%',
|
|
33
|
-
}) })) : (_jsx(SwapRouteCard, { minWidth: "100%", route: currentRoute, active: true, dense: true })) })), _jsx(Box, Object.assign({ py: 1, pr: 1 }, { children: _jsx(IconButton, Object.assign({ onClick: handleCardClick, size: "medium", "aria-label": "swap-routes" }, { children: _jsx(KeyboardArrowRightIcon, {}) })) }))] }))] })));
|
|
31
|
+
} })) : null, _jsxs(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: [_jsx(Stack, Object.assign({ direction: "row", py: 2, pl: 2, pr: routeNotFound ? 2 : 1 }, { children: routeNotFound ? (_jsx(SwapRouteNotFoundCard, { minWidth: "100%", dense: true })) : isLoading || isFetching || !currentRoute ? (_jsx(SwapRouteCardSkeleton, { minWidth: "100%", active: true, dense: true })) : (_jsx(SwapRouteCard, { minWidth: "100%", route: currentRoute, active: true, dense: true })) })), !routeNotFound ? (_jsx(Box, Object.assign({ py: 1, pr: 1 }, { children: _jsx(IconButton, Object.assign({ onClick: handleCardClick, size: "medium", "aria-label": "swap-routes" }, { children: _jsx(KeyboardArrowRightIcon, {}) })) }))) : null] }))] })));
|
|
34
32
|
};
|
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.9.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.9.0';
|
package/hooks/useSwapRoutes.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export declare const useSwapRoutes: () => {
|
|
|
2
2
|
routes: import("@lifi/types").Route[] | undefined;
|
|
3
3
|
isLoading: boolean;
|
|
4
4
|
isFetching: boolean;
|
|
5
|
+
isFetched: boolean;
|
|
5
6
|
dataUpdatedAt: number;
|
|
6
7
|
refetchTime: number;
|
|
7
8
|
refetch: <TPageData>(options?: (import("react-query").RefetchOptions & import("react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("react-query").QueryObserverResult<import("@lifi/types").RoutesResponse, unknown>>;
|
package/hooks/useSwapRoutes.js
CHANGED
|
@@ -7,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import Big from 'big.js';
|
|
10
11
|
import { useEffect } from 'react';
|
|
11
12
|
import { useWatch } from 'react-hook-form';
|
|
12
13
|
import { useQuery, useQueryClient } from 'react-query';
|
|
@@ -62,13 +63,11 @@ export const useSwapRoutes = () => {
|
|
|
62
63
|
const refetchInterval = previousDataUpdatedAt
|
|
63
64
|
? Math.min(Math.abs(refetchTime - (Date.now() - previousDataUpdatedAt)), refetchTime)
|
|
64
65
|
: refetchTime;
|
|
65
|
-
const { data, isLoading, isFetching, dataUpdatedAt, refetch } = useQuery(queryKey, ({ queryKey: [_, address, fromChainId, fromTokenAddress, fromTokenAmount, toChainId, toTokenAddress, slippage, enabledBridges, enabledExchanges, routePriority,], signal, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
|
+
const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = useQuery(queryKey, ({ queryKey: [_, address, fromChainId, fromTokenAddress, fromTokenAmount, toChainId, toTokenAddress, slippage, enabledBridges, enabledExchanges, routePriority,], signal, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
67
|
var _b;
|
|
67
68
|
return LiFi.getRoutes({
|
|
68
69
|
fromChainId,
|
|
69
|
-
|
|
70
|
-
fromAmount: (Number(fromTokenAmount) *
|
|
71
|
-
Math.pow(10, ((_b = token === null || token === void 0 ? void 0 : token.decimals) !== null && _b !== void 0 ? _b : 0))).toFixed(0),
|
|
70
|
+
fromAmount: Big(Number(fromTokenAmount) * Math.pow(10, ((_b = token === null || token === void 0 ? void 0 : token.decimals) !== null && _b !== void 0 ? _b : 0))).toString(),
|
|
72
71
|
fromTokenAddress,
|
|
73
72
|
toChainId,
|
|
74
73
|
toTokenAddress,
|
|
@@ -105,6 +104,7 @@ export const useSwapRoutes = () => {
|
|
|
105
104
|
routes: data === null || data === void 0 ? void 0 : data.routes,
|
|
106
105
|
isLoading: isEnabled && isLoading,
|
|
107
106
|
isFetching,
|
|
107
|
+
isFetched,
|
|
108
108
|
dataUpdatedAt,
|
|
109
109
|
refetchTime,
|
|
110
110
|
refetch,
|
package/i18n/en/translation.json
CHANGED
|
@@ -68,14 +68,22 @@
|
|
|
68
68
|
"fundsReceived": "You now have {{amount}} {{tokenSymbol}} in your wallet on {{chainName}} chain."
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
|
+
"info": {
|
|
72
|
+
"title": {
|
|
73
|
+
"routeNotFound": "No routes available"
|
|
74
|
+
},
|
|
75
|
+
"message": {
|
|
76
|
+
"routeNotFound": "Try another \"from\" and \"to\" token combination."
|
|
77
|
+
}
|
|
78
|
+
},
|
|
71
79
|
"warning": {
|
|
72
80
|
"title": {
|
|
73
81
|
"insufficientGas": "Insufficient gas"
|
|
74
82
|
},
|
|
75
83
|
"message": {
|
|
76
|
-
"insufficientFunds": "You don't have enough funds for this transaction on the start
|
|
77
|
-
"insufficientGasOnStartChain": "You need to have enough gas to pay for this transaction on the start
|
|
78
|
-
"insufficientGasOnDestinationChain": "You need to have enough gas to pay for this transaction on the destination
|
|
84
|
+
"insufficientFunds": "You don't have enough funds for this transaction on the start \"from\" chain.",
|
|
85
|
+
"insufficientGasOnStartChain": "You need to have enough gas to pay for this transaction on the start \"from\" chain.",
|
|
86
|
+
"insufficientGasOnDestinationChain": "You need to have enough gas to pay for this transaction on the destination \"to\" chain."
|
|
79
87
|
}
|
|
80
88
|
},
|
|
81
89
|
"error": {
|
package/i18n/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@emotion/styled": "^11.9.3",
|
|
42
42
|
"@ethersproject/experimental": "^5.6.3",
|
|
43
43
|
"@ethersproject/providers": "^5.6.8",
|
|
44
|
-
"@lifi/sdk": "^1.0.
|
|
44
|
+
"@lifi/sdk": "^1.0.1",
|
|
45
45
|
"@lifi/wallet-management": "^1.1.1",
|
|
46
46
|
"@mui/icons-material": "^5.8.4",
|
|
47
47
|
"@mui/lab": "^5.0.0-alpha.90",
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
"@sentry/react": "^7.6.0",
|
|
51
51
|
"@sentry/tracing": "^7.6.0",
|
|
52
52
|
"big.js": "^6.2.1",
|
|
53
|
-
"i18next": "^21.8.
|
|
53
|
+
"i18next": "^21.8.14",
|
|
54
54
|
"immer": "^9.0.15",
|
|
55
55
|
"react": "^18.2.0",
|
|
56
56
|
"react-dom": "^18.2.0",
|
|
57
57
|
"react-hook-form": "^7.33.1",
|
|
58
|
-
"react-i18next": "^11.18.
|
|
58
|
+
"react-i18next": "^11.18.1",
|
|
59
59
|
"react-query": "^4.0.0-beta.23",
|
|
60
60
|
"react-resize-detector": "^7.1.2",
|
|
61
61
|
"react-router-dom": "^6.3.0",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const ToggleButton: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").ToggleButtonClasses> | undefined;
|
|
5
|
-
color?: "success" | "
|
|
5
|
+
color?: "success" | "info" | "warning" | "error" | "primary" | "secondary" | "standard" | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableFocusRipple?: boolean | undefined;
|
|
8
8
|
fullWidth?: boolean | undefined;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const LinkButton: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").IconButtonClasses> | undefined;
|
|
5
|
-
color?: "inherit" | "default" | "success" | "
|
|
5
|
+
color?: "inherit" | "default" | "success" | "info" | "warning" | "error" | "primary" | "secondary" | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableFocusRipple?: boolean | undefined;
|
|
8
8
|
edge?: false | "end" | "start" | undefined;
|
|
@@ -12,7 +12,7 @@ export declare const Container: import("@emotion/styled").StyledComponent<{
|
|
|
12
12
|
export declare const Button: import("@emotion/styled").StyledComponent<{
|
|
13
13
|
children?: import("react").ReactNode;
|
|
14
14
|
classes?: Partial<import("@mui/material").ButtonClasses> | undefined;
|
|
15
|
-
color?: "inherit" | "success" | "
|
|
15
|
+
color?: "inherit" | "success" | "info" | "warning" | "error" | "primary" | "secondary" | undefined;
|
|
16
16
|
disabled?: boolean | undefined;
|
|
17
17
|
disableElevation?: boolean | undefined;
|
|
18
18
|
disableFocusRipple?: boolean | undefined;
|
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
3
|
import { useNavigate } from 'react-router-dom';
|
|
4
|
-
import { SwapRouteCard } from '../../components/SwapRouteCard';
|
|
4
|
+
import { SwapRouteCard, SwapRouteCardSkeleton, SwapRouteNotFoundCard, } from '../../components/SwapRouteCard';
|
|
5
5
|
import { useSwapRoutes } from '../../hooks';
|
|
6
6
|
import { useCurrentRoute, useSetExecutableRoute } from '../../stores';
|
|
7
7
|
import { routes } from '../../utils/routes';
|
|
8
8
|
import { Stack } from './SwapRoutesPage.style';
|
|
9
9
|
export const SwapRoutesPage = () => {
|
|
10
10
|
const navigate = useNavigate();
|
|
11
|
-
const { routes: swapRoutes, isLoading, isFetching } = useSwapRoutes();
|
|
11
|
+
const { routes: swapRoutes, isLoading, isFetching, isFetched, } = useSwapRoutes();
|
|
12
12
|
const [currentRoute] = useCurrentRoute();
|
|
13
13
|
const setExecutableRoute = useSetExecutableRoute();
|
|
14
|
-
if (!(swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.length) && !isLoading && !isFetching) {
|
|
15
|
-
// TODO: make no routes message
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
14
|
const handleRouteClick = (route) => {
|
|
19
15
|
setExecutableRoute(route);
|
|
20
16
|
navigate(routes.swap, { state: { routeId: route.id }, replace: true });
|
|
21
17
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (!(swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.length) && !isLoading && !isFetching) {
|
|
20
|
+
navigate(routes.home);
|
|
21
|
+
}
|
|
22
|
+
// redirect to the home page if no routes are found on page reload
|
|
23
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
|
+
}, []);
|
|
25
|
+
const routeNotFound = !(swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.length) && isFetched;
|
|
26
|
+
return (_jsx(Stack, Object.assign({ direction: "column", spacing: 2 }, { children: routeNotFound ? (_jsx(SwapRouteNotFoundCard, { minWidth: "100%", dense: true })) : isLoading || isFetching ? (Array.from({ length: 3 }).map((_, index) => (_jsx(SwapRouteCardSkeleton, { minWidth: "100%", dense: true }, index)))) : (swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.map((route, index) => (_jsx(SwapRouteCard, { route: route, active: (currentRoute === null || currentRoute === void 0 ? void 0 : currentRoute.id) === route.id, onClick: () => handleRouteClick(route) }, route.id)))) })));
|
|
28
27
|
};
|
package/utils/format.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Big from 'big.js';
|
|
2
|
-
// JavaScript numbers use exponential notation for positive exponents of 21 and above.
|
|
3
|
-
Big.PE =
|
|
2
|
+
// JavaScript numbers use exponential notation for positive exponents of 21 and above. We need more.
|
|
3
|
+
Big.PE = 42;
|
|
4
4
|
// JavaScript numbers use exponential notation for negative exponents of -7 and below. We need more.
|
|
5
|
-
Big.NE = -
|
|
5
|
+
Big.NE = -42;
|
|
6
6
|
/**
|
|
7
7
|
* Format token amount to at least 4 decimals.
|
|
8
8
|
* @param amount amount to format.
|