@lifi/widget 1.18.7 → 1.18.9
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/SwapRouteCard/SwapRouteCard.js +6 -3
- package/cjs/components/SwapRoutes/SwapRoutes.js +2 -12
- package/cjs/components/SwapRoutes/SwapRoutes.style.d.ts +14 -14
- package/cjs/components/SwapRoutes/SwapRoutes.style.js +13 -13
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +7 -5
- package/cjs/components/SwapRoutes/useSetSelectedRoute.d.ts +2 -0
- package/cjs/components/SwapRoutes/useSetSelectedRoute.js +13 -0
- package/cjs/components/Token/Token.js +5 -5
- package/cjs/components/Token/Token.style.d.ts +10 -0
- package/cjs/components/Token/Token.style.js +13 -7
- package/cjs/components/TokenList/TokenList.js +3 -3
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/useDebouncedWatch.js +1 -4
- package/cjs/hooks/useSwapRoutes.js +1 -1
- package/cjs/hooks/useToken.js +5 -2
- package/cjs/hooks/useTokenBalance.js +15 -10
- package/cjs/hooks/useTokenSearch.d.ts +1 -3
- package/cjs/hooks/useTokenSearch.js +3 -5
- package/cjs/i18n/en/translation.json +1 -1
- package/cjs/pages/MainPage/MainPage.js +3 -1
- package/cjs/stores/routes/useRouteExecutionStore.js +1 -0
- package/cjs/stores/settings/useSettingsStore.js +5 -2
- package/components/SwapRouteCard/SwapRouteCard.js +6 -3
- package/components/SwapRoutes/SwapRoutes.js +2 -12
- package/components/SwapRoutes/SwapRoutes.style.d.ts +14 -14
- package/components/SwapRoutes/SwapRoutes.style.js +13 -13
- package/components/SwapRoutes/SwapRoutesExpanded.js +7 -5
- package/components/SwapRoutes/useSetSelectedRoute.d.ts +2 -0
- package/components/SwapRoutes/useSetSelectedRoute.js +9 -0
- package/components/Token/Token.js +7 -7
- package/components/Token/Token.style.d.ts +10 -0
- package/components/Token/Token.style.js +12 -6
- package/components/TokenList/TokenList.js +3 -3
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/useDebouncedWatch.js +1 -4
- package/hooks/useSwapRoutes.js +1 -1
- package/hooks/useToken.js +5 -2
- package/hooks/useTokenBalance.js +15 -10
- package/hooks/useTokenSearch.d.ts +1 -3
- package/hooks/useTokenSearch.js +3 -5
- package/i18n/en/translation.json +1 -1
- package/package.json +5 -5
- package/pages/MainPage/MainPage.js +3 -1
- package/stores/routes/useRouteExecutionStore.js +1 -0
- package/stores/settings/useSettingsStore.js +5 -2
- package/tsconfig.cjs.tsbuildinfo +1 -1
|
@@ -40,8 +40,11 @@ exports.SwapRouteCard = SwapRouteCard;
|
|
|
40
40
|
const SwapRouteCardEssentials = ({ route, dense }) => {
|
|
41
41
|
var _a;
|
|
42
42
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
const executionTime = (route.steps
|
|
44
|
+
.map((step) => step.estimate.executionDuration)
|
|
45
|
+
.reduce((duration, x) => duration + x) / 60).toFixed(0) || 1;
|
|
46
|
+
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.jsxs)(material_1.Box, Object.assign({ display: "flex", alignItems: "center", pr: 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: (_a = route.gasCostUSD) !== null && _a !== void 0 ? _a : 0.01 }) }))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", alignItems: "center", pr: 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', {
|
|
47
|
+
value: executionTime,
|
|
48
|
+
}) }))] })), !dense ? ((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] })));
|
|
46
49
|
};
|
|
47
50
|
exports.SwapRouteCardEssentials = SwapRouteCardEssentials;
|
|
@@ -4,7 +4,6 @@ exports.SwapRoutes = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const icons_material_1 = require("@mui/icons-material");
|
|
6
6
|
const material_1 = require("@mui/material");
|
|
7
|
-
const react_1 = require("react");
|
|
8
7
|
const react_hook_form_1 = require("react-hook-form");
|
|
9
8
|
const react_i18next_1 = require("react-i18next");
|
|
10
9
|
const react_router_dom_1 = require("react-router-dom");
|
|
@@ -12,22 +11,16 @@ const Card_1 = require("../../components/Card");
|
|
|
12
11
|
const ProgressToNextUpdate_1 = require("../../components/ProgressToNextUpdate");
|
|
13
12
|
const SwapRouteCard_1 = require("../../components/SwapRouteCard");
|
|
14
13
|
const hooks_1 = require("../../hooks");
|
|
15
|
-
const providers_1 = require("../../providers");
|
|
16
|
-
const stores_1 = require("../../stores");
|
|
17
14
|
const utils_1 = require("../../utils");
|
|
18
15
|
const SwapRoutes_style_1 = require("./SwapRoutes.style");
|
|
16
|
+
const useSetSelectedRoute_1 = require("./useSetSelectedRoute");
|
|
19
17
|
const SwapRoutes = (props) => {
|
|
20
18
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
21
|
-
const { variant } = (0, providers_1.useWidgetConfig)();
|
|
22
19
|
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
23
20
|
const { isValid, isValidating } = (0, react_hook_form_1.useFormState)();
|
|
24
|
-
const setSelectedRoute = (0, stores_1.useSelectedRouteStore)((state) => state.setSelectedRoute);
|
|
25
21
|
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = (0, hooks_1.useSwapRoutes)();
|
|
26
22
|
const currentRoute = routes === null || routes === void 0 ? void 0 : routes[0];
|
|
27
|
-
(0,
|
|
28
|
-
setSelectedRoute(!isFetching ? currentRoute : undefined);
|
|
29
|
-
return () => setSelectedRoute(undefined);
|
|
30
|
-
}, [currentRoute, isFetching, setSelectedRoute]);
|
|
23
|
+
(0, useSetSelectedRoute_1.useSetSelectedRoute)(currentRoute, isFetching);
|
|
31
24
|
if (!currentRoute && !isLoading && !isFetching && !isFetched) {
|
|
32
25
|
return null;
|
|
33
26
|
}
|
|
@@ -35,9 +28,6 @@ const SwapRoutes = (props) => {
|
|
|
35
28
|
navigate(utils_1.navigationRoutes.swapRoutes);
|
|
36
29
|
};
|
|
37
30
|
const routeNotFound = !currentRoute && !isLoading && !isFetching;
|
|
38
|
-
if (variant === 'expandable') {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
31
|
return ((0, jsx_runtime_1.jsxs)(Card_1.Card, Object.assign({}, props, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t('swap.routes') }), (0, jsx_runtime_1.jsx)(ProgressToNextUpdate_1.ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: {
|
|
42
32
|
position: 'absolute',
|
|
43
33
|
top: 8,
|
|
@@ -1,14 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const Stack: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
3
|
-
ref?: import("react").Ref<unknown> | undefined;
|
|
4
|
-
children?: import("react").ReactNode;
|
|
5
|
-
direction?: import("@mui/system").ResponsiveStyleValue<"row" | "column" | "column-reverse" | "row-reverse"> | undefined;
|
|
6
|
-
spacing?: import("@mui/system").ResponsiveStyleValue<string | number> | undefined;
|
|
7
|
-
divider?: import("react").ReactNode;
|
|
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" | "ref" | "direction" | ("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") | "divider" | "spacing"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
12
2
|
export declare const CollapseContainer: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
13
3
|
children?: import("react").ReactNode;
|
|
14
4
|
component?: import("react").ElementType<any> | undefined;
|
|
@@ -25,14 +15,14 @@ export declare const ScrollableContainer: import("@emotion/styled").StyledCompon
|
|
|
25
15
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
26
16
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
27
17
|
}, 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<import("@mui/material").Theme>, {}, {}>;
|
|
28
|
-
export declare const Container: import("@emotion/styled").StyledComponent<
|
|
18
|
+
export declare const Container: import("@emotion/styled").StyledComponent<{
|
|
29
19
|
children?: import("react").ReactNode;
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
classes?: Partial<import("@mui/material").ScopedCssBaselineClasses> | undefined;
|
|
21
|
+
enableColorScheme?: boolean | undefined;
|
|
32
22
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
33
23
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
34
24
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
35
|
-
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "
|
|
25
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "enableColorScheme"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
36
26
|
export declare const Header: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
37
27
|
children?: import("react").ReactNode;
|
|
38
28
|
component?: import("react").ElementType<any> | undefined;
|
|
@@ -41,3 +31,13 @@ export declare const Header: import("@emotion/styled").StyledComponent<import("@
|
|
|
41
31
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
42
32
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
43
33
|
}, 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<import("@mui/material").Theme>, {}, {}>;
|
|
34
|
+
export declare const Stack: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
35
|
+
ref?: import("react").Ref<unknown> | undefined;
|
|
36
|
+
children?: import("react").ReactNode;
|
|
37
|
+
direction?: import("@mui/system").ResponsiveStyleValue<"row" | "column" | "column-reverse" | "row-reverse"> | undefined;
|
|
38
|
+
spacing?: import("@mui/system").ResponsiveStyleValue<string | number> | undefined;
|
|
39
|
+
divider?: import("react").ReactNode;
|
|
40
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
41
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
42
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
43
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "ref" | "direction" | ("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") | "divider" | "spacing"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Stack = exports.Header = exports.Container = exports.ScrollableContainer = exports.CollapseContainer = void 0;
|
|
4
4
|
const material_1 = require("@mui/material");
|
|
5
5
|
const styles_1 = require("@mui/material/styles");
|
|
6
6
|
const AppContainer_1 = require("../AppContainer");
|
|
7
|
-
exports.Stack = (0, styles_1.styled)(material_1.Stack)(({ theme }) => ({
|
|
8
|
-
alignItems: 'stretch',
|
|
9
|
-
display: 'flex',
|
|
10
|
-
flex: 1,
|
|
11
|
-
flexWrap: 'nowrap',
|
|
12
|
-
overflow: 'hidden',
|
|
13
|
-
borderRight: `solid ${theme.palette.mode === 'light'
|
|
14
|
-
? theme.palette.grey[300]
|
|
15
|
-
: theme.palette.grey[800]}`,
|
|
16
|
-
width: 'calc(100% - 48px)',
|
|
17
|
-
}));
|
|
18
7
|
exports.CollapseContainer = (0, styles_1.styled)(material_1.Box)(({ theme }) => ({
|
|
19
8
|
height: AppContainer_1.maxHeight,
|
|
20
9
|
}));
|
|
@@ -25,7 +14,7 @@ exports.ScrollableContainer = (0, styles_1.styled)(material_1.Box)({
|
|
|
25
14
|
display: 'flex',
|
|
26
15
|
flexDirection: 'column',
|
|
27
16
|
});
|
|
28
|
-
exports.Container = (0, styles_1.styled)(material_1.
|
|
17
|
+
exports.Container = (0, styles_1.styled)(material_1.ScopedCssBaseline)(({ theme }) => ({
|
|
29
18
|
backgroundColor: theme.palette.background.default,
|
|
30
19
|
overflow: 'auto',
|
|
31
20
|
width: 436,
|
|
@@ -45,3 +34,14 @@ exports.Header = (0, styles_1.styled)(material_1.Box)(({ theme }) => ({
|
|
|
45
34
|
top: 0,
|
|
46
35
|
zIndex: 1200,
|
|
47
36
|
}));
|
|
37
|
+
exports.Stack = (0, styles_1.styled)(material_1.Stack)(({ theme }) => ({
|
|
38
|
+
alignItems: 'stretch',
|
|
39
|
+
display: 'flex',
|
|
40
|
+
flex: 1,
|
|
41
|
+
flexWrap: 'nowrap',
|
|
42
|
+
overflow: 'hidden',
|
|
43
|
+
borderRight: `solid ${theme.palette.mode === 'light'
|
|
44
|
+
? theme.palette.grey[300]
|
|
45
|
+
: theme.palette.grey[800]}`,
|
|
46
|
+
width: 'calc(100% - 48px)',
|
|
47
|
+
}));
|
|
@@ -13,13 +13,16 @@ const utils_1 = require("../../utils");
|
|
|
13
13
|
const ProgressToNextUpdate_1 = require("../ProgressToNextUpdate");
|
|
14
14
|
const SwapRouteCard_1 = require("../SwapRouteCard");
|
|
15
15
|
const SwapRoutes_style_1 = require("./SwapRoutes.style");
|
|
16
|
+
const useSetSelectedRoute_1 = require("./useSetSelectedRoute");
|
|
16
17
|
const SwapRoutesExpanded = () => {
|
|
17
18
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
18
|
-
const { containerStyle } = (0, providers_1.useWidgetConfig)();
|
|
19
19
|
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
20
|
-
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = (0, hooks_1.useSwapRoutes)();
|
|
21
|
-
const { isValid, isValidating } = (0, react_hook_form_1.useFormState)();
|
|
22
20
|
const setExecutableRoute = (0, stores_1.useSetExecutableRoute)();
|
|
21
|
+
const { containerStyle } = (0, providers_1.useWidgetConfig)();
|
|
22
|
+
const { isValid, isValidating } = (0, react_hook_form_1.useFormState)();
|
|
23
|
+
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = (0, hooks_1.useSwapRoutes)();
|
|
24
|
+
const currentRoute = routes === null || routes === void 0 ? void 0 : routes[0];
|
|
25
|
+
(0, useSetSelectedRoute_1.useSetSelectedRoute)(currentRoute, isFetching);
|
|
23
26
|
const { pathname } = (0, react_router_dom_1.useLocation)();
|
|
24
27
|
const cleanedPathname = pathname.endsWith('/')
|
|
25
28
|
? pathname.slice(0, -1)
|
|
@@ -34,9 +37,8 @@ const SwapRoutesExpanded = () => {
|
|
|
34
37
|
});
|
|
35
38
|
}
|
|
36
39
|
};
|
|
37
|
-
const currentRoute = routes === null || routes === void 0 ? void 0 : routes[0];
|
|
38
40
|
const expanded = Boolean(currentRoute || isLoading || isFetching || isFetched) && !hasPath;
|
|
39
41
|
const routeNotFound = !currentRoute && !isLoading && !isFetching && expanded;
|
|
40
|
-
return ((0, jsx_runtime_1.jsx)(SwapRoutes_style_1.CollapseContainer, { children: (0, jsx_runtime_1.jsx)(material_1.Collapse, Object.assign({ appear: true, timeout: 225, in: expanded, orientation: "horizontal" }, { children: (0, jsx_runtime_1.jsx)(material_1.Grow, Object.assign({ appear: true, timeout: 225, in: expanded }, { children: (0, jsx_runtime_1.jsx)(SwapRoutes_style_1.Container, Object.assign({ sx: containerStyle }, { children: (0, jsx_runtime_1.jsxs)(SwapRoutes_style_1.ScrollableContainer, { children: [(0, jsx_runtime_1.jsxs)(SwapRoutes_style_1.Header, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 18, fontWeight: "700", flex: 1, noWrap: true }, { children: t('swap.routes') })), (0, jsx_runtime_1.jsx)(ProgressToNextUpdate_1.ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 } })] }), (0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ direction: "column", spacing: 2, flex: 1, paddingX: 3, paddingBottom: 3 }, { children: routeNotFound ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteNotFoundCard, {})) : isLoading || isFetching ? (Array.from({ length: 3 }).map((_, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, { variant: "stretched" }, index)))) : (routes === null || routes === void 0 ? void 0 : routes.map((route, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, variant: "stretched", expanded: (routes === null || routes === void 0 ? void 0 : routes.length) <= 2 }, route.id)))) }))] }) })) })) })) }));
|
|
42
|
+
return ((0, jsx_runtime_1.jsx)(SwapRoutes_style_1.CollapseContainer, { children: (0, jsx_runtime_1.jsx)(material_1.Collapse, Object.assign({ appear: true, timeout: 225, in: expanded, orientation: "horizontal" }, { children: (0, jsx_runtime_1.jsx)(material_1.Grow, Object.assign({ appear: true, timeout: 225, in: expanded }, { children: (0, jsx_runtime_1.jsx)(SwapRoutes_style_1.Container, Object.assign({ sx: containerStyle, enableColorScheme: true }, { children: (0, jsx_runtime_1.jsxs)(SwapRoutes_style_1.ScrollableContainer, { children: [(0, jsx_runtime_1.jsxs)(SwapRoutes_style_1.Header, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 18, fontWeight: "700", flex: 1, noWrap: true }, { children: t('swap.routes') })), (0, jsx_runtime_1.jsx)(ProgressToNextUpdate_1.ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 } })] }), (0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ direction: "column", spacing: 2, flex: 1, paddingX: 3, paddingBottom: 3 }, { children: routeNotFound ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteNotFoundCard, {})) : isLoading || isFetching ? (Array.from({ length: 3 }).map((_, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, { variant: "stretched" }, index)))) : (routes === null || routes === void 0 ? void 0 : routes.map((route, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, variant: "stretched", expanded: (routes === null || routes === void 0 ? void 0 : routes.length) <= 2 }, route.id)))) }))] }) })) })) })) }));
|
|
41
43
|
};
|
|
42
44
|
exports.SwapRoutesExpanded = SwapRoutesExpanded;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSetSelectedRoute = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const stores_1 = require("../../stores");
|
|
6
|
+
const useSetSelectedRoute = (currentRoute, isFetching) => {
|
|
7
|
+
const setSelectedRoute = (0, stores_1.useSelectedRouteStore)((state) => state.setSelectedRoute);
|
|
8
|
+
(0, react_1.useEffect)(() => {
|
|
9
|
+
setSelectedRoute(!isFetching ? currentRoute : undefined);
|
|
10
|
+
return () => setSelectedRoute(undefined);
|
|
11
|
+
}, [currentRoute, isFetching, setSelectedRoute]);
|
|
12
|
+
};
|
|
13
|
+
exports.useSetSelectedRoute = useSetSelectedRoute;
|
|
@@ -28,12 +28,12 @@ const Token = (_a) => {
|
|
|
28
28
|
const { getChainById } = (0, hooks_1.useChains)();
|
|
29
29
|
return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ flex: 1 }, other, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", flex: 1, alignItems: "center" }, { children: [(0, jsx_runtime_1.jsx)(TokenAvatar_1.TokenAvatar, { token: token, sx: { marginRight: 2 } }), (0, jsx_runtime_1.jsx)(TextFitter_1.TextFitter, Object.assign({ height: 30, textStyle: {
|
|
30
30
|
fontWeight: 700,
|
|
31
|
-
} }, { children: (0, utils_1.formatTokenAmount)(token.amount, token.decimals) }))] })), (0, jsx_runtime_1.jsxs)(
|
|
31
|
+
} }, { children: (0, utils_1.formatTokenAmount)(token.amount, token.decimals) }))] })), (0, jsx_runtime_1.jsxs)(Token_style_1.TextSecondaryContainer, Object.assign({ connected: connected, component: "span" }, { children: [(0, jsx_runtime_1.jsx)(Token_style_1.TextSecondary, Object.assign({ connected: connected }, { children: t(`swap.tokenOnChain`, {
|
|
32
32
|
tokenSymbol: token.symbol,
|
|
33
33
|
chainName: (_b = getChainById(token.chainId)) === null || _b === void 0 ? void 0 : _b.name,
|
|
34
|
-
}) })), step ? ((0, jsx_runtime_1.jsxs)(material_1.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
}) })), step ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 12, lineHeight: 1, fontWeight: 500, color: "text.secondary", px: 1, mt: 0.5 }, { children: "\u2022" })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", alignItems: "flex-end", height: 12, mt: 0.5 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ pr: 0.75 }, { children: (0, jsx_runtime_1.jsx)(SmallAvatar_1.SmallAvatar, Object.assign({ src: step.toolDetails.logoURI, alt: step.toolDetails.name, sx: {
|
|
35
|
+
border: 0,
|
|
36
|
+
marginBottom: -0.25,
|
|
37
|
+
} }, { children: step.toolDetails.name[0] })) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 12, lineHeight: 1, fontWeight: 500, color: "text.secondary" }, { children: step.toolDetails.name }))] }))] })) : null] }))] })));
|
|
38
38
|
};
|
|
39
39
|
exports.Token = Token;
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
export declare const TextSecondaryContainer: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
3
|
+
children?: import("react").ReactNode;
|
|
4
|
+
component?: import("react").ElementType<any> | undefined;
|
|
5
|
+
ref?: import("react").Ref<unknown> | undefined;
|
|
6
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
7
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
8
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
9
|
+
}, 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<import("@mui/material").Theme> & {
|
|
10
|
+
connected?: boolean | undefined;
|
|
11
|
+
}, {}, {}>;
|
|
2
12
|
export declare const TextSecondary: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
3
13
|
align?: "inherit" | "left" | "right" | "center" | "justify" | undefined;
|
|
4
14
|
children?: import("react").ReactNode;
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TokenDivider = exports.TextSecondary = void 0;
|
|
3
|
+
exports.TokenDivider = exports.TextSecondary = exports.TextSecondaryContainer = void 0;
|
|
4
4
|
const material_1 = require("@mui/material");
|
|
5
5
|
const styles_1 = require("@mui/material/styles");
|
|
6
|
-
exports.
|
|
6
|
+
exports.TextSecondaryContainer = (0, styles_1.styled)(material_1.Box, {
|
|
7
7
|
shouldForwardProp: (prop) => prop !== 'connected',
|
|
8
8
|
})(({ theme, connected }) => ({
|
|
9
|
-
fontSize: 12,
|
|
10
|
-
lineHeight: 1,
|
|
11
|
-
fontWeight: 500,
|
|
12
|
-
color: theme.palette.text.secondary,
|
|
13
9
|
borderLeftWidth: connected ? 2 : 0,
|
|
14
10
|
borderLeftStyle: 'solid',
|
|
15
11
|
borderColor: theme.palette.mode === 'light'
|
|
@@ -17,12 +13,22 @@ exports.TextSecondary = (0, styles_1.styled)(material_1.Typography, {
|
|
|
17
13
|
: theme.palette.grey[800],
|
|
18
14
|
margin: connected
|
|
19
15
|
? theme.spacing(0.5, 0, 0, 1.875)
|
|
20
|
-
: theme.spacing(0
|
|
16
|
+
: theme.spacing(0, 0, 0, 6),
|
|
21
17
|
padding: connected
|
|
22
18
|
? theme.spacing(0, 0, 0, 3.875)
|
|
23
19
|
: theme.spacing(0, 0, 0, 0),
|
|
24
20
|
display: 'flex',
|
|
25
21
|
alignItems: 'flex-start',
|
|
22
|
+
flexWrap: 'wrap',
|
|
23
|
+
}));
|
|
24
|
+
exports.TextSecondary = (0, styles_1.styled)(material_1.Typography, {
|
|
25
|
+
shouldForwardProp: (prop) => prop !== 'connected',
|
|
26
|
+
})(({ theme, connected }) => ({
|
|
27
|
+
fontSize: 12,
|
|
28
|
+
lineHeight: 1,
|
|
29
|
+
fontWeight: 500,
|
|
30
|
+
color: theme.palette.text.secondary,
|
|
31
|
+
marginTop: connected ? 0 : theme.spacing(0.5),
|
|
26
32
|
}));
|
|
27
33
|
exports.TokenDivider = (0, styles_1.styled)(material_1.Box)(({ theme }) => ({
|
|
28
34
|
height: 12,
|
|
@@ -17,7 +17,7 @@ const TokenList = ({ formType, height, onClick, }) => {
|
|
|
17
17
|
const [selectedChainId] = (0, react_hook_form_1.useWatch)({
|
|
18
18
|
name: [providers_1.SwapFormKeyHelper.getChainKey(formType)],
|
|
19
19
|
});
|
|
20
|
-
const [tokenSearchFilter] = (0, hooks_1.useDebouncedWatch)([providers_1.SwapFormKey.TokenSearchFilter],
|
|
20
|
+
const [tokenSearchFilter] = (0, hooks_1.useDebouncedWatch)([providers_1.SwapFormKey.TokenSearchFilter], 320);
|
|
21
21
|
const { tokens: chainTokens, tokensWithBalance, isLoading: isTokensLoading, isBalanceLoading, featuredTokens, } = (0, hooks_1.useTokenBalances)(selectedChainId);
|
|
22
22
|
let filteredTokens = ((_a = tokensWithBalance !== null && tokensWithBalance !== void 0 ? tokensWithBalance : chainTokens) !== null && _a !== void 0 ? _a : []);
|
|
23
23
|
const searchFilter = (_b = tokenSearchFilter === null || tokenSearchFilter === void 0 ? void 0 : tokenSearchFilter.toUpperCase()) !== null && _b !== void 0 ? _b : '';
|
|
@@ -27,10 +27,10 @@ const TokenList = ({ formType, height, onClick, }) => {
|
|
|
27
27
|
token.address.toUpperCase().includes(searchFilter))
|
|
28
28
|
: filteredTokens;
|
|
29
29
|
const tokenSearchEnabled = !isTokensLoading &&
|
|
30
|
-
|
|
30
|
+
!filteredTokens.length &&
|
|
31
31
|
!!tokenSearchFilter &&
|
|
32
32
|
!!selectedChainId;
|
|
33
|
-
const { token: searchedToken, isLoading: isSearchedTokenLoading } = (0, hooks_1.useTokenSearch)(
|
|
33
|
+
const { token: searchedToken, isLoading: isSearchedTokenLoading } = (0, hooks_1.useTokenSearch)(selectedChainId, tokenSearchFilter, tokenSearchEnabled);
|
|
34
34
|
const isLoading = isTokensLoading || (tokenSearchEnabled && isSearchedTokenLoading);
|
|
35
35
|
const tokens = filteredTokens.length
|
|
36
36
|
? filteredTokens
|
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.18.
|
|
2
|
+
export declare const version = "1.18.9";
|
package/cjs/config/version.js
CHANGED
|
@@ -15,10 +15,7 @@ const useDebouncedWatch = (name, delay) => {
|
|
|
15
15
|
const hasWatchedValue = Array.isArray(watchedValue)
|
|
16
16
|
? watchedValue.some((value) => value)
|
|
17
17
|
: Boolean(watchedValue);
|
|
18
|
-
|
|
19
|
-
? debouncedValueRef.current.some((value) => value)
|
|
20
|
-
: Boolean(debouncedValueRef.current);
|
|
21
|
-
if (hasWatchedValue && hasDebouncedValue) {
|
|
18
|
+
if (hasWatchedValue) {
|
|
22
19
|
const handler = setTimeout(() => {
|
|
23
20
|
setDebouncedValue(watchedValue);
|
|
24
21
|
}, delay);
|
|
@@ -38,7 +38,7 @@ const useSwapRoutes = () => {
|
|
|
38
38
|
providers_1.SwapFormKey.ToAddress,
|
|
39
39
|
],
|
|
40
40
|
});
|
|
41
|
-
const [fromTokenAmount] = (0, _1.useDebouncedWatch)([providers_1.SwapFormKey.FromAmount],
|
|
41
|
+
const [fromTokenAmount] = (0, _1.useDebouncedWatch)([providers_1.SwapFormKey.FromAmount], 320);
|
|
42
42
|
const { token } = (0, _1.useToken)(fromChainId, fromTokenAddress);
|
|
43
43
|
const isEnabled =
|
|
44
44
|
// Boolean(account.address) &&
|
package/cjs/hooks/useToken.js
CHANGED
|
@@ -3,15 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useToken = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const useTokens_1 = require("./useTokens");
|
|
6
|
+
const useTokenSearch_1 = require("./useTokenSearch");
|
|
6
7
|
const useToken = (chainId, tokenAddress) => {
|
|
7
8
|
const { tokens, isLoading } = (0, useTokens_1.useTokens)(chainId);
|
|
8
9
|
const token = (0, react_1.useMemo)(() => {
|
|
9
10
|
const token = tokens === null || tokens === void 0 ? void 0 : tokens.find((token) => token.address === tokenAddress && token.chainId === chainId);
|
|
10
11
|
return token;
|
|
11
12
|
}, [chainId, tokenAddress, tokens]);
|
|
13
|
+
const tokenSearchEnabled = !isLoading && !token;
|
|
14
|
+
const { token: searchedToken, isLoading: isSearchedTokenLoading } = (0, useTokenSearch_1.useTokenSearch)(chainId, tokenAddress, tokenSearchEnabled);
|
|
12
15
|
return {
|
|
13
|
-
token,
|
|
14
|
-
isLoading,
|
|
16
|
+
token: token !== null && token !== void 0 ? token : searchedToken,
|
|
17
|
+
isLoading: isLoading || (tokenSearchEnabled && isSearchedTokenLoading),
|
|
15
18
|
};
|
|
16
19
|
};
|
|
17
20
|
exports.useToken = useToken;
|
|
@@ -21,18 +21,23 @@ const useTokenBalance = (token, accountAddress) => {
|
|
|
21
21
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
22
22
|
const walletAddress = accountAddress !== null && accountAddress !== void 0 ? accountAddress : account.address;
|
|
23
23
|
const getTokenBalancesWithRetry = (0, react_1.useCallback)((accountAddress, tokens, depth = 0) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
try {
|
|
25
|
+
const tokenBalances = yield lifi.getTokenBalances(accountAddress, tokens);
|
|
26
|
+
if (!tokenBalances.every((token) => token.blockNumber)) {
|
|
27
|
+
if (depth > 5) {
|
|
28
|
+
console.warn('Token balance backoff depth exceeded.');
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
yield new Promise((resolve) => {
|
|
32
|
+
setTimeout(resolve, depth * 100);
|
|
33
|
+
});
|
|
34
|
+
return getTokenBalancesWithRetry(accountAddress, tokens, depth + 1);
|
|
29
35
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
return tokenBalances;
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
//
|
|
34
40
|
}
|
|
35
|
-
return tokenBalances;
|
|
36
41
|
}), [lifi]);
|
|
37
42
|
const tokenBalanceQueryKey = (0, react_1.useMemo)(() => ['token-balance', walletAddress, token === null || token === void 0 ? void 0 : token.chainId, token === null || token === void 0 ? void 0 : token.address], [token === null || token === void 0 ? void 0 : token.address, token === null || token === void 0 ? void 0 : token.chainId, walletAddress]);
|
|
38
43
|
const { data, isLoading, refetch } = (0, react_query_1.useQuery)(tokenBalanceQueryKey, ({ queryKey: [, accountAddress] }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { Token } from '../types';
|
|
2
|
-
export declare const useTokenSearch: (
|
|
2
|
+
export declare const useTokenSearch: (chainId: number, token: string, enabled?: boolean) => {
|
|
3
3
|
token: Token | undefined;
|
|
4
4
|
isLoading: boolean;
|
|
5
|
-
isFetching: boolean;
|
|
6
|
-
isFetched: boolean;
|
|
7
5
|
};
|
|
@@ -12,10 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.useTokenSearch = void 0;
|
|
13
13
|
const react_query_1 = require("@tanstack/react-query");
|
|
14
14
|
const providers_1 = require("../providers");
|
|
15
|
-
const useTokenSearch = (
|
|
15
|
+
const useTokenSearch = (chainId, token, enabled) => {
|
|
16
16
|
const lifi = (0, providers_1.useLiFi)();
|
|
17
17
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
18
|
-
const { data, isLoading
|
|
18
|
+
const { data, isLoading } = (0, react_query_1.useQuery)(['token-search', chainId, token], ({ queryKey: [, chainId, token], signal }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
19
|
const data = yield lifi.getToken(chainId, token, {
|
|
20
20
|
signal,
|
|
21
21
|
});
|
|
@@ -29,14 +29,12 @@ const useTokenSearch = (token, chainId, enabled) => {
|
|
|
29
29
|
}
|
|
30
30
|
return data;
|
|
31
31
|
}), {
|
|
32
|
-
enabled,
|
|
32
|
+
enabled: Boolean(chainId && token && enabled),
|
|
33
33
|
retry: false,
|
|
34
34
|
});
|
|
35
35
|
return {
|
|
36
36
|
token: data,
|
|
37
37
|
isLoading,
|
|
38
|
-
isFetching,
|
|
39
|
-
isFetched,
|
|
40
38
|
};
|
|
41
39
|
};
|
|
42
40
|
exports.useTokenSearch = useTokenSearch;
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"stepSwap": "Swap",
|
|
59
59
|
"stepBridge": "Bridge",
|
|
60
60
|
"stepSwapAndBridge": "Swap and bridge",
|
|
61
|
-
"estimatedTime": "
|
|
61
|
+
"estimatedTime": "{{value}}m",
|
|
62
62
|
"crossStepDetails": "Bridge from {{from}} to {{to}} via {{tool}}",
|
|
63
63
|
"swapStepDetails": "Swap on {{chain}} via {{tool}}",
|
|
64
64
|
"tokenOnChain": "{{tokenSymbol}} on {{chainName}}",
|
|
@@ -9,9 +9,11 @@ const SelectChainAndToken_1 = require("../../components/SelectChainAndToken");
|
|
|
9
9
|
const SendToWallet_1 = require("../../components/SendToWallet");
|
|
10
10
|
const SwapInput_1 = require("../../components/SwapInput");
|
|
11
11
|
const SwapRoutes_1 = require("../../components/SwapRoutes");
|
|
12
|
+
const providers_1 = require("../../providers");
|
|
12
13
|
const MainPage_style_1 = require("./MainPage.style");
|
|
13
14
|
const MainSwapButton_1 = require("./MainSwapButton");
|
|
14
15
|
const MainPage = () => {
|
|
15
|
-
|
|
16
|
+
const { variant } = (0, providers_1.useWidgetConfig)();
|
|
17
|
+
return ((0, jsx_runtime_1.jsxs)(MainPage_style_1.FormContainer, Object.assign({ disableGutters: true }, { children: [(0, jsx_runtime_1.jsx)(ActiveSwaps_1.ActiveSwaps, { mx: 3, mt: 1, mb: 2 }), (0, jsx_runtime_1.jsx)(SelectChainAndToken_1.SelectChainAndToken, { mt: 1, mx: 3, mb: 3 }), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mx: 3, mb: 3 }, { children: (0, jsx_runtime_1.jsx)(SwapInput_1.SwapInput, { formType: "from" }) })), variant !== 'expandable' ? (0, jsx_runtime_1.jsx)(SwapRoutes_1.SwapRoutes, { mx: 3, mb: 3 }) : null, (0, jsx_runtime_1.jsx)(GasSufficiencyMessage_1.GasSufficiencyMessage, { mx: 3, mb: 3 }), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ mx: 3, mb: 1 }, { children: [(0, jsx_runtime_1.jsx)(SendToWallet_1.SendToWallet, { mb: 3 }), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: { display: 'flex' } }, { children: [(0, jsx_runtime_1.jsx)(MainSwapButton_1.MainSwapButton, {}), (0, jsx_runtime_1.jsx)(SendToWallet_1.SendToWalletButton, {})] }))] }))] })));
|
|
16
18
|
};
|
|
17
19
|
exports.MainPage = MainPage;
|
|
@@ -23,7 +23,7 @@ exports.useSettingsStore = (0, zustand_1.default)()((0, middleware_1.persist)((0
|
|
|
23
23
|
appearance: 'auto',
|
|
24
24
|
gasPrice: 'normal',
|
|
25
25
|
routePriority: 'RECOMMENDED',
|
|
26
|
-
slippage: '
|
|
26
|
+
slippage: '0.5',
|
|
27
27
|
setValue: (key, value) => set((state) => {
|
|
28
28
|
state[key] = value;
|
|
29
29
|
}),
|
|
@@ -68,7 +68,7 @@ exports.useSettingsStore = (0, zustand_1.default)()((0, middleware_1.persist)((0
|
|
|
68
68
|
}),
|
|
69
69
|
})), {
|
|
70
70
|
name: 'li.fi-widget-settings',
|
|
71
|
-
version:
|
|
71
|
+
version: 2,
|
|
72
72
|
partialize: (state) => {
|
|
73
73
|
const { enabledBridges, enabledExchanges } = state, partializedState = __rest(state, ["enabledBridges", "enabledExchanges"]);
|
|
74
74
|
return partializedState;
|
|
@@ -86,6 +86,9 @@ exports.useSettingsStore = (0, zustand_1.default)()((0, middleware_1.persist)((0
|
|
|
86
86
|
if (version === 0 && persistedState.appearance === 'system') {
|
|
87
87
|
persistedState.appearance = 'auto';
|
|
88
88
|
}
|
|
89
|
+
if (version === 1) {
|
|
90
|
+
persistedState.slippage = '0.5';
|
|
91
|
+
}
|
|
89
92
|
return persistedState;
|
|
90
93
|
},
|
|
91
94
|
}));
|
|
@@ -36,7 +36,10 @@ export const SwapRouteCard = (_a) => {
|
|
|
36
36
|
export const SwapRouteCardEssentials = ({ route, dense }) => {
|
|
37
37
|
var _a;
|
|
38
38
|
const { t } = useTranslation();
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const executionTime = (route.steps
|
|
40
|
+
.map((step) => step.estimate.executionDuration)
|
|
41
|
+
.reduce((duration, x) => duration + x) / 60).toFixed(0) || 1;
|
|
42
|
+
return (_jsxs(Box, Object.assign({ display: "flex", justifyContent: dense ? 'space-between' : 'flex-end', flex: 1, pl: dense ? 0 : 2, mt: dense ? 2 : 0 }, { children: [_jsxs(Box, Object.assign({ display: "flex", alignItems: "center", pr: dense ? 0 : 2 }, { children: [_jsx(Typography, Object.assign({ lineHeight: 0, mr: 0.5, color: "grey.500" }, { children: _jsx(EvStationIcon, { fontSize: dense ? 'medium' : 'small' }) })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1 }, { children: t(`swap.currency`, { value: (_a = route.gasCostUSD) !== null && _a !== void 0 ? _a : 0.01 }) }))] })), _jsxs(Box, Object.assign({ display: "flex", alignItems: "center", pr: dense ? 0 : 2 }, { children: [_jsx(Typography, Object.assign({ lineHeight: 0, mr: 0.5, color: "grey.500" }, { children: _jsx(AccessTimeIcon, { fontSize: dense ? 'medium' : 'small' }) })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1 }, { children: t('swap.estimatedTime', {
|
|
43
|
+
value: executionTime,
|
|
44
|
+
}) }))] })), !dense ? (_jsxs(Box, Object.assign({ display: "flex", alignItems: "center" }, { children: [_jsx(Typography, Object.assign({ lineHeight: 0, mr: 0.5, color: "grey.500" }, { children: _jsx(LayersIcon, { fontSize: dense ? 'medium' : 'small' }) })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1 }, { children: route.steps.length }))] }))) : null] })));
|
|
42
45
|
};
|