@lifi/widget 1.27.1 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AppDrawer.style.d.ts +1 -1
- package/AppRoutes.js +15 -33
- package/README.md +1 -1
- package/cjs/AppDrawer.style.d.ts +1 -1
- package/cjs/AppRoutes.js +15 -33
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +1 -1
- package/cjs/components/Card/Card.d.ts +1 -1
- package/cjs/components/ChainSelect/ChainSelect.style.d.ts +1 -1
- package/cjs/components/ContractComponent/ContractComponent.d.ts +3 -0
- package/cjs/components/ContractComponent/ContractComponent.js +14 -0
- package/cjs/components/ContractComponent/index.d.ts +1 -0
- package/cjs/components/ContractComponent/index.js +17 -0
- package/cjs/components/Header/Header.style.d.ts +2 -2
- package/cjs/components/Header/NavigationHeader.js +10 -2
- package/cjs/components/Header/WalletHeader.js +1 -1
- package/cjs/components/NFT/NFT.d.ts +4 -0
- package/cjs/components/NFT/NFT.js +41 -0
- package/cjs/components/NFT/NFT.style.d.ts +16 -0
- package/cjs/components/NFT/NFT.style.js +11 -0
- package/cjs/components/NFT/index.d.ts +2 -0
- package/cjs/components/NFT/index.js +18 -0
- package/cjs/components/NFT/types.d.ts +15 -0
- package/cjs/components/NFT/types.js +2 -0
- package/cjs/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +1 -1
- package/cjs/components/Select.d.ts +1 -1
- package/cjs/components/SelectChainAndToken.js +12 -2
- package/cjs/components/SelectTokenButton/SelectTokenButton.js +5 -2
- package/cjs/components/SendToWallet/SendToWallet.style.d.ts +1 -1
- package/cjs/components/SmallAvatar.d.ts +1 -1
- package/cjs/components/Step/StepProcess.style.d.ts +1 -1
- package/cjs/components/StepActions/StepActions.d.ts +6 -7
- package/cjs/components/StepActions/StepActions.js +41 -12
- package/cjs/components/StepActions/StepActions.style.d.ts +1 -1
- package/cjs/components/StepActions/types.d.ts +5 -0
- package/cjs/components/SwapInput/SwapInput.d.ts +2 -1
- package/cjs/components/SwapInput/SwapInput.js +15 -3
- package/cjs/components/SwapInput/SwapInput.style.d.ts +1 -1
- package/cjs/components/SwapInput/SwapInputAdornment.style.d.ts +1 -1
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +3 -1
- package/cjs/components/SwapRouteCard/SwapRouteCard.style.d.ts +1 -1
- package/cjs/components/Token/Token.d.ts +1 -1
- package/cjs/components/Token/Token.js +12 -12
- package/cjs/components/TokenAvatar/TokenAvatar.d.ts +5 -3
- package/cjs/components/TokenAvatar/TokenAvatar.js +10 -9
- package/cjs/components/TokenList/TokenList.style.js +6 -0
- package/cjs/components/TokenList/VirtualizedTokenList.js +4 -2
- package/cjs/config/theme.js +3 -5
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/useSwapRoutes.d.ts +5 -2
- package/cjs/hooks/useSwapRoutes.js +64 -14
- package/cjs/hooks/useToken.d.ts +1 -1
- package/cjs/hooks/useTokenSearch.d.ts +1 -1
- package/cjs/i18n/de.json +214 -214
- package/cjs/i18n/en.json +218 -214
- package/cjs/i18n/es.json +191 -191
- package/cjs/i18n/fr.json +214 -214
- package/cjs/i18n/it.json +214 -214
- package/cjs/i18n/uk.json +214 -214
- package/cjs/i18n/zh.json +214 -214
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +4 -1
- package/cjs/pages/MainPage/MainPage.js +5 -1
- package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
- package/cjs/pages/SettingsPage/LanguageSelect.js +1 -2
- package/cjs/providers/SwapFormProvider/types.d.ts +10 -0
- package/cjs/providers/SwapFormProvider/types.js +5 -0
- package/cjs/stores/chains/useChainOrderStore.d.ts +1 -1
- package/cjs/stores/routes/useRouteExecutionStore.d.ts +1 -1
- package/cjs/stores/settings/useSettingsStore.d.ts +1 -1
- package/cjs/types/widget.d.ts +12 -6
- package/cjs/types/widget.js +2 -0
- package/components/ActiveSwaps/ActiveSwaps.style.d.ts +1 -1
- package/components/Card/Card.d.ts +1 -1
- package/components/ChainSelect/ChainSelect.style.d.ts +1 -1
- package/components/ContractComponent/ContractComponent.d.ts +3 -0
- package/components/ContractComponent/ContractComponent.js +10 -0
- package/components/ContractComponent/index.d.ts +1 -0
- package/components/ContractComponent/index.js +1 -0
- package/components/Header/Header.style.d.ts +2 -2
- package/components/Header/NavigationHeader.js +12 -4
- package/components/Header/WalletHeader.js +1 -1
- package/components/NFT/NFT.d.ts +4 -0
- package/components/NFT/NFT.js +37 -0
- package/components/NFT/NFT.style.d.ts +16 -0
- package/components/NFT/NFT.style.js +8 -0
- package/components/NFT/index.d.ts +2 -0
- package/components/NFT/index.js +2 -0
- package/components/NFT/types.d.ts +15 -0
- package/components/NFT/types.js +1 -0
- package/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +1 -1
- package/components/Select.d.ts +1 -1
- package/components/SelectChainAndToken.js +12 -2
- package/components/SelectTokenButton/SelectTokenButton.js +5 -2
- package/components/SendToWallet/SendToWallet.style.d.ts +1 -1
- package/components/SmallAvatar.d.ts +1 -1
- package/components/Step/StepProcess.style.d.ts +1 -1
- package/components/StepActions/StepActions.d.ts +6 -7
- package/components/StepActions/StepActions.js +40 -12
- package/components/StepActions/StepActions.style.d.ts +1 -1
- package/components/StepActions/types.d.ts +5 -0
- package/components/SwapInput/SwapInput.d.ts +2 -1
- package/components/SwapInput/SwapInput.js +15 -3
- package/components/SwapInput/SwapInput.style.d.ts +1 -1
- package/components/SwapInput/SwapInputAdornment.style.d.ts +1 -1
- package/components/SwapRouteCard/SwapRouteCard.js +3 -1
- package/components/SwapRouteCard/SwapRouteCard.style.d.ts +1 -1
- package/components/Token/Token.d.ts +1 -1
- package/components/Token/Token.js +13 -13
- package/components/TokenAvatar/TokenAvatar.d.ts +5 -3
- package/components/TokenAvatar/TokenAvatar.js +10 -9
- package/components/TokenList/TokenList.style.js +6 -0
- package/components/TokenList/VirtualizedTokenList.js +4 -2
- package/config/theme.js +3 -5
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/useSwapRoutes.d.ts +5 -2
- package/hooks/useSwapRoutes.js +64 -14
- package/hooks/useToken.d.ts +1 -1
- package/hooks/useTokenSearch.d.ts +1 -1
- package/i18n/de.json +214 -214
- package/i18n/en.json +218 -214
- package/i18n/es.json +191 -191
- package/i18n/fr.json +214 -214
- package/i18n/it.json +214 -214
- package/i18n/uk.json +214 -214
- package/i18n/zh.json +214 -214
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/package.json +15 -13
- package/pages/MainPage/MainPage.js +5 -1
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
- package/pages/SettingsPage/LanguageSelect.js +1 -2
- package/providers/SwapFormProvider/types.d.ts +10 -0
- package/providers/SwapFormProvider/types.js +5 -0
- package/stores/chains/useChainOrderStore.d.ts +1 -1
- package/stores/routes/useRouteExecutionStore.d.ts +1 -1
- package/stores/settings/useSettingsStore.d.ts +1 -1
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/widget.d.ts +12 -6
- package/types/widget.js +2 -0
- package/cjs/fonts/Inter-Black.woff +0 -0
- package/cjs/fonts/Inter-Black.woff2 +0 -0
- package/cjs/fonts/Inter-BlackItalic.woff +0 -0
- package/cjs/fonts/Inter-BlackItalic.woff2 +0 -0
- package/cjs/fonts/Inter-Bold.woff +0 -0
- package/cjs/fonts/Inter-Bold.woff2 +0 -0
- package/cjs/fonts/Inter-BoldItalic.woff +0 -0
- package/cjs/fonts/Inter-BoldItalic.woff2 +0 -0
- package/cjs/fonts/Inter-ExtraBold.woff +0 -0
- package/cjs/fonts/Inter-ExtraBold.woff2 +0 -0
- package/cjs/fonts/Inter-ExtraBoldItalic.woff +0 -0
- package/cjs/fonts/Inter-ExtraBoldItalic.woff2 +0 -0
- package/cjs/fonts/Inter-ExtraLight.woff +0 -0
- package/cjs/fonts/Inter-ExtraLight.woff2 +0 -0
- package/cjs/fonts/Inter-ExtraLightItalic.woff +0 -0
- package/cjs/fonts/Inter-ExtraLightItalic.woff2 +0 -0
- package/cjs/fonts/Inter-Italic.woff +0 -0
- package/cjs/fonts/Inter-Italic.woff2 +0 -0
- package/cjs/fonts/Inter-Light.woff +0 -0
- package/cjs/fonts/Inter-Light.woff2 +0 -0
- package/cjs/fonts/Inter-LightItalic.woff +0 -0
- package/cjs/fonts/Inter-LightItalic.woff2 +0 -0
- package/cjs/fonts/Inter-Medium.woff +0 -0
- package/cjs/fonts/Inter-Medium.woff2 +0 -0
- package/cjs/fonts/Inter-MediumItalic.woff +0 -0
- package/cjs/fonts/Inter-MediumItalic.woff2 +0 -0
- package/cjs/fonts/Inter-Regular.woff +0 -0
- package/cjs/fonts/Inter-Regular.woff2 +0 -0
- package/cjs/fonts/Inter-SemiBold.woff +0 -0
- package/cjs/fonts/Inter-SemiBold.woff2 +0 -0
- package/cjs/fonts/Inter-SemiBoldItalic.woff +0 -0
- package/cjs/fonts/Inter-SemiBoldItalic.woff2 +0 -0
- package/cjs/fonts/Inter-Thin.woff +0 -0
- package/cjs/fonts/Inter-Thin.woff2 +0 -0
- package/cjs/fonts/Inter-ThinItalic.woff +0 -0
- package/cjs/fonts/Inter-ThinItalic.woff2 +0 -0
- package/cjs/fonts/Inter-italic.var.woff2 +0 -0
- package/cjs/fonts/Inter-roman.var.woff2 +0 -0
- package/cjs/fonts/Inter.var.woff2 +0 -0
- package/cjs/fonts/inter.css +0 -200
- package/fonts/Inter-Black.woff +0 -0
- package/fonts/Inter-Black.woff2 +0 -0
- package/fonts/Inter-BlackItalic.woff +0 -0
- package/fonts/Inter-BlackItalic.woff2 +0 -0
- package/fonts/Inter-Bold.woff +0 -0
- package/fonts/Inter-Bold.woff2 +0 -0
- package/fonts/Inter-BoldItalic.woff +0 -0
- package/fonts/Inter-BoldItalic.woff2 +0 -0
- package/fonts/Inter-ExtraBold.woff +0 -0
- package/fonts/Inter-ExtraBold.woff2 +0 -0
- package/fonts/Inter-ExtraBoldItalic.woff +0 -0
- package/fonts/Inter-ExtraBoldItalic.woff2 +0 -0
- package/fonts/Inter-ExtraLight.woff +0 -0
- package/fonts/Inter-ExtraLight.woff2 +0 -0
- package/fonts/Inter-ExtraLightItalic.woff +0 -0
- package/fonts/Inter-ExtraLightItalic.woff2 +0 -0
- package/fonts/Inter-Italic.woff +0 -0
- package/fonts/Inter-Italic.woff2 +0 -0
- package/fonts/Inter-Light.woff +0 -0
- package/fonts/Inter-Light.woff2 +0 -0
- package/fonts/Inter-LightItalic.woff +0 -0
- package/fonts/Inter-LightItalic.woff2 +0 -0
- package/fonts/Inter-Medium.woff +0 -0
- package/fonts/Inter-Medium.woff2 +0 -0
- package/fonts/Inter-MediumItalic.woff +0 -0
- package/fonts/Inter-MediumItalic.woff2 +0 -0
- package/fonts/Inter-Regular.woff +0 -0
- package/fonts/Inter-Regular.woff2 +0 -0
- package/fonts/Inter-SemiBold.woff +0 -0
- package/fonts/Inter-SemiBold.woff2 +0 -0
- package/fonts/Inter-SemiBoldItalic.woff +0 -0
- package/fonts/Inter-SemiBoldItalic.woff2 +0 -0
- package/fonts/Inter-Thin.woff +0 -0
- package/fonts/Inter-Thin.woff2 +0 -0
- package/fonts/Inter-ThinItalic.woff +0 -0
- package/fonts/Inter-ThinItalic.woff2 +0 -0
- package/fonts/Inter-italic.var.woff2 +0 -0
- package/fonts/Inter-roman.var.woff2 +0 -0
- package/fonts/Inter.var.woff2 +0 -0
- package/fonts/inter.css +0 -200
|
@@ -11,25 +11,43 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.SwapStepDetailsLabel = exports.CrossStepDetailsLabel = exports.StepDetailsContent = exports.StepActions = void 0;
|
|
14
|
+
exports.SwapStepDetailsLabel = exports.CrossStepDetailsLabel = exports.CustomStepDetailsLabel = exports.StepDetailsContent = exports.StepActions = void 0;
|
|
15
15
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
16
|
const icons_material_1 = require("@mui/icons-material");
|
|
17
17
|
const material_1 = require("@mui/material");
|
|
18
18
|
const react_i18next_1 = require("react-i18next");
|
|
19
19
|
const hooks_1 = require("../../hooks");
|
|
20
20
|
const icons_1 = require("../../icons");
|
|
21
|
+
const providers_1 = require("../../providers");
|
|
21
22
|
const utils_1 = require("../../utils");
|
|
22
23
|
const SmallAvatar_1 = require("../SmallAvatar");
|
|
23
24
|
const StepActions_style_1 = require("./StepActions.style");
|
|
24
25
|
const StepActions = (_a) => {
|
|
25
|
-
var _b;
|
|
26
|
+
var _b, _c;
|
|
26
27
|
var { step, dense } = _a, other = __rest(_a, ["step", "dense"]);
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
const { variant, contractTool } = (0, providers_1.useWidgetConfig)();
|
|
29
|
+
const StepDetailsLabel = step.tool === 'custom' && variant === 'nft'
|
|
30
|
+
? exports.CustomStepDetailsLabel
|
|
31
|
+
: step.type === 'cross' ||
|
|
32
|
+
(step.type === 'lifi' &&
|
|
33
|
+
step.includedSteps.some((step) => step.type === 'cross'))
|
|
34
|
+
? exports.CrossStepDetailsLabel
|
|
35
|
+
: exports.SwapStepDetailsLabel;
|
|
32
36
|
const isFullView = !dense && ((_b = step.includedSteps) === null || _b === void 0 ? void 0 : _b.length) > 1;
|
|
37
|
+
const customStep = variant === 'nft'
|
|
38
|
+
? (_c = step.includedSteps) === null || _c === void 0 ? void 0 : _c.find((step) => step.type === 'custom')
|
|
39
|
+
: undefined;
|
|
40
|
+
if (customStep && contractTool) {
|
|
41
|
+
const toolDetails = {
|
|
42
|
+
key: contractTool.name,
|
|
43
|
+
name: contractTool.name,
|
|
44
|
+
logoURI: contractTool.logoURI,
|
|
45
|
+
};
|
|
46
|
+
customStep.toolDetails = toolDetails;
|
|
47
|
+
if (!isFullView) {
|
|
48
|
+
step.toolDetails = toolDetails;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
33
51
|
// eslint-disable-next-line react/no-unstable-nested-components
|
|
34
52
|
const StepIconComponent = ({ icon }) => {
|
|
35
53
|
var _a;
|
|
@@ -40,19 +58,30 @@ const StepActions = (_a) => {
|
|
|
40
58
|
};
|
|
41
59
|
return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({}, other, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' }, mb: isFullView ? 1.5 : 0 }, { children: [(0, jsx_runtime_1.jsx)(StepActions_style_1.StepAvatar, Object.assign({ variant: "circular", src: step.type !== 'lifi' ? step.toolDetails.logoURI : undefined, alt: step.toolDetails.name }, { children: step.type === 'lifi' ? (0, jsx_runtime_1.jsx)(icons_1.LiFiToolLogo, {}) : step.toolDetails.name[0] })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ ml: 2, fontSize: 18, fontWeight: "500", textTransform: "capitalize" }, { children: step.type === 'lifi'
|
|
42
60
|
? 'LI.FI Smart Contract'
|
|
43
|
-
: step.toolDetails.name }))] })), isFullView ? ((0, jsx_runtime_1.jsx)(material_1.Stepper, Object.assign({ orientation: "vertical", connector: (0, jsx_runtime_1.jsx)(StepActions_style_1.StepConnector, {}), activeStep: -1 }, { children: step.includedSteps.map((step) => ((0, jsx_runtime_1.jsxs)(material_1.Step, Object.assign({ expanded: true }, { children: [(0, jsx_runtime_1.jsx)(StepActions_style_1.StepLabel, Object.assign({ StepIconComponent: StepIconComponent }, { children: step.type === 'cross' || step.type === 'lifi' ? ((0, jsx_runtime_1.jsx)(exports.CrossStepDetailsLabel, { step: step })) : ((0, jsx_runtime_1.jsx)(exports.SwapStepDetailsLabel, { step: step })) })), (0, jsx_runtime_1.jsx)(StepActions_style_1.StepContent, { children: (0, jsx_runtime_1.jsx)(exports.StepDetailsContent, { step: step }) })] }), step.id))) }))) : ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ ml: 6 }, { children: [(0, jsx_runtime_1.jsx)(StepDetailsLabel, { step: step }), (0, jsx_runtime_1.jsx)(exports.StepDetailsContent, { step: step })] })))] })));
|
|
61
|
+
: step.toolDetails.name }))] })), isFullView ? ((0, jsx_runtime_1.jsx)(material_1.Stepper, Object.assign({ orientation: "vertical", connector: (0, jsx_runtime_1.jsx)(StepActions_style_1.StepConnector, {}), activeStep: -1 }, { children: step.includedSteps.map((step, i) => ((0, jsx_runtime_1.jsxs)(material_1.Step, Object.assign({ expanded: true }, { children: [(0, jsx_runtime_1.jsx)(StepActions_style_1.StepLabel, Object.assign({ StepIconComponent: StepIconComponent }, { children: step.type === 'custom' && variant === 'nft' ? ((0, jsx_runtime_1.jsx)(exports.CustomStepDetailsLabel, { step: step, variant: variant })) : step.type === 'cross' || step.type === 'lifi' ? ((0, jsx_runtime_1.jsx)(exports.CrossStepDetailsLabel, { step: step })) : ((0, jsx_runtime_1.jsx)(exports.SwapStepDetailsLabel, { step: step })) })), (0, jsx_runtime_1.jsx)(StepActions_style_1.StepContent, { children: (0, jsx_runtime_1.jsx)(exports.StepDetailsContent, { step: step, variant: variant }) })] }), step.id))) }))) : ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ ml: 6 }, { children: [(0, jsx_runtime_1.jsx)(StepDetailsLabel, { step: step, variant: variant === 'nft' ? variant : undefined }), (0, jsx_runtime_1.jsx)(exports.StepDetailsContent, { step: step, variant: variant })] })))] })));
|
|
44
62
|
};
|
|
45
63
|
exports.StepActions = StepActions;
|
|
46
|
-
const StepDetailsContent = ({ step }) => {
|
|
64
|
+
const StepDetailsContent = ({ step, variant }) => {
|
|
47
65
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
48
66
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
49
67
|
return ((0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ fontSize: 12, fontWeight: "500", color: "text.secondary", alignItems: "center", display: "flex" }, { children: [t('format.number', {
|
|
50
68
|
value: (0, utils_1.formatTokenAmount)(step.estimate.fromAmount, step.action.fromToken.decimals),
|
|
51
|
-
}), ' ', step.action.fromToken.symbol, (
|
|
52
|
-
|
|
53
|
-
|
|
69
|
+
}), ' ', step.action.fromToken.symbol, !((step.type === 'custom' || step.tool === 'custom') &&
|
|
70
|
+
variant === 'nft') ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(icons_material_1.ArrowForward, { sx: { fontSize: 18, paddingX: 0.5 } }), t('format.number', {
|
|
71
|
+
value: (0, utils_1.formatTokenAmount)((_b = (_a = step.execution) === null || _a === void 0 ? void 0 : _a.toAmount) !== null && _b !== void 0 ? _b : step.estimate.toAmount, (_e = (_d = (_c = step.execution) === null || _c === void 0 ? void 0 : _c.toToken) === null || _d === void 0 ? void 0 : _d.decimals) !== null && _e !== void 0 ? _e : step.action.toToken.decimals),
|
|
72
|
+
}), ' ', (_h = (_g = (_f = step.execution) === null || _f === void 0 ? void 0 : _f.toToken) === null || _g === void 0 ? void 0 : _g.symbol) !== null && _h !== void 0 ? _h : step.action.toToken.symbol] })) : null] })));
|
|
54
73
|
};
|
|
55
74
|
exports.StepDetailsContent = StepDetailsContent;
|
|
75
|
+
const CustomStepDetailsLabel = ({ step, variant, }) => {
|
|
76
|
+
const { t } = (0, react_i18next_1.useTranslation)();
|
|
77
|
+
if (!variant) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: 12, fontWeight: "500", color: "text.secondary" }, { children: t(`swap.${variant}StepDetails`, {
|
|
81
|
+
tool: step.toolDetails.name,
|
|
82
|
+
}) })));
|
|
83
|
+
};
|
|
84
|
+
exports.CustomStepDetailsLabel = CustomStepDetailsLabel;
|
|
56
85
|
const CrossStepDetailsLabel = ({ step }) => {
|
|
57
86
|
var _a, _b;
|
|
58
87
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
@@ -17,4 +17,4 @@ export declare const StepAvatar: import("@emotion/styled").StyledComponent<{
|
|
|
17
17
|
variant?: "square" | "circular" | "rounded" | undefined;
|
|
18
18
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
|
|
19
19
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
20
|
-
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "variant" | "alt" | "
|
|
20
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "variant" | "alt" | "imgProps" | "sizes" | "src" | "srcSet"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { Step } from '@lifi/sdk';
|
|
2
2
|
import type { BoxProps } from '@mui/material';
|
|
3
|
+
import type { WidgetVariant } from '../../types';
|
|
3
4
|
export interface StepActionsProps extends BoxProps {
|
|
4
5
|
step: Step;
|
|
5
6
|
dense?: boolean;
|
|
6
7
|
}
|
|
8
|
+
export interface StepDetailsLabelProps {
|
|
9
|
+
step: Step;
|
|
10
|
+
variant?: Extract<WidgetVariant, 'nft'>;
|
|
11
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import type { BoxProps } from '@mui/material';
|
|
2
3
|
import type { SwapFormTypeProps } from '../../providers';
|
|
3
|
-
export declare const SwapInput: React.FC<SwapFormTypeProps>;
|
|
4
|
+
export declare const SwapInput: React.FC<SwapFormTypeProps & BoxProps>;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.SwapInput = void 0;
|
|
4
15
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
@@ -14,7 +25,8 @@ const FormPriceHelperText_1 = require("./FormPriceHelperText");
|
|
|
14
25
|
const SwapInput_style_1 = require("./SwapInput.style");
|
|
15
26
|
const SwapInputEndAdornment_1 = require("./SwapInputEndAdornment");
|
|
16
27
|
const SwapInputStartAdornment_1 = require("./SwapInputStartAdornment");
|
|
17
|
-
const SwapInput = (
|
|
28
|
+
const SwapInput = (_a) => {
|
|
29
|
+
var { formType } = _a, props = __rest(_a, ["formType"]);
|
|
18
30
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
19
31
|
const amountKey = providers_1.SwapFormKeyHelper.getAmountKey(formType);
|
|
20
32
|
const { field: { onChange, onBlur, value }, } = (0, react_hook_form_1.useController)({
|
|
@@ -34,8 +46,8 @@ const SwapInput = ({ formType }) => {
|
|
|
34
46
|
onBlur();
|
|
35
47
|
};
|
|
36
48
|
const disabled = disabledUI === null || disabledUI === void 0 ? void 0 : disabledUI.includes(types_1.DisabledUI.FromAmount);
|
|
37
|
-
return ((0, jsx_runtime_1.jsxs)(Card_1.Card, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t('swap.fromAmount') }), (0, jsx_runtime_1.jsxs)(SwapInput_style_1.FormControl, Object.assign({ fullWidth: true }, { children: [(0, jsx_runtime_1.jsx)(SwapInput_style_1.Input, { inputRef: ref, size: "small", autoComplete: "off", placeholder: "0", startAdornment: (0, jsx_runtime_1.jsx)(SwapInputStartAdornment_1.SwapInputStartAdornment, { formType: formType }), endAdornment: !disabled ? ((0, jsx_runtime_1.jsx)(SwapInputEndAdornment_1.SwapInputEndAdornment, { formType: formType })) : undefined, inputProps: {
|
|
49
|
+
return ((0, jsx_runtime_1.jsxs)(Card_1.Card, Object.assign({}, props, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t('swap.fromAmount') }), (0, jsx_runtime_1.jsxs)(SwapInput_style_1.FormControl, Object.assign({ fullWidth: true }, { children: [(0, jsx_runtime_1.jsx)(SwapInput_style_1.Input, { inputRef: ref, size: "small", autoComplete: "off", placeholder: "0", startAdornment: (0, jsx_runtime_1.jsx)(SwapInputStartAdornment_1.SwapInputStartAdornment, { formType: formType }), endAdornment: !disabled ? ((0, jsx_runtime_1.jsx)(SwapInputEndAdornment_1.SwapInputEndAdornment, { formType: formType })) : undefined, inputProps: {
|
|
38
50
|
inputMode: 'decimal',
|
|
39
|
-
}, onChange: handleChange, onBlur: handleBlur, value: value, name: amountKey, disabled: disabled, required: true }), (0, jsx_runtime_1.jsx)(FormPriceHelperText_1.FormPriceHelperText, { formType: formType })] })), (0, jsx_runtime_1.jsx)(FitInputText_1.FitInputText, { ref: ref, formType: formType })] }));
|
|
51
|
+
}, onChange: handleChange, onBlur: handleBlur, value: value, name: amountKey, disabled: disabled, required: true }), (0, jsx_runtime_1.jsx)(FormPriceHelperText_1.FormPriceHelperText, { formType: formType })] })), (0, jsx_runtime_1.jsx)(FitInputText_1.FitInputText, { ref: ref, formType: formType })] })));
|
|
40
52
|
};
|
|
41
53
|
exports.SwapInput = SwapInput;
|
|
@@ -4,7 +4,7 @@ export declare const minInputFontSize = 14;
|
|
|
4
4
|
export declare const FormControl: import("@emotion/styled").StyledComponent<{
|
|
5
5
|
children?: import("react").ReactNode;
|
|
6
6
|
classes?: Partial<import("@mui/material").FormControlClasses> | undefined;
|
|
7
|
-
color?: "success" | "warning" | "error" | "
|
|
7
|
+
color?: "success" | "warning" | "error" | "primary" | "secondary" | "info" | undefined;
|
|
8
8
|
disabled?: boolean | undefined;
|
|
9
9
|
error?: boolean | undefined;
|
|
10
10
|
fullWidth?: boolean | undefined;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const Button: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").ButtonClasses> | undefined;
|
|
5
|
-
color?: "inherit" | "success" | "warning" | "error" | "
|
|
5
|
+
color?: "inherit" | "success" | "warning" | "error" | "primary" | "secondary" | "info" | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableElevation?: boolean | undefined;
|
|
8
8
|
disableFocusRipple?: boolean | undefined;
|
|
@@ -37,7 +37,9 @@ const SwapRouteCard = (_a) => {
|
|
|
37
37
|
e.stopPropagation();
|
|
38
38
|
setCardExpanded((expanded) => !expanded);
|
|
39
39
|
};
|
|
40
|
-
const
|
|
40
|
+
const token = widgetVariant === 'nft'
|
|
41
|
+
? Object.assign(Object.assign({}, route.fromToken), { amount: route.fromAmount }) : Object.assign(Object.assign({}, route.toToken), { amount: route.toAmount });
|
|
42
|
+
const cardContent = ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ flex: 1 }, { children: [widgetVariant !== 'refuel' && !useRecommendedRoute ? ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", justifyContent: "space-between", alignItems: "center", mb: 2 }, { children: [(0, jsx_runtime_1.jsx)(SwapRouteCard_style_1.Label, Object.assign({ active: active !== null && active !== void 0 ? active : label !== alternativeTag }, { children: label })), variant === 'stretched' ? ((0, jsx_runtime_1.jsx)(exports.SwapRouteCardEssentials, { route: route })) : null] }))) : null, (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ display: "flex", justifyContent: "space-between", alignItems: "center" }, { children: [(0, jsx_runtime_1.jsx)(Token_1.Token, { token: token, step: variant === 'stretched' ? route.steps[0] : undefined, disableDescription: variant === 'dense' && widgetVariant !== 'refuel' }), variant === 'stretched' && !expanded ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_style_1.IconButton, Object.assign({ onClick: handleExpand, size: "small" }, { children: cardExpanded ? (0, jsx_runtime_1.jsx)(icons_material_1.ExpandLess, {}) : (0, jsx_runtime_1.jsx)(icons_material_1.ExpandMore, {}) }))) : null] })), (0, jsx_runtime_1.jsx)(material_1.Collapse, Object.assign({ 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))) })), variant !== 'stretched' ? ((0, jsx_runtime_1.jsx)(exports.SwapRouteCardEssentials, { route: route, dense: true })) : null] })));
|
|
41
43
|
return widgetVariant === 'refuel' ? (cardContent) : ((0, jsx_runtime_1.jsx)(Card_1.Card, Object.assign({ dense: variant === 'dense', variant: active ? 'selected' : 'default', selectionColor: "secondary", indented: true }, other, { children: cardContent })));
|
|
42
44
|
};
|
|
43
45
|
exports.SwapRouteCard = SwapRouteCard;
|
|
@@ -17,7 +17,7 @@ export declare const Label: import("@emotion/styled").StyledComponent<import("@m
|
|
|
17
17
|
export declare const IconButton: import("@emotion/styled").StyledComponent<{
|
|
18
18
|
children?: import("react").ReactNode;
|
|
19
19
|
classes?: Partial<import("@mui/material").IconButtonClasses> | undefined;
|
|
20
|
-
color?: "inherit" | "default" | "success" | "warning" | "error" | "
|
|
20
|
+
color?: "inherit" | "default" | "success" | "warning" | "error" | "primary" | "secondary" | "info" | undefined;
|
|
21
21
|
disabled?: boolean | undefined;
|
|
22
22
|
disableFocusRipple?: boolean | undefined;
|
|
23
23
|
edge?: false | "end" | "start" | undefined;
|
|
@@ -23,34 +23,34 @@ const TokenAvatar_1 = require("../TokenAvatar");
|
|
|
23
23
|
const Token_style_1 = require("./Token.style");
|
|
24
24
|
const Token = (_a) => {
|
|
25
25
|
var { token } = _a, other = __rest(_a, ["token"]);
|
|
26
|
-
if (!token.priceUSD || !token.logoURI) {
|
|
26
|
+
if (!(token === null || token === void 0 ? void 0 : token.priceUSD) || !token.logoURI) {
|
|
27
27
|
return (0, jsx_runtime_1.jsx)(exports.TokenFallback, Object.assign({ token: token }, other));
|
|
28
28
|
}
|
|
29
29
|
return (0, jsx_runtime_1.jsx)(exports.TokenBase, Object.assign({ token: token }, other));
|
|
30
30
|
};
|
|
31
31
|
exports.Token = Token;
|
|
32
32
|
const TokenFallback = (_a) => {
|
|
33
|
-
var { token, connected, step, disableDescription } = _a, other = __rest(_a, ["token", "connected", "step", "disableDescription"]);
|
|
34
|
-
const { token: chainToken, isLoading } = (0, hooks_1.useToken)(token.chainId, token.address);
|
|
35
|
-
return ((0, jsx_runtime_1.jsx)(exports.TokenBase, Object.assign({ token: Object.assign(Object.assign({}, token), chainToken), isLoading: isLoading }, other)));
|
|
33
|
+
var { token, connected, step, disableDescription, isLoading } = _a, other = __rest(_a, ["token", "connected", "step", "disableDescription", "isLoading"]);
|
|
34
|
+
const { token: chainToken, isLoading: isLoadingToken } = (0, hooks_1.useToken)(token === null || token === void 0 ? void 0 : token.chainId, token === null || token === void 0 ? void 0 : token.address);
|
|
35
|
+
return ((0, jsx_runtime_1.jsx)(exports.TokenBase, Object.assign({ token: Object.assign(Object.assign({}, token), chainToken), isLoading: isLoading || isLoadingToken }, other)));
|
|
36
36
|
};
|
|
37
37
|
exports.TokenFallback = TokenFallback;
|
|
38
38
|
const TokenBase = (_a) => {
|
|
39
39
|
var { token, connected, step, disableDescription, isLoading } = _a, other = __rest(_a, ["token", "connected", "step", "disableDescription", "isLoading"]);
|
|
40
40
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
41
|
-
const { chain } = (0, hooks_1.useChain)(token.chainId);
|
|
42
|
-
const formattedTokenAmount = (0, utils_1.formatTokenAmount)(token.amount, token.decimals);
|
|
43
|
-
const formattedTokenPrice = (0, utils_1.formatTokenPrice)(formattedTokenAmount, token.priceUSD);
|
|
44
|
-
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, chain: chain, sx: { marginRight: 2 } }), (0, jsx_runtime_1.jsx)(TextFitter_1.TextFitter, Object.assign({ height: 30, textStyle: {
|
|
41
|
+
const { chain } = (0, hooks_1.useChain)(token === null || token === void 0 ? void 0 : token.chainId);
|
|
42
|
+
const formattedTokenAmount = (0, utils_1.formatTokenAmount)(token === null || token === void 0 ? void 0 : token.amount, token === null || token === void 0 ? void 0 : token.decimals);
|
|
43
|
+
const formattedTokenPrice = (0, utils_1.formatTokenPrice)(formattedTokenAmount, token === null || token === void 0 ? void 0 : token.priceUSD);
|
|
44
|
+
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, chain: chain, isLoading: isLoading, sx: { marginRight: 2 } }), isLoading ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { width: 112, height: 32, variant: "text" })) : ((0, jsx_runtime_1.jsx)(TextFitter_1.TextFitter, Object.assign({ height: 30, textStyle: {
|
|
45
45
|
fontWeight: 700,
|
|
46
46
|
} }, { children: t('format.number', {
|
|
47
47
|
value: formattedTokenAmount,
|
|
48
|
-
}) }))] })), (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(`format.currency`, {
|
|
48
|
+
}) })))] })), (0, jsx_runtime_1.jsxs)(Token_style_1.TextSecondaryContainer, Object.assign({ connected: connected, component: "span" }, { children: [isLoading ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { width: 48, height: 12, variant: "rounded", sx: { marginTop: 0.5 } })) : ((0, jsx_runtime_1.jsx)(Token_style_1.TextSecondary, Object.assign({ connected: connected }, { children: t(`format.currency`, {
|
|
49
49
|
value: formattedTokenPrice,
|
|
50
|
-
}) })), !disableDescription ? ((0, jsx_runtime_1.jsx)(Token_style_1.TextSecondary, Object.assign({ connected: connected, px: 0.5, dot: true }, { children: "\u2022" }))) : null, !step && !disableDescription ? ((0, jsx_runtime_1.jsx)(Token_style_1.TextSecondary, Object.assign({ connected: connected }, { children: t(`swap.tokenOnChain`, {
|
|
51
|
-
tokenSymbol: token.symbol,
|
|
50
|
+
}) }))), !disableDescription ? ((0, jsx_runtime_1.jsx)(Token_style_1.TextSecondary, Object.assign({ connected: connected, px: 0.5, dot: true }, { children: "\u2022" }))) : null, !step && !disableDescription ? (isLoading ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { width: 96, height: 12, variant: "rounded", sx: { marginTop: 0.5 } })) : ((0, jsx_runtime_1.jsx)(Token_style_1.TextSecondary, Object.assign({ connected: connected }, { children: t(`swap.tokenOnChain`, {
|
|
51
|
+
tokenSymbol: token === null || token === void 0 ? void 0 : token.symbol,
|
|
52
52
|
chainName: chain === null || chain === void 0 ? void 0 : chain.name,
|
|
53
|
-
}) }))) : null, step ? ((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: {
|
|
53
|
+
}) })))) : null, step ? ((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: {
|
|
54
54
|
border: 0,
|
|
55
55
|
marginBottom: -0.25,
|
|
56
56
|
} }, { children: step.toolDetails.name[0] })) })), (0, jsx_runtime_1.jsx)(Token_style_1.TextSecondary, Object.assign({ connected: true }, { children: step.toolDetails.name }))] }))) : null] }))] })));
|
|
@@ -2,18 +2,20 @@
|
|
|
2
2
|
import type { Chain, Token } from '@lifi/sdk';
|
|
3
3
|
import type { SxProps, Theme } from '@mui/material';
|
|
4
4
|
export declare const TokenAvatarFallback: React.FC<{
|
|
5
|
-
token
|
|
5
|
+
token?: Token;
|
|
6
|
+
isLoading?: boolean;
|
|
6
7
|
sx?: SxProps<Theme>;
|
|
7
8
|
}>;
|
|
8
9
|
export declare const TokenAvatarBase: React.FC<{
|
|
9
|
-
token
|
|
10
|
+
token?: Token;
|
|
10
11
|
chain?: Chain;
|
|
11
12
|
isLoading?: boolean;
|
|
12
13
|
sx?: SxProps<Theme>;
|
|
13
14
|
}>;
|
|
14
15
|
export declare const TokenAvatar: React.FC<{
|
|
15
|
-
token
|
|
16
|
+
token?: Token;
|
|
16
17
|
chain?: Chain;
|
|
18
|
+
isLoading?: boolean;
|
|
17
19
|
sx?: SxProps<Theme>;
|
|
18
20
|
}>;
|
|
19
21
|
export declare const TokenAvatarDefault: React.FC<{
|
|
@@ -6,21 +6,22 @@ const material_1 = require("@mui/material");
|
|
|
6
6
|
const hooks_1 = require("../../hooks");
|
|
7
7
|
const SmallAvatar_1 = require("../SmallAvatar");
|
|
8
8
|
const TokenAvatar_style_1 = require("./TokenAvatar.style");
|
|
9
|
-
const TokenAvatarFallback = ({ token, sx }) => {
|
|
10
|
-
const { chain } = (0, hooks_1.useChain)(token.chainId);
|
|
11
|
-
const { token: chainToken, isLoading } = (0, hooks_1.useToken)(token.chainId, token.address);
|
|
12
|
-
return ((0, jsx_runtime_1.jsx)(exports.TokenAvatarBase, { token: chainToken !== null && chainToken !== void 0 ? chainToken : token, isLoading: isLoading, chain: chain, sx: sx }));
|
|
9
|
+
const TokenAvatarFallback = ({ token, isLoading, sx }) => {
|
|
10
|
+
const { chain } = (0, hooks_1.useChain)(token === null || token === void 0 ? void 0 : token.chainId);
|
|
11
|
+
const { token: chainToken, isLoading: isLoadingToken } = (0, hooks_1.useToken)(token === null || token === void 0 ? void 0 : token.chainId, token === null || token === void 0 ? void 0 : token.address);
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)(exports.TokenAvatarBase, { token: chainToken !== null && chainToken !== void 0 ? chainToken : token, isLoading: isLoading || isLoadingToken, chain: chain, sx: sx }));
|
|
13
13
|
};
|
|
14
14
|
exports.TokenAvatarFallback = TokenAvatarFallback;
|
|
15
15
|
const TokenAvatarBase = ({ token, chain, isLoading, sx }) => {
|
|
16
|
-
|
|
16
|
+
var _a;
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Badge, Object.assign({ overlap: "circular", anchorOrigin: { vertical: 'bottom', horizontal: 'right' }, badgeContent: chain && !isLoading ? ((0, jsx_runtime_1.jsx)(SmallAvatar_1.SmallAvatar, Object.assign({ src: chain.logoURI, alt: chain.name }, { children: chain.name[0] }))) : ((0, jsx_runtime_1.jsx)(SmallAvatar_1.SmallAvatarSkeleton, {})), sx: sx }, { children: isLoading ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { width: 32, height: 32, variant: "circular" })) : ((0, jsx_runtime_1.jsx)(material_1.Avatar, Object.assign({ src: token === null || token === void 0 ? void 0 : token.logoURI, alt: token === null || token === void 0 ? void 0 : token.symbol }, { children: (_a = token === null || token === void 0 ? void 0 : token.symbol) === null || _a === void 0 ? void 0 : _a[0] }))) })));
|
|
17
18
|
};
|
|
18
19
|
exports.TokenAvatarBase = TokenAvatarBase;
|
|
19
|
-
const TokenAvatar = ({ token, chain, sx }) => {
|
|
20
|
-
if (!chain || !token.logoURI) {
|
|
21
|
-
return (0, jsx_runtime_1.jsx)(exports.TokenAvatarFallback, { token: token, sx: sx });
|
|
20
|
+
const TokenAvatar = ({ token, chain, isLoading, sx }) => {
|
|
21
|
+
if (!chain || !(token === null || token === void 0 ? void 0 : token.logoURI)) {
|
|
22
|
+
return (0, jsx_runtime_1.jsx)(exports.TokenAvatarFallback, { token: token, isLoading: isLoading, sx: sx });
|
|
22
23
|
}
|
|
23
|
-
return (0, jsx_runtime_1.jsx)(exports.TokenAvatarBase, { token: token, chain: chain, sx: sx });
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)(exports.TokenAvatarBase, { token: token, chain: chain, isLoading: isLoading, sx: sx }));
|
|
24
25
|
};
|
|
25
26
|
exports.TokenAvatar = TokenAvatar;
|
|
26
27
|
const TokenAvatarDefault = ({ sx }) => {
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ListItem = exports.ListItemButton = void 0;
|
|
4
4
|
const material_1 = require("@mui/material");
|
|
5
5
|
const ListItemSecondaryAction_1 = require("@mui/material/ListItemSecondaryAction");
|
|
6
|
+
const ListItemText_1 = require("@mui/material/ListItemText");
|
|
6
7
|
const styles_1 = require("@mui/material/styles");
|
|
7
8
|
const utils_1 = require("../../utils");
|
|
8
9
|
exports.ListItemButton = (0, styles_1.styled)(material_1.ListItemButton)(({ theme }) => ({
|
|
@@ -26,4 +27,9 @@ exports.ListItem = (0, styles_1.styled)(material_1.ListItem)(({ theme }) => ({
|
|
|
26
27
|
[`.${ListItemSecondaryAction_1.listItemSecondaryActionClasses.root}`]: {
|
|
27
28
|
right: theme.spacing(3),
|
|
28
29
|
},
|
|
30
|
+
[`& .${ListItemText_1.listItemTextClasses.primary}, & .${ListItemText_1.listItemTextClasses.secondary}`]: {
|
|
31
|
+
textOverflow: 'ellipsis',
|
|
32
|
+
overflow: 'hidden',
|
|
33
|
+
whiteSpace: 'nowrap',
|
|
34
|
+
},
|
|
29
35
|
}));
|
|
@@ -39,8 +39,10 @@ const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollElementRef,
|
|
|
39
39
|
getItemKey: (index) => { var _a; return (_a = tokens[index].address) !== null && _a !== void 0 ? _a : index; },
|
|
40
40
|
});
|
|
41
41
|
(0, react_1.useEffect)(() => {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
if (getVirtualItems().length) {
|
|
43
|
+
scrollToIndex(0, { align: 'start' });
|
|
44
|
+
}
|
|
45
|
+
}, [scrollToIndex, chainId, getVirtualItems]);
|
|
44
46
|
if (isLoading) {
|
|
45
47
|
return ((0, jsx_runtime_1.jsx)(material_1.List, Object.assign({ disablePadding: true }, { children: Array.from({ length: 3 }).map((_, index) => (
|
|
46
48
|
// eslint-disable-next-line react/no-array-index-key
|
package/cjs/config/theme.js
CHANGED
|
@@ -45,7 +45,7 @@ const shape = {
|
|
|
45
45
|
borderRadiusSecondary: 6,
|
|
46
46
|
};
|
|
47
47
|
const createTheme = (mode, theme = {}) => {
|
|
48
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
48
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
49
49
|
const primaryMainColor = (_c = (_b = (_a = theme.palette) === null || _a === void 0 ? void 0 : _a.primary) === null || _b === void 0 ? void 0 : _b.main) !== null && _c !== void 0 ? _c : palette.primary.main;
|
|
50
50
|
const primaryLightColor = (0, styles_1.lighten)((_f = (_e = (_d = theme.palette) === null || _d === void 0 ? void 0 : _d.primary) === null || _e === void 0 ? void 0 : _e.main) !== null && _f !== void 0 ? _f : palette.primary.main, 0.5);
|
|
51
51
|
const primaryDarkColor = (0, styles_1.darken)((_j = (_h = (_g = theme.palette) === null || _g === void 0 ? void 0 : _g.primary) === null || _h === void 0 ? void 0 : _h.main) !== null && _j !== void 0 ? _j : palette.primary.main, 0.2);
|
|
@@ -150,14 +150,12 @@ const createTheme = (mode, theme = {}) => {
|
|
|
150
150
|
},
|
|
151
151
|
},
|
|
152
152
|
},
|
|
153
|
-
MuiAvatar: {
|
|
154
|
-
styleOverrides: {
|
|
153
|
+
MuiAvatar: Object.assign({ styleOverrides: {
|
|
155
154
|
root: {
|
|
156
155
|
height: 32,
|
|
157
156
|
width: 32,
|
|
158
157
|
},
|
|
159
|
-
},
|
|
160
|
-
},
|
|
158
|
+
} }, (_w = theme.components) === null || _w === void 0 ? void 0 : _w.MuiAvatar),
|
|
161
159
|
MuiListItemAvatar: {
|
|
162
160
|
styleOverrides: {
|
|
163
161
|
root: {
|
package/cjs/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "1.
|
|
2
|
+
export declare const version = "1.28.0";
|
package/cjs/config/version.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import type { Route } from '@lifi/sdk';
|
|
1
2
|
export declare const useSwapRoutes: () => {
|
|
2
|
-
routes:
|
|
3
|
+
routes: Route[] | undefined;
|
|
3
4
|
isLoading: boolean;
|
|
4
5
|
isFetching: boolean;
|
|
5
6
|
isFetched: boolean;
|
|
6
7
|
dataUpdatedAt: number;
|
|
7
8
|
refetchTime: number;
|
|
8
|
-
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@lifi/sdk").RoutesResponse
|
|
9
|
+
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@lifi/sdk").RoutesResponse | {
|
|
10
|
+
routes: Route[];
|
|
11
|
+
}, any>>;
|
|
9
12
|
};
|
|
@@ -15,6 +15,7 @@ const sdk_1 = require("@lifi/sdk");
|
|
|
15
15
|
const react_query_1 = require("@tanstack/react-query");
|
|
16
16
|
const big_js_1 = require("big.js");
|
|
17
17
|
const react_hook_form_1 = require("react-hook-form");
|
|
18
|
+
const uuid_1 = require("uuid");
|
|
18
19
|
const _1 = require(".");
|
|
19
20
|
const providers_1 = require("../providers");
|
|
20
21
|
const stores_1 = require("../stores");
|
|
@@ -31,36 +32,47 @@ const useSwapRoutes = () => {
|
|
|
31
32
|
'enabledBridges',
|
|
32
33
|
'enabledExchanges',
|
|
33
34
|
]);
|
|
34
|
-
const [
|
|
35
|
+
const [fromTokenAmount] = (0, _1.useDebouncedWatch)([providers_1.SwapFormKey.FromAmount], 320);
|
|
36
|
+
const [fromChainId, fromTokenAddress, toAddress, toTokenAmount, toChainId, toContractAddress, toContractCallData, toContractGasLimit, toTokenAddress,] = (0, react_hook_form_1.useWatch)({
|
|
35
37
|
name: [
|
|
36
38
|
providers_1.SwapFormKey.FromChain,
|
|
37
39
|
providers_1.SwapFormKey.FromToken,
|
|
40
|
+
providers_1.SwapFormKey.ToAddress,
|
|
41
|
+
providers_1.SwapFormKey.ToAmount,
|
|
38
42
|
providers_1.SwapFormKey.ToChain,
|
|
43
|
+
providers_1.SwapFormKey.ToContractAddress,
|
|
44
|
+
providers_1.SwapFormKey.ToContractCallData,
|
|
45
|
+
providers_1.SwapFormKey.ToContractGasLimit,
|
|
39
46
|
providers_1.SwapFormKey.ToToken,
|
|
40
|
-
providers_1.SwapFormKey.ToAddress,
|
|
41
47
|
],
|
|
42
48
|
});
|
|
43
|
-
const [fromTokenAmount] = (0, _1.useDebouncedWatch)([providers_1.SwapFormKey.FromAmount], 320);
|
|
44
49
|
const { token: fromToken } = (0, _1.useToken)(fromChainId, fromTokenAddress);
|
|
45
50
|
const { token: toToken } = (0, _1.useToken)(toChainId, toTokenAddress);
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
const hasAmount = (!isNaN(fromTokenAmount) && Number(fromTokenAmount) > 0) ||
|
|
52
|
+
(!isNaN(toTokenAmount) && Number(toTokenAmount) > 0);
|
|
53
|
+
const contractCallQuoteEnabled = variant === 'nft'
|
|
54
|
+
? Boolean(toContractAddress && toContractCallData && toContractGasLimit)
|
|
55
|
+
: true;
|
|
56
|
+
const isEnabled = !isNaN(fromChainId) &&
|
|
49
57
|
!isNaN(toChainId) &&
|
|
50
58
|
Boolean(fromToken === null || fromToken === void 0 ? void 0 : fromToken.address) &&
|
|
51
59
|
Boolean(toToken === null || toToken === void 0 ? void 0 : toToken.address) &&
|
|
52
|
-
!isNaN(
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
!Number.isNaN(slippage) &&
|
|
61
|
+
hasAmount &&
|
|
62
|
+
contractCallQuoteEnabled;
|
|
55
63
|
const queryKey = [
|
|
56
64
|
'routes',
|
|
57
65
|
account.address,
|
|
58
66
|
fromChainId,
|
|
59
67
|
fromToken === null || fromToken === void 0 ? void 0 : fromToken.address,
|
|
60
68
|
fromTokenAmount,
|
|
69
|
+
toAddress,
|
|
61
70
|
toChainId,
|
|
62
71
|
toToken === null || toToken === void 0 ? void 0 : toToken.address,
|
|
63
|
-
|
|
72
|
+
toTokenAmount,
|
|
73
|
+
toContractAddress,
|
|
74
|
+
toContractCallData,
|
|
75
|
+
toContractGasLimit,
|
|
64
76
|
slippage,
|
|
65
77
|
enabledBridges,
|
|
66
78
|
enabledExchanges,
|
|
@@ -72,20 +84,58 @@ const useSwapRoutes = () => {
|
|
|
72
84
|
const refetchInterval = previousDataUpdatedAt
|
|
73
85
|
? Math.min(Math.abs(refetchTime - (Date.now() - previousDataUpdatedAt)), refetchTime)
|
|
74
86
|
: refetchTime;
|
|
75
|
-
const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = (0, react_query_1.useQuery)(queryKey, ({ queryKey: [_, fromAddress, fromChainId, fromTokenAddress, fromTokenAmount, toChainId, toTokenAddress,
|
|
76
|
-
var _c, _d;
|
|
87
|
+
const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = (0, react_query_1.useQuery)(queryKey, ({ queryKey: [_, fromAddress, fromChainId, fromTokenAddress, fromTokenAmount, toAddress, toChainId, toTokenAddress, toTokenAmount, toContractAddress, toContractCallData, toContractGasLimit, slippage, enabledBridges, enabledExchanges, routePriority, variant, allowSwitchChain,], signal, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
88
|
+
var _c, _d, _e;
|
|
77
89
|
let toWalletAddress;
|
|
78
90
|
try {
|
|
79
91
|
toWalletAddress =
|
|
80
92
|
(_c = (yield (provider === null || provider === void 0 ? void 0 : provider.resolveName(toAddress)))) !== null && _c !== void 0 ? _c : ((0, address_1.isAddress)(toAddress) ? toAddress : fromAddress);
|
|
81
93
|
}
|
|
82
|
-
catch (
|
|
94
|
+
catch (_f) {
|
|
83
95
|
toWalletAddress = (0, address_1.isAddress)(toAddress) ? toAddress : fromAddress;
|
|
84
96
|
}
|
|
85
|
-
const fromAmount = (0, big_js_1.default)(fromTokenAmount)
|
|
97
|
+
const fromAmount = (0, big_js_1.default)(fromTokenAmount || 0)
|
|
86
98
|
.mul(Math.pow(10, ((_d = fromToken === null || fromToken === void 0 ? void 0 : fromToken.decimals) !== null && _d !== void 0 ? _d : 0)))
|
|
87
99
|
.toString();
|
|
100
|
+
// const toAmount = Big(toTokenAmount || 0)
|
|
101
|
+
// .mul(10 ** (toToken?.decimals ?? 0))
|
|
102
|
+
// .toString();
|
|
88
103
|
const formattedSlippage = parseFloat(slippage) / 100;
|
|
104
|
+
if (variant === 'nft') {
|
|
105
|
+
const contractCallQuote = yield lifi.getContractCallQuote({
|
|
106
|
+
fromAddress,
|
|
107
|
+
fromChain: fromChainId,
|
|
108
|
+
fromToken: fromTokenAddress,
|
|
109
|
+
toAmount: toTokenAmount,
|
|
110
|
+
toChain: toChainId,
|
|
111
|
+
toToken: toTokenAddress,
|
|
112
|
+
toContractAddress,
|
|
113
|
+
toContractCallData,
|
|
114
|
+
toContractGasLimit,
|
|
115
|
+
// toFallbackAddress: toAddress,
|
|
116
|
+
slippage: formattedSlippage,
|
|
117
|
+
}, { signal });
|
|
118
|
+
contractCallQuote.estimate.toAmount = toTokenAmount;
|
|
119
|
+
contractCallQuote.estimate.toAmountMin = toTokenAmount;
|
|
120
|
+
contractCallQuote.action.toToken = toToken;
|
|
121
|
+
const route = {
|
|
122
|
+
id: (0, uuid_1.v4)(),
|
|
123
|
+
fromChainId: contractCallQuote.action.fromChainId,
|
|
124
|
+
fromAmountUSD: contractCallQuote.estimate.fromAmountUSD || '',
|
|
125
|
+
fromAmount: contractCallQuote.action.fromAmount,
|
|
126
|
+
fromToken: contractCallQuote.action.fromToken,
|
|
127
|
+
fromAddress: contractCallQuote.action.fromAddress,
|
|
128
|
+
toChainId: contractCallQuote.action.toChainId,
|
|
129
|
+
toAmountUSD: contractCallQuote.estimate.toAmountUSD || '',
|
|
130
|
+
toAmount: toTokenAmount,
|
|
131
|
+
toAmountMin: toTokenAmount,
|
|
132
|
+
toToken: toToken,
|
|
133
|
+
toAddress: toAddress,
|
|
134
|
+
gasCostUSD: (_e = contractCallQuote.estimate.gasCosts) === null || _e === void 0 ? void 0 : _e[0].amountUSD,
|
|
135
|
+
steps: [contractCallQuote],
|
|
136
|
+
};
|
|
137
|
+
return { routes: [route] };
|
|
138
|
+
}
|
|
89
139
|
return lifi.getRoutes({
|
|
90
140
|
fromChainId,
|
|
91
141
|
fromAmount,
|
package/cjs/hooks/useToken.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Token } from '../types';
|
|
2
|
-
export declare const useTokenSearch: (chainId
|
|
2
|
+
export declare const useTokenSearch: (chainId?: number, token?: string, enabled?: boolean) => {
|
|
3
3
|
token: Token | undefined;
|
|
4
4
|
isLoading: boolean;
|
|
5
5
|
};
|