@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
|
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { Box } from '@mui/material';
|
|
13
|
+
import { Box, Skeleton } from '@mui/material';
|
|
14
14
|
import { useTranslation } from 'react-i18next';
|
|
15
15
|
import { useChain, useToken } from '../../hooks';
|
|
16
16
|
import { formatTokenAmount, formatTokenPrice } from '../../utils';
|
|
@@ -20,32 +20,32 @@ import { TokenAvatar } from '../TokenAvatar';
|
|
|
20
20
|
import { TextSecondary, TextSecondaryContainer } from './Token.style';
|
|
21
21
|
export const Token = (_a) => {
|
|
22
22
|
var { token } = _a, other = __rest(_a, ["token"]);
|
|
23
|
-
if (!token.priceUSD || !token.logoURI) {
|
|
23
|
+
if (!(token === null || token === void 0 ? void 0 : token.priceUSD) || !token.logoURI) {
|
|
24
24
|
return _jsx(TokenFallback, Object.assign({ token: token }, other));
|
|
25
25
|
}
|
|
26
26
|
return _jsx(TokenBase, Object.assign({ token: token }, other));
|
|
27
27
|
};
|
|
28
28
|
export const TokenFallback = (_a) => {
|
|
29
|
-
var { token, connected, step, disableDescription } = _a, other = __rest(_a, ["token", "connected", "step", "disableDescription"]);
|
|
30
|
-
const { token: chainToken, isLoading } = useToken(token.chainId, token.address);
|
|
31
|
-
return (_jsx(TokenBase, Object.assign({ token: Object.assign(Object.assign({}, token), chainToken), isLoading: isLoading }, other)));
|
|
29
|
+
var { token, connected, step, disableDescription, isLoading } = _a, other = __rest(_a, ["token", "connected", "step", "disableDescription", "isLoading"]);
|
|
30
|
+
const { token: chainToken, isLoading: isLoadingToken } = useToken(token === null || token === void 0 ? void 0 : token.chainId, token === null || token === void 0 ? void 0 : token.address);
|
|
31
|
+
return (_jsx(TokenBase, Object.assign({ token: Object.assign(Object.assign({}, token), chainToken), isLoading: isLoading || isLoadingToken }, other)));
|
|
32
32
|
};
|
|
33
33
|
export const TokenBase = (_a) => {
|
|
34
34
|
var { token, connected, step, disableDescription, isLoading } = _a, other = __rest(_a, ["token", "connected", "step", "disableDescription", "isLoading"]);
|
|
35
35
|
const { t } = useTranslation();
|
|
36
|
-
const { chain } = useChain(token.chainId);
|
|
37
|
-
const formattedTokenAmount = formatTokenAmount(token.amount, token.decimals);
|
|
38
|
-
const formattedTokenPrice = formatTokenPrice(formattedTokenAmount, token.priceUSD);
|
|
39
|
-
return (_jsxs(Box, Object.assign({ flex: 1 }, other, { children: [_jsxs(Box, Object.assign({ display: "flex", flex: 1, alignItems: "center" }, { children: [_jsx(TokenAvatar, { token: token, chain: chain, sx: { marginRight: 2 } }), _jsx(TextFitter, Object.assign({ height: 30, textStyle: {
|
|
36
|
+
const { chain } = useChain(token === null || token === void 0 ? void 0 : token.chainId);
|
|
37
|
+
const formattedTokenAmount = formatTokenAmount(token === null || token === void 0 ? void 0 : token.amount, token === null || token === void 0 ? void 0 : token.decimals);
|
|
38
|
+
const formattedTokenPrice = formatTokenPrice(formattedTokenAmount, token === null || token === void 0 ? void 0 : token.priceUSD);
|
|
39
|
+
return (_jsxs(Box, Object.assign({ flex: 1 }, other, { children: [_jsxs(Box, Object.assign({ display: "flex", flex: 1, alignItems: "center" }, { children: [_jsx(TokenAvatar, { token: token, chain: chain, isLoading: isLoading, sx: { marginRight: 2 } }), isLoading ? (_jsx(Skeleton, { width: 112, height: 32, variant: "text" })) : (_jsx(TextFitter, Object.assign({ height: 30, textStyle: {
|
|
40
40
|
fontWeight: 700,
|
|
41
41
|
} }, { children: t('format.number', {
|
|
42
42
|
value: formattedTokenAmount,
|
|
43
|
-
}) }))] })), _jsxs(TextSecondaryContainer, Object.assign({ connected: connected, component: "span" }, { children: [_jsx(TextSecondary, Object.assign({ connected: connected }, { children: t(`format.currency`, {
|
|
43
|
+
}) })))] })), _jsxs(TextSecondaryContainer, Object.assign({ connected: connected, component: "span" }, { children: [isLoading ? (_jsx(Skeleton, { width: 48, height: 12, variant: "rounded", sx: { marginTop: 0.5 } })) : (_jsx(TextSecondary, Object.assign({ connected: connected }, { children: t(`format.currency`, {
|
|
44
44
|
value: formattedTokenPrice,
|
|
45
|
-
}) })), !disableDescription ? (_jsx(TextSecondary, Object.assign({ connected: connected, px: 0.5, dot: true }, { children: "\u2022" }))) : null, !step && !disableDescription ? (_jsx(TextSecondary, Object.assign({ connected: connected }, { children: t(`swap.tokenOnChain`, {
|
|
46
|
-
tokenSymbol: token.symbol,
|
|
45
|
+
}) }))), !disableDescription ? (_jsx(TextSecondary, Object.assign({ connected: connected, px: 0.5, dot: true }, { children: "\u2022" }))) : null, !step && !disableDescription ? (isLoading ? (_jsx(Skeleton, { width: 96, height: 12, variant: "rounded", sx: { marginTop: 0.5 } })) : (_jsx(TextSecondary, Object.assign({ connected: connected }, { children: t(`swap.tokenOnChain`, {
|
|
46
|
+
tokenSymbol: token === null || token === void 0 ? void 0 : token.symbol,
|
|
47
47
|
chainName: chain === null || chain === void 0 ? void 0 : chain.name,
|
|
48
|
-
}) }))) : null, step ? (_jsxs(Box, Object.assign({ display: "flex", alignItems: "flex-end", height: 12, mt: 0.5 }, { children: [_jsx(Box, Object.assign({ pr: 0.75 }, { children: _jsx(SmallAvatar, Object.assign({ src: step.toolDetails.logoURI, alt: step.toolDetails.name, sx: {
|
|
48
|
+
}) })))) : null, step ? (_jsxs(Box, Object.assign({ display: "flex", alignItems: "flex-end", height: 12, mt: 0.5 }, { children: [_jsx(Box, Object.assign({ pr: 0.75 }, { children: _jsx(SmallAvatar, Object.assign({ src: step.toolDetails.logoURI, alt: step.toolDetails.name, sx: {
|
|
49
49
|
border: 0,
|
|
50
50
|
marginBottom: -0.25,
|
|
51
51
|
} }, { children: step.toolDetails.name[0] })) })), _jsx(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<{
|
|
@@ -3,19 +3,20 @@ import { Avatar, Badge, Skeleton } from '@mui/material';
|
|
|
3
3
|
import { useChain, useToken } from '../../hooks';
|
|
4
4
|
import { SmallAvatar, SmallAvatarSkeleton } from '../SmallAvatar';
|
|
5
5
|
import { AvatarDefault, AvatarDefaultContainer } from './TokenAvatar.style';
|
|
6
|
-
export const TokenAvatarFallback = ({ token, sx }) => {
|
|
7
|
-
const { chain } = useChain(token.chainId);
|
|
8
|
-
const { token: chainToken, isLoading } = useToken(token.chainId, token.address);
|
|
9
|
-
return (_jsx(TokenAvatarBase, { token: chainToken !== null && chainToken !== void 0 ? chainToken : token, isLoading: isLoading, chain: chain, sx: sx }));
|
|
6
|
+
export const TokenAvatarFallback = ({ token, isLoading, sx }) => {
|
|
7
|
+
const { chain } = useChain(token === null || token === void 0 ? void 0 : token.chainId);
|
|
8
|
+
const { token: chainToken, isLoading: isLoadingToken } = useToken(token === null || token === void 0 ? void 0 : token.chainId, token === null || token === void 0 ? void 0 : token.address);
|
|
9
|
+
return (_jsx(TokenAvatarBase, { token: chainToken !== null && chainToken !== void 0 ? chainToken : token, isLoading: isLoading || isLoadingToken, chain: chain, sx: sx }));
|
|
10
10
|
};
|
|
11
11
|
export const TokenAvatarBase = ({ token, chain, isLoading, sx }) => {
|
|
12
|
-
|
|
12
|
+
var _a;
|
|
13
|
+
return (_jsx(Badge, Object.assign({ overlap: "circular", anchorOrigin: { vertical: 'bottom', horizontal: 'right' }, badgeContent: chain && !isLoading ? (_jsx(SmallAvatar, Object.assign({ src: chain.logoURI, alt: chain.name }, { children: chain.name[0] }))) : (_jsx(SmallAvatarSkeleton, {})), sx: sx }, { children: isLoading ? (_jsx(Skeleton, { width: 32, height: 32, variant: "circular" })) : (_jsx(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] }))) })));
|
|
13
14
|
};
|
|
14
|
-
export const TokenAvatar = ({ token, chain, sx }) => {
|
|
15
|
-
if (!chain || !token.logoURI) {
|
|
16
|
-
return _jsx(TokenAvatarFallback, { token: token, sx: sx });
|
|
15
|
+
export const TokenAvatar = ({ token, chain, isLoading, sx }) => {
|
|
16
|
+
if (!chain || !(token === null || token === void 0 ? void 0 : token.logoURI)) {
|
|
17
|
+
return _jsx(TokenAvatarFallback, { token: token, isLoading: isLoading, sx: sx });
|
|
17
18
|
}
|
|
18
|
-
return _jsx(TokenAvatarBase, { token: token, chain: chain, sx: sx });
|
|
19
|
+
return (_jsx(TokenAvatarBase, { token: token, chain: chain, isLoading: isLoading, sx: sx }));
|
|
19
20
|
};
|
|
20
21
|
export const TokenAvatarDefault = ({ sx }) => {
|
|
21
22
|
return (_jsx(Badge, Object.assign({ overlap: "circular", anchorOrigin: { vertical: 'bottom', horizontal: 'right' }, badgeContent: _jsx(AvatarDefault, { width: 16, height: 16 }), sx: sx }, { children: _jsx(AvatarDefaultContainer, { children: _jsx(AvatarDefault, { width: 28, height: 28 }) }) })));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ListItem as MuiListItem, ListItemButton as MuiListItemButton, } from '@mui/material';
|
|
2
2
|
import { listItemSecondaryActionClasses } from '@mui/material/ListItemSecondaryAction';
|
|
3
|
+
import { listItemTextClasses } from '@mui/material/ListItemText';
|
|
3
4
|
import { styled } from '@mui/material/styles';
|
|
4
5
|
import { getContrastAlphaColor } from '../../utils';
|
|
5
6
|
export const ListItemButton = styled(MuiListItemButton)(({ theme }) => ({
|
|
@@ -23,4 +24,9 @@ export const ListItem = styled(MuiListItem)(({ theme }) => ({
|
|
|
23
24
|
[`.${listItemSecondaryActionClasses.root}`]: {
|
|
24
25
|
right: theme.spacing(3),
|
|
25
26
|
},
|
|
27
|
+
[`& .${listItemTextClasses.primary}, & .${listItemTextClasses.secondary}`]: {
|
|
28
|
+
textOverflow: 'ellipsis',
|
|
29
|
+
overflow: 'hidden',
|
|
30
|
+
whiteSpace: 'nowrap',
|
|
31
|
+
},
|
|
26
32
|
}));
|
|
@@ -36,8 +36,10 @@ export const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollEleme
|
|
|
36
36
|
getItemKey: (index) => { var _a; return (_a = tokens[index].address) !== null && _a !== void 0 ? _a : index; },
|
|
37
37
|
});
|
|
38
38
|
useEffect(() => {
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
if (getVirtualItems().length) {
|
|
40
|
+
scrollToIndex(0, { align: 'start' });
|
|
41
|
+
}
|
|
42
|
+
}, [scrollToIndex, chainId, getVirtualItems]);
|
|
41
43
|
if (isLoading) {
|
|
42
44
|
return (_jsx(List, Object.assign({ disablePadding: true }, { children: Array.from({ length: 3 }).map((_, index) => (
|
|
43
45
|
// eslint-disable-next-line react/no-array-index-key
|
package/config/theme.js
CHANGED
|
@@ -42,7 +42,7 @@ const shape = {
|
|
|
42
42
|
borderRadiusSecondary: 6,
|
|
43
43
|
};
|
|
44
44
|
export const createTheme = (mode, theme = {}) => {
|
|
45
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
45
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
46
46
|
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;
|
|
47
47
|
const primaryLightColor = 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);
|
|
48
48
|
const primaryDarkColor = 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);
|
|
@@ -147,14 +147,12 @@ export const createTheme = (mode, theme = {}) => {
|
|
|
147
147
|
},
|
|
148
148
|
},
|
|
149
149
|
},
|
|
150
|
-
MuiAvatar: {
|
|
151
|
-
styleOverrides: {
|
|
150
|
+
MuiAvatar: Object.assign({ styleOverrides: {
|
|
152
151
|
root: {
|
|
153
152
|
height: 32,
|
|
154
153
|
width: 32,
|
|
155
154
|
},
|
|
156
|
-
},
|
|
157
|
-
},
|
|
155
|
+
} }, (_w = theme.components) === null || _w === void 0 ? void 0 : _w.MuiAvatar),
|
|
158
156
|
MuiListItemAvatar: {
|
|
159
157
|
styleOverrides: {
|
|
160
158
|
root: {
|
package/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/config/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '1.
|
|
2
|
+
export const version = '1.28.0';
|
package/hooks/useSwapRoutes.d.ts
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
|
};
|
package/hooks/useSwapRoutes.js
CHANGED
|
@@ -12,6 +12,7 @@ import { LifiErrorCode } from '@lifi/sdk';
|
|
|
12
12
|
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
13
13
|
import Big from 'big.js';
|
|
14
14
|
import { useWatch } from 'react-hook-form';
|
|
15
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
15
16
|
import { useDebouncedWatch, useToken } from '.';
|
|
16
17
|
import { SwapFormKey, useLiFi, useWallet, useWidgetConfig } from '../providers';
|
|
17
18
|
import { useSettings } from '../stores';
|
|
@@ -28,36 +29,47 @@ export const useSwapRoutes = () => {
|
|
|
28
29
|
'enabledBridges',
|
|
29
30
|
'enabledExchanges',
|
|
30
31
|
]);
|
|
31
|
-
const [
|
|
32
|
+
const [fromTokenAmount] = useDebouncedWatch([SwapFormKey.FromAmount], 320);
|
|
33
|
+
const [fromChainId, fromTokenAddress, toAddress, toTokenAmount, toChainId, toContractAddress, toContractCallData, toContractGasLimit, toTokenAddress,] = useWatch({
|
|
32
34
|
name: [
|
|
33
35
|
SwapFormKey.FromChain,
|
|
34
36
|
SwapFormKey.FromToken,
|
|
37
|
+
SwapFormKey.ToAddress,
|
|
38
|
+
SwapFormKey.ToAmount,
|
|
35
39
|
SwapFormKey.ToChain,
|
|
40
|
+
SwapFormKey.ToContractAddress,
|
|
41
|
+
SwapFormKey.ToContractCallData,
|
|
42
|
+
SwapFormKey.ToContractGasLimit,
|
|
36
43
|
SwapFormKey.ToToken,
|
|
37
|
-
SwapFormKey.ToAddress,
|
|
38
44
|
],
|
|
39
45
|
});
|
|
40
|
-
const [fromTokenAmount] = useDebouncedWatch([SwapFormKey.FromAmount], 320);
|
|
41
46
|
const { token: fromToken } = useToken(fromChainId, fromTokenAddress);
|
|
42
47
|
const { token: toToken } = useToken(toChainId, toTokenAddress);
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
const hasAmount = (!isNaN(fromTokenAmount) && Number(fromTokenAmount) > 0) ||
|
|
49
|
+
(!isNaN(toTokenAmount) && Number(toTokenAmount) > 0);
|
|
50
|
+
const contractCallQuoteEnabled = variant === 'nft'
|
|
51
|
+
? Boolean(toContractAddress && toContractCallData && toContractGasLimit)
|
|
52
|
+
: true;
|
|
53
|
+
const isEnabled = !isNaN(fromChainId) &&
|
|
46
54
|
!isNaN(toChainId) &&
|
|
47
55
|
Boolean(fromToken === null || fromToken === void 0 ? void 0 : fromToken.address) &&
|
|
48
56
|
Boolean(toToken === null || toToken === void 0 ? void 0 : toToken.address) &&
|
|
49
|
-
!isNaN(
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
!Number.isNaN(slippage) &&
|
|
58
|
+
hasAmount &&
|
|
59
|
+
contractCallQuoteEnabled;
|
|
52
60
|
const queryKey = [
|
|
53
61
|
'routes',
|
|
54
62
|
account.address,
|
|
55
63
|
fromChainId,
|
|
56
64
|
fromToken === null || fromToken === void 0 ? void 0 : fromToken.address,
|
|
57
65
|
fromTokenAmount,
|
|
66
|
+
toAddress,
|
|
58
67
|
toChainId,
|
|
59
68
|
toToken === null || toToken === void 0 ? void 0 : toToken.address,
|
|
60
|
-
|
|
69
|
+
toTokenAmount,
|
|
70
|
+
toContractAddress,
|
|
71
|
+
toContractCallData,
|
|
72
|
+
toContractGasLimit,
|
|
61
73
|
slippage,
|
|
62
74
|
enabledBridges,
|
|
63
75
|
enabledExchanges,
|
|
@@ -69,20 +81,58 @@ export const useSwapRoutes = () => {
|
|
|
69
81
|
const refetchInterval = previousDataUpdatedAt
|
|
70
82
|
? Math.min(Math.abs(refetchTime - (Date.now() - previousDataUpdatedAt)), refetchTime)
|
|
71
83
|
: refetchTime;
|
|
72
|
-
const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = useQuery(queryKey, ({ queryKey: [_, fromAddress, fromChainId, fromTokenAddress, fromTokenAmount, toChainId, toTokenAddress,
|
|
73
|
-
var _c, _d;
|
|
84
|
+
const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = 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* () {
|
|
85
|
+
var _c, _d, _e;
|
|
74
86
|
let toWalletAddress;
|
|
75
87
|
try {
|
|
76
88
|
toWalletAddress =
|
|
77
89
|
(_c = (yield (provider === null || provider === void 0 ? void 0 : provider.resolveName(toAddress)))) !== null && _c !== void 0 ? _c : (isAddress(toAddress) ? toAddress : fromAddress);
|
|
78
90
|
}
|
|
79
|
-
catch (
|
|
91
|
+
catch (_f) {
|
|
80
92
|
toWalletAddress = isAddress(toAddress) ? toAddress : fromAddress;
|
|
81
93
|
}
|
|
82
|
-
const fromAmount = Big(fromTokenAmount)
|
|
94
|
+
const fromAmount = Big(fromTokenAmount || 0)
|
|
83
95
|
.mul(Math.pow(10, ((_d = fromToken === null || fromToken === void 0 ? void 0 : fromToken.decimals) !== null && _d !== void 0 ? _d : 0)))
|
|
84
96
|
.toString();
|
|
97
|
+
// const toAmount = Big(toTokenAmount || 0)
|
|
98
|
+
// .mul(10 ** (toToken?.decimals ?? 0))
|
|
99
|
+
// .toString();
|
|
85
100
|
const formattedSlippage = parseFloat(slippage) / 100;
|
|
101
|
+
if (variant === 'nft') {
|
|
102
|
+
const contractCallQuote = yield lifi.getContractCallQuote({
|
|
103
|
+
fromAddress,
|
|
104
|
+
fromChain: fromChainId,
|
|
105
|
+
fromToken: fromTokenAddress,
|
|
106
|
+
toAmount: toTokenAmount,
|
|
107
|
+
toChain: toChainId,
|
|
108
|
+
toToken: toTokenAddress,
|
|
109
|
+
toContractAddress,
|
|
110
|
+
toContractCallData,
|
|
111
|
+
toContractGasLimit,
|
|
112
|
+
// toFallbackAddress: toAddress,
|
|
113
|
+
slippage: formattedSlippage,
|
|
114
|
+
}, { signal });
|
|
115
|
+
contractCallQuote.estimate.toAmount = toTokenAmount;
|
|
116
|
+
contractCallQuote.estimate.toAmountMin = toTokenAmount;
|
|
117
|
+
contractCallQuote.action.toToken = toToken;
|
|
118
|
+
const route = {
|
|
119
|
+
id: uuidv4(),
|
|
120
|
+
fromChainId: contractCallQuote.action.fromChainId,
|
|
121
|
+
fromAmountUSD: contractCallQuote.estimate.fromAmountUSD || '',
|
|
122
|
+
fromAmount: contractCallQuote.action.fromAmount,
|
|
123
|
+
fromToken: contractCallQuote.action.fromToken,
|
|
124
|
+
fromAddress: contractCallQuote.action.fromAddress,
|
|
125
|
+
toChainId: contractCallQuote.action.toChainId,
|
|
126
|
+
toAmountUSD: contractCallQuote.estimate.toAmountUSD || '',
|
|
127
|
+
toAmount: toTokenAmount,
|
|
128
|
+
toAmountMin: toTokenAmount,
|
|
129
|
+
toToken: toToken,
|
|
130
|
+
toAddress: toAddress,
|
|
131
|
+
gasCostUSD: (_e = contractCallQuote.estimate.gasCosts) === null || _e === void 0 ? void 0 : _e[0].amountUSD,
|
|
132
|
+
steps: [contractCallQuote],
|
|
133
|
+
};
|
|
134
|
+
return { routes: [route] };
|
|
135
|
+
}
|
|
86
136
|
return lifi.getRoutes({
|
|
87
137
|
fromChainId,
|
|
88
138
|
fromAmount,
|
package/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
|
};
|