@lifi/widget 1.11.4 → 1.13.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/AppDrawer.style.js +6 -2
- package/AppProvider.d.ts +4 -0
- package/AppProvider.js +5 -2
- package/components/Header/Header.js +1 -0
- package/components/Initializer.js +1 -1
- package/components/NotFound.js +2 -1
- package/components/PoweredBy/PoweredBy.js +3 -2
- package/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +1 -1
- package/components/Step/CircularProgress.d.ts +0 -1
- package/components/Step/Step.js +4 -1
- package/components/Step/StepProcess.style.d.ts +1 -1
- package/components/StepActions/StepActions.js +4 -2
- package/components/SwapButton/ButtonTooltip.d.ts +0 -1
- package/components/SwapButton/SwapButton.js +7 -4
- package/components/SwapButton/SwapButton.style.d.ts +1 -1
- package/components/SwapInput/FormPriceHelperText.js +2 -2
- package/components/SwapInput/SwapInput.style.d.ts +1 -1
- package/components/SwapInput/SwapInputAdornment.d.ts +0 -1
- package/components/SwapInput/SwapInputAdornment.js +2 -2
- package/components/SwapInput/SwapInputAdornment.style.d.ts +1 -1
- package/components/SwapRouteCard/SwapRouteCard.style.js +4 -1
- package/components/TokenAvatar/TokenAvatar.js +3 -2
- package/components/TokenList/TokenList.js +25 -42
- package/components/TokenList/TokenList.style.d.ts +2 -2
- package/components/TokenList/TokenList.style.js +5 -2
- package/components/TokenList/TokenListItem.d.ts +2 -2
- package/components/TokenList/TokenListItem.js +7 -10
- package/components/TokenList/TokenNotFound.d.ts +2 -0
- package/components/TokenList/TokenNotFound.js +15 -0
- package/components/TokenList/VirtualizedTokenList.d.ts +3 -0
- package/components/TokenList/VirtualizedTokenList.js +53 -0
- package/components/TokenList/types.d.ts +16 -1
- package/config/lifi.d.ts +1 -1
- package/config/lifi.js +2 -8
- package/config/sentry.d.ts +1 -1
- package/config/sentry.js +33 -18
- package/config/theme.js +14 -11
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/index.d.ts +3 -0
- package/hooks/index.js +3 -0
- package/hooks/useFeaturedTokens.d.ts +1 -0
- package/hooks/useFeaturedTokens.js +6 -0
- package/hooks/useGasSufficiency.js +11 -4
- package/hooks/useRouteExecution.js +31 -17
- package/hooks/useSwapRoutes.js +2 -2
- package/hooks/useToken.d.ts +2 -1
- package/hooks/useToken.js +2 -1
- package/hooks/useTokenBalance.d.ts +2 -4
- package/hooks/useTokenBalance.js +11 -42
- package/hooks/useTokenBalances.d.ts +6 -3
- package/hooks/useTokenBalances.js +46 -22
- package/hooks/useTokenSearch.d.ts +7 -0
- package/hooks/useTokenSearch.js +37 -0
- package/hooks/useTokens.d.ts +2 -1
- package/hooks/useTokens.js +12 -4
- package/i18n/en/translation.json +5 -2
- package/i18n/index.d.ts +3 -0
- package/package.json +14 -15
- package/pages/MainPage/SwapRoutes.style.d.ts +1 -1
- package/pages/SelectTokenPage/ChainSelect.d.ts +0 -1
- package/pages/SelectTokenPage/ChainSelect.js +8 -5
- package/pages/SelectTokenPage/SearchTokenInput.d.ts +0 -1
- package/pages/SelectTokenPage/SearchTokenInput.js +2 -2
- package/pages/SelectWalletPage/SelectWalletPage.d.ts +0 -1
- package/pages/SelectWalletPage/SelectWalletPage.style.d.ts +2 -2
- package/pages/SettingsPage/AdvancedPreferences.d.ts +0 -1
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
- package/pages/SettingsPage/GasPriceSelect.d.ts +0 -1
- package/pages/SettingsPage/SettingsPage.d.ts +0 -1
- package/pages/SettingsPage/SlippageInput.d.ts +0 -1
- package/pages/SwapHistoryPage/SwapHistoryPage.js +19 -3
- package/pages/SwapPage/StatusBottomSheet.js +2 -2
- package/pages/SwapRoutesPage/SwapRoutesPage.style.d.ts +1 -1
- package/providers/SwapFormProvider/SwapFormProvider.d.ts +1 -1
- package/providers/SwapFormProvider/SwapFormProvider.js +22 -5
- package/providers/SwapFormProvider/types.d.ts +2 -3
- package/providers/SwapFormProvider/types.js +1 -2
- package/providers/WalletProvider/WalletProvider.d.ts +11 -1
- package/providers/WalletProvider/WalletProvider.js +24 -33
- package/providers/WidgetProvider/WidgetProvider.js +24 -12
- package/stores/route/types.d.ts +1 -0
- package/stores/route/useRouteStore.js +3 -12
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/types/token.d.ts +4 -0
- package/types/token.js +1 -0
- package/types/widget.d.ts +4 -3
- package/utils/colors.d.ts +1 -0
- package/utils/colors.js +5 -0
- package/components/TokenList/utils.d.ts +0 -15
- package/components/TokenList/utils.js +0 -10
package/AppDrawer.style.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const DrawerButton: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").ButtonClasses> | undefined;
|
|
5
|
-
color?: "inherit" | "
|
|
5
|
+
color?: "inherit" | "primary" | "secondary" | "error" | "warning" | "info" | "success" | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableElevation?: boolean | undefined;
|
|
8
8
|
disableFocusRipple?: boolean | undefined;
|
package/AppDrawer.style.js
CHANGED
|
@@ -39,8 +39,12 @@ export const DrawerButton = styled(Button, {
|
|
|
39
39
|
? getButtonTransformWidth(drawerProps === null || drawerProps === void 0 ? void 0 : drawerProps.width, drawerProps === null || drawerProps === void 0 ? void 0 : drawerProps.maxWidth)
|
|
40
40
|
: '0px'} * -1), 0, 0)`,
|
|
41
41
|
transition: theme.transitions.create(['transform'], {
|
|
42
|
-
duration:
|
|
43
|
-
|
|
42
|
+
duration: open
|
|
43
|
+
? theme.transitions.duration.enteringScreen
|
|
44
|
+
: theme.transitions.duration.leavingScreen,
|
|
45
|
+
easing: open
|
|
46
|
+
? theme.transitions.easing.easeOut
|
|
47
|
+
: theme.transitions.easing.sharp,
|
|
44
48
|
}),
|
|
45
49
|
zIndex: 1500,
|
|
46
50
|
'&:hover': {
|
package/AppProvider.d.ts
CHANGED
|
@@ -5,3 +5,7 @@ export interface AppProps {
|
|
|
5
5
|
}
|
|
6
6
|
export declare const AppProvider: React.FC<PropsWithChildren<AppProps>>;
|
|
7
7
|
export declare const AppRouter: React.FC<PropsWithChildren<{}>>;
|
|
8
|
+
export declare const TelemetryProvider: React.FC<{
|
|
9
|
+
children: React.ReactElement<any, any> | null;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}>;
|
package/AppProvider.js
CHANGED
|
@@ -12,11 +12,14 @@ import { WalletProvider } from './providers/WalletProvider';
|
|
|
12
12
|
import { WidgetProvider } from './providers/WidgetProvider';
|
|
13
13
|
const QueryProvider = QueryClientProvider;
|
|
14
14
|
export const AppProvider = ({ children, config, }) => {
|
|
15
|
-
|
|
16
|
-
return (_jsx(WidgetProvider, Object.assign({ config: config }, { children: _jsx(ThemeProvider, { children: _jsx(QueryProvider, Object.assign({ client: queryClient }, { children: _jsx(WalletProvider, { children: _jsx(SwapFormProvider, { children: _jsx(AppRouter, { children: children }) }) }) })) }) })));
|
|
15
|
+
return (_jsx(QueryProvider, Object.assign({ client: queryClient }, { children: _jsx(TelemetryProvider, Object.assign({ disabled: config === null || config === void 0 ? void 0 : config.disableTelemetry }, { children: _jsx(WalletProvider, Object.assign({ walletManagement: config === null || config === void 0 ? void 0 : config.walletManagement }, { children: _jsx(WidgetProvider, Object.assign({ config: config }, { children: _jsx(ThemeProvider, { children: _jsx(SwapFormProvider, { children: _jsx(AppRouter, { children: children }) }) }) })) })) })) })));
|
|
17
16
|
};
|
|
18
17
|
export const AppRouter = ({ children }) => {
|
|
19
18
|
const inRouterContext = useInRouterContext();
|
|
20
19
|
const Router = inRouterContext ? Fragment : MemoryRouter;
|
|
21
20
|
return _jsx(Router, { children: children });
|
|
22
21
|
};
|
|
22
|
+
export const TelemetryProvider = ({ children, disabled }) => {
|
|
23
|
+
useTelemetry(disabled);
|
|
24
|
+
return children;
|
|
25
|
+
};
|
package/components/NotFound.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Block as BlockIcon } from '@mui/icons-material';
|
|
2
3
|
import { Box, Typography } from '@mui/material';
|
|
3
4
|
import { useTranslation } from 'react-i18next';
|
|
4
5
|
export const NotFound = () => {
|
|
@@ -10,5 +11,5 @@ export const NotFound = () => {
|
|
|
10
11
|
flexDirection: 'column',
|
|
11
12
|
flex: 1,
|
|
12
13
|
padding: 3,
|
|
13
|
-
} }, { children: [_jsx(Typography, Object.assign({
|
|
14
|
+
} }, { children: [_jsx(Typography, Object.assign({ fontSize: 48 }, { children: _jsx(BlockIcon, { fontSize: "inherit" }) })), _jsx(Typography, Object.assign({ fontSize: 18, fontWeight: 700 }, { children: t('tooltip.notFound.title') })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.secondary", textAlign: "center", mt: 2 }, { children: t('tooltip.notFound.text') }))] })));
|
|
14
15
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Typography } from '@mui/material';
|
|
2
|
+
import { Box, Tooltip, Typography } from '@mui/material';
|
|
3
|
+
import { version } from '../../config/version';
|
|
3
4
|
import { LiFiLogo } from '../LiFiLogo';
|
|
4
5
|
import { Link } from './PoweredBy.style';
|
|
5
6
|
export const PoweredBy = () => {
|
|
@@ -7,5 +8,5 @@ export const PoweredBy = () => {
|
|
|
7
8
|
display: 'flex',
|
|
8
9
|
alignItems: 'flex-end',
|
|
9
10
|
justifyContent: 'flex-end',
|
|
10
|
-
} }, { children: _jsxs(Link, Object.assign({ href: "https://li.fi", target: "_blank", underline: "none", color: "text.primary" }, { children: [_jsx(Typography, Object.assign({ color: "text.secondary", fontSize: 12, px: 0.5 }, { children: "Powered by" })), _jsx(LiFiLogo, { variant: "full", style: { height: 16, width: 42 } })] })) })));
|
|
11
|
+
} }, { children: _jsx(Tooltip, Object.assign({ title: `v${version}`, placement: "top", enterDelay: 5000, arrow: true }, { children: _jsxs(Link, Object.assign({ href: "https://li.fi", target: "_blank", underline: "none", color: "text.primary" }, { children: [_jsx(Typography, Object.assign({ color: "text.secondary", fontSize: 12, px: 0.5 }, { children: "Powered by" })), _jsx(LiFiLogo, { variant: "full", style: { height: 16, width: 42 } })] })) })) })));
|
|
11
12
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const IconButton: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").IconButtonClasses> | undefined;
|
|
5
|
-
color?: "inherit" | "default" | "
|
|
5
|
+
color?: "inherit" | "default" | "primary" | "secondary" | "error" | "warning" | "info" | "success" | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableFocusRipple?: boolean | undefined;
|
|
8
8
|
edge?: false | "end" | "start" | undefined;
|
package/components/Step/Step.js
CHANGED
|
@@ -13,7 +13,10 @@ export const Step = ({ step, fromToken, toToken }) => {
|
|
|
13
13
|
const getCardTitle = () => {
|
|
14
14
|
switch (step.type) {
|
|
15
15
|
case 'lifi':
|
|
16
|
-
|
|
16
|
+
if (step.includedSteps.some((step) => step.type === 'cross')) {
|
|
17
|
+
return t('swap.stepSwapAndBridge');
|
|
18
|
+
}
|
|
19
|
+
return t('swap.stepSwap');
|
|
17
20
|
case 'swap':
|
|
18
21
|
return t('swap.stepSwap');
|
|
19
22
|
case 'cross':
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const LinkButton: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
children?: import("react").ReactNode;
|
|
4
4
|
classes?: Partial<import("@mui/material").IconButtonClasses> | undefined;
|
|
5
|
-
color?: "inherit" | "default" | "
|
|
5
|
+
color?: "inherit" | "default" | "primary" | "secondary" | "error" | "warning" | "info" | "success" | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableFocusRipple?: boolean | undefined;
|
|
8
8
|
edge?: false | "end" | "start" | undefined;
|
|
@@ -21,7 +21,9 @@ import { StepAvatar, StepConnector, StepContent, StepLabel, } from './StepAction
|
|
|
21
21
|
export const StepActions = (_a) => {
|
|
22
22
|
var _b;
|
|
23
23
|
var { step, dense } = _a, other = __rest(_a, ["step", "dense"]);
|
|
24
|
-
const StepDetailsLabel = step.type === 'cross' ||
|
|
24
|
+
const StepDetailsLabel = step.type === 'cross' ||
|
|
25
|
+
(step.type === 'lifi' &&
|
|
26
|
+
step.includedSteps.some((step) => step.type === 'cross'))
|
|
25
27
|
? CrossStepDetailsLabel
|
|
26
28
|
: SwapStepDetailsLabel;
|
|
27
29
|
const isFullView = !dense && ((_b = step.includedSteps) === null || _b === void 0 ? void 0 : _b.length) > 1;
|
|
@@ -33,7 +35,7 @@ export const StepActions = (_a) => {
|
|
|
33
35
|
boxSizing: 'content-box',
|
|
34
36
|
} }, { children: tool.toolDetails.name[0] }))) : null;
|
|
35
37
|
};
|
|
36
|
-
return (_jsxs(Box, Object.assign({}, other, { children: [_jsxs(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' }, mb: isFullView ? 1.5 : 0 }, { children: [_jsx(StepAvatar, Object.assign({ variant:
|
|
38
|
+
return (_jsxs(Box, Object.assign({}, other, { children: [_jsxs(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' }, mb: isFullView ? 1.5 : 0 }, { children: [_jsx(StepAvatar, Object.assign({ variant: "circular", src: step.type !== 'lifi' ? step.toolDetails.logoURI : undefined, alt: step.toolDetails.name }, { children: step.type === 'lifi' ? _jsx(LiFiToolLogo, {}) : step.toolDetails.name[0] })), _jsx(Typography, Object.assign({ ml: 2, fontSize: 18, fontWeight: "500", textTransform: "capitalize" }, { children: step.type === 'lifi'
|
|
37
39
|
? 'LI.FI Smart Contract'
|
|
38
40
|
: step.toolDetails.name }))] })), isFullView ? (_jsx(Stepper, Object.assign({ orientation: "vertical", connector: _jsx(StepConnector, {}), activeStep: -1 }, { children: step.includedSteps.map((step) => (_jsxs(MuiStep, Object.assign({ expanded: true }, { children: [_jsx(StepLabel, Object.assign({ StepIconComponent: StepIconComponent }, { children: step.type === 'cross' || step.type === 'lifi' ? (_jsx(CrossStepDetailsLabel, { step: step })) : (_jsx(SwapStepDetailsLabel, { step: step })) })), _jsx(StepContent, { children: _jsx(StepDetailsContent, { step: step }) })] }), step.id))) }))) : (_jsxs(Box, Object.assign({ ml: 6 }, { children: [_jsx(StepDetailsLabel, { step: step }), _jsx(StepDetailsContent, { step: step })] })))] })));
|
|
39
41
|
};
|
|
@@ -29,7 +29,10 @@ export const SwapButton = ({ onClick, currentRoute, text, loading, }) => {
|
|
|
29
29
|
const [chainId] = useWatch({
|
|
30
30
|
name: [SwapFormKeyHelper.getChainKey('from')],
|
|
31
31
|
});
|
|
32
|
-
|
|
32
|
+
// Allow switching chain only if execution is not started
|
|
33
|
+
const switchChainAllowed = ((_a = getChainById(chainId || ChainId.ETH)) === null || _a === void 0 ? void 0 : _a.id) !== account.chainId &&
|
|
34
|
+
currentRoute &&
|
|
35
|
+
!currentRoute.steps.some((step) => step.execution);
|
|
33
36
|
const handleSwapButtonClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
37
|
if (!account.isActive) {
|
|
35
38
|
if (config.walletManagement) {
|
|
@@ -39,7 +42,7 @@ export const SwapButton = ({ onClick, currentRoute, text, loading, }) => {
|
|
|
39
42
|
navigate(navigationRoutes.selectWallet);
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
|
-
else if (
|
|
45
|
+
else if (switchChainAllowed) {
|
|
43
46
|
yield switchChain(chainId);
|
|
44
47
|
// check that the current route exists in the up to date route list
|
|
45
48
|
}
|
|
@@ -49,7 +52,7 @@ export const SwapButton = ({ onClick, currentRoute, text, loading, }) => {
|
|
|
49
52
|
});
|
|
50
53
|
const getButtonText = () => {
|
|
51
54
|
if (account.isActive) {
|
|
52
|
-
if (
|
|
55
|
+
if (switchChainAllowed) {
|
|
53
56
|
return t(`button.switchChain`);
|
|
54
57
|
}
|
|
55
58
|
if (!currentRoute) {
|
|
@@ -63,5 +66,5 @@ export const SwapButton = ({ onClick, currentRoute, text, loading, }) => {
|
|
|
63
66
|
// loading={isLoading || isFetching}
|
|
64
67
|
disabled: (insufficientFunds || !!insufficientGas.length || loading) &&
|
|
65
68
|
currentRoute &&
|
|
66
|
-
|
|
69
|
+
!switchChainAllowed, fullWidth: true }, { children: getButtonText() })));
|
|
67
70
|
};
|
|
@@ -17,7 +17,7 @@ export declare const Button: import("@emotion/styled").StyledComponent<{
|
|
|
17
17
|
} & Omit<{
|
|
18
18
|
children?: import("react").ReactNode;
|
|
19
19
|
classes?: Partial<import("@mui/material").ButtonClasses> | undefined;
|
|
20
|
-
color?: "inherit" | "
|
|
20
|
+
color?: "inherit" | "primary" | "secondary" | "error" | "warning" | "info" | "success" | undefined;
|
|
21
21
|
disabled?: boolean | undefined;
|
|
22
22
|
disableElevation?: boolean | undefined;
|
|
23
23
|
disableFocusRipple?: boolean | undefined;
|
|
@@ -14,14 +14,14 @@ export const FormPriceHelperText = ({ formType, selected }) => {
|
|
|
14
14
|
SwapFormKeyHelper.getTokenKey(formType),
|
|
15
15
|
],
|
|
16
16
|
});
|
|
17
|
-
const { token, isLoading
|
|
17
|
+
const { token, isLoading } = useTokenBalance(chainId, tokenAddress);
|
|
18
18
|
const fromAmountTokenPrice = formatTokenPrice(amount, token === null || token === void 0 ? void 0 : token.priceUSD);
|
|
19
19
|
return (_jsxs(FormHelperText, Object.assign({ component: "div", sx: { display: 'flex', justifyContent: 'space-between', margin: 0 } }, { children: [_jsx(Typography, Object.assign({ color: fromAmountTokenPrice ? 'text.secondary' : 'grey.600', fontWeight: 400, fontSize: 12, marginLeft: selected ? 8 : 2, lineHeight: 1.3334, flex: 1, sx: {
|
|
20
20
|
wordBreak: 'break-word',
|
|
21
21
|
overflowWrap: 'break-word',
|
|
22
22
|
} }, { children: t(`swap.currency`, {
|
|
23
23
|
value: fromAmountTokenPrice,
|
|
24
|
-
}) })), isLoading &&
|
|
24
|
+
}) })), isLoading && tokenAddress ? (_jsx(Skeleton, { variant: "text", width: 48, height: 16, sx: { borderRadius: 0.25 } })) : (token === null || token === void 0 ? void 0 : token.amount) ? (_jsx(Typography, Object.assign({ fontWeight: 400, fontSize: 12, color: "text.secondary", lineHeight: 1.3334, pl: 0.25 }, { children: t(`swap.maxAmount`, {
|
|
25
25
|
amount: token === null || token === void 0 ? void 0 : token.amount,
|
|
26
26
|
}) }))) : null] })));
|
|
27
27
|
};
|
|
@@ -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?: "
|
|
7
|
+
color?: "primary" | "secondary" | "error" | "warning" | "info" | "success" | undefined;
|
|
8
8
|
disabled?: boolean | undefined;
|
|
9
9
|
error?: boolean | undefined;
|
|
10
10
|
fullWidth?: boolean | undefined;
|
|
@@ -14,10 +14,10 @@ export const SwapInputAdornment = ({ formType }) => {
|
|
|
14
14
|
SwapFormKeyHelper.getTokenKey(formType),
|
|
15
15
|
],
|
|
16
16
|
});
|
|
17
|
-
const { token, isLoading
|
|
17
|
+
const { token, isLoading } = useTokenBalance(chainId, tokenAddress);
|
|
18
18
|
const handleMax = () => {
|
|
19
19
|
var _a;
|
|
20
20
|
setValue(SwapFormKeyHelper.getAmountKey(formType), (_a = token === null || token === void 0 ? void 0 : token.amount) !== null && _a !== void 0 ? _a : '');
|
|
21
21
|
};
|
|
22
|
-
return (_jsx(InputAdornment, Object.assign({ position: "end" }, { children: isLoading &&
|
|
22
|
+
return (_jsx(InputAdornment, Object.assign({ position: "end" }, { children: isLoading && tokenAddress ? (_jsx(Skeleton, { variant: "rectangular", width: 46, height: 20, sx: { borderRadius: 0.5 } })) : formType === 'from' && (token === null || token === void 0 ? void 0 : token.amount) ? (_jsx(Button, Object.assign({ onClick: handleMax, variant: "outlined" }, { children: t('button.max') }))) : null })));
|
|
23
23
|
};
|
|
@@ -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" | "
|
|
5
|
+
color?: "inherit" | "primary" | "secondary" | "error" | "warning" | "info" | "success" | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
disableElevation?: boolean | undefined;
|
|
8
8
|
disableFocusRipple?: boolean | undefined;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Typography } from '@mui/material';
|
|
2
2
|
import { styled } from '@mui/material/styles';
|
|
3
|
+
import { getContrastTextColor } from '../../utils';
|
|
3
4
|
export const Label = styled(Typography, {
|
|
4
5
|
shouldForwardProp: (prop) => prop !== 'active',
|
|
5
6
|
})(({ theme, active }) => ({
|
|
@@ -11,7 +12,9 @@ export const Label = styled(Typography, {
|
|
|
11
12
|
? theme.palette.grey[500]
|
|
12
13
|
: theme.palette.grey[600],
|
|
13
14
|
borderRadius: theme.shape.borderRadiusSecondary,
|
|
14
|
-
color: active
|
|
15
|
+
color: active
|
|
16
|
+
? getContrastTextColor(theme, theme.palette.primary.main)
|
|
17
|
+
: theme.palette.text.secondary,
|
|
15
18
|
padding: theme.spacing(0.75),
|
|
16
19
|
fontSize: 12,
|
|
17
20
|
lineHeight: 1,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Avatar, Badge } from '@mui/material';
|
|
3
|
-
import { useChain } from '../../hooks';
|
|
3
|
+
import { useChain, useToken } from '../../hooks';
|
|
4
4
|
import { SmallAvatar } from '../SmallAvatar';
|
|
5
5
|
export const TokenAvatar = ({ token, sx }) => {
|
|
6
6
|
const { chain } = useChain(token.chainId);
|
|
7
|
-
|
|
7
|
+
const { token: chainToken } = useToken(token.chainId, token.address);
|
|
8
|
+
return (_jsx(Badge, Object.assign({ overlap: "circular", anchorOrigin: { vertical: 'bottom', horizontal: 'right' }, badgeContent: chain ? (_jsx(SmallAvatar, Object.assign({ src: chain.logoURI, alt: chain.name }, { children: chain.name[0] }))) : null, sx: sx }, { children: _jsx(Avatar, Object.assign({ src: token.logoURI || (chainToken === null || chainToken === void 0 ? void 0 : chainToken.logoURI), alt: token.symbol }, { children: token.symbol[0] })) })));
|
|
8
9
|
};
|
|
@@ -1,48 +1,37 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box
|
|
3
|
-
import { useCallback,
|
|
2
|
+
import { Box } from '@mui/material';
|
|
3
|
+
import { useCallback, useRef } from 'react';
|
|
4
4
|
import { useFormContext, useWatch } from 'react-hook-form';
|
|
5
|
-
import {
|
|
6
|
-
import { useVirtual } from 'react-virtual';
|
|
7
|
-
import { useDebouncedWatch, useTokenBalances } from '../../hooks';
|
|
5
|
+
import { useDebouncedWatch, useTokenBalances, useTokenSearch, } from '../../hooks';
|
|
8
6
|
import { SwapFormKey, SwapFormKeyHelper, } from '../../providers/SwapFormProvider';
|
|
9
7
|
import { useWallet } from '../../providers/WalletProvider';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import { TokenNotFound } from './TokenNotFound';
|
|
9
|
+
import { VirtualizedTokenList } from './VirtualizedTokenList';
|
|
12
10
|
export const TokenList = ({ formType, height, onClick, }) => {
|
|
13
|
-
|
|
11
|
+
var _a, _b;
|
|
12
|
+
const parentRef = useRef(null);
|
|
14
13
|
const { account } = useWallet();
|
|
15
14
|
const { setValue, getValues } = useFormContext();
|
|
16
15
|
const [selectedChainId] = useWatch({
|
|
17
16
|
name: [SwapFormKeyHelper.getChainKey(formType)],
|
|
18
17
|
});
|
|
19
|
-
const [
|
|
20
|
-
const { tokens, isLoading, isBalanceLoading } = useTokenBalances(selectedChainId);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
size: chainTokens.length,
|
|
37
|
-
parentRef,
|
|
38
|
-
overscan: 3,
|
|
39
|
-
paddingEnd: 12,
|
|
40
|
-
estimateSize: useCallback(() => 64, []),
|
|
41
|
-
keyExtractor: (index) => { var _a; return (_a = chainTokens[index].address) !== null && _a !== void 0 ? _a : index; },
|
|
42
|
-
});
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
scrollToIndex(0);
|
|
45
|
-
}, [scrollToIndex, selectedChainId]);
|
|
18
|
+
const [tokenSearchFilter] = useDebouncedWatch([SwapFormKey.TokenSearchFilter], 250);
|
|
19
|
+
const { tokens: chainTokens, tokensWithBalance, isLoading: isTokensLoading, isBalanceLoading, featuredTokens, } = useTokenBalances(selectedChainId);
|
|
20
|
+
let filteredTokens = ((_a = tokensWithBalance !== null && tokensWithBalance !== void 0 ? tokensWithBalance : chainTokens) !== null && _a !== void 0 ? _a : []);
|
|
21
|
+
const searchFilter = (_b = tokenSearchFilter === null || tokenSearchFilter === void 0 ? void 0 : tokenSearchFilter.toUpperCase()) !== null && _b !== void 0 ? _b : '';
|
|
22
|
+
filteredTokens = tokenSearchFilter
|
|
23
|
+
? filteredTokens.filter((token) => token.name.toUpperCase().includes(searchFilter) ||
|
|
24
|
+
token.symbol.toUpperCase().includes(searchFilter) ||
|
|
25
|
+
token.address.toUpperCase().includes(searchFilter))
|
|
26
|
+
: filteredTokens;
|
|
27
|
+
const tokenSearchEnabled = !filteredTokens.length && !isTokensLoading;
|
|
28
|
+
const { token: searchedToken, isLoading: isSearchedTokenLoading } = useTokenSearch(tokenSearchFilter, selectedChainId, tokenSearchEnabled);
|
|
29
|
+
const isLoading = isTokensLoading || (tokenSearchEnabled && isSearchedTokenLoading);
|
|
30
|
+
const tokens = filteredTokens.length
|
|
31
|
+
? filteredTokens
|
|
32
|
+
: searchedToken
|
|
33
|
+
? [searchedToken]
|
|
34
|
+
: filteredTokens;
|
|
46
35
|
const handleTokenClick = useCallback((tokenAddress) => {
|
|
47
36
|
setValue(SwapFormKeyHelper.getTokenKey(formType), tokenAddress);
|
|
48
37
|
setValue(SwapFormKeyHelper.getAmountKey(formType), '');
|
|
@@ -58,11 +47,5 @@ export const TokenList = ({ formType, height, onClick, }) => {
|
|
|
58
47
|
}
|
|
59
48
|
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
60
49
|
}, [formType, getValues, onClick, setValue]);
|
|
61
|
-
return (_jsxs(Box, Object.assign({ ref: parentRef, style: { height, overflow: 'auto' } }, { children: [!
|
|
62
|
-
const token = chainTokens[item.index];
|
|
63
|
-
if (token.name.includes(skeletonKey)) {
|
|
64
|
-
return (_jsx(TokenListItemSkeleton, { size: item.size, start: item.start }, item.key));
|
|
65
|
-
}
|
|
66
|
-
return (_jsx(TokenListItem, { onClick: handleTokenClick, size: item.size, start: item.start, token: token, isBalanceLoading: isBalanceLoading, showBalance: account.isActive }, item.key));
|
|
67
|
-
}) }))] })));
|
|
50
|
+
return (_jsxs(Box, Object.assign({ ref: parentRef, style: { height, overflow: 'auto' } }, { children: [!tokens.length && !isLoading ? _jsx(TokenNotFound, {}) : null, _jsx(VirtualizedTokenList, { tokens: tokens, featuredTokensLength: featuredTokens === null || featuredTokens === void 0 ? void 0 : featuredTokens.length, scrollElementRef: parentRef, chainId: selectedChainId, isLoading: isLoading, isBalanceLoading: isBalanceLoading, showBalance: account.isActive, showFeatured: !tokenSearchFilter, onClick: handleTokenClick })] })));
|
|
68
51
|
};
|
|
@@ -17,7 +17,7 @@ export declare const ListItemButton: import("@emotion/styled").StyledComponent<i
|
|
|
17
17
|
touchRippleRef?: import("react").Ref<import("@mui/material/ButtonBase/TouchRipple").TouchRippleActions> | undefined;
|
|
18
18
|
}, "classes"> & 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
|
-
}, "className" | "style" | "classes" | "tabIndex" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "alignItems" | "autoFocus" | "dense" | "
|
|
20
|
+
}, "className" | "style" | "classes" | "tabIndex" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "alignItems" | "autoFocus" | "dense" | "divider" | "selected" | "disableGutters"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
21
21
|
export declare const ListItem: import("@emotion/styled").StyledComponent<{
|
|
22
22
|
button?: false | undefined;
|
|
23
23
|
} & import("@mui/material").ListItemBaseProps & {
|
|
@@ -29,4 +29,4 @@ export declare const ListItem: import("@emotion/styled").StyledComponent<{
|
|
|
29
29
|
} | undefined;
|
|
30
30
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "key" | keyof import("react").LiHTMLAttributes<HTMLLIElement>> & {
|
|
31
31
|
ref?: ((instance: HTMLLIElement | null) => void) | import("react").RefObject<HTMLLIElement> | null | undefined;
|
|
32
|
-
}, "button" | "className" | "style" | "classes" | "children" | "disabled" | "sx" | "alignItems" | "autoFocus" | "dense" | "
|
|
32
|
+
}, "button" | "className" | "style" | "classes" | "children" | "disabled" | "sx" | "alignItems" | "autoFocus" | "dense" | "divider" | "components" | "componentsProps" | "selected" | "disableGutters" | "ContainerComponent" | "ContainerProps" | "disablePadding" | "secondaryAction"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -6,6 +6,7 @@ export const ListItemButton = styled(MuiListItemButton)(({ theme }) => ({
|
|
|
6
6
|
borderRadius: theme.shape.borderRadiusSecondary,
|
|
7
7
|
paddingLeft: theme.spacing(2),
|
|
8
8
|
height: 64,
|
|
9
|
+
width: '100%',
|
|
9
10
|
'&:hover': {
|
|
10
11
|
backgroundColor: getContrastAlphaColor(theme, '4%'),
|
|
11
12
|
},
|
|
@@ -14,8 +15,10 @@ export const ListItem = styled(MuiListItem)(({ theme }) => ({
|
|
|
14
15
|
position: 'absolute',
|
|
15
16
|
top: 0,
|
|
16
17
|
left: 0,
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
height: 64,
|
|
19
|
+
flexDirection: 'column',
|
|
20
|
+
alignItems: 'flex-start',
|
|
21
|
+
padding: theme.spacing(0, 3),
|
|
19
22
|
[`.${listItemSecondaryActionClasses.root}`]: {
|
|
20
23
|
right: theme.spacing(5),
|
|
21
24
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { TokenListItemProps } from './types';
|
|
3
3
|
export declare const TokenListItem: React.FC<TokenListItemProps>;
|
|
4
|
-
export declare const TokenListItemSkeleton:
|
|
4
|
+
export declare const TokenListItemSkeleton: () => JSX.Element;
|
|
5
5
|
export declare const TokenAmountSkeleton: React.FC;
|
|
@@ -4,22 +4,19 @@ import { memo } from 'react';
|
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { formatTokenPrice } from '../../utils';
|
|
6
6
|
import { ListItem, ListItemButton } from './TokenList.style';
|
|
7
|
-
export const TokenListItem = memo(({ onClick, size, start, token, showBalance, isBalanceLoading }) => {
|
|
7
|
+
export const TokenListItem = memo(({ onClick, size, start, token, showBalance, isBalanceLoading, startAdornment, endAdornment, }) => {
|
|
8
8
|
const { t } = useTranslation();
|
|
9
9
|
const handleClick = () => onClick === null || onClick === void 0 ? void 0 : onClick(token.address);
|
|
10
10
|
const tokenPrice = formatTokenPrice(token.amount, token.priceUSD);
|
|
11
|
-
return (
|
|
11
|
+
return (_jsxs(ListItem, Object.assign({ disablePadding: true, style: {
|
|
12
12
|
height: `${size}px`,
|
|
13
13
|
transform: `translateY(${start}px)`,
|
|
14
|
-
} }, { children: _jsxs(ListItemButton, Object.assign({ onClick: handleClick, dense: true, disableRipple: true }, { children: [_jsx(ListItemAvatar, { children: _jsx(Avatar, Object.assign({ src: token.logoURI, alt: token.symbol }, { children: token.symbol[0] })) }), _jsx(ListItemText, { primary: token.symbol, secondary: token.name }), showBalance ? (isBalanceLoading ? (_jsx(TokenAmountSkeleton, {})) : (_jsxs(Box, Object.assign({ sx: { textAlign: 'right' } }, { children: [Number(token.amount) ? (_jsx(Typography, Object.assign({ variant: "body1", noWrap: true }, { children: token.amount }))) : null, tokenPrice ? (_jsx(Typography, Object.assign({ fontWeight: 400, fontSize: 12, color: "text.secondary", "data-price": token.priceUSD }, { children: t(`swap.currency`, {
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
} }, { children: [startAdornment, _jsxs(ListItemButton, Object.assign({ onClick: handleClick, dense: true, disableRipple: true }, { children: [_jsx(ListItemAvatar, { children: _jsx(Avatar, Object.assign({ src: token.logoURI, alt: token.symbol }, { children: token.symbol[0] })) }), _jsx(ListItemText, { primary: token.symbol, secondary: token.name }), showBalance ? (isBalanceLoading ? (_jsx(TokenAmountSkeleton, {})) : (_jsxs(Box, Object.assign({ sx: { textAlign: 'right' } }, { children: [Number(token.amount) ? (_jsx(Typography, Object.assign({ variant: "body1", noWrap: true }, { children: token.amount }))) : null, tokenPrice ? (_jsx(Typography, Object.assign({ fontWeight: 400, fontSize: 12, color: "text.secondary", "data-price": token.priceUSD }, { children: t(`swap.currency`, {
|
|
15
|
+
value: tokenPrice,
|
|
16
|
+
}) }))) : null] })))) : null] })), endAdornment] })));
|
|
17
17
|
});
|
|
18
|
-
export const TokenListItemSkeleton = (
|
|
19
|
-
return (_jsxs(ListItem, Object.assign({ secondaryAction: _jsx(TokenAmountSkeleton, {}), disablePadding: true,
|
|
20
|
-
height: `${size}px`,
|
|
21
|
-
transform: `translateY(${start}px)`,
|
|
22
|
-
} }, { children: [_jsx(ListItemAvatar, { children: _jsx(Skeleton, { variant: "circular", width: 32, height: 32, sx: { marginLeft: 2, marginRight: 2 } }) }), _jsx(ListItemText, { primary: _jsx(Skeleton, { variant: "text", width: 48, height: 20 }), secondary: _jsx(Skeleton, { variant: "text", width: 96, height: 20 }) })] })));
|
|
18
|
+
export const TokenListItemSkeleton = () => {
|
|
19
|
+
return (_jsxs(ListItem, Object.assign({ secondaryAction: _jsx(TokenAmountSkeleton, {}), disablePadding: true, sx: { position: 'relative', flexDirection: 'row', alignItems: 'center' } }, { children: [_jsx(ListItemAvatar, { children: _jsx(Skeleton, { variant: "circular", width: 32, height: 32, sx: { marginLeft: 2, marginRight: 2 } }) }), _jsx(ListItemText, { primary: _jsx(Skeleton, { variant: "text", width: 48, height: 20 }), secondary: _jsx(Skeleton, { variant: "text", width: 96, height: 20 }) })] })));
|
|
23
20
|
};
|
|
24
21
|
export const TokenAmountSkeleton = () => {
|
|
25
22
|
return (_jsxs(Box, Object.assign({ sx: {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { SearchOff as SearchOffIcon } from '@mui/icons-material';
|
|
3
|
+
import { Box, Typography } from '@mui/material';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
export const TokenNotFound = () => {
|
|
6
|
+
const { t } = useTranslation();
|
|
7
|
+
return (_jsxs(Box, Object.assign({ sx: {
|
|
8
|
+
display: 'flex',
|
|
9
|
+
justifyContent: 'center',
|
|
10
|
+
alignItems: 'center',
|
|
11
|
+
flexDirection: 'column',
|
|
12
|
+
flex: 1,
|
|
13
|
+
padding: 3,
|
|
14
|
+
} }, { children: [_jsx(Typography, Object.assign({ fontSize: 48, lineHeight: 1 }, { children: _jsx(SearchOffIcon, { fontSize: "inherit" }) })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.secondary", textAlign: "center", mt: 2, px: 2 }, { children: t('swap.couldntFindTokens') }))] })));
|
|
15
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { List, Typography } from '@mui/material';
|
|
3
|
+
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
4
|
+
import { useEffect } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { TokenListItem, TokenListItemSkeleton } from './TokenListItem';
|
|
7
|
+
export const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollElementRef, chainId, isLoading, isBalanceLoading, showBalance, showFeatured, onClick, }) => {
|
|
8
|
+
const { t } = useTranslation();
|
|
9
|
+
const hasFeaturedTokens = !!featuredTokensLength && showFeatured;
|
|
10
|
+
const featuredTokensLastIndex = (featuredTokensLength !== null && featuredTokensLength !== void 0 ? featuredTokensLength : 0) - 1;
|
|
11
|
+
const tokensLastIndex = tokens.length - 1;
|
|
12
|
+
const { getVirtualItems, getTotalSize, scrollToIndex } = useVirtualizer({
|
|
13
|
+
count: tokens.length,
|
|
14
|
+
getScrollElement: () => scrollElementRef.current,
|
|
15
|
+
overscan: 5,
|
|
16
|
+
paddingEnd: 12,
|
|
17
|
+
estimateSize: (index) => {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
// heigth of TokenListItem
|
|
20
|
+
let size = 64;
|
|
21
|
+
if (!hasFeaturedTokens) {
|
|
22
|
+
return size;
|
|
23
|
+
}
|
|
24
|
+
if (index === 0 && ((_a = tokens[index]) === null || _a === void 0 ? void 0 : _a.featured)) {
|
|
25
|
+
// height of startAdornment
|
|
26
|
+
size += 24;
|
|
27
|
+
}
|
|
28
|
+
if (index === featuredTokensLastIndex &&
|
|
29
|
+
index !== tokensLastIndex &&
|
|
30
|
+
((_b = tokens[index]) === null || _b === void 0 ? void 0 : _b.featured)) {
|
|
31
|
+
// height of endAdornment
|
|
32
|
+
size += 32;
|
|
33
|
+
}
|
|
34
|
+
return size;
|
|
35
|
+
},
|
|
36
|
+
getItemKey: (index) => { var _a; return (_a = tokens[index].address) !== null && _a !== void 0 ? _a : index; },
|
|
37
|
+
});
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
scrollToIndex(0, { align: 'start', smoothScroll: false });
|
|
40
|
+
}, [scrollToIndex, chainId]);
|
|
41
|
+
if (isLoading) {
|
|
42
|
+
return (_jsx(List, Object.assign({ disablePadding: true }, { children: Array.from({ length: 3 }).map((_, index) => (
|
|
43
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
44
|
+
_jsx(TokenListItemSkeleton, {}, index))) })));
|
|
45
|
+
}
|
|
46
|
+
return (_jsx(List, Object.assign({ style: { height: getTotalSize() }, disablePadding: true }, { children: getVirtualItems().map((item) => {
|
|
47
|
+
const token = tokens[item.index];
|
|
48
|
+
return (_jsx(TokenListItem, { onClick: onClick, size: item.size, start: item.start, token: token, isBalanceLoading: isBalanceLoading, showBalance: showBalance, startAdornment: hasFeaturedTokens && token.featured && item.index === 0 ? (_jsx(Typography, Object.assign({ fontSize: 14, fontWeight: 600, lineHeight: 1, px: 2, pb: 1.25 }, { children: t('swap.featuredTokens') }))) : null, endAdornment: hasFeaturedTokens &&
|
|
49
|
+
token.featured &&
|
|
50
|
+
item.index === featuredTokensLastIndex &&
|
|
51
|
+
item.index !== tokensLastIndex ? (_jsx(Typography, Object.assign({ fontSize: 14, fontWeight: 600, lineHeight: 1, px: 2, py: 1.25 }, { children: t('swap.otherTokens') }))) : null }, item.key));
|
|
52
|
+
}) })));
|
|
53
|
+
};
|
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
import { TokenAmount } from '@lifi/sdk';
|
|
2
|
+
import { MutableRefObject } from 'react';
|
|
2
3
|
import { SwapFormDirection } from '../../providers/SwapFormProvider';
|
|
4
|
+
import { Token } from '../../types';
|
|
3
5
|
export interface TokenListProps {
|
|
4
6
|
formType: SwapFormDirection;
|
|
5
7
|
height: number;
|
|
6
8
|
onClick?(): void;
|
|
7
9
|
}
|
|
10
|
+
export interface VirtualizedTokenListProps {
|
|
11
|
+
tokens: Token[];
|
|
12
|
+
featuredTokensLength?: number;
|
|
13
|
+
scrollElementRef: MutableRefObject<HTMLElement | null>;
|
|
14
|
+
isLoading: boolean;
|
|
15
|
+
isBalanceLoading: boolean;
|
|
16
|
+
chainId: number;
|
|
17
|
+
showBalance?: boolean;
|
|
18
|
+
showFeatured?: boolean;
|
|
19
|
+
onClick(tokenAddress: string): void;
|
|
20
|
+
}
|
|
8
21
|
export interface TokenListItemBaseProps {
|
|
9
|
-
onClick?(
|
|
22
|
+
onClick?(tokenAddress: string): void;
|
|
10
23
|
size: number;
|
|
11
24
|
start: number;
|
|
12
25
|
}
|
|
@@ -14,4 +27,6 @@ export interface TokenListItemProps extends TokenListItemBaseProps {
|
|
|
14
27
|
showBalance?: boolean;
|
|
15
28
|
token: TokenAmount;
|
|
16
29
|
isBalanceLoading?: boolean;
|
|
30
|
+
startAdornment?: React.ReactNode;
|
|
31
|
+
endAdornment?: React.ReactNode;
|
|
17
32
|
}
|
package/config/lifi.d.ts
CHANGED