@lifi/widget 1.20.1 → 1.20.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/components/ActiveSwaps/ActiveSwaps.js +1 -3
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.js +2 -0
- package/cjs/components/Card/Card.d.ts +10 -1
- package/cjs/components/Card/Card.js +9 -2
- package/cjs/components/ChainSelect/ChainSelect.style.d.ts +1 -0
- package/cjs/components/SwapRouteCard/SwapRouteCard.d.ts +2 -2
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +6 -1
- package/cjs/components/SwapRouteCard/utils.d.ts +7 -0
- package/cjs/components/SwapRouteCard/utils.js +30 -0
- package/cjs/components/SwapRoutes/SwapRoutes.js +1 -1
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/useGasSufficiency.d.ts +1 -2
- package/cjs/hooks/useTokens.js +6 -1
- package/cjs/i18n/en/translation.json +3 -2
- package/cjs/i18n/index.d.ts +1 -0
- package/cjs/stores/settings/useSettingsStore.d.ts +1 -0
- package/cjs/stores/settings/useSettingsStore.js +10 -13
- package/components/ActiveSwaps/ActiveSwaps.js +1 -3
- package/components/ActiveSwaps/ActiveSwaps.style.js +2 -0
- package/components/Card/Card.d.ts +10 -1
- package/components/Card/Card.js +9 -2
- package/components/ChainSelect/ChainSelect.style.d.ts +1 -0
- package/components/SwapRouteCard/SwapRouteCard.d.ts +2 -2
- package/components/SwapRouteCard/SwapRouteCard.js +6 -1
- package/components/SwapRouteCard/utils.d.ts +7 -0
- package/components/SwapRouteCard/utils.js +26 -0
- package/components/SwapRoutes/SwapRoutes.js +1 -1
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/useGasSufficiency.d.ts +1 -2
- package/hooks/useTokens.js +6 -1
- package/i18n/en/translation.json +3 -2
- package/i18n/index.d.ts +1 -0
- package/package.json +4 -4
- package/stores/settings/useSettingsStore.d.ts +1 -0
- package/stores/settings/useSettingsStore.js +9 -12
- package/tsconfig.cjs.tsbuildinfo +1 -1
|
@@ -23,8 +23,6 @@ const ActiveSwaps = (props) => {
|
|
|
23
23
|
navigate(utils_1.navigationRoutes.activeSwaps);
|
|
24
24
|
};
|
|
25
25
|
const hasShowAll = (executingRoutes === null || executingRoutes === void 0 ? void 0 : executingRoutes.length) > 2;
|
|
26
|
-
return ((0, jsx_runtime_1.jsxs)(Card_1.Card, Object.assign({ variant: "selected", selectionColor: "secondary" }, props, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t('header.activeSwaps') }), (0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ spacing: 1.5, pt: 1.5, pb: hasShowAll ? 0 : 2 }, { children: executingRoutes.slice(0, 2).map((routeId) => ((0, jsx_runtime_1.jsx)(ActiveSwapItem_1.ActiveSwapItem, { routeId: routeId, dense: true }, routeId))) })), hasShowAll ? ((0, jsx_runtime_1.jsx)(ActiveSwaps_style_1.ShowAllButton, Object.assign({ disableRipple: true, fullWidth: true, onClick: handleShowAll,
|
|
27
|
-
padding: theme.spacing(0.75, 2),
|
|
28
|
-
}) }, { children: t('button.showAll') }))) : null] })));
|
|
26
|
+
return ((0, jsx_runtime_1.jsxs)(Card_1.Card, Object.assign({ variant: "selected", selectionColor: "secondary" }, props, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t('header.activeSwaps') }), (0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ spacing: 1.5, pt: 1.5, pb: hasShowAll ? 0 : 2 }, { children: executingRoutes.slice(0, 2).map((routeId) => ((0, jsx_runtime_1.jsx)(ActiveSwapItem_1.ActiveSwapItem, { routeId: routeId, dense: true }, routeId))) })), hasShowAll ? ((0, jsx_runtime_1.jsx)(ActiveSwaps_style_1.ShowAllButton, Object.assign({ disableRipple: true, fullWidth: true, onClick: handleShowAll }, { children: t('button.showAll') }))) : null] })));
|
|
29
27
|
};
|
|
30
28
|
exports.ActiveSwaps = ActiveSwaps;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import type { Theme } from '@mui/material';
|
|
1
|
+
import type { BoxProps, Theme } from '@mui/material';
|
|
2
2
|
import type { MouseEventHandler } from 'react';
|
|
3
3
|
declare type CardVariant = 'default' | 'selected' | 'error';
|
|
4
|
+
export declare type CardProps = {
|
|
5
|
+
variant?: CardVariant;
|
|
6
|
+
selectionColor?: 'primary' | 'secondary';
|
|
7
|
+
dense?: boolean;
|
|
8
|
+
indented?: boolean;
|
|
9
|
+
onClick?: MouseEventHandler<HTMLDivElement>;
|
|
10
|
+
pointerEvents?: 'auto' | 'none';
|
|
11
|
+
} & BoxProps;
|
|
4
12
|
export declare const Card: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<Theme> & {
|
|
5
13
|
children?: import("react").ReactNode;
|
|
6
14
|
component?: import("react").ElementType<any> | undefined;
|
|
@@ -14,5 +22,6 @@ export declare const Card: import("@emotion/styled").StyledComponent<import("@mu
|
|
|
14
22
|
dense?: boolean | undefined;
|
|
15
23
|
indented?: boolean | undefined;
|
|
16
24
|
onClick?: MouseEventHandler<HTMLDivElement> | undefined;
|
|
25
|
+
pointerEvents?: "none" | "auto" | undefined;
|
|
17
26
|
}, {}, {}>;
|
|
18
27
|
export {};
|
|
@@ -11,8 +11,14 @@ const getBackgroundColor = (theme, variant, selectionColor) => variant === 'sele
|
|
|
11
11
|
: (0, styles_1.alpha)(theme.palette.secondary.main, theme.palette.mode === 'light' ? 0.08 : 0.12)
|
|
12
12
|
: theme.palette.background.paper;
|
|
13
13
|
exports.Card = (0, styles_1.styled)(material_1.Box, {
|
|
14
|
-
shouldForwardProp: (prop) => ![
|
|
15
|
-
|
|
14
|
+
shouldForwardProp: (prop) => ![
|
|
15
|
+
'dense',
|
|
16
|
+
'variant',
|
|
17
|
+
'indented',
|
|
18
|
+
'selectionColor',
|
|
19
|
+
'pointerEvents',
|
|
20
|
+
].includes(prop),
|
|
21
|
+
})(({ theme, variant, selectionColor = 'primary', dense, indented, pointerEvents, onClick, }) => {
|
|
16
22
|
const backgroundColor = getBackgroundColor(theme, variant, selectionColor);
|
|
17
23
|
return {
|
|
18
24
|
backgroundColor,
|
|
@@ -45,5 +51,6 @@ exports.Card = (0, styles_1.styled)(material_1.Box, {
|
|
|
45
51
|
duration: theme.transitions.duration.enteringScreen,
|
|
46
52
|
easing: theme.transitions.easing.easeOut,
|
|
47
53
|
}),
|
|
54
|
+
pointerEvents,
|
|
48
55
|
};
|
|
49
56
|
});
|
|
@@ -12,6 +12,7 @@ export declare const ChainCard: import("@emotion/styled").StyledComponent<import
|
|
|
12
12
|
dense?: boolean | undefined;
|
|
13
13
|
indented?: boolean | undefined;
|
|
14
14
|
onClick?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
|
|
15
|
+
pointerEvents?: "none" | "auto" | undefined;
|
|
15
16
|
}, {}, {}>;
|
|
16
17
|
export declare const ChainContainer: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
17
18
|
children?: import("react").ReactNode;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
2
|
+
import type { CardProps } from '../Card';
|
|
3
3
|
import type { SwapRouteCardEssentialsProps, SwapRouteCardProps } from './types';
|
|
4
|
-
export declare const SwapRouteCard: React.FC<SwapRouteCardProps &
|
|
4
|
+
export declare const SwapRouteCard: React.FC<SwapRouteCardProps & Omit<CardProps, 'variant'>>;
|
|
5
5
|
export declare const SwapRouteCardEssentials: React.FC<SwapRouteCardEssentialsProps>;
|
|
@@ -21,6 +21,7 @@ const Card_1 = require("../Card");
|
|
|
21
21
|
const StepActions_1 = require("../StepActions");
|
|
22
22
|
const Token_1 = require("../Token");
|
|
23
23
|
const SwapRouteCard_style_1 = require("./SwapRouteCard.style");
|
|
24
|
+
const utils_1 = require("./utils");
|
|
24
25
|
const SwapRouteCard = (_a) => {
|
|
25
26
|
var _b;
|
|
26
27
|
var { route, active, variant = 'default', expanded } = _a, other = __rest(_a, ["route", "active", "variant", "expanded"]);
|
|
@@ -44,7 +45,11 @@ const SwapRouteCardEssentials = ({ route, dense }) => {
|
|
|
44
45
|
.map((step) => step.estimate.executionDuration)
|
|
45
46
|
.reduce((duration, x) => duration + x, 0) / 60);
|
|
46
47
|
const gasCostUSD = parseFloat((_a = route.gasCostUSD) !== null && _a !== void 0 ? _a : '') || 0.01;
|
|
47
|
-
|
|
48
|
+
const gasCosts = (0, utils_1.getGasCostsBreakdown)(route);
|
|
49
|
+
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: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ component: "span" }, { children: [t(`tooltip.estimatedNetworkFee`), gasCosts.map((gas) => {
|
|
50
|
+
var _a;
|
|
51
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ fontSize: 11 }, { children: [(_a = gas.amount) === null || _a === void 0 ? void 0 : _a.toFixed(6), " ", gas.token.symbol, " (", t(`swap.currency`, { value: gas.amountUSD }), ")"] }), `${gas.token.address}${gas.token.symbol}`));
|
|
52
|
+
})] })), 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
53
|
value: executionTimeMinutes,
|
|
49
54
|
}) }))] })) })), !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
55
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGasCostsBreakdown = void 0;
|
|
4
|
+
const big_js_1 = require("big.js");
|
|
5
|
+
const getGasCostsBreakdown = (route) => {
|
|
6
|
+
return Object.values(route.steps.reduce((groupedGasCosts, step) => {
|
|
7
|
+
if (step.estimate.gasCosts) {
|
|
8
|
+
const { token } = step.estimate.gasCosts[0];
|
|
9
|
+
const gasCostAmount = step.estimate.gasCosts
|
|
10
|
+
.reduce((amount, gasCost) => amount.plus((0, big_js_1.default)(gasCost.amount || 0)), (0, big_js_1.default)(0))
|
|
11
|
+
.div(Math.pow(10, token.decimals));
|
|
12
|
+
const gasCostAmountUSD = step.estimate.gasCosts.reduce((amount, gasCost) => amount + parseFloat(gasCost.amountUSD || '0'), 0);
|
|
13
|
+
const groupedGasCost = groupedGasCosts[token.chainId];
|
|
14
|
+
const amount = groupedGasCost
|
|
15
|
+
? groupedGasCost.amount.plus(gasCostAmount)
|
|
16
|
+
: gasCostAmount;
|
|
17
|
+
const amountUSD = groupedGasCost
|
|
18
|
+
? groupedGasCost.amountUSD + gasCostAmountUSD
|
|
19
|
+
: gasCostAmountUSD;
|
|
20
|
+
groupedGasCosts[token.chainId] = {
|
|
21
|
+
amount,
|
|
22
|
+
amountUSD,
|
|
23
|
+
token,
|
|
24
|
+
};
|
|
25
|
+
return groupedGasCosts;
|
|
26
|
+
}
|
|
27
|
+
return groupedGasCosts;
|
|
28
|
+
}, {}));
|
|
29
|
+
};
|
|
30
|
+
exports.getGasCostsBreakdown = getGasCostsBreakdown;
|
|
@@ -36,6 +36,6 @@ const SwapRoutes = (props) => {
|
|
|
36
36
|
borderRightWidth: !routeNotFound && (isFetching || (routes && routes.length > 1))
|
|
37
37
|
? 1
|
|
38
38
|
: 0,
|
|
39
|
-
} }, { children: isLoading || isFetching ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" }), (0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" })] })) : !currentRoute ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteNotFoundCard, {})) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { minWidth: routes.length > 1 ? '80%' : '100%', route: currentRoute, variant: "dense", active: true }), routes.length > 1 ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { minWidth: "80%", route: routes[1], variant: "dense" })) : null] })) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: !routeNotFound ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ py: 1, pr: 1 }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: handleCardClick, size: "medium", disabled: isValidating || !isValid }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.KeyboardArrowRight, {}) })) }))) : null }))] }))] })));
|
|
39
|
+
} }, { children: isLoading || isFetching ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" }), (0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" })] })) : !currentRoute ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteNotFoundCard, {})) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { minWidth: routes.length > 1 ? '80%' : '100%', route: currentRoute, variant: "dense", active: true }), routes.length > 1 ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { minWidth: "80%", route: routes[1], variant: "dense", pointerEvents: "none" })) : null] })) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: !routeNotFound ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ py: 1, pr: 1 }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: handleCardClick, size: "medium", disabled: isValidating || !isValid }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.KeyboardArrowRight, {}) })) }))) : null }))] }))] })));
|
|
40
40
|
};
|
|
41
41
|
exports.SwapRoutes = SwapRoutes;
|
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.20.
|
|
2
|
+
export declare const version = "1.20.2";
|
package/cjs/config/version.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EVMChain, Route, Token } from '@lifi/sdk';
|
|
2
2
|
import Big from 'big.js';
|
|
3
|
-
interface GasSufficiency {
|
|
3
|
+
export interface GasSufficiency {
|
|
4
4
|
gasAmount: Big;
|
|
5
5
|
tokenAmount?: Big;
|
|
6
6
|
insufficientAmount?: Big;
|
|
@@ -13,4 +13,3 @@ export declare const useGasSufficiency: (route?: Route) => {
|
|
|
13
13
|
insufficientFunds: boolean | null | undefined;
|
|
14
14
|
isLoading: boolean;
|
|
15
15
|
};
|
|
16
|
-
export {};
|
package/cjs/hooks/useTokens.js
CHANGED
|
@@ -12,10 +12,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.useTokens = void 0;
|
|
13
13
|
const react_query_1 = require("@tanstack/react-query");
|
|
14
14
|
const providers_1 = require("../providers");
|
|
15
|
+
const useChains_1 = require("./useChains");
|
|
15
16
|
const useFeaturedTokens_1 = require("./useFeaturedTokens");
|
|
16
17
|
const useTokens = (selectedChainId) => {
|
|
17
18
|
var _a, _b, _c, _d;
|
|
18
19
|
const lifi = (0, providers_1.useLiFi)();
|
|
20
|
+
const { getChainById, isLoading: isSupportedChainsLoading } = (0, useChains_1.useChains)();
|
|
19
21
|
const featuredTokens = (0, useFeaturedTokens_1.useFeaturedTokens)(selectedChainId);
|
|
20
22
|
const { tokens, chains, disabledChains } = (0, providers_1.useWidgetConfig)();
|
|
21
23
|
const { data, isLoading } = (0, react_query_1.useQuery)([
|
|
@@ -29,6 +31,7 @@ const useTokens = (selectedChainId) => {
|
|
|
29
31
|
], () => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
32
|
var _e, _f, _g, _h, _j;
|
|
31
33
|
const chainAllowed = selectedChainId &&
|
|
34
|
+
getChainById(selectedChainId) &&
|
|
32
35
|
(0, providers_1.isItemAllowed)(selectedChainId, chains, disabledChains);
|
|
33
36
|
if (!chainAllowed) {
|
|
34
37
|
return [];
|
|
@@ -50,7 +53,9 @@ const useTokens = (selectedChainId) => {
|
|
|
50
53
|
})) !== null && _h !== void 0 ? _h : []),
|
|
51
54
|
...((_j = filteredTokens === null || filteredTokens === void 0 ? void 0 : filteredTokens.filter((token) => !featuredTokenAddresses.has(token.address))) !== null && _j !== void 0 ? _j : []),
|
|
52
55
|
];
|
|
53
|
-
})
|
|
56
|
+
}), {
|
|
57
|
+
enabled: !isSupportedChainsLoading,
|
|
58
|
+
});
|
|
54
59
|
return {
|
|
55
60
|
tokens: data,
|
|
56
61
|
isLoading,
|
|
@@ -186,7 +186,8 @@
|
|
|
186
186
|
},
|
|
187
187
|
"progressToNextUpdate": "Displayed data will auto-refresh after {{value}} seconds. Click here to update manually.",
|
|
188
188
|
"numberOfSteps": "A number of swap steps. Each step can contain 1-3 transactions that require a signature.",
|
|
189
|
-
"estimatedTime": "Estimated time in minutes.",
|
|
190
|
-
"estimatedNetworkFee": "Estimated network fee."
|
|
189
|
+
"estimatedTime": "Estimated swap execution time in minutes.",
|
|
190
|
+
"estimatedNetworkFee": "Estimated network fee.",
|
|
191
|
+
"settingsModified": "Settings (modified)"
|
|
191
192
|
}
|
|
192
193
|
}
|
package/cjs/i18n/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SettingsState, SettingsStore } from './types';
|
|
2
|
+
export declare const defaultSettings: Omit<SettingsState, 'enabledBridges' | 'enabledExchanges' | '_enabledBridges' | '_enabledExchanges'>;
|
|
2
3
|
export declare const useSettingsStore: import("zustand").UseBoundStore<Omit<Omit<import("zustand").StoreApi<SettingsStore>, "persist"> & {
|
|
3
4
|
persist: {
|
|
4
5
|
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<SettingsStore, {
|
|
@@ -11,30 +11,29 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.useSettingsStore = void 0;
|
|
14
|
+
exports.useSettingsStore = exports.defaultSettings = void 0;
|
|
15
15
|
/* eslint-disable no-underscore-dangle */
|
|
16
16
|
const zustand_1 = require("zustand");
|
|
17
17
|
const middleware_1 = require("zustand/middleware");
|
|
18
18
|
const immer_1 = require("zustand/middleware/immer");
|
|
19
19
|
const types_1 = require("./types");
|
|
20
|
-
exports.
|
|
21
|
-
advancedPreferences: false,
|
|
22
|
-
showDestinationWallet: true,
|
|
20
|
+
exports.defaultSettings = {
|
|
23
21
|
appearance: 'auto',
|
|
24
22
|
gasPrice: 'normal',
|
|
25
23
|
routePriority: 'RECOMMENDED',
|
|
26
24
|
slippage: '0.5',
|
|
27
|
-
|
|
25
|
+
advancedPreferences: false,
|
|
26
|
+
showDestinationWallet: true,
|
|
27
|
+
};
|
|
28
|
+
exports.useSettingsStore = (0, zustand_1.default)()((0, middleware_1.persist)((0, immer_1.immer)((set) => (Object.assign(Object.assign({}, exports.defaultSettings), { setValue: (key, value) => set((state) => {
|
|
28
29
|
state[key] = value;
|
|
29
|
-
}),
|
|
30
|
-
setValues: (values) => set((state) => {
|
|
30
|
+
}), setValues: (values) => set((state) => {
|
|
31
31
|
for (const key in values) {
|
|
32
32
|
if (Object.prototype.hasOwnProperty.call(state, key)) {
|
|
33
33
|
state[key] = values[key];
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
}),
|
|
37
|
-
initializeTools: (toolType, tools) => set((state) => {
|
|
36
|
+
}), initializeTools: (toolType, tools) => set((state) => {
|
|
38
37
|
if (!tools.length) {
|
|
39
38
|
return;
|
|
40
39
|
}
|
|
@@ -58,15 +57,13 @@ exports.useSettingsStore = (0, zustand_1.default)()((0, middleware_1.persist)((0
|
|
|
58
57
|
state[`enabled${toolType}`] = Object.entries(state[`_enabled${toolType}`])
|
|
59
58
|
.filter(([_, value]) => value)
|
|
60
59
|
.map(([key]) => key);
|
|
61
|
-
}),
|
|
62
|
-
setTools: (toolType, tools, availableTools) => set((state) => {
|
|
60
|
+
}), setTools: (toolType, tools, availableTools) => set((state) => {
|
|
63
61
|
state[`enabled${toolType}`] = tools;
|
|
64
62
|
state[`_enabled${toolType}`] = availableTools.reduce((values, tool) => {
|
|
65
63
|
values[tool.key] = tools.includes(tool.key);
|
|
66
64
|
return values;
|
|
67
65
|
}, {});
|
|
68
|
-
}),
|
|
69
|
-
})), {
|
|
66
|
+
}) }))), {
|
|
70
67
|
name: 'li.fi-widget-settings',
|
|
71
68
|
version: 2,
|
|
72
69
|
partialize: (state) => {
|
|
@@ -20,7 +20,5 @@ export const ActiveSwaps = (props) => {
|
|
|
20
20
|
navigate(navigationRoutes.activeSwaps);
|
|
21
21
|
};
|
|
22
22
|
const hasShowAll = (executingRoutes === null || executingRoutes === void 0 ? void 0 : executingRoutes.length) > 2;
|
|
23
|
-
return (_jsxs(Card, Object.assign({ variant: "selected", selectionColor: "secondary" }, props, { children: [_jsx(CardTitle, { children: t('header.activeSwaps') }), _jsx(Stack, Object.assign({ spacing: 1.5, pt: 1.5, pb: hasShowAll ? 0 : 2 }, { children: executingRoutes.slice(0, 2).map((routeId) => (_jsx(ActiveSwapItem, { routeId: routeId, dense: true }, routeId))) })), hasShowAll ? (_jsx(ShowAllButton, Object.assign({ disableRipple: true, fullWidth: true, onClick: handleShowAll,
|
|
24
|
-
padding: theme.spacing(0.75, 2),
|
|
25
|
-
}) }, { children: t('button.showAll') }))) : null] })));
|
|
23
|
+
return (_jsxs(Card, Object.assign({ variant: "selected", selectionColor: "secondary" }, props, { children: [_jsx(CardTitle, { children: t('header.activeSwaps') }), _jsx(Stack, Object.assign({ spacing: 1.5, pt: 1.5, pb: hasShowAll ? 0 : 2 }, { children: executingRoutes.slice(0, 2).map((routeId) => (_jsx(ActiveSwapItem, { routeId: routeId, dense: true }, routeId))) })), hasShowAll ? (_jsx(ShowAllButton, Object.assign({ disableRipple: true, fullWidth: true, onClick: handleShowAll }, { children: t('button.showAll') }))) : null] })));
|
|
26
24
|
};
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import type { Theme } from '@mui/material';
|
|
1
|
+
import type { BoxProps, Theme } from '@mui/material';
|
|
2
2
|
import type { MouseEventHandler } from 'react';
|
|
3
3
|
declare type CardVariant = 'default' | 'selected' | 'error';
|
|
4
|
+
export declare type CardProps = {
|
|
5
|
+
variant?: CardVariant;
|
|
6
|
+
selectionColor?: 'primary' | 'secondary';
|
|
7
|
+
dense?: boolean;
|
|
8
|
+
indented?: boolean;
|
|
9
|
+
onClick?: MouseEventHandler<HTMLDivElement>;
|
|
10
|
+
pointerEvents?: 'auto' | 'none';
|
|
11
|
+
} & BoxProps;
|
|
4
12
|
export declare const Card: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<Theme> & {
|
|
5
13
|
children?: import("react").ReactNode;
|
|
6
14
|
component?: import("react").ElementType<any> | undefined;
|
|
@@ -14,5 +22,6 @@ export declare const Card: import("@emotion/styled").StyledComponent<import("@mu
|
|
|
14
22
|
dense?: boolean | undefined;
|
|
15
23
|
indented?: boolean | undefined;
|
|
16
24
|
onClick?: MouseEventHandler<HTMLDivElement> | undefined;
|
|
25
|
+
pointerEvents?: "none" | "auto" | undefined;
|
|
17
26
|
}, {}, {}>;
|
|
18
27
|
export {};
|
package/components/Card/Card.js
CHANGED
|
@@ -8,8 +8,14 @@ const getBackgroundColor = (theme, variant, selectionColor) => variant === 'sele
|
|
|
8
8
|
: alpha(theme.palette.secondary.main, theme.palette.mode === 'light' ? 0.08 : 0.12)
|
|
9
9
|
: theme.palette.background.paper;
|
|
10
10
|
export const Card = styled(Box, {
|
|
11
|
-
shouldForwardProp: (prop) => ![
|
|
12
|
-
|
|
11
|
+
shouldForwardProp: (prop) => ![
|
|
12
|
+
'dense',
|
|
13
|
+
'variant',
|
|
14
|
+
'indented',
|
|
15
|
+
'selectionColor',
|
|
16
|
+
'pointerEvents',
|
|
17
|
+
].includes(prop),
|
|
18
|
+
})(({ theme, variant, selectionColor = 'primary', dense, indented, pointerEvents, onClick, }) => {
|
|
13
19
|
const backgroundColor = getBackgroundColor(theme, variant, selectionColor);
|
|
14
20
|
return {
|
|
15
21
|
backgroundColor,
|
|
@@ -42,5 +48,6 @@ export const Card = styled(Box, {
|
|
|
42
48
|
duration: theme.transitions.duration.enteringScreen,
|
|
43
49
|
easing: theme.transitions.easing.easeOut,
|
|
44
50
|
}),
|
|
51
|
+
pointerEvents,
|
|
45
52
|
};
|
|
46
53
|
});
|
|
@@ -12,6 +12,7 @@ export declare const ChainCard: import("@emotion/styled").StyledComponent<import
|
|
|
12
12
|
dense?: boolean | undefined;
|
|
13
13
|
indented?: boolean | undefined;
|
|
14
14
|
onClick?: import("react").MouseEventHandler<HTMLDivElement> | undefined;
|
|
15
|
+
pointerEvents?: "none" | "auto" | undefined;
|
|
15
16
|
}, {}, {}>;
|
|
16
17
|
export declare const ChainContainer: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
17
18
|
children?: import("react").ReactNode;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
2
|
+
import type { CardProps } from '../Card';
|
|
3
3
|
import type { SwapRouteCardEssentialsProps, SwapRouteCardProps } from './types';
|
|
4
|
-
export declare const SwapRouteCard: React.FC<SwapRouteCardProps &
|
|
4
|
+
export declare const SwapRouteCard: React.FC<SwapRouteCardProps & Omit<CardProps, 'variant'>>;
|
|
5
5
|
export declare const SwapRouteCardEssentials: React.FC<SwapRouteCardEssentialsProps>;
|
|
@@ -18,6 +18,7 @@ import { Card } from '../Card';
|
|
|
18
18
|
import { StepActions } from '../StepActions';
|
|
19
19
|
import { Token } from '../Token';
|
|
20
20
|
import { IconButton, Label } from './SwapRouteCard.style';
|
|
21
|
+
import { getGasCostsBreakdown } from './utils';
|
|
21
22
|
export const SwapRouteCard = (_a) => {
|
|
22
23
|
var _b;
|
|
23
24
|
var { route, active, variant = 'default', expanded } = _a, other = __rest(_a, ["route", "active", "variant", "expanded"]);
|
|
@@ -40,7 +41,11 @@ export const SwapRouteCardEssentials = ({ route, dense }) => {
|
|
|
40
41
|
.map((step) => step.estimate.executionDuration)
|
|
41
42
|
.reduce((duration, x) => duration + x, 0) / 60);
|
|
42
43
|
const gasCostUSD = parseFloat((_a = route.gasCostUSD) !== null && _a !== void 0 ? _a : '') || 0.01;
|
|
43
|
-
|
|
44
|
+
const gasCosts = getGasCostsBreakdown(route);
|
|
45
|
+
return (_jsxs(Box, Object.assign({ display: "flex", justifyContent: dense ? 'space-between' : 'flex-end', flex: 1, pl: dense ? 0 : 2, mt: dense ? 2 : 0 }, { children: [_jsx(Tooltip, Object.assign({ title: _jsxs(Box, Object.assign({ component: "span" }, { children: [t(`tooltip.estimatedNetworkFee`), gasCosts.map((gas) => {
|
|
46
|
+
var _a;
|
|
47
|
+
return (_jsxs(Typography, Object.assign({ fontSize: 11 }, { children: [(_a = gas.amount) === null || _a === void 0 ? void 0 : _a.toFixed(6), " ", gas.token.symbol, " (", t(`swap.currency`, { value: gas.amountUSD }), ")"] }), `${gas.token.address}${gas.token.symbol}`));
|
|
48
|
+
})] })), placement: "top", enterDelay: 400, arrow: true }, { children: _jsxs(Box, Object.assign({ display: "flex", alignItems: "center", mr: 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: gasCostUSD }) }))] })) })), _jsx(Tooltip, Object.assign({ title: t(`tooltip.estimatedTime`), placement: "top", enterDelay: 400, arrow: true }, { children: _jsxs(Box, Object.assign({ display: "flex", alignItems: "center", mr: 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', {
|
|
44
49
|
value: executionTimeMinutes,
|
|
45
50
|
}) }))] })) })), !dense ? (_jsx(Tooltip, Object.assign({ title: t(`tooltip.numberOfSteps`), placement: "top", enterDelay: 400, arrow: true }, { children: _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] })));
|
|
46
51
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import Big from 'big.js';
|
|
2
|
+
export const getGasCostsBreakdown = (route) => {
|
|
3
|
+
return Object.values(route.steps.reduce((groupedGasCosts, step) => {
|
|
4
|
+
if (step.estimate.gasCosts) {
|
|
5
|
+
const { token } = step.estimate.gasCosts[0];
|
|
6
|
+
const gasCostAmount = step.estimate.gasCosts
|
|
7
|
+
.reduce((amount, gasCost) => amount.plus(Big(gasCost.amount || 0)), Big(0))
|
|
8
|
+
.div(Math.pow(10, token.decimals));
|
|
9
|
+
const gasCostAmountUSD = step.estimate.gasCosts.reduce((amount, gasCost) => amount + parseFloat(gasCost.amountUSD || '0'), 0);
|
|
10
|
+
const groupedGasCost = groupedGasCosts[token.chainId];
|
|
11
|
+
const amount = groupedGasCost
|
|
12
|
+
? groupedGasCost.amount.plus(gasCostAmount)
|
|
13
|
+
: gasCostAmount;
|
|
14
|
+
const amountUSD = groupedGasCost
|
|
15
|
+
? groupedGasCost.amountUSD + gasCostAmountUSD
|
|
16
|
+
: gasCostAmountUSD;
|
|
17
|
+
groupedGasCosts[token.chainId] = {
|
|
18
|
+
amount,
|
|
19
|
+
amountUSD,
|
|
20
|
+
token,
|
|
21
|
+
};
|
|
22
|
+
return groupedGasCosts;
|
|
23
|
+
}
|
|
24
|
+
return groupedGasCosts;
|
|
25
|
+
}, {}));
|
|
26
|
+
};
|
|
@@ -33,5 +33,5 @@ export const SwapRoutes = (props) => {
|
|
|
33
33
|
borderRightWidth: !routeNotFound && (isFetching || (routes && routes.length > 1))
|
|
34
34
|
? 1
|
|
35
35
|
: 0,
|
|
36
|
-
} }, { children: isLoading || isFetching ? (_jsxs(_Fragment, { children: [_jsx(SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" }), _jsx(SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" })] })) : !currentRoute ? (_jsx(SwapRouteNotFoundCard, {})) : (_jsxs(_Fragment, { children: [_jsx(SwapRouteCard, { minWidth: routes.length > 1 ? '80%' : '100%', route: currentRoute, variant: "dense", active: true }), routes.length > 1 ? (_jsx(SwapRouteCard, { minWidth: "80%", route: routes[1], variant: "dense" })) : null] })) })), _jsx(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: !routeNotFound ? (_jsx(Box, Object.assign({ py: 1, pr: 1 }, { children: _jsx(IconButton, Object.assign({ onClick: handleCardClick, size: "medium", disabled: isValidating || !isValid }, { children: _jsx(KeyboardArrowRightIcon, {}) })) }))) : null }))] }))] })));
|
|
36
|
+
} }, { children: isLoading || isFetching ? (_jsxs(_Fragment, { children: [_jsx(SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" }), _jsx(SwapRouteCardSkeleton, { minWidth: "80%", variant: "dense" })] })) : !currentRoute ? (_jsx(SwapRouteNotFoundCard, {})) : (_jsxs(_Fragment, { children: [_jsx(SwapRouteCard, { minWidth: routes.length > 1 ? '80%' : '100%', route: currentRoute, variant: "dense", active: true }), routes.length > 1 ? (_jsx(SwapRouteCard, { minWidth: "80%", route: routes[1], variant: "dense", pointerEvents: "none" })) : null] })) })), _jsx(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: !routeNotFound ? (_jsx(Box, Object.assign({ py: 1, pr: 1 }, { children: _jsx(IconButton, Object.assign({ onClick: handleCardClick, size: "medium", disabled: isValidating || !isValid }, { children: _jsx(KeyboardArrowRightIcon, {}) })) }))) : null }))] }))] })));
|
|
37
37
|
};
|
package/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "1.20.
|
|
2
|
+
export declare const version = "1.20.2";
|
package/config/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '1.20.
|
|
2
|
+
export const version = '1.20.2';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EVMChain, Route, Token } from '@lifi/sdk';
|
|
2
2
|
import Big from 'big.js';
|
|
3
|
-
interface GasSufficiency {
|
|
3
|
+
export interface GasSufficiency {
|
|
4
4
|
gasAmount: Big;
|
|
5
5
|
tokenAmount?: Big;
|
|
6
6
|
insufficientAmount?: Big;
|
|
@@ -13,4 +13,3 @@ export declare const useGasSufficiency: (route?: Route) => {
|
|
|
13
13
|
insufficientFunds: boolean | null | undefined;
|
|
14
14
|
isLoading: boolean;
|
|
15
15
|
};
|
|
16
|
-
export {};
|
package/hooks/useTokens.js
CHANGED
|
@@ -9,10 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { useQuery } from '@tanstack/react-query';
|
|
11
11
|
import { isItemAllowed, useLiFi, useWidgetConfig } from '../providers';
|
|
12
|
+
import { useChains } from './useChains';
|
|
12
13
|
import { useFeaturedTokens } from './useFeaturedTokens';
|
|
13
14
|
export const useTokens = (selectedChainId) => {
|
|
14
15
|
var _a, _b, _c, _d;
|
|
15
16
|
const lifi = useLiFi();
|
|
17
|
+
const { getChainById, isLoading: isSupportedChainsLoading } = useChains();
|
|
16
18
|
const featuredTokens = useFeaturedTokens(selectedChainId);
|
|
17
19
|
const { tokens, chains, disabledChains } = useWidgetConfig();
|
|
18
20
|
const { data, isLoading } = useQuery([
|
|
@@ -26,6 +28,7 @@ export const useTokens = (selectedChainId) => {
|
|
|
26
28
|
], () => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
29
|
var _e, _f, _g, _h, _j;
|
|
28
30
|
const chainAllowed = selectedChainId &&
|
|
31
|
+
getChainById(selectedChainId) &&
|
|
29
32
|
isItemAllowed(selectedChainId, chains, disabledChains);
|
|
30
33
|
if (!chainAllowed) {
|
|
31
34
|
return [];
|
|
@@ -47,7 +50,9 @@ export const useTokens = (selectedChainId) => {
|
|
|
47
50
|
})) !== null && _h !== void 0 ? _h : []),
|
|
48
51
|
...((_j = filteredTokens === null || filteredTokens === void 0 ? void 0 : filteredTokens.filter((token) => !featuredTokenAddresses.has(token.address))) !== null && _j !== void 0 ? _j : []),
|
|
49
52
|
];
|
|
50
|
-
})
|
|
53
|
+
}), {
|
|
54
|
+
enabled: !isSupportedChainsLoading,
|
|
55
|
+
});
|
|
51
56
|
return {
|
|
52
57
|
tokens: data,
|
|
53
58
|
isLoading,
|
package/i18n/en/translation.json
CHANGED
|
@@ -186,7 +186,8 @@
|
|
|
186
186
|
},
|
|
187
187
|
"progressToNextUpdate": "Displayed data will auto-refresh after {{value}} seconds. Click here to update manually.",
|
|
188
188
|
"numberOfSteps": "A number of swap steps. Each step can contain 1-3 transactions that require a signature.",
|
|
189
|
-
"estimatedTime": "Estimated time in minutes.",
|
|
190
|
-
"estimatedNetworkFee": "Estimated network fee."
|
|
189
|
+
"estimatedTime": "Estimated swap execution time in minutes.",
|
|
190
|
+
"estimatedNetworkFee": "Estimated network fee.",
|
|
191
|
+
"settingsModified": "Settings (modified)"
|
|
191
192
|
}
|
|
192
193
|
}
|
package/i18n/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.2",
|
|
4
4
|
"description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"@ethersproject/providers": "^5.7.1",
|
|
45
45
|
"@lifi/sdk": "^1.6.0",
|
|
46
46
|
"@lifi/wallet-management": "^1.1.10",
|
|
47
|
-
"@mui/icons-material": "^5.10.
|
|
48
|
-
"@mui/lab": "^5.0.0-alpha.
|
|
49
|
-
"@mui/material": "^5.10.
|
|
47
|
+
"@mui/icons-material": "^5.10.9",
|
|
48
|
+
"@mui/lab": "^5.0.0-alpha.103",
|
|
49
|
+
"@mui/material": "^5.10.9",
|
|
50
50
|
"@sentry/integrations": "^7.15.0",
|
|
51
51
|
"@sentry/react": "^7.15.0",
|
|
52
52
|
"@sentry/tracing": "^7.15.0",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SettingsState, SettingsStore } from './types';
|
|
2
|
+
export declare const defaultSettings: Omit<SettingsState, 'enabledBridges' | 'enabledExchanges' | '_enabledBridges' | '_enabledExchanges'>;
|
|
2
3
|
export declare const useSettingsStore: import("zustand").UseBoundStore<Omit<Omit<import("zustand").StoreApi<SettingsStore>, "persist"> & {
|
|
3
4
|
persist: {
|
|
4
5
|
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<SettingsStore, {
|