@lifi/widget 2.0.0-beta.2 → 2.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/components/ChainSelect/ChainSelect.d.ts +0 -1
- package/cjs/components/ChainSelect/ChainSelect.style.js +1 -1
- package/cjs/components/GasMessage/FundsSufficiencyMessage.d.ts +0 -1
- package/cjs/components/Header/NavigationHeader.js +18 -5
- package/cjs/components/Insurance/InsuranceCard.js +27 -11
- package/cjs/components/Insurance/InsuranceCollapsed.js +1 -1
- package/cjs/components/Insurance/types.d.ts +1 -2
- package/cjs/components/NFT/NFT.js +2 -2
- package/cjs/components/NFT/types.d.ts +1 -1
- package/cjs/components/PoweredBy/PoweredBy.js +2 -3
- package/cjs/components/SelectTokenButton/SelectTokenButton.js +1 -1
- package/cjs/components/Step/CircularProgress.d.ts +0 -1
- package/cjs/components/Step/Step.js +14 -4
- package/cjs/components/Step/StepList.d.ts +0 -1
- package/cjs/components/StepActions/StepActions.js +2 -19
- package/cjs/components/SwapButton/SwapButton.js +16 -4
- package/cjs/components/SwapInput/SwapInputEndAdornment.d.ts +0 -1
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +6 -3
- package/cjs/components/SwapRouteCard/SwapRouteCardEssentials.js +1 -1
- package/cjs/components/SwapRouteCard/SwapRouteCardSkeleton.js +1 -1
- package/cjs/components/SwapRoutes/SwapRoutes.js +1 -1
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.d.ts +0 -1
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +2 -2
- package/cjs/components/Token/Token.js +1 -1
- package/cjs/components/TokenAvatar/TokenAvatar.d.ts +4 -4
- package/cjs/components/TokenList/TokenList.js +4 -2
- package/cjs/components/TokenList/types.d.ts +2 -3
- package/cjs/config/theme.js +14 -1
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/useFeaturedTokens.d.ts +1 -1
- package/cjs/hooks/useProcessMessage.d.ts +2 -1
- package/cjs/hooks/useProcessMessage.js +23 -9
- package/cjs/hooks/useSwapRoutes.js +24 -11
- package/cjs/hooks/useToken.d.ts +1 -1
- package/cjs/hooks/useTokenAddressBalance.d.ts +2 -2
- package/cjs/hooks/useTokenBalances.d.ts +5 -5
- package/cjs/hooks/useTokenBalances.js +3 -14
- package/cjs/hooks/useTokenSearch.d.ts +2 -2
- package/cjs/hooks/useTokens.d.ts +2 -2
- package/cjs/i18n/bn.json +8 -0
- package/cjs/i18n/en.json +24 -2
- package/cjs/i18n/fr.json +8 -0
- package/cjs/i18n/id.json +22 -7
- package/cjs/i18n/ko.json +22 -7
- package/cjs/i18n/pt.json +8 -0
- package/cjs/i18n/th.json +21 -6
- package/cjs/i18n/uk.json +20 -12
- package/cjs/i18n/zh.json +8 -0
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +0 -1
- package/cjs/pages/SelectTokenPage/SearchTokenInput.d.ts +0 -1
- package/cjs/pages/SelectWalletPage/SelectWalletPage.d.ts +0 -1
- package/cjs/pages/SettingsPage/GasPriceSelect.d.ts +0 -1
- package/cjs/pages/SettingsPage/SettingsPage.d.ts +0 -1
- package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +0 -1
- package/cjs/pages/SettingsPage/SlippageInput.d.ts +0 -1
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +4 -1
- package/cjs/pages/SwapPage/ExchangeRateBottomSheet.js +1 -1
- package/cjs/pages/SwapPage/StatusBottomSheet.js +9 -3
- package/cjs/pages/SwapPage/StatusBottomSheet.style.d.ts +1 -1
- package/cjs/pages/SwapPage/StatusBottomSheet.style.js +2 -2
- package/cjs/pages/SwapPage/SwapPage.js +12 -6
- package/cjs/pages/SwapPage/TokenValueBottomSheet.js +1 -1
- package/cjs/providers/WalletProvider/types.d.ts +2 -2
- package/cjs/types/token.d.ts +2 -2
- package/cjs/types/widget.d.ts +7 -6
- package/cjs/types/widget.js +1 -0
- package/components/ChainSelect/ChainSelect.d.ts +0 -1
- package/components/ChainSelect/ChainSelect.style.js +1 -1
- package/components/GasMessage/FundsSufficiencyMessage.d.ts +0 -1
- package/components/Header/NavigationHeader.js +18 -5
- package/components/Insurance/InsuranceCard.js +29 -13
- package/components/Insurance/InsuranceCollapsed.js +1 -1
- package/components/Insurance/types.d.ts +1 -2
- package/components/NFT/NFT.js +2 -2
- package/components/NFT/types.d.ts +1 -1
- package/components/PoweredBy/PoweredBy.js +2 -3
- package/components/SelectTokenButton/SelectTokenButton.js +1 -1
- package/components/Step/CircularProgress.d.ts +0 -1
- package/components/Step/Step.js +14 -4
- package/components/Step/StepList.d.ts +0 -1
- package/components/StepActions/StepActions.js +2 -19
- package/components/SwapButton/SwapButton.js +16 -4
- package/components/SwapInput/SwapInputEndAdornment.d.ts +0 -1
- package/components/SwapRouteCard/SwapRouteCard.js +7 -4
- package/components/SwapRouteCard/SwapRouteCardEssentials.js +1 -1
- package/components/SwapRouteCard/SwapRouteCardSkeleton.js +1 -1
- package/components/SwapRoutes/SwapRoutes.js +1 -1
- package/components/SwapRoutes/SwapRoutesExpanded.d.ts +0 -1
- package/components/SwapRoutes/SwapRoutesExpanded.js +2 -2
- package/components/Token/Token.js +1 -1
- package/components/TokenAvatar/TokenAvatar.d.ts +4 -4
- package/components/TokenList/TokenList.js +4 -2
- package/components/TokenList/types.d.ts +2 -3
- package/config/theme.js +14 -1
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/useFeaturedTokens.d.ts +1 -1
- package/hooks/useProcessMessage.d.ts +2 -1
- package/hooks/useProcessMessage.js +23 -9
- package/hooks/useSwapRoutes.js +24 -11
- package/hooks/useToken.d.ts +1 -1
- package/hooks/useTokenAddressBalance.d.ts +2 -2
- package/hooks/useTokenBalances.d.ts +5 -5
- package/hooks/useTokenBalances.js +3 -14
- package/hooks/useTokenSearch.d.ts +2 -2
- package/hooks/useTokens.d.ts +2 -2
- package/i18n/bn.json +8 -0
- package/i18n/en.json +24 -2
- package/i18n/fr.json +8 -0
- package/i18n/id.json +22 -7
- package/i18n/ko.json +22 -7
- package/i18n/pt.json +8 -0
- package/i18n/th.json +21 -6
- package/i18n/uk.json +20 -12
- package/i18n/zh.json +8 -0
- package/package.json +7 -7
- package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +0 -1
- package/pages/SelectTokenPage/SearchTokenInput.d.ts +0 -1
- package/pages/SelectWalletPage/SelectWalletPage.d.ts +0 -1
- package/pages/SettingsPage/GasPriceSelect.d.ts +0 -1
- package/pages/SettingsPage/SettingsPage.d.ts +0 -1
- package/pages/SettingsPage/ShowDestinationWallet.d.ts +0 -1
- package/pages/SettingsPage/SlippageInput.d.ts +0 -1
- package/pages/SwapDetailsPage/SwapDetailsPage.js +4 -1
- package/pages/SwapPage/ExchangeRateBottomSheet.js +2 -2
- package/pages/SwapPage/StatusBottomSheet.js +11 -5
- package/pages/SwapPage/StatusBottomSheet.style.d.ts +1 -1
- package/pages/SwapPage/StatusBottomSheet.style.js +1 -1
- package/pages/SwapPage/SwapPage.js +12 -6
- package/pages/SwapPage/TokenValueBottomSheet.js +2 -2
- package/providers/WalletProvider/types.d.ts +2 -2
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/token.d.ts +2 -2
- package/types/widget.d.ts +7 -6
- package/types/widget.js +1 -0
|
@@ -12,7 +12,7 @@ exports.ChainCard = (0, styles_1.styled)(Card_1.Card)({
|
|
|
12
12
|
});
|
|
13
13
|
exports.ChainContainer = (0, styles_1.styled)(material_1.Box)(({ theme }) => ({
|
|
14
14
|
display: 'grid',
|
|
15
|
-
gridTemplateColumns: 'repeat(
|
|
15
|
+
gridTemplateColumns: 'repeat(auto-fit, minmax(52px, 1fr))',
|
|
16
16
|
gridAutoRows: '56px',
|
|
17
17
|
justifyContent: 'space-between',
|
|
18
18
|
gap: theme.spacing(1.5),
|
|
@@ -10,12 +10,13 @@ const react_i18next_1 = require("react-i18next");
|
|
|
10
10
|
const react_router_dom_1 = require("react-router-dom");
|
|
11
11
|
const hooks_1 = require("../../hooks");
|
|
12
12
|
const providers_1 = require("../../providers");
|
|
13
|
+
const types_1 = require("../../types");
|
|
13
14
|
const utils_1 = require("../../utils");
|
|
14
15
|
const Header_style_1 = require("./Header.style");
|
|
15
16
|
const useHeaderActionStore_1 = require("./useHeaderActionStore");
|
|
16
17
|
const NavigationHeader = () => {
|
|
17
18
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
18
|
-
const { variant } = (0, providers_1.useWidgetConfig)();
|
|
19
|
+
const { variant, hiddenUI } = (0, providers_1.useWidgetConfig)();
|
|
19
20
|
const { navigate, navigateBack } = (0, hooks_1.useNavigateBack)();
|
|
20
21
|
const { account } = (0, providers_1.useWallet)();
|
|
21
22
|
const { element } = (0, useHeaderActionStore_1.useHeaderActionStore)();
|
|
@@ -37,8 +38,12 @@ const NavigationHeader = () => {
|
|
|
37
38
|
return t(`settings.enabledExchanges`);
|
|
38
39
|
case utils_1.navigationRoutes.swapHistory:
|
|
39
40
|
return t(`header.swapHistory`);
|
|
40
|
-
case utils_1.navigationRoutes.fromToken:
|
|
41
|
+
case utils_1.navigationRoutes.fromToken: {
|
|
42
|
+
if (variant === 'nft') {
|
|
43
|
+
return t(`header.payWith`);
|
|
44
|
+
}
|
|
41
45
|
return t(`header.from`);
|
|
46
|
+
}
|
|
42
47
|
case utils_1.navigationRoutes.toToken:
|
|
43
48
|
return t(`header.to`);
|
|
44
49
|
case utils_1.navigationRoutes.fromChain:
|
|
@@ -49,10 +54,18 @@ const NavigationHeader = () => {
|
|
|
49
54
|
return t(`header.routes`);
|
|
50
55
|
case utils_1.navigationRoutes.activeSwaps:
|
|
51
56
|
return t(`header.activeSwaps`);
|
|
52
|
-
case utils_1.navigationRoutes.swapExecution:
|
|
57
|
+
case utils_1.navigationRoutes.swapExecution: {
|
|
58
|
+
if (variant === 'nft') {
|
|
59
|
+
return t(`header.purchase`);
|
|
60
|
+
}
|
|
53
61
|
return t(`header.swap`);
|
|
54
|
-
|
|
62
|
+
}
|
|
63
|
+
case utils_1.navigationRoutes.swapDetails: {
|
|
64
|
+
if (variant === 'nft') {
|
|
65
|
+
return t(`header.purchaseDetails`);
|
|
66
|
+
}
|
|
55
67
|
return t(`header.swapDetails`);
|
|
68
|
+
}
|
|
56
69
|
default: {
|
|
57
70
|
switch (variant) {
|
|
58
71
|
case 'nft':
|
|
@@ -65,7 +78,7 @@ const NavigationHeader = () => {
|
|
|
65
78
|
}
|
|
66
79
|
}
|
|
67
80
|
};
|
|
68
|
-
return ((0, jsx_runtime_1.jsxs)(Header_style_1.HeaderAppBar, { elevation: 0, children: [utils_1.backButtonRoutes.includes(path) ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "medium", edge: "start", onClick: navigateBack, children: (0, jsx_runtime_1.jsx)(ArrowBack_1.default, {}) })) : null, (0, jsx_runtime_1.jsx)(material_1.Typography, { 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, { title: t(`header.swapHistory`), enterDelay: 400, arrow: true, children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "medium", edge: "start", onClick: () => navigate(utils_1.navigationRoutes.swapHistory), children: (0, jsx_runtime_1.jsx)(ReceiptLong_1.default, {}) }) })) : null, (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: t(`header.settings`), enterDelay: 400, arrow: true, children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "medium", onClick: () => navigate(utils_1.navigationRoutes.settings), sx: {
|
|
81
|
+
return ((0, jsx_runtime_1.jsxs)(Header_style_1.HeaderAppBar, { elevation: 0, children: [utils_1.backButtonRoutes.includes(path) ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "medium", edge: "start", onClick: navigateBack, children: (0, jsx_runtime_1.jsx)(ArrowBack_1.default, {}) })) : null, (0, jsx_runtime_1.jsx)(material_1.Typography, { 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 && !hiddenUI?.includes(types_1.HiddenUI.History) ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: t(`header.swapHistory`), enterDelay: 400, arrow: true, children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "medium", edge: "start", onClick: () => navigate(utils_1.navigationRoutes.swapHistory), children: (0, jsx_runtime_1.jsx)(ReceiptLong_1.default, {}) }) })) : null, (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: t(`header.settings`), enterDelay: 400, arrow: true, children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "medium", onClick: () => navigate(utils_1.navigationRoutes.settings), sx: {
|
|
69
82
|
marginRight: -1.25,
|
|
70
83
|
}, children: (0, jsx_runtime_1.jsx)(Settings_1.default, {}) }) })] }) }), (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 }) })] })] }));
|
|
71
84
|
};
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InsuranceCard = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const ExpandLess_1 = require("@mui/icons-material/ExpandLess");
|
|
6
|
+
const ExpandMore_1 = require("@mui/icons-material/ExpandMore");
|
|
5
7
|
const VerifiedUser_1 = require("@mui/icons-material/VerifiedUser");
|
|
6
8
|
const material_1 = require("@mui/material");
|
|
9
|
+
const react_1 = require("react");
|
|
7
10
|
const react_i18next_1 = require("react-i18next");
|
|
8
11
|
const icons_1 = require("../../icons");
|
|
9
12
|
const stores_1 = require("../../stores");
|
|
@@ -11,16 +14,29 @@ const Card_1 = require("../Card");
|
|
|
11
14
|
const Switch_1 = require("../Switch");
|
|
12
15
|
const InsuranceCard = ({ status, feeAmountUsd, insuranceCoverageId, onChange, ...props }) => {
|
|
13
16
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
const [enabled, setEnabled] = (0, react_1.useState)(false);
|
|
18
|
+
const [cardExpanded, setCardExpanded] = (0, react_1.useState)(status === stores_1.RouteExecutionStatus.Idle);
|
|
19
|
+
const handleExpand = (e) => {
|
|
20
|
+
e.stopPropagation();
|
|
21
|
+
setCardExpanded((expanded) => !expanded);
|
|
22
|
+
};
|
|
23
|
+
const handleSwitch = (_, checked) => {
|
|
24
|
+
setEnabled(checked);
|
|
25
|
+
onChange?.(checked);
|
|
26
|
+
};
|
|
27
|
+
return ((0, jsx_runtime_1.jsxs)(Card_1.Card, { selectionColor: "secondary", indented: true, ...props, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", alignItems: "center", justifyContent: "space-between", children: [(0, jsx_runtime_1.jsxs)(Card_1.CardLabel, { type: 'insurance', children: [(0, jsx_runtime_1.jsx)(VerifiedUser_1.default, { fontSize: "inherit" }), (0, jsx_runtime_1.jsx)(Card_1.CardLabelTypography, { type: "icon", children: status === stores_1.RouteExecutionStatus.Idle
|
|
28
|
+
? t('swap.tags.insurance')
|
|
29
|
+
: t('swap.tags.insured') })] }), status === stores_1.RouteExecutionStatus.Idle ? ((0, jsx_runtime_1.jsx)(Switch_1.Switch, { onChange: handleSwitch, value: enabled })) : ((0, jsx_runtime_1.jsx)(material_1.Box, { my: -0.5, children: (0, jsx_runtime_1.jsx)(Card_1.CardIconButton, { onClick: handleExpand, size: "small", children: cardExpanded ? (0, jsx_runtime_1.jsx)(ExpandLess_1.default, {}) : (0, jsx_runtime_1.jsx)(ExpandMore_1.default, {}) }) }))] }), (0, jsx_runtime_1.jsx)(material_1.Collapse, { timeout: 225, in: cardExpanded, mountOnEnter: true, unmountOnExit: true, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { mt: 2, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", alignItems: "center", justifyContent: "space-between", mb: 2, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 24, fontWeight: 700, lineHeight: 1, children: t('format.currency', {
|
|
30
|
+
value: feeAmountUsd,
|
|
31
|
+
}) }), (0, jsx_runtime_1.jsx)(icons_1.InsuraceLogo, {})] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 14, children: status === stores_1.RouteExecutionStatus.Idle
|
|
32
|
+
? t('swap.insurance.insure')
|
|
33
|
+
: t('swap.insurance.insured') }), (0, jsx_runtime_1.jsx)(material_1.Collapse, { timeout: 225, in: enabled || status !== stores_1.RouteExecutionStatus.Idle, mountOnEnter: true, unmountOnExit: true, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
34
|
+
listStyleType: 'disc',
|
|
35
|
+
pl: 2,
|
|
36
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 14, display: "list-item", children: t('swap.insurance.bridgeExploits') }), (0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 14, display: "list-item", children: t('swap.insurance.slippageError') })] }) }), (0, jsx_runtime_1.jsx)(material_1.Link, { href: status === stores_1.RouteExecutionStatus.Idle
|
|
37
|
+
? 'https://docs.insurace.io/landing-page/documentation/cover-products/bridge-cover/li.fi'
|
|
38
|
+
: `https://app.insurace.io/bridge-cover?search=${insuranceCoverageId}`, target: "_blank", underline: "none", color: "text.primary", children: (0, jsx_runtime_1.jsx)(material_1.Typography, { pt: 0.5, color: "primary", fontSize: 14, fontWeight: 600, children: status === stores_1.RouteExecutionStatus.Idle
|
|
39
|
+
? t('button.learnMore')
|
|
40
|
+
: t('button.viewCoverage') }) })] })] }) })] }));
|
|
25
41
|
};
|
|
26
42
|
exports.InsuranceCard = InsuranceCard;
|
|
@@ -19,7 +19,7 @@ const InsuranceCollapsed = ({ status, insurableRouteId, insuranceCoverageId, fee
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
});
|
|
22
|
-
const toggleInsurance = (
|
|
22
|
+
const toggleInsurance = (checked) => {
|
|
23
23
|
if (insuredRoute) {
|
|
24
24
|
if (checked) {
|
|
25
25
|
setExecutableRoute(insuredRoute, insurableRouteId);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { BoxProps } from '@mui/material';
|
|
3
2
|
import type { RouteExecutionStatus } from '../../stores';
|
|
4
3
|
export interface InsuranceProps extends Omit<BoxProps, 'onChange'> {
|
|
@@ -12,5 +11,5 @@ export interface InsuranceCardProps {
|
|
|
12
11
|
feeAmountUsd?: string;
|
|
13
12
|
status?: RouteExecutionStatus;
|
|
14
13
|
insuranceCoverageId?: string;
|
|
15
|
-
onChange?: (
|
|
14
|
+
onChange?: (checked: boolean) => void;
|
|
16
15
|
}
|
|
@@ -9,7 +9,7 @@ const react_i18next_1 = require("react-i18next");
|
|
|
9
9
|
const providers_1 = require("../../providers");
|
|
10
10
|
const Token_1 = require("../Token");
|
|
11
11
|
const NFT_style_1 = require("./NFT.style");
|
|
12
|
-
const NFT = ({ imageUrl, isLoading,
|
|
12
|
+
const NFT = ({ imageUrl, isLoading, collectionName, assetName, owner, token, contract, ...props }) => {
|
|
13
13
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
14
14
|
const { setValue } = (0, react_hook_form_1.useFormContext)();
|
|
15
15
|
(0, react_1.useEffect)(() => {
|
|
@@ -24,6 +24,6 @@ const NFT = ({ imageUrl, isLoading, collectonName, assetName, owner, token, cont
|
|
|
24
24
|
setValue(providers_1.SwapFormKey.ToContractGasLimit, contract.gasLimit);
|
|
25
25
|
}
|
|
26
26
|
}, [contract, setValue, token]);
|
|
27
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { p: 2, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", children: [isLoading ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { width: 96, height: 96, variant: "rectangular", sx: { borderRadius: 1 } })) : ((0, jsx_runtime_1.jsx)(NFT_style_1.PreviewAvatar, { src: imageUrl })), (0, jsx_runtime_1.jsxs)(material_1.Box, { ml: 2, children: [isLoading ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { width: 144, height: 21, variant: "text" })) : ((0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 14, color: "text.secondary", children:
|
|
27
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { p: 2, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", children: [isLoading ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { width: 96, height: 96, variant: "rectangular", sx: { borderRadius: 1 } })) : ((0, jsx_runtime_1.jsx)(NFT_style_1.PreviewAvatar, { src: imageUrl })), (0, jsx_runtime_1.jsxs)(material_1.Box, { ml: 2, children: [isLoading ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { width: 144, height: 21, variant: "text" })) : ((0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 14, color: "text.secondary", children: collectionName })), isLoading ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { width: 112, height: 27, variant: "text" })) : ((0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 18, fontWeight: 600, children: assetName })), isLoading ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { width: 128, height: 21, variant: "text" })) : owner ? ((0, jsx_runtime_1.jsxs)(material_1.Typography, { fontSize: 14, color: "text.secondary", children: [t('swap.ownedBy'), ' ', (0, jsx_runtime_1.jsx)(material_1.Link, { href: owner.url, target: "_blank", underline: "none", color: "primary", children: owner.name })] })) : null] })] }), (0, jsx_runtime_1.jsx)(Token_1.Token, { token: token, isLoading: isLoading, mt: 2 })] }));
|
|
28
28
|
};
|
|
29
29
|
exports.NFT = NFT;
|
|
@@ -8,7 +8,6 @@ const version_1 = require("../../config/version");
|
|
|
8
8
|
const providers_1 = require("../../providers");
|
|
9
9
|
const types_1 = require("../../types");
|
|
10
10
|
const utils_1 = require("../../utils");
|
|
11
|
-
const LiFiLogo_1 = require("../LiFiLogo");
|
|
12
11
|
const PoweredBy_style_1 = require("./PoweredBy.style");
|
|
13
12
|
const PoweredBy = () => {
|
|
14
13
|
const { hiddenUI } = (0, providers_1.useWidgetConfig)();
|
|
@@ -17,10 +16,10 @@ const PoweredBy = () => {
|
|
|
17
16
|
pathname.includes(utils_1.navigationRoutes.toToken)) {
|
|
18
17
|
return null;
|
|
19
18
|
}
|
|
20
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Box, { px: 3,
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Box, { px: 3, pt: 1, pb: hiddenUI?.includes(types_1.HiddenUI.PoweredBy) ? 1 : 2, sx: {
|
|
21
20
|
display: 'flex',
|
|
22
21
|
alignItems: 'flex-end',
|
|
23
22
|
justifyContent: 'flex-end',
|
|
24
|
-
}, children: !hiddenUI?.includes(types_1.HiddenUI.PoweredBy) ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: `v${version_1.version}`, placement: "top", enterDelay:
|
|
23
|
+
}, children: !hiddenUI?.includes(types_1.HiddenUI.PoweredBy) ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: `v${version_1.version}`, placement: "top", enterDelay: 1000, arrow: true, children: (0, jsx_runtime_1.jsxs)(PoweredBy_style_1.Link, { href: "https://li.fi", target: "_blank", underline: "none", color: "text.primary", children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { color: "text.secondary", fontSize: 12, fontWeight: 500, px: 0.5, children: "Powered by" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { color: "text.primary", fontSize: 12, fontWeight: 500, children: "LI.FI" })] }) })) : null }));
|
|
25
24
|
};
|
|
26
25
|
exports.PoweredBy = PoweredBy;
|
|
@@ -35,7 +35,7 @@ const SelectTokenButton = ({ formType, compact }) => {
|
|
|
35
35
|
? t(`header.selectChain`)
|
|
36
36
|
: t(`swap.selectChainAndToken`);
|
|
37
37
|
const cardTitle = formType === 'from' && variant === 'nft'
|
|
38
|
-
? t(`
|
|
38
|
+
? t(`header.payWith`)
|
|
39
39
|
: t(`swap.${formType}`);
|
|
40
40
|
return ((0, jsx_runtime_1.jsxs)(Card_1.Card, { flex: 1, onClick: onClick, children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: cardTitle }), chainId && tokenAddress && (isChainLoading || isTokenLoading) ? ((0, jsx_runtime_1.jsx)(SelectTokenButton_style_1.SelectTokenCardHeader, { avatar: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "circular", width: 32, height: 32 }), title: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 64, height: 24 }), subheader: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 64, height: 16 }), compact: compact })) : ((0, jsx_runtime_1.jsx)(SelectTokenButton_style_1.SelectTokenCardHeader, { avatar: isSelected ? ((0, jsx_runtime_1.jsx)(TokenAvatar_1.TokenAvatar, { token: token, chain: chain })) : ((0, jsx_runtime_1.jsx)(TokenAvatar_1.TokenAvatarDefault, {})), title: isSelected ? token.symbol : defaultPlaceholder, subheader: isSelected ? t(`swap.onChain`, { chainName: chain.name }) : null, selected: isSelected, compact: compact }))] }));
|
|
41
41
|
};
|
|
@@ -8,6 +8,7 @@ const Card_1 = require("../../components/Card");
|
|
|
8
8
|
const StepActions_1 = require("../../components/StepActions");
|
|
9
9
|
const Token_1 = require("../../components/Token");
|
|
10
10
|
const hooks_1 = require("../../hooks");
|
|
11
|
+
const providers_1 = require("../../providers");
|
|
11
12
|
const utils_1 = require("../../utils");
|
|
12
13
|
const DestinationWalletAddress_1 = require("./DestinationWalletAddress");
|
|
13
14
|
const GasStepProcess_1 = require("./GasStepProcess");
|
|
@@ -16,6 +17,7 @@ const StepTimer_1 = require("./StepTimer");
|
|
|
16
17
|
const Step = ({ step, fromToken, toToken, toAddress }) => {
|
|
17
18
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
18
19
|
const { getChainById } = (0, hooks_1.useChains)();
|
|
20
|
+
const { variant } = (0, providers_1.useWidgetConfig)();
|
|
19
21
|
const stepHasError = step.execution?.process.some((process) => process.status === 'FAILED');
|
|
20
22
|
const getCardTitle = () => {
|
|
21
23
|
switch (step.type) {
|
|
@@ -23,14 +25,22 @@ const Step = ({ step, fromToken, toToken, toAddress }) => {
|
|
|
23
25
|
const hasCrossStep = step.includedSteps.some((step) => step.type === 'cross');
|
|
24
26
|
const hasSwapStep = step.includedSteps.some((step) => step.type === 'swap');
|
|
25
27
|
if (hasCrossStep && hasSwapStep) {
|
|
26
|
-
return
|
|
28
|
+
return variant === 'nft'
|
|
29
|
+
? t('swap.stepBridgeAndBuy')
|
|
30
|
+
: t('swap.stepSwapAndBridge');
|
|
27
31
|
}
|
|
28
32
|
if (hasCrossStep) {
|
|
29
|
-
return
|
|
33
|
+
return variant === 'nft'
|
|
34
|
+
? t('swap.stepBridgeAndBuy')
|
|
35
|
+
: t('swap.stepBridge');
|
|
30
36
|
}
|
|
31
|
-
return
|
|
37
|
+
return variant === 'nft'
|
|
38
|
+
? t('swap.stepSwapAndBuy')
|
|
39
|
+
: t('swap.stepSwap');
|
|
32
40
|
default:
|
|
33
|
-
return
|
|
41
|
+
return variant === 'nft'
|
|
42
|
+
? t('swap.stepSwapAndBuy')
|
|
43
|
+
: t('swap.stepSwap');
|
|
34
44
|
}
|
|
35
45
|
};
|
|
36
46
|
const formattedToAddress = (0, utils_1.shortenWalletAddress)(toAddress);
|
|
@@ -18,27 +18,13 @@ const SmallAvatar_1 = require("../SmallAvatar");
|
|
|
18
18
|
const StepActions_style_1 = require("./StepActions.style");
|
|
19
19
|
const StepActions = ({ step, dense, ...other }) => {
|
|
20
20
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
21
|
-
const { variant
|
|
21
|
+
const { variant } = (0, providers_1.useWidgetConfig)();
|
|
22
22
|
const [cardExpanded, setCardExpanded] = (0, react_1.useState)(false);
|
|
23
23
|
const handleExpand = (e) => {
|
|
24
24
|
e.stopPropagation();
|
|
25
25
|
setCardExpanded((expanded) => !expanded);
|
|
26
26
|
};
|
|
27
|
-
const customStep = variant === 'nft'
|
|
28
|
-
? step.includedSteps?.find((step) => step.type === 'custom')
|
|
29
|
-
: undefined;
|
|
30
27
|
const hasCollapsedSteps = dense && step.includedSteps?.length > 1;
|
|
31
|
-
if (customStep && contractTool) {
|
|
32
|
-
const toolDetails = {
|
|
33
|
-
key: contractTool.name,
|
|
34
|
-
name: contractTool.name,
|
|
35
|
-
logoURI: contractTool.logoURI,
|
|
36
|
-
};
|
|
37
|
-
customStep.toolDetails = toolDetails;
|
|
38
|
-
if (dense) {
|
|
39
|
-
step.toolDetails = toolDetails;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
28
|
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { ...other, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", alignItems: "center", children: [(0, jsx_runtime_1.jsx)(material_1.Badge, { overlap: "circular", anchorOrigin: { vertical: 'bottom', horizontal: 'right' }, badgeContent: (0, jsx_runtime_1.jsx)(SmallAvatar_1.SmallAvatar, { children: (0, jsx_runtime_1.jsx)(icons_1.LiFiToolLogo, {}) }), children: (0, jsx_runtime_1.jsx)(StepActions_style_1.StepAvatar, { variant: "circular", src: step.toolDetails.logoURI, alt: step.toolDetails.name, children: step.toolDetails.name[0] }) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { ml: 2, fontSize: 18, fontWeight: "500", flex: 1, children: t(`swap.stepDetails`, {
|
|
43
29
|
tool: step.toolDetails.name,
|
|
44
30
|
}) }), hasCollapsedSteps ? ((0, jsx_runtime_1.jsx)(Card_1.CardIconButton, { onClick: handleExpand, size: "small", children: cardExpanded ? (0, jsx_runtime_1.jsx)(ExpandLess_1.default, {}) : (0, jsx_runtime_1.jsx)(ExpandMore_1.default, {}) })) : null] }), hasCollapsedSteps ? ((0, jsx_runtime_1.jsx)(material_1.Collapse, { timeout: 225, in: cardExpanded, mountOnEnter: true, unmountOnExit: true, children: (0, jsx_runtime_1.jsx)(exports.IncludedSteps, { step: step, variant: variant }) })) : ((0, jsx_runtime_1.jsx)(exports.IncludedSteps, { step: step, variant: variant }))] }));
|
|
@@ -74,10 +60,7 @@ const StepDetailsContent = ({ step, variant }) => {
|
|
|
74
60
|
else {
|
|
75
61
|
fromAmount = (0, utils_1.formatTokenAmount)(step.estimate.fromAmount, step.action.fromToken.decimals);
|
|
76
62
|
}
|
|
77
|
-
const showToAmount = step.type !== 'custom' &&
|
|
78
|
-
step.tool !== 'custom' &&
|
|
79
|
-
variant !== 'nft' &&
|
|
80
|
-
!sameTokenProtocolStep;
|
|
63
|
+
const showToAmount = step.type !== 'custom' && step.tool !== 'custom' && !sameTokenProtocolStep;
|
|
81
64
|
return ((0, jsx_runtime_1.jsxs)(material_1.Typography, { fontSize: 12, fontWeight: "500", color: "text.secondary", alignItems: "center", display: "flex", children: [t('format.number', {
|
|
82
65
|
value: fromAmount,
|
|
83
66
|
}), ' ', step.action.fromToken.symbol, showToAmount ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ArrowForward_1.default, { sx: { fontSize: 18, paddingX: 0.5 } }), t('format.number', {
|
|
@@ -28,14 +28,26 @@ const SwapButton = ({ onClick, hasRoute, text, disabled, loading, }) => {
|
|
|
28
28
|
const getButtonText = () => {
|
|
29
29
|
if (account.isActive) {
|
|
30
30
|
if (!hasRoute) {
|
|
31
|
-
|
|
31
|
+
switch (variant) {
|
|
32
|
+
case 'nft':
|
|
33
|
+
return t(`button.buy`);
|
|
34
|
+
case 'refuel':
|
|
35
|
+
return t(`button.getGas`);
|
|
36
|
+
default:
|
|
37
|
+
return t(`button.swap`);
|
|
38
|
+
}
|
|
32
39
|
}
|
|
33
40
|
if (text) {
|
|
34
41
|
return text;
|
|
35
42
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
switch (variant) {
|
|
44
|
+
case 'nft':
|
|
45
|
+
return t(`button.reviewPurchase`);
|
|
46
|
+
case 'refuel':
|
|
47
|
+
return t(`button.reviewGasSwap`);
|
|
48
|
+
default:
|
|
49
|
+
return t(`button.reviewSwap`);
|
|
50
|
+
}
|
|
39
51
|
}
|
|
40
52
|
return t(`button.connectWallet`);
|
|
41
53
|
};
|
|
@@ -25,9 +25,12 @@ const SwapRouteCard = ({ route, active, variant = 'default', expanded, ...other
|
|
|
25
25
|
const token = widgetVariant === 'nft'
|
|
26
26
|
? { ...route.fromToken, amount: route.fromAmount }
|
|
27
27
|
: { ...route.toToken, amount: route.toAmount };
|
|
28
|
-
const cardContent = ((0, jsx_runtime_1.jsxs)(material_1.Box, { flex: 1, children: [widgetVariant !== 'refuel' && (insurable || route.tags?.length) ? ((0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", alignItems: "center", mb: 2, children: [insurable ? ((0, jsx_runtime_1.jsxs)(
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
const cardContent = ((0, jsx_runtime_1.jsxs)(material_1.Box, { flex: 1, children: [widgetVariant !== 'refuel' && (insurable || route.tags?.length) ? ((0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", alignItems: "center", mb: 2, children: [insurable ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "span", children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 12, children: t('swap.insurance.insure') }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
29
|
+
listStyleType: 'disc',
|
|
30
|
+
pl: 2,
|
|
31
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 12, display: "list-item", children: t('swap.insurance.bridgeExploits') }), (0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 12, display: "list-item", children: t('swap.insurance.slippageError') })] })] }), placement: "top", enterDelay: 400, arrow: true, children: (0, jsx_runtime_1.jsxs)(Card_1.CardLabel, { type: route.tags?.length && !cardExpanded
|
|
32
|
+
? 'insurance-icon'
|
|
33
|
+
: 'insurance', children: [(0, jsx_runtime_1.jsx)(VerifiedUser_1.default, { fontSize: "inherit" }), cardExpanded || !route.tags?.length ? ((0, jsx_runtime_1.jsx)(Card_1.CardLabelTypography, { type: "icon", children: t(`swap.tags.insurable`) })) : null] }) })) : null, route.tags?.length ? ((0, jsx_runtime_1.jsx)(Card_1.CardLabel, { type: active ? 'active' : undefined, children: (0, jsx_runtime_1.jsx)(Card_1.CardLabelTypography, { children: t(`swap.tags.${route.tags[0].toLowerCase()}`) }) })) : null] })) : null, (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", justifyContent: "space-between", alignItems: "start", children: [(0, jsx_runtime_1.jsx)(Token_1.Token, { token: token, step: !cardExpanded ? route.steps[0] : undefined }), !expanded ? ((0, jsx_runtime_1.jsx)(Card_1.CardIconButton, { onClick: handleExpand, size: "small", children: cardExpanded ? (0, jsx_runtime_1.jsx)(ExpandLess_1.default, {}) : (0, jsx_runtime_1.jsx)(ExpandMore_1.default, {}) })) : null] }), (0, jsx_runtime_1.jsx)(material_1.Collapse, { timeout: 225, in: cardExpanded, mountOnEnter: true, unmountOnExit: true, children: route.steps.map((step) => ((0, jsx_runtime_1.jsx)(StepActions_1.StepActions, { step: step, mt: 2 }, step.id))) }), (0, jsx_runtime_1.jsx)(SwapRouteCardEssentials_1.SwapRouteCardEssentials, { route: route })] }));
|
|
31
34
|
return widgetVariant === 'refuel' || variant === 'cardless' ? (cardContent) : ((0, jsx_runtime_1.jsx)(Card_1.Card, { variant: active ? 'selected' : 'default', selectionColor: "secondary", indented: true, ...other, children: cardContent }));
|
|
32
35
|
};
|
|
33
36
|
exports.SwapRouteCard = SwapRouteCard;
|
|
@@ -18,7 +18,7 @@ const SwapRouteCardEssentials = ({ route, dense }) => {
|
|
|
18
18
|
const gasCostUSD = parseFloat(route.gasCostUSD ?? '') || 0.01;
|
|
19
19
|
const gasCosts = (0, utils_1.getGasCostsBreakdown)(route);
|
|
20
20
|
const feeCosts = (0, utils_1.getFeeCostsBreakdown)(route, false);
|
|
21
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", justifyContent: 'space-between', flex: 1, mt: 2, children: [(0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "span", children: [t(`tooltip.estimatedNetworkFee`), gasCosts.map((gas, index) => ((0, jsx_runtime_1.jsxs)(material_1.Typography, { fontSize:
|
|
21
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", justifyContent: 'space-between', flex: 1, mt: 2, children: [(0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "span", children: [t(`tooltip.estimatedNetworkFee`), gasCosts.map((gas, index) => ((0, jsx_runtime_1.jsxs)(material_1.Typography, { fontSize: 12, children: [gas.amount?.toFixed(9), " ", gas.token.symbol, " (", t(`format.currency`, { value: gas.amountUSD }), ")"] }, `${gas.token.address}${index}`)))] }), placement: "top", enterDelay: 400, arrow: true, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_style_1.IconTypography, { children: (0, jsx_runtime_1.jsx)(EvStation_1.default, { fontSize: "small" }) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t(`format.currency`, { value: gasCostUSD }) })] }) }), (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "span", children: [t(`tooltip.additionalProviderFee`), feeCosts.map((fee, index) => ((0, jsx_runtime_1.jsxs)(material_1.Typography, { fontSize: 12, children: [fee.amount?.toFixed(9), " ", fee.token.symbol, " (", t(`format.currency`, { value: fee.amountUSD }), ")"] }, `${fee.token.address}${index}`)))] }), placement: "top", enterDelay: 400, arrow: true, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_style_1.IconTypography, { children: (0, jsx_runtime_1.jsx)(MonetizationOn_1.default, { fontSize: "small" }) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t(`format.currency`, {
|
|
22
22
|
value: feeCosts.reduce((sum, feeCost) => sum + feeCost.amountUSD, 0),
|
|
23
23
|
}) })] }) }), (0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: t(`tooltip.estimatedTime`), placement: "top", enterDelay: 400, arrow: true, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_style_1.IconTypography, { children: (0, jsx_runtime_1.jsx)(AccessTimeFilled_1.default, { fontSize: "small" }) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t('swap.estimatedTime', {
|
|
24
24
|
value: executionTimeMinutes,
|
|
@@ -7,7 +7,7 @@ const providers_1 = require("../../providers");
|
|
|
7
7
|
const Card_1 = require("../Card");
|
|
8
8
|
const SwapRouteCardSkeleton = ({ variant, ...other }) => {
|
|
9
9
|
const { variant: widgetVariant } = (0, providers_1.useWidgetConfig)();
|
|
10
|
-
const cardContent = ((0, jsx_runtime_1.jsxs)(material_1.Box, { flex: 1, children: [widgetVariant !== 'refuel' ? ((0, jsx_runtime_1.jsx)(material_1.Box, { display: "flex", alignItems: "center", mb: 2, children: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "rectangular", width: 112, height: 24, sx: (theme) => ({
|
|
10
|
+
const cardContent = ((0, jsx_runtime_1.jsxs)(material_1.Box, { flex: 1, children: [widgetVariant !== 'refuel' && widgetVariant !== 'nft' ? ((0, jsx_runtime_1.jsx)(material_1.Box, { display: "flex", alignItems: "center", mb: 2, children: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "rectangular", width: 112, height: 24, sx: (theme) => ({
|
|
11
11
|
borderRadius: `${theme.shape.borderRadius}px`,
|
|
12
12
|
}) }) })) : null, (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { display: "flex", alignItems: "center", children: [(0, jsx_runtime_1.jsx)(material_1.Box, { mr: 2, children: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "circular", width: 32, height: 32 }) }), (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 96, height: 32 })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { ml: 6, display: "flex", alignItems: "center", children: [(0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 102, height: 16 }), (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 72, height: 16, sx: { marginLeft: 1 } })] })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { mt: 2, display: "flex", justifyContent: "space-between", children: [(0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 64, height: 20 }), (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 64, height: 20 }), (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 48, height: 20 }), (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 32, height: 20 })] })] }));
|
|
13
13
|
return widgetVariant === 'refuel' || variant === 'cardless' ? (cardContent) : ((0, jsx_runtime_1.jsx)(Card_1.Card, { indented: true, ...other, children: cardContent }));
|
|
@@ -28,7 +28,7 @@ const SwapRoutes = (props) => {
|
|
|
28
28
|
const routeNotFound = !currentRoute && !isLoading && !isFetching;
|
|
29
29
|
const onlyRecommendedRoute = variant === 'refuel' || useRecommendedRoute;
|
|
30
30
|
const showAll = !onlyRecommendedRoute && !routeNotFound && (routes?.length ?? 0) > 1;
|
|
31
|
-
return ((0, jsx_runtime_1.jsxs)(Card_1.Card, { ...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: {
|
|
31
|
+
return ((0, jsx_runtime_1.jsxs)(Card_1.Card, { ...props, children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: variant === 'nft' ? t('swap.fromAmount') : t('header.routes') }), (0, jsx_runtime_1.jsx)(ProgressToNextUpdate_1.ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: {
|
|
32
32
|
position: 'absolute',
|
|
33
33
|
top: 8,
|
|
34
34
|
right: 8,
|
|
@@ -23,7 +23,7 @@ const SwapRoutesExpandedElement = () => {
|
|
|
23
23
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
24
24
|
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
25
25
|
const setExecutableRoute = (0, stores_1.useSetExecutableRoute)();
|
|
26
|
-
const { containerStyle } = (0, providers_1.useWidgetConfig)();
|
|
26
|
+
const { variant, containerStyle } = (0, providers_1.useWidgetConfig)();
|
|
27
27
|
const { isValid, isValidating } = (0, react_hook_form_1.useFormState)();
|
|
28
28
|
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = (0, hooks_1.useSwapRoutes)();
|
|
29
29
|
const currentRoute = routes?.[0];
|
|
@@ -37,6 +37,6 @@ const SwapRoutesExpandedElement = () => {
|
|
|
37
37
|
};
|
|
38
38
|
const expanded = Boolean(currentRoute || isLoading || isFetching || isFetched);
|
|
39
39
|
const routeNotFound = !currentRoute && !isLoading && !isFetching && expanded;
|
|
40
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Collapse, { timeout: timeout.enter, in: expanded, orientation: "horizontal", children: (0, jsx_runtime_1.jsx)(material_1.Grow, { timeout: timeout.enter, in: expanded, mountOnEnter: true, unmountOnExit: true, children: (0, jsx_runtime_1.jsx)(SwapRoutesExpanded_style_1.Container, { sx: containerStyle, enableColorScheme: true, children: (0, jsx_runtime_1.jsxs)(SwapRoutesExpanded_style_1.ScrollableContainer, { children: [(0, jsx_runtime_1.jsxs)(SwapRoutesExpanded_style_1.Header, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { 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, { direction: "column", spacing: 2, flex: 1, paddingX: 3, paddingBottom: 3, children: routeNotFound ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteNotFoundCard, {})) : isLoading || (isFetching && !routes?.length) ? (Array.from({ length: 3 }).map((_, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, {}, index)))) : (routes?.map((route, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, expanded: routes?.length <= 2 }, route.id)))) })] }) }) }) }));
|
|
40
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Collapse, { timeout: timeout.enter, in: expanded, orientation: "horizontal", children: (0, jsx_runtime_1.jsx)(material_1.Grow, { timeout: timeout.enter, in: expanded, mountOnEnter: true, unmountOnExit: true, children: (0, jsx_runtime_1.jsx)(SwapRoutesExpanded_style_1.Container, { sx: containerStyle, enableColorScheme: true, children: (0, jsx_runtime_1.jsxs)(SwapRoutesExpanded_style_1.ScrollableContainer, { children: [(0, jsx_runtime_1.jsxs)(SwapRoutesExpanded_style_1.Header, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 18, fontWeight: "700", flex: 1, noWrap: true, children: variant === 'nft' ? t('swap.fromAmount') : t('header.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, { direction: "column", spacing: 2, flex: 1, paddingX: 3, paddingBottom: 3, children: routeNotFound ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteNotFoundCard, {})) : isLoading || (isFetching && !routes?.length) ? (Array.from({ length: 3 }).map((_, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, {}, index)))) : (routes?.map((route, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, expanded: routes?.length <= 2 }, route.id)))) })] }) }) }) }));
|
|
41
41
|
};
|
|
42
42
|
exports.SwapRoutesExpandedElement = SwapRoutesExpandedElement;
|
|
@@ -17,7 +17,7 @@ const Token = ({ token, ...other }) => {
|
|
|
17
17
|
return (0, jsx_runtime_1.jsx)(exports.TokenBase, { token: token, ...other });
|
|
18
18
|
};
|
|
19
19
|
exports.Token = Token;
|
|
20
|
-
const TokenFallback = ({ token,
|
|
20
|
+
const TokenFallback = ({ token, isLoading, ...other }) => {
|
|
21
21
|
const { token: chainToken, isLoading: isLoadingToken } = (0, hooks_1.useToken)(token?.chainId, token?.address);
|
|
22
22
|
return ((0, jsx_runtime_1.jsx)(exports.TokenBase, { token: { ...token, ...chainToken }, isLoading: isLoading || isLoadingToken, ...other }));
|
|
23
23
|
};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { Chain,
|
|
2
|
+
import type { Chain, StaticToken } from '@lifi/sdk';
|
|
3
3
|
import type { SxProps, Theme } from '@mui/material';
|
|
4
4
|
export declare const TokenAvatarFallback: React.FC<{
|
|
5
|
-
token?:
|
|
5
|
+
token?: StaticToken;
|
|
6
6
|
isLoading?: boolean;
|
|
7
7
|
sx?: SxProps<Theme>;
|
|
8
8
|
}>;
|
|
9
9
|
export declare const TokenAvatarBase: React.FC<{
|
|
10
|
-
token?:
|
|
10
|
+
token?: StaticToken;
|
|
11
11
|
chain?: Chain;
|
|
12
12
|
isLoading?: boolean;
|
|
13
13
|
sx?: SxProps<Theme>;
|
|
14
14
|
}>;
|
|
15
15
|
export declare const TokenAvatar: React.FC<{
|
|
16
|
-
token?:
|
|
16
|
+
token?: StaticToken;
|
|
17
17
|
chain?: Chain;
|
|
18
18
|
isLoading?: boolean;
|
|
19
19
|
sx?: SxProps<Theme>;
|
|
@@ -8,8 +8,8 @@ const react_hook_form_1 = require("react-hook-form");
|
|
|
8
8
|
const hooks_1 = require("../../hooks");
|
|
9
9
|
const providers_1 = require("../../providers");
|
|
10
10
|
const TokenNotFound_1 = require("./TokenNotFound");
|
|
11
|
-
const useTokenSelect_1 = require("./useTokenSelect");
|
|
12
11
|
const VirtualizedTokenList_1 = require("./VirtualizedTokenList");
|
|
12
|
+
const useTokenSelect_1 = require("./useTokenSelect");
|
|
13
13
|
const TokenList = ({ formType, height, onClick, }) => {
|
|
14
14
|
const parentRef = (0, react_1.useRef)(null);
|
|
15
15
|
const { account } = (0, providers_1.useWallet)();
|
|
@@ -18,7 +18,9 @@ const TokenList = ({ formType, height, onClick, }) => {
|
|
|
18
18
|
});
|
|
19
19
|
const [tokenSearchFilter] = (0, hooks_1.useDebouncedWatch)([providers_1.SwapFormKey.TokenSearchFilter], 320);
|
|
20
20
|
const { tokens: chainTokens, tokensWithBalance, isLoading: isTokensLoading, isBalanceLoading, featuredTokens, } = (0, hooks_1.useTokenBalances)(selectedChainId);
|
|
21
|
-
let filteredTokens = (tokensWithBalance ??
|
|
21
|
+
let filteredTokens = (tokensWithBalance ??
|
|
22
|
+
chainTokens ??
|
|
23
|
+
[]);
|
|
22
24
|
const searchFilter = tokenSearchFilter?.toUpperCase() ?? '';
|
|
23
25
|
filteredTokens = tokenSearchFilter
|
|
24
26
|
? filteredTokens.filter((token) => token.name.toUpperCase().includes(searchFilter) ||
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import type { TokenAmount } from '@lifi/sdk';
|
|
2
1
|
import type { MutableRefObject } from 'react';
|
|
3
2
|
import type { SwapFormType } from '../../providers';
|
|
4
|
-
import type {
|
|
3
|
+
import type { TokenAmount } from '../../types';
|
|
5
4
|
export interface TokenListProps {
|
|
6
5
|
formType: SwapFormType;
|
|
7
6
|
height: number;
|
|
8
7
|
onClick?(): void;
|
|
9
8
|
}
|
|
10
9
|
export interface VirtualizedTokenListProps {
|
|
11
|
-
tokens:
|
|
10
|
+
tokens: TokenAmount[];
|
|
12
11
|
featuredTokensLength?: number;
|
|
13
12
|
scrollElementRef: MutableRefObject<HTMLElement | null>;
|
|
14
13
|
isLoading: boolean;
|
package/cjs/config/theme.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createTheme = void 0;
|
|
4
4
|
const LoadingButton_1 = require("@mui/lab/LoadingButton");
|
|
5
5
|
const ButtonBase_1 = require("@mui/material/ButtonBase");
|
|
6
|
-
const colors_1 = require("@mui/material/colors");
|
|
7
6
|
const DialogActions_1 = require("@mui/material/DialogActions");
|
|
7
|
+
const colors_1 = require("@mui/material/colors");
|
|
8
8
|
const styles_1 = require("@mui/material/styles");
|
|
9
9
|
const system_1 = require("@mui/system");
|
|
10
10
|
const palette = {
|
|
@@ -226,6 +226,19 @@ const createTheme = (mode, theme = {}) => {
|
|
|
226
226
|
}),
|
|
227
227
|
},
|
|
228
228
|
},
|
|
229
|
+
MuiTooltip: {
|
|
230
|
+
styleOverrides: {
|
|
231
|
+
tooltip: ({ theme }) => ({
|
|
232
|
+
backgroundColor: 'rgb(0 0 0 / 64%)',
|
|
233
|
+
backdropFilter: 'blur(3px)',
|
|
234
|
+
fontSize: '0.75rem',
|
|
235
|
+
padding: theme.spacing(1, 1.5),
|
|
236
|
+
}),
|
|
237
|
+
arrow: {
|
|
238
|
+
color: 'rgb(0 0 0 / 64%)',
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
},
|
|
229
242
|
},
|
|
230
243
|
});
|
|
231
244
|
};
|
package/cjs/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "2.0.0-beta.
|
|
2
|
+
export declare const version = "2.0.0-beta.4";
|
package/cjs/config/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useFeaturedTokens: (selectedChainId?: number) => import("@lifi/types").
|
|
1
|
+
export declare const useFeaturedTokens: (selectedChainId?: number) => import("@lifi/types").StaticToken[] | undefined;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { EVMChain, LifiStep, Process } from '@lifi/sdk';
|
|
2
2
|
import type { TFunction } from 'i18next';
|
|
3
|
+
import type { WidgetVariant } from '../types';
|
|
3
4
|
export declare const useProcessMessage: (step?: LifiStep, process?: Process) => {
|
|
4
5
|
title?: string | undefined;
|
|
5
6
|
message?: string | undefined;
|
|
6
7
|
};
|
|
7
|
-
export declare function getProcessMessage(t: TFunction, getChainById: (chainId: number) => EVMChain | undefined, step: LifiStep, process: Process): {
|
|
8
|
+
export declare function getProcessMessage(t: TFunction, getChainById: (chainId: number) => EVMChain | undefined, step: LifiStep, process: Process, variant?: WidgetVariant): {
|
|
8
9
|
title?: string;
|
|
9
10
|
message?: string;
|
|
10
11
|
};
|