@lifi/widget 1.19.0 → 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/cjs/components/AppContainer.js +0 -1
- package/cjs/components/BottomSheet/BottomSheet.js +2 -1
- package/cjs/components/ChainSelect/ChainSelect.js +1 -1
- package/cjs/components/Dialog.js +2 -1
- package/cjs/components/Header/NavigationHeader.js +1 -1
- package/cjs/components/ProgressToNextUpdate/ProgressToNextUpdate.js +1 -1
- package/cjs/components/SendToWallet/SendToWalletButton.js +1 -1
- package/cjs/components/SwapInput/SwapInputAdornment.js +1 -1
- package/cjs/components/SwapInput/SwapInputAdornment.style.js +1 -1
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +2 -2
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/useContentHeight.d.ts +2 -0
- package/cjs/hooks/useContentHeight.js +18 -1
- package/cjs/i18n/en/translation.json +9 -2
- package/cjs/i18n/index.d.ts +7 -0
- package/cjs/pages/SwapPage/StatusBottomSheet.js +1 -1
- 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/stores/routes/types.d.ts +1 -1
- package/components/AppContainer.js +0 -1
- package/components/BottomSheet/BottomSheet.js +2 -1
- package/components/ChainSelect/ChainSelect.js +1 -1
- package/components/Dialog.js +2 -1
- package/components/Header/NavigationHeader.js +1 -1
- package/components/ProgressToNextUpdate/ProgressToNextUpdate.js +1 -1
- package/components/SendToWallet/SendToWalletButton.js +1 -1
- package/components/SwapInput/SwapInputAdornment.js +1 -1
- package/components/SwapInput/SwapInputAdornment.style.js +1 -1
- package/components/SwapRouteCard/SwapRouteCard.js +2 -2
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/useContentHeight.d.ts +2 -0
- package/hooks/useContentHeight.js +16 -0
- package/i18n/en/translation.json +9 -2
- package/i18n/index.d.ts +7 -0
- package/package.json +1 -1
- package/pages/SwapPage/StatusBottomSheet.js +2 -2
- package/pages/SwapPage/StatusBottomSheet.style.d.ts +0 -4
- package/pages/SwapPage/StatusBottomSheet.style.js +23 -17
- package/pages/SwapPage/SwapPage.js +40 -19
- package/pages/SwapPage/TokenValueBottomSheet.d.ts +11 -0
- package/pages/SwapPage/TokenValueBottomSheet.js +38 -0
- package/stores/routes/types.d.ts +1 -1
- package/tsconfig.cjs.tsbuildinfo +1 -1
|
@@ -33,7 +33,6 @@ const RelativeContainer = (0, styles_1.styled)(material_1.Box, {
|
|
|
33
33
|
const CssBaselineContainer = (0, styles_1.styled)(material_1.ScopedCssBaseline, {
|
|
34
34
|
shouldForwardProp: (prop) => prop !== 'variant',
|
|
35
35
|
})(({ variant }) => ({
|
|
36
|
-
position: 'relative',
|
|
37
36
|
display: 'flex',
|
|
38
37
|
flex: 1,
|
|
39
38
|
flexDirection: 'column',
|
|
@@ -4,6 +4,7 @@ exports.BottomSheet = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const material_1 = require("@mui/material");
|
|
6
6
|
const react_1 = require("react");
|
|
7
|
+
const hooks_1 = require("../../hooks");
|
|
7
8
|
const Dialog_1 = require("../Dialog");
|
|
8
9
|
exports.BottomSheet = (0, react_1.forwardRef)(({ elementRef, children, open }, ref) => {
|
|
9
10
|
const openRef = (0, react_1.useRef)(open);
|
|
@@ -20,5 +21,5 @@ exports.BottomSheet = (0, react_1.forwardRef)(({ elementRef, children, open }, r
|
|
|
20
21
|
},
|
|
21
22
|
close,
|
|
22
23
|
}), [close]);
|
|
23
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Drawer, Object.assign({ ref: elementRef, anchor: "bottom", open: drawerOpen, onClose: close, ModalProps: Dialog_1.modalProps, PaperProps: Dialog_1.paperProps, BackdropProps: Dialog_1.backdropProps, disableAutoFocus: true
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Drawer, Object.assign({ container: hooks_1.getScrollableContainer, ref: elementRef, anchor: "bottom", open: drawerOpen, onClose: close, ModalProps: Dialog_1.modalProps, PaperProps: Dialog_1.paperProps, BackdropProps: Dialog_1.backdropProps, disableAutoFocus: true }, { children: children })));
|
|
24
25
|
});
|
|
@@ -25,7 +25,7 @@ const ChainSelect = ({ formType }) => {
|
|
|
25
25
|
const chainsToHide = ((_a = chains === null || chains === void 0 ? void 0 : chains.length) !== null && _a !== void 0 ? _a : 0) - stores_1.maxChainToOrder;
|
|
26
26
|
return ((0, jsx_runtime_1.jsxs)(ChainSelect_style_1.ChainContainer, { children: [isLoading
|
|
27
27
|
? Array.from({ length: stores_1.maxChainToOrder + 1 }).map((_, index) => ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "rectangular", width: 56, height: 56, sx: { borderRadius: 1 } }, index)))
|
|
28
|
-
: getChains().map((chain) => ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: chain.name, placement: "top", enterDelay: 400,
|
|
28
|
+
: getChains().map((chain) => ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: chain.name, placement: "top", enterDelay: 400, arrow: true }, { children: (0, jsx_runtime_1.jsx)(ChainSelect_style_1.ChainCard, Object.assign({ onClick: () => setCurrentChain(chain.id), variant: chainId === chain.id ? 'selected' : 'default' }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, Object.assign({ src: chain.logoURI, alt: chain.key, sx: { width: 40, height: 40 } }, { children: chain.name[0] })) })) }), chain.id))), chainsToHide > 0 ? ((0, jsx_runtime_1.jsx)(ChainSelect_style_1.ChainCard, Object.assign({ onClick: showAllChains }, { children: (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ sx: {
|
|
29
29
|
width: 40,
|
|
30
30
|
height: 40,
|
|
31
31
|
display: 'grid',
|
package/cjs/components/Dialog.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Dialog = exports.backdropProps = exports.paperProps = exports.modalProps = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const material_1 = require("@mui/material");
|
|
6
|
+
const hooks_1 = require("../hooks");
|
|
6
7
|
exports.modalProps = {
|
|
7
8
|
sx: {
|
|
8
9
|
position: 'absolute',
|
|
@@ -25,6 +26,6 @@ exports.backdropProps = {
|
|
|
25
26
|
},
|
|
26
27
|
};
|
|
27
28
|
const Dialog = ({ children, open, onClose, }) => {
|
|
28
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Dialog, Object.assign({ open: open, onClose: onClose, sx: exports.modalProps.sx, PaperProps: exports.paperProps, BackdropProps: exports.backdropProps
|
|
29
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Dialog, Object.assign({ container: hooks_1.getScrollableContainer, open: open, onClose: onClose, sx: exports.modalProps.sx, PaperProps: exports.paperProps, BackdropProps: exports.backdropProps }, { children: children })));
|
|
29
30
|
};
|
|
30
31
|
exports.Dialog = Dialog;
|
|
@@ -49,6 +49,6 @@ const NavigationHeader = () => {
|
|
|
49
49
|
return t(`header.swap`);
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
-
return ((0, jsx_runtime_1.jsxs)(Header_style_1.HeaderAppBar, Object.assign({ elevation: 0 }, { children: [utils_1.backButtonRoutes.includes(path) ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", edge: "start", onClick: navigateBack }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.ArrowBack, {}) }))) : null, (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: hasPath ? 18 : 24, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true }, { children: handleHeaderTitle() })), (0, jsx_runtime_1.jsxs)(react_router_dom_1.Routes, { children: [(0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { path: utils_1.navigationRoutes.home, element: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [account.isActive ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: t(`header.swapHistory`), enterDelay: 400,
|
|
52
|
+
return ((0, jsx_runtime_1.jsxs)(Header_style_1.HeaderAppBar, Object.assign({ elevation: 0 }, { children: [utils_1.backButtonRoutes.includes(path) ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", edge: "start", onClick: navigateBack }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.ArrowBack, {}) }))) : null, (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: hasPath ? 18 : 24, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true }, { children: handleHeaderTitle() })), (0, jsx_runtime_1.jsxs)(react_router_dom_1.Routes, { children: [(0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { path: utils_1.navigationRoutes.home, element: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [account.isActive ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: t(`header.swapHistory`), enterDelay: 400, arrow: true }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", edge: "start", onClick: () => navigate(utils_1.navigationRoutes.swapHistory) }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.History, {}) })) }))) : null, (0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: t(`header.settings`), enterDelay: 400, arrow: true }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", edge: "end", onClick: () => navigate(utils_1.navigationRoutes.settings) }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.SettingsOutlined, {}) })) }))] }) }), (0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { path: "*", element: element || (0, jsx_runtime_1.jsx)(material_1.Box, { width: 28, height: 40 }) })] })] })));
|
|
53
53
|
};
|
|
54
54
|
exports.NavigationHeader = NavigationHeader;
|
|
@@ -42,7 +42,7 @@ const ProgressToNextUpdate = (_a) => {
|
|
|
42
42
|
}, [isLoading]);
|
|
43
43
|
return ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: onClick, disabled: isLoading }, other, { children: (0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: t('tooltip.progressToNextUpdate', {
|
|
44
44
|
value: getSecondsToUpdate(updatedAt, timeToUpdate),
|
|
45
|
-
}), placement: "top", enterDelay: 400,
|
|
45
|
+
}), placement: "top", enterDelay: 400, arrow: true }, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: {
|
|
46
46
|
display: 'grid',
|
|
47
47
|
position: 'relative',
|
|
48
48
|
placeItems: 'center',
|
|
@@ -24,7 +24,7 @@ const SendToWalletButton = () => {
|
|
|
24
24
|
}
|
|
25
25
|
toggleSendToWallet();
|
|
26
26
|
};
|
|
27
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: t('swap.sendToWallet'), placement: "bottom-end", enterDelay: 400,
|
|
27
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: t('swap.sendToWallet'), placement: "bottom-end", enterDelay: 400, arrow: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: showSendToWallet ? 'contained' : 'text', onClick: handleClick, sx: {
|
|
28
28
|
minWidth: 48,
|
|
29
29
|
marginLeft: 1,
|
|
30
30
|
} }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.WalletOutlined, {}) })) })));
|
|
@@ -24,6 +24,6 @@ const SwapInputAdornment = ({ formType }) => {
|
|
|
24
24
|
shouldTouch: true,
|
|
25
25
|
});
|
|
26
26
|
};
|
|
27
|
-
return ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "end" }, { children: isLoading && tokenAddress ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "rectangular", width: 46, height:
|
|
27
|
+
return ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "end" }, { children: isLoading && tokenAddress ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "rectangular", width: 46, height: 24, sx: { borderRadius: 0.5 } })) : formType === 'from' && (token === null || token === void 0 ? void 0 : token.amount) ? ((0, jsx_runtime_1.jsx)(SwapInputAdornment_style_1.Button, Object.assign({ onClick: handleMax }, { children: t('button.max') }))) : null })));
|
|
28
28
|
};
|
|
29
29
|
exports.SwapInputAdornment = SwapInputAdornment;
|
|
@@ -5,7 +5,7 @@ const material_1 = require("@mui/material");
|
|
|
5
5
|
const styles_1 = require("@mui/material/styles");
|
|
6
6
|
exports.Button = (0, styles_1.styled)(material_1.Button)(({ theme }) => ({
|
|
7
7
|
padding: theme.spacing(0.5, 1, 0.625, 1),
|
|
8
|
-
lineHeight: 1,
|
|
8
|
+
lineHeight: 1.0715,
|
|
9
9
|
fontSize: '0.875rem',
|
|
10
10
|
minWidth: 'unset',
|
|
11
11
|
}));
|
|
@@ -44,8 +44,8 @@ const SwapRouteCardEssentials = ({ route, dense }) => {
|
|
|
44
44
|
.map((step) => step.estimate.executionDuration)
|
|
45
45
|
.reduce((duration, x) => duration + x, 0) / 60);
|
|
46
46
|
const gasCostUSD = parseFloat((_a = route.gasCostUSD) !== null && _a !== void 0 ? _a : '') || 0.01;
|
|
47
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", justifyContent: dense ? 'space-between' : 'flex-end', flex: 1, pl: dense ? 0 : 2, mt: dense ? 2 : 0 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: t(`tooltip.estimatedNetworkFee`), placement: "top", enterDelay: 400,
|
|
47
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", justifyContent: dense ? 'space-between' : 'flex-end', flex: 1, pl: dense ? 0 : 2, mt: dense ? 2 : 0 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: t(`tooltip.estimatedNetworkFee`), placement: "top", enterDelay: 400, arrow: true }, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", alignItems: "center", mr: dense ? 0 : 2 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ lineHeight: 0, mr: 0.5, color: "grey.500" }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.EvStationOutlined, { fontSize: dense ? 'medium' : 'small' }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1 }, { children: t(`swap.currency`, { value: gasCostUSD }) }))] })) })), (0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: t(`tooltip.estimatedTime`), placement: "top", enterDelay: 400, arrow: true }, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", alignItems: "center", mr: dense ? 0 : 2 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ lineHeight: 0, mr: 0.5, color: "grey.500" }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.AccessTime, { fontSize: dense ? 'medium' : 'small' }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1 }, { children: t('swap.estimatedTime', {
|
|
48
48
|
value: executionTimeMinutes,
|
|
49
|
-
}) }))] })) })), !dense ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: t(`tooltip.numberOfSteps`), placement: "top", enterDelay: 400,
|
|
49
|
+
}) }))] })) })), !dense ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: t(`tooltip.numberOfSteps`), placement: "top", enterDelay: 400, arrow: true }, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", alignItems: "center" }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ lineHeight: 0, mr: 0.5, color: "grey.500" }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.LayersOutlined, { fontSize: dense ? 'medium' : 'small' }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1 }, { children: route.steps.length }))] })) }))) : null] })));
|
|
50
50
|
};
|
|
51
51
|
exports.SwapRouteCardEssentials = SwapRouteCardEssentials;
|
package/cjs/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/cjs/config/version.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useContentHeight = void 0;
|
|
3
|
+
exports.useSetContentHeight = exports.useContentHeight = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
+
const useScrollableContainer_1 = require("./useScrollableContainer");
|
|
6
7
|
const getContentHeight = () => {
|
|
7
8
|
const headerElement = document.getElementById(utils_1.ElementId.Header);
|
|
8
9
|
const containerElement = document.getElementById(utils_1.ElementId.ScrollableContainer);
|
|
@@ -25,3 +26,19 @@ const useContentHeight = () => {
|
|
|
25
26
|
return contentHeight;
|
|
26
27
|
};
|
|
27
28
|
exports.useContentHeight = useContentHeight;
|
|
29
|
+
const useSetContentHeight = (ref) => {
|
|
30
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
31
|
+
var _a;
|
|
32
|
+
const scrollableContainer = (0, useScrollableContainer_1.getScrollableContainer)();
|
|
33
|
+
if (!scrollableContainer ||
|
|
34
|
+
!ref.current ||
|
|
35
|
+
((_a = ref.current) === null || _a === void 0 ? void 0 : _a.clientHeight) <= (scrollableContainer === null || scrollableContainer === void 0 ? void 0 : scrollableContainer.clientHeight)) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
scrollableContainer.style.height = `${ref.current.clientHeight}px`;
|
|
39
|
+
return () => {
|
|
40
|
+
scrollableContainer.style.removeProperty('height');
|
|
41
|
+
};
|
|
42
|
+
}, [ref]);
|
|
43
|
+
};
|
|
44
|
+
exports.useSetContentHeight = useSetContentHeight;
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"removeSwap": "Remove swap",
|
|
23
23
|
"done": "Done",
|
|
24
24
|
"okay": "Okay",
|
|
25
|
+
"continue": "Continue",
|
|
25
26
|
"seeDetails": "See details",
|
|
26
27
|
"tryAgain": "Try again",
|
|
27
28
|
"light": "Light",
|
|
@@ -62,6 +63,10 @@
|
|
|
62
63
|
"supportId": "Support ID",
|
|
63
64
|
"sendToWallet": "Send to a different wallet",
|
|
64
65
|
"walletAddressOrEns": "Wallet address or ENS name",
|
|
66
|
+
"swapping": "Swapping",
|
|
67
|
+
"gasCost": "Gas cost",
|
|
68
|
+
"receiving": "Receiving",
|
|
69
|
+
"valueLoss": "Value loss",
|
|
65
70
|
"tags": {
|
|
66
71
|
"RECOMMENDED": "RECOMMENDED",
|
|
67
72
|
"FASTEST": "FAST",
|
|
@@ -95,13 +100,15 @@
|
|
|
95
100
|
"insufficientGas": "Insufficient gas",
|
|
96
101
|
"deleteSwap": "Delete this swap?",
|
|
97
102
|
"deleteSwapHistory": "Delete swap history?",
|
|
98
|
-
"deleteActiveSwaps": "Delete all active swaps?"
|
|
103
|
+
"deleteActiveSwaps": "Delete all active swaps?",
|
|
104
|
+
"highValueLoss": "High value loss"
|
|
99
105
|
},
|
|
100
106
|
"message": {
|
|
101
107
|
"insufficientFunds": "You don't have enough funds to execute the swap.",
|
|
102
108
|
"insufficientGas": "You need to add at least:",
|
|
103
109
|
"deleteSwapHistory": "Swap history is only stored locally and can't be recovered if you delete it.",
|
|
104
|
-
"deleteActiveSwaps": "Active swaps are only stored locally and can't be recovered if you delete them."
|
|
110
|
+
"deleteActiveSwaps": "Active swaps are only stored locally and can't be recovered if you delete them.",
|
|
111
|
+
"highValueLoss": "The value of the received tokens is significantly lower than the swapped tokens and transaction cost."
|
|
105
112
|
}
|
|
106
113
|
},
|
|
107
114
|
"error": {
|
package/cjs/i18n/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export declare const resources: {
|
|
|
25
25
|
removeSwap: string;
|
|
26
26
|
done: string;
|
|
27
27
|
okay: string;
|
|
28
|
+
continue: string;
|
|
28
29
|
seeDetails: string;
|
|
29
30
|
tryAgain: string;
|
|
30
31
|
light: string;
|
|
@@ -65,6 +66,10 @@ export declare const resources: {
|
|
|
65
66
|
supportId: string;
|
|
66
67
|
sendToWallet: string;
|
|
67
68
|
walletAddressOrEns: string;
|
|
69
|
+
swapping: string;
|
|
70
|
+
gasCost: string;
|
|
71
|
+
receiving: string;
|
|
72
|
+
valueLoss: string;
|
|
68
73
|
tags: {
|
|
69
74
|
RECOMMENDED: string;
|
|
70
75
|
FASTEST: string;
|
|
@@ -99,12 +104,14 @@ export declare const resources: {
|
|
|
99
104
|
deleteSwap: string;
|
|
100
105
|
deleteSwapHistory: string;
|
|
101
106
|
deleteActiveSwaps: string;
|
|
107
|
+
highValueLoss: string;
|
|
102
108
|
};
|
|
103
109
|
message: {
|
|
104
110
|
insufficientFunds: string;
|
|
105
111
|
insufficientGas: string;
|
|
106
112
|
deleteSwapHistory: string;
|
|
107
113
|
deleteActiveSwaps: string;
|
|
114
|
+
highValueLoss: string;
|
|
108
115
|
};
|
|
109
116
|
};
|
|
110
117
|
error: {
|
|
@@ -79,6 +79,6 @@ const StatusBottomSheet = ({ status, route, }) => {
|
|
|
79
79
|
(_b = ref.current) === null || _b === void 0 ? void 0 : _b.open();
|
|
80
80
|
}
|
|
81
81
|
}, [refetch, refetchNewBalance, status]);
|
|
82
|
-
return ((0, jsx_runtime_1.jsx)(BottomSheet_1.BottomSheet, Object.assign({ ref: ref }, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ p: 3 }, { children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.IconContainer, { children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.IconCircle, Object.assign({ status: status, mb: 1 }, { children: [status === 'idle' ? (
|
|
82
|
+
return ((0, jsx_runtime_1.jsx)(BottomSheet_1.BottomSheet, Object.assign({ ref: ref }, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ p: 3 }, { children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.IconContainer, { children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.IconCircle, Object.assign({ status: status, mb: 1 }, { children: [status === 'idle' ? (0, jsx_runtime_1.jsx)(icons_material_1.Info, { color: "primary" }) : null, status === 'success' ? (0, jsx_runtime_1.jsx)(icons_material_1.Done, { color: "success" }) : null, status === 'error' ? (0, jsx_runtime_1.jsx)(icons_material_1.Warning, { color: "error" }) : null] })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ py: 1, fontSize: 18, fontWeight: 700 }, { children: title })), status === 'success' ? ((0, jsx_runtime_1.jsx)(Token_1.Token, { token: Object.assign(Object.assign({}, route.toToken), { amount: (_g = (_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 : (_f = route.steps.at(-1)) === null || _f === void 0 ? void 0 : _f.estimate.toAmount) !== null && _g !== void 0 ? _g : route.toAmount }), py: 1 })) : null] }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ py: 1 }, { children: message })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsxs)(material_1.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.seeDetails') : null] })) })), status === 'success' ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "text", fullWidth: true, onClick: handleSeeDetails }, { children: t('button.seeDetails') })) }))) : null] })) })));
|
|
83
83
|
};
|
|
84
84
|
exports.StatusBottomSheet = StatusBottomSheet;
|
|
@@ -19,7 +19,3 @@ export declare const IconCircle: import("@emotion/styled").StyledComponent<impor
|
|
|
19
19
|
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "component"> & import("@mui/system").MUIStyledCommonProps<Theme> & {
|
|
20
20
|
status: RouteExecutionStatus;
|
|
21
21
|
}, {}, {}>;
|
|
22
|
-
export declare const iconStyles: {
|
|
23
|
-
position: string;
|
|
24
|
-
fontSize: string;
|
|
25
|
-
};
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.IconCircle = exports.IconContainer = void 0;
|
|
4
4
|
const material_1 = require("@mui/material");
|
|
5
5
|
const styles_1 = require("@mui/material/styles");
|
|
6
6
|
const getStatusColor = (status, theme) => {
|
|
7
7
|
switch (status) {
|
|
8
8
|
case 'success':
|
|
9
|
-
return theme.palette.success.main;
|
|
9
|
+
return { color: theme.palette.success.main, alpha: 0.15, darken: 0 };
|
|
10
10
|
case 'error':
|
|
11
|
-
return theme.palette.error.main;
|
|
11
|
+
return { color: theme.palette.error.main, alpha: 0.2, darken: 0 };
|
|
12
|
+
case 'warning':
|
|
13
|
+
return { color: theme.palette.warning.main, alpha: 0.7, darken: 0.4 };
|
|
12
14
|
default:
|
|
13
|
-
return theme.palette.primary.main;
|
|
15
|
+
return { color: theme.palette.primary.main, alpha: 0.15, darken: 0 };
|
|
14
16
|
}
|
|
15
17
|
};
|
|
16
18
|
exports.IconContainer = (0, styles_1.styled)(material_1.Box)(({ theme }) => ({
|
|
@@ -20,16 +22,20 @@ exports.IconContainer = (0, styles_1.styled)(material_1.Box)(({ theme }) => ({
|
|
|
20
22
|
}));
|
|
21
23
|
exports.IconCircle = (0, styles_1.styled)(material_1.Box, {
|
|
22
24
|
shouldForwardProp: (prop) => prop !== 'status',
|
|
23
|
-
})(({ theme, status }) =>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
})(({ theme, status }) => {
|
|
26
|
+
const { color, alpha: alphaValue, darken: darkenValue, } = getStatusColor(status, theme);
|
|
27
|
+
return {
|
|
28
|
+
backgroundColor: (0, styles_1.alpha)(color, alphaValue),
|
|
29
|
+
borderRadius: '50%',
|
|
30
|
+
width: 64,
|
|
31
|
+
height: 64,
|
|
32
|
+
display: 'grid',
|
|
33
|
+
position: 'relative',
|
|
34
|
+
placeItems: 'center',
|
|
35
|
+
'& > svg': {
|
|
36
|
+
color: (0, styles_1.darken)(color, darkenValue),
|
|
37
|
+
width: 32,
|
|
38
|
+
height: 32,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
});
|
|
@@ -25,32 +25,51 @@ const hooks_1 = require("../../hooks");
|
|
|
25
25
|
const providers_1 = require("../../providers");
|
|
26
26
|
const StatusBottomSheet_1 = require("./StatusBottomSheet");
|
|
27
27
|
const SwapPage_style_1 = require("./SwapPage.style");
|
|
28
|
+
const TokenValueBottomSheet_1 = require("./TokenValueBottomSheet");
|
|
28
29
|
const SwapPage = () => {
|
|
29
30
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
30
31
|
const { state } = (0, react_router_dom_1.useLocation)();
|
|
31
32
|
const { navigateBack } = (0, hooks_1.useNavigateBack)();
|
|
32
|
-
const
|
|
33
|
+
const tokenValueBottomSheetRef = (0, react_1.useRef)(null);
|
|
34
|
+
const { setValue,
|
|
35
|
+
// formState: { isValid, isValidating },
|
|
36
|
+
} = (0, react_hook_form_1.useFormContext)();
|
|
33
37
|
const { route, status, executeRoute, restartRoute, deleteRoute } = (0, hooks_1.useRouteExecution)(state === null || state === void 0 ? void 0 : state.routeId);
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
const handleExecuteRoute = (0, react_1.useCallback)(() => {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
if ((_a = tokenValueBottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.isOpen()) {
|
|
41
|
+
(_b = tokenValueBottomSheetRef.current) === null || _b === void 0 ? void 0 : _b.close();
|
|
42
|
+
}
|
|
43
|
+
executeRoute();
|
|
44
|
+
setValue(providers_1.SwapFormKey.FromAmount, '');
|
|
45
|
+
}, [executeRoute, setValue]);
|
|
38
46
|
const handleSwapClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
+
var _a;
|
|
39
48
|
if (status === 'idle') {
|
|
40
|
-
|
|
41
|
-
|
|
49
|
+
const thresholdExceeded = (0, TokenValueBottomSheet_1.getTokenValueLossThreshold)(route);
|
|
50
|
+
if (thresholdExceeded) {
|
|
51
|
+
(_a = tokenValueBottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.open();
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
handleExecuteRoute();
|
|
55
|
+
}
|
|
42
56
|
}
|
|
43
57
|
if (status === 'error') {
|
|
44
58
|
restartRoute();
|
|
45
59
|
}
|
|
46
60
|
});
|
|
47
|
-
|
|
61
|
+
const handleRemoveRoute = () => {
|
|
62
|
+
navigateBack();
|
|
63
|
+
deleteRoute();
|
|
64
|
+
};
|
|
48
65
|
const getSwapButtonText = () => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
66
|
+
switch (status) {
|
|
67
|
+
case 'idle':
|
|
68
|
+
return t('button.startSwap');
|
|
69
|
+
case 'error':
|
|
70
|
+
return t('button.restartSwap');
|
|
71
|
+
default:
|
|
72
|
+
return '';
|
|
54
73
|
}
|
|
55
74
|
};
|
|
56
75
|
return ((0, jsx_runtime_1.jsxs)(SwapPage_style_1.Container, { children: [route === null || route === void 0 ? void 0 : route.steps.map((step, index, steps) => {
|
|
@@ -58,9 +77,11 @@ const SwapPage = () => {
|
|
|
58
77
|
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Step_1.Step, { step: step, fromToken: index === 0
|
|
59
78
|
? Object.assign(Object.assign({}, step.action.fromToken), { amount: step.action.fromAmount }) : undefined, toToken: index === steps.length - 1
|
|
60
79
|
? 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 ? ((0, jsx_runtime_1.jsx)(StepDivider_1.StepDivider, {})) : null] }, step.id));
|
|
61
|
-
}), status === 'idle' || status === 'error' ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(GasSufficiencyMessage_1.GasSufficiencyMessage, { route: route, mt: 2 }), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ mt: 2, display: "flex" }, { children: [(0, jsx_runtime_1.jsx)(SwapButton_1.SwapButton, { text: getSwapButtonText(), onClick: handleSwapClick, currentRoute: route,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
80
|
+
}), status === 'idle' || status === 'error' ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(GasSufficiencyMessage_1.GasSufficiencyMessage, { route: route, mt: 2 }), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ mt: 2, display: "flex" }, { children: [(0, jsx_runtime_1.jsx)(SwapButton_1.SwapButton, { text: getSwapButtonText(), onClick: handleSwapClick, currentRoute: route,
|
|
81
|
+
// disable={status === 'idle' && (isValidating || !isValid)}
|
|
82
|
+
enableLoading: true }), status === 'error' ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: t('button.removeSwap'), placement: "bottom-end", enterDelay: 400, arrow: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ onClick: handleRemoveRoute, sx: {
|
|
83
|
+
minWidth: 48,
|
|
84
|
+
marginLeft: 1,
|
|
85
|
+
} }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.Delete, {}) })) }))) : null] }))] })) : null, route && status ? ((0, jsx_runtime_1.jsx)(StatusBottomSheet_1.StatusBottomSheet, { status: status, route: route })) : null, route ? ((0, jsx_runtime_1.jsx)(TokenValueBottomSheet_1.TokenValueBottomSheet, { route: route, ref: tokenValueBottomSheetRef, onContinue: handleExecuteRoute })) : null] }));
|
|
65
86
|
};
|
|
66
87
|
exports.SwapPage = SwapPage;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { Route } from '@lifi/sdk';
|
|
3
|
+
import type { BottomSheetBase } from '../../components/BottomSheet';
|
|
4
|
+
interface TokenValueBottomSheetProps {
|
|
5
|
+
route: Route;
|
|
6
|
+
onContinue(): void;
|
|
7
|
+
onCancel?(): void;
|
|
8
|
+
}
|
|
9
|
+
export declare const TokenValueBottomSheet: import("react").ForwardRefExoticComponent<TokenValueBottomSheetProps & import("react").RefAttributes<BottomSheetBase>>;
|
|
10
|
+
export declare const getTokenValueLossThreshold: (route?: Route) => boolean;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTokenValueLossThreshold = exports.TokenValueBottomSheet = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const icons_material_1 = require("@mui/icons-material");
|
|
6
|
+
const material_1 = require("@mui/material");
|
|
7
|
+
const big_js_1 = require("big.js");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const react_i18next_1 = require("react-i18next");
|
|
10
|
+
const BottomSheet_1 = require("../../components/BottomSheet");
|
|
11
|
+
const hooks_1 = require("../../hooks");
|
|
12
|
+
const StatusBottomSheet_style_1 = require("./StatusBottomSheet.style");
|
|
13
|
+
exports.TokenValueBottomSheet = (0, react_1.forwardRef)(({ route, onContinue, onCancel }, ref) => {
|
|
14
|
+
const handleCancel = () => {
|
|
15
|
+
var _a;
|
|
16
|
+
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.close();
|
|
17
|
+
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
18
|
+
};
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(BottomSheet_1.BottomSheet, Object.assign({ ref: ref }, { children: (0, jsx_runtime_1.jsx)(TokenValueBottomSheetContent, { route: route, onContinue: onContinue, onCancel: handleCancel }) })));
|
|
20
|
+
});
|
|
21
|
+
const TokenValueBottomSheetContent = ({ route, onCancel, onContinue, }) => {
|
|
22
|
+
const { t } = (0, react_i18next_1.useTranslation)();
|
|
23
|
+
const ref = (0, react_1.useRef)();
|
|
24
|
+
(0, hooks_1.useSetContentHeight)(ref);
|
|
25
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ p: 3, ref: ref }, { children: [(0, jsx_runtime_1.jsxs)(StatusBottomSheet_style_1.IconContainer, { children: [(0, jsx_runtime_1.jsx)(StatusBottomSheet_style_1.IconCircle, Object.assign({ status: "warning", mb: 1 }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.Warning, { color: "warning" }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ py: 1, fontSize: 18, fontWeight: 700 }, { children: t('swap.warning.title.highValueLoss') }))] }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ py: 1 }, { children: t('swap.warning.message.highValueLoss') })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", justifyContent: "space-between", mt: 1 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: t('swap.swapping') }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontWeight: 600 }, { children: t('swap.currency', { value: route.fromAmountUSD }) }))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", justifyContent: "space-between", mt: 0.25 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: t('swap.gasCost') }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontWeight: 600 }, { children: t('swap.currency', { value: route.gasCostUSD }) }))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", justifyContent: "space-between", mt: 0.25 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: t('swap.receiving') }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontWeight: 600 }, { children: t('swap.currency', { value: route.toAmountUSD }) }))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", justifyContent: "space-between", mt: 0.25 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: t('swap.valueLoss') }), (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ fontWeight: 600 }, { children: [(0, big_js_1.default)(route.toAmountUSD || 0)
|
|
26
|
+
.div((0, big_js_1.default)(route.fromAmountUSD || 0).plus((0, big_js_1.default)(route.gasCostUSD || 0)))
|
|
27
|
+
.mul(-100)
|
|
28
|
+
.toFixed(1), "%"] }))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", mt: 3 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "text", onClick: onCancel, fullWidth: true }, { children: t('button.cancel') })), (0, jsx_runtime_1.jsx)(material_1.Box, { display: "flex", p: 1 }), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "contained", onClick: onContinue, fullWidth: true }, { children: t('button.continue') }))] }))] })));
|
|
29
|
+
};
|
|
30
|
+
const getTokenValueLossThreshold = (route) => {
|
|
31
|
+
if (!route) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const fromAmountUSD = (0, big_js_1.default)((route === null || route === void 0 ? void 0 : route.fromAmountUSD) || 0);
|
|
35
|
+
const toAmountUSD = (0, big_js_1.default)((route === null || route === void 0 ? void 0 : route.toAmountUSD) || 0);
|
|
36
|
+
const gasCostUSD = (0, big_js_1.default)((route === null || route === void 0 ? void 0 : route.gasCostUSD) || 0);
|
|
37
|
+
if (fromAmountUSD.eq(0) && toAmountUSD.eq(0)) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
return toAmountUSD.div(fromAmountUSD.plus(gasCostUSD)).lt(0.9);
|
|
41
|
+
};
|
|
42
|
+
exports.getTokenValueLossThreshold = getTokenValueLossThreshold;
|
|
@@ -7,7 +7,7 @@ export interface RouteExecutionStore {
|
|
|
7
7
|
deleteRoute: (routeId: string) => void;
|
|
8
8
|
deleteRoutes: (type: 'completed' | 'active') => void;
|
|
9
9
|
}
|
|
10
|
-
export declare type RouteExecutionStatus = 'error' | 'idle' | 'loading' | 'success';
|
|
10
|
+
export declare type RouteExecutionStatus = 'error' | 'idle' | 'loading' | 'success' | 'warning';
|
|
11
11
|
export interface RouteExecution {
|
|
12
12
|
route: Route;
|
|
13
13
|
status: RouteExecutionStatus;
|
|
@@ -30,7 +30,6 @@ const RelativeContainer = styled(Box, {
|
|
|
30
30
|
const CssBaselineContainer = styled(ScopedCssBaseline, {
|
|
31
31
|
shouldForwardProp: (prop) => prop !== 'variant',
|
|
32
32
|
})(({ variant }) => ({
|
|
33
|
-
position: 'relative',
|
|
34
33
|
display: 'flex',
|
|
35
34
|
flex: 1,
|
|
36
35
|
flexDirection: 'column',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Drawer } from '@mui/material';
|
|
3
3
|
import { forwardRef, useCallback, useImperativeHandle, useRef, useState, } from 'react';
|
|
4
|
+
import { getScrollableContainer } from '../../hooks';
|
|
4
5
|
import { backdropProps, modalProps, paperProps } from '../Dialog';
|
|
5
6
|
export const BottomSheet = forwardRef(({ elementRef, children, open }, ref) => {
|
|
6
7
|
const openRef = useRef(open);
|
|
@@ -17,5 +18,5 @@ export const BottomSheet = forwardRef(({ elementRef, children, open }, ref) => {
|
|
|
17
18
|
},
|
|
18
19
|
close,
|
|
19
20
|
}), [close]);
|
|
20
|
-
return (_jsx(Drawer, Object.assign({ ref: elementRef, anchor: "bottom", open: drawerOpen, onClose: close, ModalProps: modalProps, PaperProps: paperProps, BackdropProps: backdropProps, disableAutoFocus: true
|
|
21
|
+
return (_jsx(Drawer, Object.assign({ container: getScrollableContainer, ref: elementRef, anchor: "bottom", open: drawerOpen, onClose: close, ModalProps: modalProps, PaperProps: paperProps, BackdropProps: backdropProps, disableAutoFocus: true }, { children: children })));
|
|
21
22
|
});
|
|
@@ -22,7 +22,7 @@ export const ChainSelect = ({ formType }) => {
|
|
|
22
22
|
const chainsToHide = ((_a = chains === null || chains === void 0 ? void 0 : chains.length) !== null && _a !== void 0 ? _a : 0) - maxChainToOrder;
|
|
23
23
|
return (_jsxs(ChainContainer, { children: [isLoading
|
|
24
24
|
? Array.from({ length: maxChainToOrder + 1 }).map((_, index) => (_jsx(Skeleton, { variant: "rectangular", width: 56, height: 56, sx: { borderRadius: 1 } }, index)))
|
|
25
|
-
: getChains().map((chain) => (_jsx(Tooltip, Object.assign({ title: chain.name, placement: "top", enterDelay: 400,
|
|
25
|
+
: getChains().map((chain) => (_jsx(Tooltip, Object.assign({ title: chain.name, placement: "top", enterDelay: 400, arrow: true }, { children: _jsx(ChainCard, Object.assign({ onClick: () => setCurrentChain(chain.id), variant: chainId === chain.id ? 'selected' : 'default' }, { children: _jsx(Avatar, Object.assign({ src: chain.logoURI, alt: chain.key, sx: { width: 40, height: 40 } }, { children: chain.name[0] })) })) }), chain.id))), chainsToHide > 0 ? (_jsx(ChainCard, Object.assign({ onClick: showAllChains }, { children: _jsx(Box, Object.assign({ sx: {
|
|
26
26
|
width: 40,
|
|
27
27
|
height: 40,
|
|
28
28
|
display: 'grid',
|
package/components/Dialog.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Dialog as MuiDialog } from '@mui/material';
|
|
3
|
+
import { getScrollableContainer } from '../hooks';
|
|
3
4
|
export const modalProps = {
|
|
4
5
|
sx: {
|
|
5
6
|
position: 'absolute',
|
|
@@ -22,5 +23,5 @@ export const backdropProps = {
|
|
|
22
23
|
},
|
|
23
24
|
};
|
|
24
25
|
export const Dialog = ({ children, open, onClose, }) => {
|
|
25
|
-
return (_jsx(MuiDialog, Object.assign({ open: open, onClose: onClose, sx: modalProps.sx, PaperProps: paperProps, BackdropProps: backdropProps
|
|
26
|
+
return (_jsx(MuiDialog, Object.assign({ container: getScrollableContainer, open: open, onClose: onClose, sx: modalProps.sx, PaperProps: paperProps, BackdropProps: backdropProps }, { children: children })));
|
|
26
27
|
};
|
|
@@ -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", 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,
|
|
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
|
};
|
|
@@ -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: 400,
|
|
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',
|
|
@@ -21,7 +21,7 @@ export const SendToWalletButton = () => {
|
|
|
21
21
|
}
|
|
22
22
|
toggleSendToWallet();
|
|
23
23
|
};
|
|
24
|
-
return (_jsx(Tooltip, Object.assign({ title: t('swap.sendToWallet'), placement: "bottom-end", enterDelay: 400,
|
|
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, {}) })) })));
|
|
@@ -21,5 +21,5 @@ export const SwapInputAdornment = ({ formType }) => {
|
|
|
21
21
|
shouldTouch: true,
|
|
22
22
|
});
|
|
23
23
|
};
|
|
24
|
-
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 })));
|
|
25
25
|
};
|
|
@@ -2,7 +2,7 @@ import { Button as MuiButton } from '@mui/material';
|
|
|
2
2
|
import { styled } from '@mui/material/styles';
|
|
3
3
|
export const Button = styled(MuiButton)(({ theme }) => ({
|
|
4
4
|
padding: theme.spacing(0.5, 1, 0.625, 1),
|
|
5
|
-
lineHeight: 1,
|
|
5
|
+
lineHeight: 1.0715,
|
|
6
6
|
fontSize: '0.875rem',
|
|
7
7
|
minWidth: 'unset',
|
|
8
8
|
}));
|