@lifi/widget 1.11.3 → 1.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Header/Header.js +3 -1
- package/components/SwapButton/SwapButton.js +4 -0
- package/components/SwapRouteCard/SwapRouteCard.js +2 -2
- package/components/SwapRouteCard/SwapRouteCardSkeleton.js +2 -2
- package/components/SwapRouteCard/SwapRouteNotFoundCard.js +7 -8
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/i18n/en/translation.json +5 -2
- package/i18n/index.d.ts +3 -0
- package/package.json +1 -1
- package/pages/MainPage/SwapRoutes.js +3 -3
- package/pages/SwapHistoryPage/SwapHistoryEmpty.js +1 -1
- package/pages/SwapRoutesPage/SwapRoutesPage.js +3 -3
|
@@ -9,10 +9,12 @@ const stickyHeaderRoutes = [
|
|
|
9
9
|
navigationRoutes.selectWallet,
|
|
10
10
|
navigationRoutes.settings,
|
|
11
11
|
navigationRoutes.swapRoutes,
|
|
12
|
+
navigationRoutes.swapHistory,
|
|
13
|
+
navigationRoutes.swapDetails,
|
|
12
14
|
];
|
|
13
15
|
const HeaderContainer = ({ children }) => {
|
|
14
16
|
const { pathname } = useLocation();
|
|
15
|
-
return (_jsx(Container, Object.assign({ id: ElementId.Header, sticky: stickyHeaderRoutes.includes(
|
|
17
|
+
return (_jsx(Container, Object.assign({ id: ElementId.Header, sticky: stickyHeaderRoutes.some((route) => pathname.includes(route)) }, { children: children })));
|
|
16
18
|
};
|
|
17
19
|
export const Header = () => {
|
|
18
20
|
const { walletManagement } = useWidgetConfig();
|
|
@@ -52,6 +52,9 @@ export const SwapButton = ({ onClick, currentRoute, text, loading, }) => {
|
|
|
52
52
|
if (!isCurrentChainMatch) {
|
|
53
53
|
return t(`button.switchChain`);
|
|
54
54
|
}
|
|
55
|
+
if (!currentRoute) {
|
|
56
|
+
return t(`button.swap`);
|
|
57
|
+
}
|
|
55
58
|
return text || t(`button.reviewSwap`);
|
|
56
59
|
}
|
|
57
60
|
return t(`button.connectWallet`);
|
|
@@ -59,5 +62,6 @@ export const SwapButton = ({ onClick, currentRoute, text, loading, }) => {
|
|
|
59
62
|
return (_jsx(Button, Object.assign({ variant: "contained", color: account.isActive ? 'primary' : 'success', onClick: handleSwapButtonClick,
|
|
60
63
|
// loading={isLoading || isFetching}
|
|
61
64
|
disabled: (insufficientFunds || !!insufficientGas.length || loading) &&
|
|
65
|
+
currentRoute &&
|
|
62
66
|
isCurrentChainMatch, fullWidth: true }, { children: getButtonText() })));
|
|
63
67
|
};
|
|
@@ -32,7 +32,7 @@ export const SwapRouteCard = (_a) => {
|
|
|
32
32
|
: null, _jsxs(Box, Object.assign({ sx: {
|
|
33
33
|
display: 'flex',
|
|
34
34
|
justifyContent: 'space-between',
|
|
35
|
-
} }, { children: [_jsxs(Box, { children: [_jsx(Typography, Object.assign({ fontSize: 18, fontWeight: "500" }, { children: t(`swap.currency`, { value: (_c = route.gasCostUSD) !== null && _c !== void 0 ? _c : 0 }) })), _jsx(Typography, Object.assign({ fontSize: 12, color: "text.secondary" }, { children: t(`swap.gas`) }))] }), _jsxs(Box, { children: [_jsxs(Typography, Object.assign({ fontSize: 18, fontWeight: "500", display: "flex", justifyContent: "flex-end" }, { children: ["~", (route.steps
|
|
35
|
+
} }, { children: [_jsxs(Box, { children: [_jsx(Typography, Object.assign({ fontSize: 18, fontWeight: "500", lineHeight: 1, pt: 0.25 }, { children: t(`swap.currency`, { value: (_c = route.gasCostUSD) !== null && _c !== void 0 ? _c : 0 }) })), _jsx(Typography, Object.assign({ fontSize: 12, color: "text.secondary", lineHeight: 1, mt: 0.5 }, { children: t(`swap.gas`) }))] }), _jsxs(Box, { children: [_jsxs(Typography, Object.assign({ fontSize: 18, fontWeight: "500", display: "flex", justifyContent: "flex-end", lineHeight: 1, pt: 0.25 }, { children: ["~", (route.steps
|
|
36
36
|
.map((step) => step.estimate.executionDuration)
|
|
37
|
-
.reduce((cumulated, x) => cumulated + x) / 60).toFixed(0)] })), _jsx(Typography, Object.assign({ fontSize: 12, color: "text.secondary", textAlign: "end" }, { children: t(`swap.minutes`) }))] })] }))] })));
|
|
37
|
+
.reduce((cumulated, x) => cumulated + x) / 60).toFixed(0)] })), _jsx(Typography, Object.assign({ fontSize: 12, color: "text.secondary", textAlign: "end", lineHeight: 1, mt: 0.5 }, { children: t(`swap.minutes`) }))] })] }))] })));
|
|
38
38
|
};
|
|
@@ -20,9 +20,9 @@ export const SwapRouteCardSkeleton = (_a) => {
|
|
|
20
20
|
} }, { 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: 102, height: 16, sx: { borderRadius: 0.5 } }) }))] })), _jsxs(Box, Object.assign({ sx: {
|
|
21
21
|
display: 'flex',
|
|
22
22
|
justifyContent: 'space-between',
|
|
23
|
-
} }, { children: [_jsxs(Box, { children: [_jsx(Skeleton, { variant: "text", width: 56, height:
|
|
23
|
+
} }, { children: [_jsxs(Box, { children: [_jsx(Skeleton, { variant: "text", width: 56, height: 20 }), _jsx(Skeleton, { variant: "text", width: 52, height: 16 })] }), _jsxs(Box, Object.assign({ sx: {
|
|
24
24
|
display: 'flex',
|
|
25
25
|
alignItems: 'flex-end',
|
|
26
26
|
flexDirection: 'column',
|
|
27
|
-
} }, { children: [_jsx(Skeleton, { variant: "text", width: 40, height:
|
|
27
|
+
} }, { children: [_jsx(Skeleton, { variant: "text", width: 40, height: 20 }), _jsx(Skeleton, { variant: "text", width: 48, height: 16 })] }))] }))] })));
|
|
28
28
|
};
|
|
@@ -13,15 +13,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
import { Route as RouteIcon } from '@mui/icons-material';
|
|
14
14
|
import { Box, Typography } from '@mui/material';
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
|
-
import { Card } from '../Card';
|
|
17
16
|
export const SwapRouteNotFoundCard = (_a) => {
|
|
18
17
|
var { dense } = _a, other = __rest(_a, ["dense"]);
|
|
19
18
|
const { t } = useTranslation();
|
|
20
|
-
return (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
return (_jsxs(Box, Object.assign({ sx: {
|
|
20
|
+
display: 'flex',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
justifyContent: 'center',
|
|
23
|
+
flexDirection: 'column',
|
|
24
|
+
flex: 1,
|
|
25
|
+
}, py: 2.375 }, { children: [_jsx(Typography, Object.assign({ fontSize: 48 }, { children: _jsx(RouteIcon, { fontSize: "inherit" }) })), _jsx(Typography, Object.assign({ fontSize: 18, fontWeight: 700 }, { children: t('swap.info.title.routeNotFound') })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.secondary", textAlign: "center", mt: 2 }, { children: t('swap.info.message.routeNotFound') }))] })));
|
|
27
26
|
};
|
package/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "1.11.
|
|
2
|
+
export declare const version = "1.11.4";
|
package/config/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '1.11.
|
|
2
|
+
export const version = '1.11.4';
|
package/i18n/en/translation.json
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"button": {
|
|
15
15
|
"connectWallet": "Connect wallet",
|
|
16
16
|
"switchChain": "Switch chain",
|
|
17
|
+
"swap": "Swap",
|
|
17
18
|
"reviewSwap": "Review swap",
|
|
18
19
|
"startSwap": "Start swap",
|
|
19
20
|
"restartSwap": "Restart swap",
|
|
@@ -78,10 +79,12 @@
|
|
|
78
79
|
},
|
|
79
80
|
"info": {
|
|
80
81
|
"title": {
|
|
81
|
-
"routeNotFound": "No routes available"
|
|
82
|
+
"routeNotFound": "No routes available",
|
|
83
|
+
"emptySwapHistory": "No recent swaps"
|
|
82
84
|
},
|
|
83
85
|
"message": {
|
|
84
|
-
"routeNotFound": "Try another token combination."
|
|
86
|
+
"routeNotFound": "Try another token combination.",
|
|
87
|
+
"emptySwapHistory": "Swap history is only stored locally and will be deleted if you clear your browser data."
|
|
85
88
|
}
|
|
86
89
|
},
|
|
87
90
|
"warning": {
|
package/i18n/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare const resources: {
|
|
|
17
17
|
button: {
|
|
18
18
|
connectWallet: string;
|
|
19
19
|
switchChain: string;
|
|
20
|
+
swap: string;
|
|
20
21
|
reviewSwap: string;
|
|
21
22
|
startSwap: string;
|
|
22
23
|
restartSwap: string;
|
|
@@ -82,9 +83,11 @@ export declare const resources: {
|
|
|
82
83
|
info: {
|
|
83
84
|
title: {
|
|
84
85
|
routeNotFound: string;
|
|
86
|
+
emptySwapHistory: string;
|
|
85
87
|
};
|
|
86
88
|
message: {
|
|
87
89
|
routeNotFound: string;
|
|
90
|
+
emptySwapHistory: string;
|
|
88
91
|
};
|
|
89
92
|
};
|
|
90
93
|
warning: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.4",
|
|
4
4
|
"description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./index.js",
|
|
@@ -23,8 +23,8 @@ export const SwapRoutes = (props) => {
|
|
|
23
23
|
if (!currentRoute && !isLoading && !isFetching && !isFetched) {
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
|
-
const routeNotFound = !currentRoute &&
|
|
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: {
|
|
26
|
+
const routeNotFound = !currentRoute && !isLoading && !isFetching;
|
|
27
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Card, Object.assign({}, props, { children: [_jsx(CardTitle, { children: t('swap.routes') }), _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: {
|
|
28
28
|
position: 'absolute',
|
|
29
29
|
top: 8,
|
|
30
30
|
right: 8,
|
|
@@ -32,5 +32,5 @@ export const SwapRoutes = (props) => {
|
|
|
32
32
|
borderWidth: !routeNotFound && (isFetching || (routes && routes.length > 1))
|
|
33
33
|
? 1
|
|
34
34
|
: 0,
|
|
35
|
-
} }, { children:
|
|
35
|
+
} }, { children: isLoading || isFetching ? (_jsxs(_Fragment, { children: [_jsx(SwapRouteCardSkeleton, { minWidth: "80%", dense: true }), _jsx(SwapRouteCardSkeleton, { minWidth: "80%", dense: true })] })) : !currentRoute ? (_jsx(SwapRouteNotFoundCard, { minWidth: "100%", 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
36
|
};
|
|
@@ -10,5 +10,5 @@ export const SwapHistoryEmpty = () => {
|
|
|
10
10
|
flexDirection: 'column',
|
|
11
11
|
alignItems: 'center',
|
|
12
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:
|
|
13
|
+
} }, { children: [_jsx(Typography, Object.assign({ fontSize: 48 }, { children: _jsx(HistoryIcon, { fontSize: "inherit" }) })), _jsx(Typography, Object.assign({ fontSize: 18, fontWeight: 700 }, { children: t('swap.info.title.emptySwapHistory') })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.secondary", textAlign: "center", mt: 2 }, { children: t('swap.info.message.emptySwapHistory') }))] })));
|
|
14
14
|
};
|
|
@@ -28,8 +28,8 @@ export const SwapRoutesPage = () => {
|
|
|
28
28
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
29
|
}, []);
|
|
30
30
|
useEffect(() => {
|
|
31
|
-
return setHeaderAction(_jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt, timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 }, size: "medium", edge: "end" }));
|
|
31
|
+
return setHeaderAction(_jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 }, size: "medium", edge: "end" }));
|
|
32
32
|
}, [dataUpdatedAt, isFetching, refetch, refetchTime, setHeaderAction]);
|
|
33
|
-
const routeNotFound = !(swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.length) &&
|
|
34
|
-
return (_jsx(Stack, Object.assign({ direction: "column", spacing: 2 }, { children: routeNotFound ? (_jsx(SwapRouteNotFoundCard, {})) : isLoading || isFetching ? (Array.from({ length: 3 }).map((_, index) => (_jsx(SwapRouteCardSkeleton, {}, index)))) : (swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.map((route
|
|
33
|
+
const routeNotFound = !(swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.length) && !isLoading && !isFetching;
|
|
34
|
+
return (_jsx(Stack, Object.assign({ direction: "column", spacing: 2, flex: 1 }, { children: routeNotFound ? (_jsx(SwapRouteNotFoundCard, {})) : isLoading || isFetching ? (Array.from({ length: 3 }).map((_, index) => (_jsx(SwapRouteCardSkeleton, {}, index)))) : (swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.map((route) => (_jsx(SwapRouteCard, { route: route, onClick: () => handleRouteClick(route) }, route.id)))) })));
|
|
35
35
|
};
|