@lifi/widget 2.0.0-beta.1 → 2.0.0-beta.11
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/App.d.ts +4 -3
- package/AppDrawer.d.ts +1 -1
- package/AppDrawer.js +2 -1
- package/AppProvider.js +1 -1
- package/README.md +11 -12
- package/cjs/App.d.ts +4 -3
- package/cjs/AppDrawer.d.ts +1 -1
- package/cjs/AppDrawer.js +2 -1
- package/cjs/AppProvider.js +1 -1
- package/cjs/components/ChainSelect/ChainSelect.d.ts +1 -2
- package/cjs/components/ChainSelect/ChainSelect.style.js +1 -1
- package/cjs/components/ChainSelect/useChainSelect.js +6 -0
- package/cjs/components/GasMessage/FundsSufficiencyMessage.d.ts +1 -2
- package/cjs/components/GasMessage/GasMessage.js +1 -6
- package/cjs/components/Header/Header.js +2 -2
- package/cjs/components/Header/Header.style.d.ts +10 -3
- package/cjs/components/Header/Header.style.js +3 -0
- package/cjs/components/Header/NavigationHeader.js +23 -7
- package/cjs/components/Header/NavigationTabs.d.ts +1 -0
- package/cjs/components/Header/NavigationTabs.js +26 -0
- package/cjs/components/Header/NavigationTabs.style.d.ts +34 -0
- package/cjs/components/Header/NavigationTabs.style.js +61 -0
- package/cjs/components/Header/WalletHeader.d.ts +1 -0
- package/cjs/components/Header/WalletHeader.js +16 -9
- package/cjs/components/Header/useHeaderActionStore.js +0 -1
- package/cjs/components/Insurance/Insurance.js +2 -2
- package/cjs/components/Insurance/InsuranceCard.js +34 -12
- package/cjs/components/Insurance/InsuranceCollapsed.js +9 -11
- package/cjs/components/Insurance/index.d.ts +1 -0
- package/cjs/components/Insurance/index.js +1 -0
- package/cjs/components/Insurance/types.d.ts +12 -9
- package/cjs/components/NFT/NFT.js +2 -2
- package/cjs/components/NFT/types.d.ts +1 -1
- package/cjs/components/PoweredBy/PoweredBy.js +2 -3
- package/cjs/components/SelectChainAndToken.js +8 -7
- package/cjs/components/SelectTokenButton/SelectTokenButton.js +6 -3
- package/cjs/components/SendToWallet/SendToWallet.js +2 -2
- package/cjs/components/SmallAvatar.d.ts +1 -1
- package/cjs/components/Step/CircularProgress.d.ts +1 -2
- package/cjs/components/Step/Step.js +15 -5
- package/cjs/components/Step/StepList.d.ts +1 -2
- package/cjs/components/StepActions/StepActions.js +4 -20
- package/cjs/components/SwapButton/SwapButton.js +16 -4
- package/cjs/components/SwapInput/FormPriceHelperText.js +1 -1
- package/cjs/components/SwapInput/SwapInput.js +2 -2
- package/cjs/components/SwapInput/SwapInputEndAdornment.d.ts +1 -2
- package/cjs/components/SwapInput/SwapInputEndAdornment.js +2 -2
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +19 -3
- package/cjs/components/SwapRouteCard/SwapRouteCardEssentials.js +1 -1
- package/cjs/components/SwapRouteCard/SwapRouteCardSkeleton.js +1 -1
- package/cjs/components/SwapRoutes/SwapRoutes.js +1 -1
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.d.ts +2 -3
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +2 -2
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.style.js +1 -0
- package/cjs/components/Token/Token.js +1 -1
- package/cjs/components/TokenAvatar/TokenAvatar.d.ts +4 -4
- package/cjs/components/TokenList/TokenList.js +9 -4
- package/cjs/components/TokenList/TokenList.style.d.ts +5 -2
- package/cjs/components/TokenList/TokenList.style.js +20 -1
- package/cjs/components/TokenList/TokenListItem.d.ts +1 -1
- package/cjs/components/TokenList/TokenListItem.js +28 -5
- package/cjs/components/TokenList/VirtualizedTokenList.js +3 -3
- package/cjs/components/TokenList/types.d.ts +6 -3
- package/cjs/config/theme.js +15 -3
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/index.d.ts +2 -1
- package/cjs/hooks/index.js +2 -1
- package/cjs/hooks/useContentHeight.js +3 -5
- package/cjs/hooks/useFeaturedTokens.d.ts +1 -1
- package/cjs/hooks/useFundsSufficiency.js +2 -2
- package/cjs/hooks/useGasRefuel.d.ts +1 -1
- package/cjs/hooks/useGasRefuel.js +5 -15
- package/cjs/hooks/useGasSufficiency.js +12 -3
- package/cjs/hooks/useInitializer.js +0 -1
- package/cjs/hooks/useProcessMessage.d.ts +2 -1
- package/cjs/hooks/useProcessMessage.js +27 -9
- package/cjs/hooks/useRouteExecution.js +6 -5
- package/cjs/hooks/useSwapOnly.d.ts +1 -0
- package/cjs/hooks/useSwapOnly.js +9 -0
- package/cjs/hooks/useSwapRoutes.d.ts +1 -2
- package/cjs/hooks/useSwapRoutes.js +32 -18
- package/cjs/hooks/useToken.d.ts +1 -1
- package/cjs/hooks/useTokenAddressBalance.d.ts +2 -2
- package/cjs/hooks/useTokenBalance.js +6 -7
- package/cjs/hooks/useTokenBalances.d.ts +5 -5
- package/cjs/hooks/useTokenBalances.js +4 -19
- package/cjs/hooks/useTokenSearch.d.ts +2 -2
- package/cjs/hooks/useTokens.d.ts +2 -2
- package/cjs/i18n/bn.json +8 -0
- package/cjs/i18n/en.json +30 -5
- package/cjs/i18n/fr.json +8 -0
- package/cjs/i18n/id.json +22 -7
- package/cjs/i18n/ko.json +22 -7
- package/cjs/i18n/pt.json +32 -7
- package/cjs/i18n/th.json +21 -6
- package/cjs/i18n/uk.json +43 -18
- package/cjs/i18n/zh.json +23 -8
- package/cjs/icons/InsuraceLogo.d.ts +1 -1
- package/cjs/icons/LiFiFullLogo.d.ts +1 -1
- package/cjs/icons/LiFiLogo.d.ts +1 -1
- package/cjs/icons/LiFiToolLogo.d.ts +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +1 -2
- package/cjs/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -2
- package/cjs/pages/SelectTokenPage/SelectTokenPage.js +3 -1
- package/cjs/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -2
- package/cjs/pages/SettingsPage/GasPriceSelect.d.ts +1 -2
- package/cjs/pages/SettingsPage/LanguageSelect.js +1 -1
- package/cjs/pages/SettingsPage/SettingsPage.d.ts +1 -2
- package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -2
- package/cjs/pages/SettingsPage/SlippageInput.d.ts +1 -2
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +6 -2
- package/cjs/pages/SwapPage/ExchangeRateBottomSheet.js +1 -1
- package/cjs/pages/SwapPage/StatusBottomSheet.js +15 -9
- package/cjs/pages/SwapPage/StatusBottomSheet.style.d.ts +1 -1
- package/cjs/pages/SwapPage/StatusBottomSheet.style.js +2 -2
- package/cjs/pages/SwapPage/SwapPage.js +31 -10
- package/cjs/pages/SwapPage/TokenValueBottomSheet.js +7 -12
- package/cjs/pages/SwapPage/utils.d.ts +2 -0
- package/cjs/pages/SwapPage/utils.js +10 -0
- package/cjs/providers/I18nProvider/I18nProvider.js +3 -3
- package/cjs/providers/SDKProvider/SDKProvider.js +2 -0
- package/cjs/providers/SwapFormProvider/FormUpdater.js +3 -0
- package/cjs/providers/WalletProvider/WalletProvider.js +77 -49
- package/cjs/providers/WalletProvider/types.d.ts +3 -5
- package/cjs/providers/WidgetProvider/WidgetProvider.js +1 -1
- package/cjs/stores/StoreProvider.d.ts +2 -2
- package/cjs/stores/StoreProvider.js +3 -2
- package/cjs/stores/routes/RouteExecutionStore.d.ts +1 -1
- package/cjs/stores/routes/RouteExecutionStore.js +0 -1
- package/cjs/stores/settings/index.d.ts +1 -0
- package/cjs/stores/settings/index.js +1 -0
- package/cjs/stores/settings/types.d.ts +11 -0
- package/cjs/stores/settings/useSplitSubvariantStore.d.ts +7 -0
- package/cjs/stores/settings/useSplitSubvariantStore.js +44 -0
- package/cjs/types/events.d.ts +9 -1
- package/cjs/types/events.js +1 -0
- package/cjs/types/token.d.ts +2 -2
- package/cjs/types/widget.d.ts +13 -8
- package/cjs/types/widget.js +4 -2
- package/cjs/utils/format.d.ts +1 -1
- package/cjs/utils/format.js +7 -12
- package/cjs/utils/wallet.d.ts +1 -1
- package/cjs/utils/wallet.js +3 -3
- package/components/ChainSelect/ChainSelect.d.ts +1 -2
- package/components/ChainSelect/ChainSelect.style.js +1 -1
- package/components/ChainSelect/useChainSelect.js +7 -1
- package/components/GasMessage/FundsSufficiencyMessage.d.ts +1 -2
- package/components/GasMessage/GasMessage.js +2 -7
- package/components/Header/Header.js +3 -3
- package/components/Header/Header.style.d.ts +10 -3
- package/components/Header/Header.style.js +3 -0
- package/components/Header/NavigationHeader.js +23 -7
- package/components/Header/NavigationTabs.d.ts +1 -0
- package/components/Header/NavigationTabs.js +22 -0
- package/components/Header/NavigationTabs.style.d.ts +34 -0
- package/components/Header/NavigationTabs.style.js +58 -0
- package/components/Header/WalletHeader.d.ts +1 -0
- package/components/Header/WalletHeader.js +14 -8
- package/components/Header/useHeaderActionStore.js +0 -1
- package/components/Insurance/Insurance.js +2 -2
- package/components/Insurance/InsuranceCard.js +37 -15
- package/components/Insurance/InsuranceCollapsed.js +9 -11
- package/components/Insurance/index.d.ts +1 -0
- package/components/Insurance/index.js +1 -0
- package/components/Insurance/types.d.ts +12 -9
- package/components/NFT/NFT.js +2 -2
- package/components/NFT/types.d.ts +1 -1
- package/components/PoweredBy/PoweredBy.js +2 -3
- package/components/SelectChainAndToken.js +9 -8
- package/components/SelectTokenButton/SelectTokenButton.js +7 -4
- package/components/SendToWallet/SendToWallet.js +2 -2
- package/components/SmallAvatar.d.ts +1 -1
- package/components/Step/CircularProgress.d.ts +1 -2
- package/components/Step/Step.js +16 -6
- package/components/Step/StepList.d.ts +1 -2
- package/components/StepActions/StepActions.js +4 -20
- package/components/SwapButton/SwapButton.js +16 -4
- package/components/SwapInput/FormPriceHelperText.js +2 -2
- package/components/SwapInput/SwapInput.js +3 -3
- package/components/SwapInput/SwapInputEndAdornment.d.ts +1 -2
- package/components/SwapInput/SwapInputEndAdornment.js +2 -2
- package/components/SwapRouteCard/SwapRouteCard.js +21 -5
- package/components/SwapRouteCard/SwapRouteCardEssentials.js +1 -1
- package/components/SwapRouteCard/SwapRouteCardSkeleton.js +1 -1
- package/components/SwapRoutes/SwapRoutes.js +1 -1
- package/components/SwapRoutes/SwapRoutesExpanded.d.ts +2 -3
- package/components/SwapRoutes/SwapRoutesExpanded.js +2 -2
- package/components/SwapRoutes/SwapRoutesExpanded.style.js +1 -0
- package/components/Token/Token.js +1 -1
- package/components/TokenAvatar/TokenAvatar.d.ts +4 -4
- package/components/TokenList/TokenList.js +10 -5
- package/components/TokenList/TokenList.style.d.ts +5 -2
- package/components/TokenList/TokenList.style.js +21 -2
- package/components/TokenList/TokenListItem.d.ts +1 -1
- package/components/TokenList/TokenListItem.js +32 -9
- package/components/TokenList/VirtualizedTokenList.js +3 -3
- package/components/TokenList/types.d.ts +6 -3
- package/config/theme.js +15 -3
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/index.d.ts +2 -1
- package/hooks/index.js +2 -1
- package/hooks/useContentHeight.js +4 -6
- package/hooks/useFeaturedTokens.d.ts +1 -1
- package/hooks/useFundsSufficiency.js +2 -2
- package/hooks/useGasRefuel.d.ts +1 -1
- package/hooks/useGasRefuel.js +5 -15
- package/hooks/useGasSufficiency.js +13 -4
- package/hooks/useInitializer.js +0 -1
- package/hooks/useProcessMessage.d.ts +2 -1
- package/hooks/useProcessMessage.js +27 -9
- package/hooks/useRouteExecution.js +6 -5
- package/hooks/useSwapOnly.d.ts +1 -0
- package/hooks/useSwapOnly.js +5 -0
- package/hooks/useSwapRoutes.d.ts +1 -2
- package/hooks/useSwapRoutes.js +32 -18
- package/hooks/useToken.d.ts +1 -1
- package/hooks/useTokenAddressBalance.d.ts +2 -2
- package/hooks/useTokenBalance.js +6 -7
- package/hooks/useTokenBalances.d.ts +5 -5
- package/hooks/useTokenBalances.js +4 -19
- package/hooks/useTokenSearch.d.ts +2 -2
- package/hooks/useTokens.d.ts +2 -2
- package/i18n/bn.json +8 -0
- package/i18n/en.json +30 -5
- package/i18n/fr.json +8 -0
- package/i18n/id.json +22 -7
- package/i18n/ko.json +22 -7
- package/i18n/pt.json +32 -7
- package/i18n/th.json +21 -6
- package/i18n/uk.json +43 -18
- package/i18n/zh.json +23 -8
- package/icons/InsuraceLogo.d.ts +1 -1
- package/icons/LiFiFullLogo.d.ts +1 -1
- package/icons/LiFiLogo.d.ts +1 -1
- package/icons/LiFiToolLogo.d.ts +1 -1
- package/index.d.ts +1 -1
- package/package.json +13 -13
- package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +1 -2
- package/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -2
- package/pages/SelectTokenPage/SelectTokenPage.js +4 -2
- package/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -2
- package/pages/SettingsPage/GasPriceSelect.d.ts +1 -2
- package/pages/SettingsPage/LanguageSelect.js +1 -1
- package/pages/SettingsPage/SettingsPage.d.ts +1 -2
- package/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -2
- package/pages/SettingsPage/SlippageInput.d.ts +1 -2
- package/pages/SwapDetailsPage/SwapDetailsPage.js +6 -2
- package/pages/SwapPage/ExchangeRateBottomSheet.js +2 -2
- package/pages/SwapPage/StatusBottomSheet.js +18 -12
- package/pages/SwapPage/StatusBottomSheet.style.d.ts +1 -1
- package/pages/SwapPage/StatusBottomSheet.style.js +1 -1
- package/pages/SwapPage/SwapPage.js +33 -12
- package/pages/SwapPage/TokenValueBottomSheet.js +8 -13
- package/pages/SwapPage/utils.d.ts +2 -0
- package/pages/SwapPage/utils.js +6 -0
- package/providers/I18nProvider/I18nProvider.js +3 -3
- package/providers/SDKProvider/SDKProvider.js +2 -0
- package/providers/SwapFormProvider/FormUpdater.js +3 -0
- package/providers/WalletProvider/WalletProvider.js +78 -50
- package/providers/WalletProvider/types.d.ts +3 -5
- package/providers/WidgetProvider/WidgetProvider.js +2 -2
- package/stores/StoreProvider.d.ts +2 -2
- package/stores/StoreProvider.js +3 -2
- package/stores/routes/RouteExecutionStore.d.ts +1 -1
- package/stores/routes/RouteExecutionStore.js +0 -1
- package/stores/settings/index.d.ts +1 -0
- package/stores/settings/index.js +1 -0
- package/stores/settings/types.d.ts +11 -0
- package/stores/settings/useSplitSubvariantStore.d.ts +7 -0
- package/stores/settings/useSplitSubvariantStore.js +37 -0
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/events.d.ts +9 -1
- package/types/events.js +1 -0
- package/types/token.d.ts +2 -2
- package/types/widget.d.ts +13 -8
- package/types/widget.js +4 -2
- package/utils/format.d.ts +1 -1
- package/utils/format.js +5 -10
- package/utils/wallet.d.ts +1 -1
- package/utils/wallet.js +1 -1
|
@@ -23,7 +23,7 @@ const SwapRoutesExpandedElement = () => {
|
|
|
23
23
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
24
24
|
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
25
25
|
const setExecutableRoute = (0, stores_1.useSetExecutableRoute)();
|
|
26
|
-
const { containerStyle } = (0, providers_1.useWidgetConfig)();
|
|
26
|
+
const { variant, containerStyle } = (0, providers_1.useWidgetConfig)();
|
|
27
27
|
const { isValid, isValidating } = (0, react_hook_form_1.useFormState)();
|
|
28
28
|
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = (0, hooks_1.useSwapRoutes)();
|
|
29
29
|
const currentRoute = routes?.[0];
|
|
@@ -37,6 +37,6 @@ const SwapRoutesExpandedElement = () => {
|
|
|
37
37
|
};
|
|
38
38
|
const expanded = Boolean(currentRoute || isLoading || isFetching || isFetched);
|
|
39
39
|
const routeNotFound = !currentRoute && !isLoading && !isFetching && expanded;
|
|
40
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Collapse, { timeout: timeout.enter, in: expanded, orientation: "horizontal", children: (0, jsx_runtime_1.jsx)(material_1.Grow, { timeout: timeout.enter, in: expanded, mountOnEnter: true, unmountOnExit: true, children: (0, jsx_runtime_1.jsx)(SwapRoutesExpanded_style_1.Container, { sx: containerStyle, enableColorScheme: true, children: (0, jsx_runtime_1.jsxs)(SwapRoutesExpanded_style_1.ScrollableContainer, { children: [(0, jsx_runtime_1.jsxs)(SwapRoutesExpanded_style_1.Header, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 18, fontWeight: "700", flex: 1, noWrap: true, children: t('swap.routes') }), (0, jsx_runtime_1.jsx)(ProgressToNextUpdate_1.ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 } })] }), (0, jsx_runtime_1.jsx)(material_1.Stack, { direction: "column", spacing: 2, flex: 1, paddingX: 3, paddingBottom: 3, children: routeNotFound ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteNotFoundCard, {})) : isLoading || (isFetching && !routes?.length) ? (Array.from({ length: 3 }).map((_, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, {}, index)))) : (routes?.map((route, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, expanded: routes?.length <= 2 }, route.id)))) })] }) }) }) }));
|
|
40
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Collapse, { timeout: timeout.enter, in: expanded, orientation: "horizontal", children: (0, jsx_runtime_1.jsx)(material_1.Grow, { timeout: timeout.enter, in: expanded, mountOnEnter: true, unmountOnExit: true, children: (0, jsx_runtime_1.jsx)(SwapRoutesExpanded_style_1.Container, { sx: containerStyle, enableColorScheme: true, children: (0, jsx_runtime_1.jsxs)(SwapRoutesExpanded_style_1.ScrollableContainer, { children: [(0, jsx_runtime_1.jsxs)(SwapRoutesExpanded_style_1.Header, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 18, fontWeight: "700", flex: 1, noWrap: true, children: variant === 'nft' ? t('swap.fromAmount') : t('header.routes') }), (0, jsx_runtime_1.jsx)(ProgressToNextUpdate_1.ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 } })] }), (0, jsx_runtime_1.jsx)(material_1.Stack, { direction: "column", spacing: 2, flex: 1, paddingX: 3, paddingBottom: 3, children: routeNotFound ? ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteNotFoundCard, {})) : isLoading || (isFetching && !routes?.length) ? (Array.from({ length: 3 }).map((_, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCardSkeleton, {}, index)))) : (routes?.map((route, index) => ((0, jsx_runtime_1.jsx)(SwapRouteCard_1.SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, expanded: routes?.length <= 2 }, route.id)))) })] }) }) }) }));
|
|
41
41
|
};
|
|
42
42
|
exports.SwapRoutesExpandedElement = SwapRoutesExpandedElement;
|
|
@@ -11,6 +11,7 @@ exports.CollapseContainer = (0, styles_1.styled)(material_1.Box)(({ theme }) =>
|
|
|
11
11
|
exports.ScrollableContainer = (0, styles_1.styled)(material_1.Box)({
|
|
12
12
|
overflowY: 'auto',
|
|
13
13
|
height: '100%',
|
|
14
|
+
width: '100%',
|
|
14
15
|
flex: 1,
|
|
15
16
|
display: 'flex',
|
|
16
17
|
flexDirection: 'column',
|
|
@@ -17,7 +17,7 @@ const Token = ({ token, ...other }) => {
|
|
|
17
17
|
return (0, jsx_runtime_1.jsx)(exports.TokenBase, { token: token, ...other });
|
|
18
18
|
};
|
|
19
19
|
exports.Token = Token;
|
|
20
|
-
const TokenFallback = ({ token,
|
|
20
|
+
const TokenFallback = ({ token, isLoading, ...other }) => {
|
|
21
21
|
const { token: chainToken, isLoading: isLoadingToken } = (0, hooks_1.useToken)(token?.chainId, token?.address);
|
|
22
22
|
return ((0, jsx_runtime_1.jsx)(exports.TokenBase, { token: { ...token, ...chainToken }, isLoading: isLoading || isLoadingToken, ...other }));
|
|
23
23
|
};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { Chain,
|
|
2
|
+
import type { Chain, StaticToken } from '@lifi/sdk';
|
|
3
3
|
import type { SxProps, Theme } from '@mui/material';
|
|
4
4
|
export declare const TokenAvatarFallback: React.FC<{
|
|
5
|
-
token?:
|
|
5
|
+
token?: StaticToken;
|
|
6
6
|
isLoading?: boolean;
|
|
7
7
|
sx?: SxProps<Theme>;
|
|
8
8
|
}>;
|
|
9
9
|
export declare const TokenAvatarBase: React.FC<{
|
|
10
|
-
token?:
|
|
10
|
+
token?: StaticToken;
|
|
11
11
|
chain?: Chain;
|
|
12
12
|
isLoading?: boolean;
|
|
13
13
|
sx?: SxProps<Theme>;
|
|
14
14
|
}>;
|
|
15
15
|
export declare const TokenAvatar: React.FC<{
|
|
16
|
-
token?:
|
|
16
|
+
token?: StaticToken;
|
|
17
17
|
chain?: Chain;
|
|
18
18
|
isLoading?: boolean;
|
|
19
19
|
sx?: SxProps<Theme>;
|
|
@@ -8,8 +8,8 @@ const react_hook_form_1 = require("react-hook-form");
|
|
|
8
8
|
const hooks_1 = require("../../hooks");
|
|
9
9
|
const providers_1 = require("../../providers");
|
|
10
10
|
const TokenNotFound_1 = require("./TokenNotFound");
|
|
11
|
-
const useTokenSelect_1 = require("./useTokenSelect");
|
|
12
11
|
const VirtualizedTokenList_1 = require("./VirtualizedTokenList");
|
|
12
|
+
const useTokenSelect_1 = require("./useTokenSelect");
|
|
13
13
|
const TokenList = ({ formType, height, onClick, }) => {
|
|
14
14
|
const parentRef = (0, react_1.useRef)(null);
|
|
15
15
|
const { account } = (0, providers_1.useWallet)();
|
|
@@ -17,8 +17,11 @@ const TokenList = ({ formType, height, onClick, }) => {
|
|
|
17
17
|
name: [providers_1.SwapFormKeyHelper.getChainKey(formType)],
|
|
18
18
|
});
|
|
19
19
|
const [tokenSearchFilter] = (0, hooks_1.useDebouncedWatch)([providers_1.SwapFormKey.TokenSearchFilter], 320);
|
|
20
|
+
const { chain, isLoading: isChainLoading } = (0, hooks_1.useChain)(selectedChainId);
|
|
20
21
|
const { tokens: chainTokens, tokensWithBalance, isLoading: isTokensLoading, isBalanceLoading, featuredTokens, } = (0, hooks_1.useTokenBalances)(selectedChainId);
|
|
21
|
-
let filteredTokens = (tokensWithBalance ??
|
|
22
|
+
let filteredTokens = (tokensWithBalance ??
|
|
23
|
+
chainTokens ??
|
|
24
|
+
[]);
|
|
22
25
|
const searchFilter = tokenSearchFilter?.toUpperCase() ?? '';
|
|
23
26
|
filteredTokens = tokenSearchFilter
|
|
24
27
|
? filteredTokens.filter((token) => token.name.toUpperCase().includes(searchFilter) ||
|
|
@@ -30,13 +33,15 @@ const TokenList = ({ formType, height, onClick, }) => {
|
|
|
30
33
|
!!tokenSearchFilter &&
|
|
31
34
|
!!selectedChainId;
|
|
32
35
|
const { token: searchedToken, isLoading: isSearchedTokenLoading } = (0, hooks_1.useTokenSearch)(selectedChainId, tokenSearchFilter, tokenSearchEnabled);
|
|
33
|
-
const isLoading = isTokensLoading ||
|
|
36
|
+
const isLoading = isTokensLoading ||
|
|
37
|
+
isChainLoading ||
|
|
38
|
+
(tokenSearchEnabled && isSearchedTokenLoading);
|
|
34
39
|
const tokens = filteredTokens.length
|
|
35
40
|
? filteredTokens
|
|
36
41
|
: searchedToken
|
|
37
42
|
? [searchedToken]
|
|
38
43
|
: filteredTokens;
|
|
39
44
|
const handleTokenClick = (0, useTokenSelect_1.useTokenSelect)(formType, onClick);
|
|
40
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { ref: parentRef, style: { height, overflow: 'auto' }, children: [!tokens.length && !isLoading ? ((0, jsx_runtime_1.jsx)(TokenNotFound_1.TokenNotFound, { formType: formType })) : null, (0, jsx_runtime_1.jsx)(VirtualizedTokenList_1.VirtualizedTokenList, { tokens: tokens, featuredTokensLength: featuredTokens?.length, scrollElementRef: parentRef, chainId: selectedChainId, isLoading: isLoading, isBalanceLoading: isBalanceLoading, showBalance: account.isActive, showFeatured: !tokenSearchFilter, onClick: handleTokenClick })] }));
|
|
45
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { ref: parentRef, style: { height, overflow: 'auto' }, children: [!tokens.length && !isLoading ? ((0, jsx_runtime_1.jsx)(TokenNotFound_1.TokenNotFound, { formType: formType })) : null, (0, jsx_runtime_1.jsx)(VirtualizedTokenList_1.VirtualizedTokenList, { tokens: tokens, featuredTokensLength: featuredTokens?.length, scrollElementRef: parentRef, chainId: selectedChainId, chain: chain, isLoading: isLoading, isBalanceLoading: isBalanceLoading, showBalance: account.isActive, showFeatured: !tokenSearchFilter, onClick: handleTokenClick })] }));
|
|
41
46
|
};
|
|
42
47
|
exports.TokenList = TokenList;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
2
|
+
import type { StyledComponent } from '@emotion/styled';
|
|
3
|
+
import type { ButtonProps, LinkProps } from '@mui/material';
|
|
4
|
+
export declare const ListItemButton: StyledComponent<import("@mui/material").ListItemButtonBaseProps & Omit<{
|
|
3
5
|
action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
|
|
4
6
|
centerRipple?: boolean | undefined;
|
|
5
7
|
children?: import("react").ReactNode;
|
|
@@ -18,7 +20,7 @@ export declare const ListItemButton: import("@emotion/styled").StyledComponent<i
|
|
|
18
20
|
}, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
19
21
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
20
22
|
}, "className" | "style" | "classes" | "autoFocus" | "tabIndex" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "alignItems" | "dense" | "divider" | "selected" | "disableGutters"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
21
|
-
export declare const ListItem:
|
|
23
|
+
export declare const ListItem: StyledComponent<{
|
|
22
24
|
button?: false | undefined;
|
|
23
25
|
} & import("@mui/material").ListItemBaseProps & {
|
|
24
26
|
components?: {
|
|
@@ -36,3 +38,4 @@ export declare const ListItem: import("@emotion/styled").StyledComponent<{
|
|
|
36
38
|
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & {
|
|
37
39
|
ref?: ((instance: HTMLLIElement | null) => void) | import("react").RefObject<HTMLLIElement> | null | undefined;
|
|
38
40
|
}, "button" | "className" | "style" | "classes" | "autoFocus" | "children" | "disabled" | "sx" | "alignItems" | "dense" | "divider" | "components" | "slotProps" | "slots" | "componentsProps" | "selected" | "disableGutters" | "ContainerComponent" | "ContainerProps" | "disablePadding" | "secondaryAction"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
41
|
+
export declare const LinkButton: StyledComponent<ButtonProps & LinkProps>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ListItem = exports.ListItemButton = void 0;
|
|
3
|
+
exports.LinkButton = exports.ListItem = exports.ListItemButton = void 0;
|
|
4
4
|
const material_1 = require("@mui/material");
|
|
5
5
|
const ListItemSecondaryAction_1 = require("@mui/material/ListItemSecondaryAction");
|
|
6
6
|
const ListItemText_1 = require("@mui/material/ListItemText");
|
|
@@ -29,3 +29,22 @@ exports.ListItem = (0, styles_1.styled)(material_1.ListItem)(({ theme }) => ({
|
|
|
29
29
|
whiteSpace: 'nowrap',
|
|
30
30
|
},
|
|
31
31
|
}));
|
|
32
|
+
exports.LinkButton = (0, styles_1.styled)(material_1.Button)(({ theme }) => ({
|
|
33
|
+
lineHeight: 1,
|
|
34
|
+
fontSize: '0.75rem',
|
|
35
|
+
fontWeight: 400,
|
|
36
|
+
padding: theme.spacing(0.375, 0.75),
|
|
37
|
+
color: 'inherit',
|
|
38
|
+
backgroundColor: 'unset',
|
|
39
|
+
'&:hover': {
|
|
40
|
+
backgroundColor: theme.palette.mode === 'light'
|
|
41
|
+
? (0, styles_1.alpha)(theme.palette.common.black, 0.04)
|
|
42
|
+
: (0, styles_1.alpha)(theme.palette.common.white, 0.08),
|
|
43
|
+
},
|
|
44
|
+
[`.${material_1.buttonClasses.endIcon}`]: {
|
|
45
|
+
marginLeft: theme.spacing(0.25),
|
|
46
|
+
},
|
|
47
|
+
[`.${material_1.buttonClasses.endIcon} > *:nth-of-type(1)`]: {
|
|
48
|
+
fontSize: '0.75rem',
|
|
49
|
+
},
|
|
50
|
+
}));
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
import type { TokenListItemButtonProps, TokenListItemProps } from './types';
|
|
3
3
|
export declare const TokenListItem: React.FC<TokenListItemProps>;
|
|
4
4
|
export declare const TokenListItemButton: React.FC<TokenListItemButtonProps>;
|
|
5
|
-
export declare const TokenListItemSkeleton: () => JSX.Element;
|
|
5
|
+
export declare const TokenListItemSkeleton: () => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export declare const TokenAmountSkeleton: React.FC;
|
|
@@ -2,23 +2,46 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TokenAmountSkeleton = exports.TokenListItemSkeleton = exports.TokenListItemButton = exports.TokenListItem = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const OpenInNewRounded_1 = require("@mui/icons-material/OpenInNewRounded");
|
|
5
6
|
const material_1 = require("@mui/material");
|
|
6
7
|
const react_1 = require("react");
|
|
7
8
|
const react_i18next_1 = require("react-i18next");
|
|
8
9
|
const utils_1 = require("../../utils");
|
|
9
10
|
const TokenList_style_1 = require("./TokenList.style");
|
|
10
|
-
exports.TokenListItem = (0, react_1.memo)(({ onClick, size, start, token, showBalance, isBalanceLoading, startAdornment, endAdornment, }) => {
|
|
11
|
+
exports.TokenListItem = (0, react_1.memo)(({ onClick, size, start, token, chain, showBalance, isBalanceLoading, startAdornment, endAdornment, }) => {
|
|
11
12
|
const handleClick = () => onClick?.(token.address);
|
|
12
13
|
return ((0, jsx_runtime_1.jsxs)(TokenList_style_1.ListItem, { disablePadding: true, style: {
|
|
13
14
|
height: `${size}px`,
|
|
14
15
|
transform: `translateY(${start}px)`,
|
|
15
|
-
}, children: [startAdornment, (0, jsx_runtime_1.jsx)(exports.TokenListItemButton, { token: token, showBalance: showBalance, isBalanceLoading: isBalanceLoading, onClick: handleClick }), endAdornment] }));
|
|
16
|
+
}, children: [startAdornment, (0, jsx_runtime_1.jsx)(exports.TokenListItemButton, { token: token, chain: chain, showBalance: showBalance, isBalanceLoading: isBalanceLoading, onClick: handleClick }), endAdornment] }));
|
|
16
17
|
});
|
|
17
|
-
const TokenListItemButton = ({ onClick, token, showBalance, isBalanceLoading, }) => {
|
|
18
|
+
const TokenListItemButton = ({ onClick, token, chain, showBalance, isBalanceLoading, }) => {
|
|
18
19
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
19
20
|
const tokenPrice = (0, utils_1.formatTokenPrice)(token.amount, token.priceUSD);
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
const container = (0, react_1.useRef)(null);
|
|
22
|
+
const timeoutId = (0, react_1.useRef)();
|
|
23
|
+
const [showAddress, setShowAddress] = (0, react_1.useState)(false);
|
|
24
|
+
const onMouseEnter = () => {
|
|
25
|
+
timeoutId.current = setTimeout(() => setShowAddress(true), 350);
|
|
26
|
+
};
|
|
27
|
+
const onMouseLeave = () => {
|
|
28
|
+
clearTimeout(timeoutId.current);
|
|
29
|
+
if (showAddress) {
|
|
30
|
+
setShowAddress(false);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
return ((0, jsx_runtime_1.jsxs)(TokenList_style_1.ListItemButton, { onClick: onClick, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, dense: true, children: [(0, jsx_runtime_1.jsx)(material_1.ListItemAvatar, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { src: token.logoURI, alt: token.symbol, children: token.symbol[0] }) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: token.symbol, secondaryTypographyProps: {
|
|
34
|
+
component: 'div',
|
|
35
|
+
sx: {
|
|
36
|
+
overflow: 'auto',
|
|
37
|
+
marginLeft: -0.75,
|
|
38
|
+
},
|
|
39
|
+
}, secondary: (0, jsx_runtime_1.jsxs)(material_1.Box, { position: "relative", height: 18, ref: container, children: [(0, jsx_runtime_1.jsx)(material_1.Slide, { direction: "down", in: !showAddress, container: container.current, style: {
|
|
40
|
+
position: 'absolute',
|
|
41
|
+
}, appear: false, children: (0, jsx_runtime_1.jsx)(material_1.Box, { pl: 0.75, children: token.name }) }), (0, jsx_runtime_1.jsx)(material_1.Slide, { direction: "up", in: showAddress, container: container.current, style: {
|
|
42
|
+
position: 'absolute',
|
|
43
|
+
}, appear: false, mountOnEnter: true, children: (0, jsx_runtime_1.jsx)(TokenList_style_1.LinkButton, { size: "small", LinkComponent: material_1.Link, href: `${chain?.metamask.blockExplorerUrls[0]}address/${token.address}`, target: "_blank", rel: "nofollow noreferrer", onClick: (e) => e.stopPropagation(), endIcon: (0, jsx_runtime_1.jsx)(OpenInNewRounded_1.default, {}), children: (0, utils_1.shortenAddress)(token.address) }) })] }) }), showBalance ? (isBalanceLoading ? ((0, jsx_runtime_1.jsx)(exports.TokenAmountSkeleton, {})) : ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { textAlign: 'right' }, children: [Number(token.amount) ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", noWrap: true, children: t('format.number', {
|
|
44
|
+
value: (0, utils_1.formatTokenAmount)(token.amount),
|
|
22
45
|
}) })) : null, tokenPrice ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { fontWeight: 400, fontSize: 12, color: "text.secondary", "data-price": token.priceUSD, children: t(`format.currency`, {
|
|
23
46
|
value: tokenPrice,
|
|
24
47
|
}) })) : null] }))) : null] }));
|
|
@@ -7,7 +7,7 @@ const react_virtual_1 = require("@tanstack/react-virtual");
|
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
const react_i18next_1 = require("react-i18next");
|
|
9
9
|
const TokenListItem_1 = require("./TokenListItem");
|
|
10
|
-
const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollElementRef, chainId, isLoading, isBalanceLoading, showBalance, showFeatured, onClick, }) => {
|
|
10
|
+
const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollElementRef, chainId, chain, isLoading, isBalanceLoading, showBalance, showFeatured, onClick, }) => {
|
|
11
11
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
12
12
|
const hasFeaturedTokens = !!featuredTokensLength && showFeatured;
|
|
13
13
|
const featuredTokensLastIndex = (featuredTokensLength ?? 0) - 1;
|
|
@@ -35,7 +35,7 @@ const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollElementRef,
|
|
|
35
35
|
}
|
|
36
36
|
return size;
|
|
37
37
|
},
|
|
38
|
-
getItemKey: (index) => tokens[index].address
|
|
38
|
+
getItemKey: (index) => `${tokens[index].address}-${index}`,
|
|
39
39
|
});
|
|
40
40
|
(0, react_1.useEffect)(() => {
|
|
41
41
|
if (getVirtualItems().length) {
|
|
@@ -49,7 +49,7 @@ const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollElementRef,
|
|
|
49
49
|
}
|
|
50
50
|
return ((0, jsx_runtime_1.jsx)(material_1.List, { style: { height: getTotalSize() }, disablePadding: true, children: getVirtualItems().map((item) => {
|
|
51
51
|
const token = tokens[item.index];
|
|
52
|
-
return ((0, jsx_runtime_1.jsx)(TokenListItem_1.TokenListItem, { onClick: onClick, size: item.size, start: item.start, token: token, isBalanceLoading: isBalanceLoading, showBalance: showBalance, startAdornment: hasFeaturedTokens && token.featured && item.index === 0 ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 14, fontWeight: 600, lineHeight: 1, px: 2, pb: 1.25, children: t('swap.featuredTokens') })) : null, endAdornment: hasFeaturedTokens &&
|
|
52
|
+
return ((0, jsx_runtime_1.jsx)(TokenListItem_1.TokenListItem, { onClick: onClick, size: item.size, start: item.start, token: token, chain: chain, isBalanceLoading: isBalanceLoading, showBalance: showBalance, startAdornment: hasFeaturedTokens && token.featured && item.index === 0 ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 14, fontWeight: 600, lineHeight: 1, px: 2, pb: 1.25, children: t('swap.featuredTokens') })) : null, endAdornment: hasFeaturedTokens &&
|
|
53
53
|
token.featured &&
|
|
54
54
|
item.index === featuredTokensLastIndex &&
|
|
55
55
|
item.index !== tokensLastIndex ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 14, fontWeight: 600, lineHeight: 1, px: 2, py: 1.25, children: t('swap.otherTokens') })) : null }, item.key));
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ExtendedChain } from '@lifi/sdk';
|
|
2
2
|
import type { MutableRefObject } from 'react';
|
|
3
3
|
import type { SwapFormType } from '../../providers';
|
|
4
|
-
import type {
|
|
4
|
+
import type { TokenAmount } from '../../types';
|
|
5
5
|
export interface TokenListProps {
|
|
6
6
|
formType: SwapFormType;
|
|
7
7
|
height: number;
|
|
8
8
|
onClick?(): void;
|
|
9
9
|
}
|
|
10
10
|
export interface VirtualizedTokenListProps {
|
|
11
|
-
tokens:
|
|
11
|
+
tokens: TokenAmount[];
|
|
12
12
|
featuredTokensLength?: number;
|
|
13
13
|
scrollElementRef: MutableRefObject<HTMLElement | null>;
|
|
14
14
|
isLoading: boolean;
|
|
15
15
|
isBalanceLoading: boolean;
|
|
16
16
|
chainId: number;
|
|
17
|
+
chain?: ExtendedChain;
|
|
17
18
|
showBalance?: boolean;
|
|
18
19
|
showFeatured?: boolean;
|
|
19
20
|
onClick(tokenAddress: string): void;
|
|
@@ -26,6 +27,7 @@ export interface TokenListItemBaseProps {
|
|
|
26
27
|
export interface TokenListItemProps extends TokenListItemBaseProps {
|
|
27
28
|
showBalance?: boolean;
|
|
28
29
|
token: TokenAmount;
|
|
30
|
+
chain?: ExtendedChain;
|
|
29
31
|
isBalanceLoading?: boolean;
|
|
30
32
|
startAdornment?: React.ReactNode;
|
|
31
33
|
endAdornment?: React.ReactNode;
|
|
@@ -34,5 +36,6 @@ export interface TokenListItemButtonProps {
|
|
|
34
36
|
onClick?(): void;
|
|
35
37
|
showBalance?: boolean;
|
|
36
38
|
token: TokenAmount;
|
|
39
|
+
chain?: ExtendedChain;
|
|
37
40
|
isBalanceLoading?: boolean;
|
|
38
41
|
}
|
package/cjs/config/theme.js
CHANGED
|
@@ -3,10 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createTheme = void 0;
|
|
4
4
|
const LoadingButton_1 = require("@mui/lab/LoadingButton");
|
|
5
5
|
const ButtonBase_1 = require("@mui/material/ButtonBase");
|
|
6
|
-
const colors_1 = require("@mui/material/colors");
|
|
7
6
|
const DialogActions_1 = require("@mui/material/DialogActions");
|
|
7
|
+
const colors_1 = require("@mui/material/colors");
|
|
8
8
|
const styles_1 = require("@mui/material/styles");
|
|
9
|
-
const system_1 = require("@mui/system");
|
|
10
9
|
const palette = {
|
|
11
10
|
primary: {
|
|
12
11
|
main: '#3F49E1',
|
|
@@ -46,7 +45,7 @@ const shape = {
|
|
|
46
45
|
borderRadius: 12,
|
|
47
46
|
borderRadiusSecondary: 8,
|
|
48
47
|
};
|
|
49
|
-
const enterKeyframe = (0,
|
|
48
|
+
const enterKeyframe = (0, styles_1.keyframes) `
|
|
50
49
|
0% {
|
|
51
50
|
transform: scale(0);
|
|
52
51
|
opacity: 0.05;
|
|
@@ -226,6 +225,19 @@ const createTheme = (mode, theme = {}) => {
|
|
|
226
225
|
}),
|
|
227
226
|
},
|
|
228
227
|
},
|
|
228
|
+
MuiTooltip: {
|
|
229
|
+
styleOverrides: {
|
|
230
|
+
tooltip: ({ theme }) => ({
|
|
231
|
+
backgroundColor: 'rgb(0 0 0 / 64%)',
|
|
232
|
+
backdropFilter: 'blur(3px)',
|
|
233
|
+
fontSize: '0.75rem',
|
|
234
|
+
padding: theme.spacing(1, 1.5),
|
|
235
|
+
}),
|
|
236
|
+
arrow: {
|
|
237
|
+
color: 'rgb(0 0 0 / 64%)',
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
},
|
|
229
241
|
},
|
|
230
242
|
});
|
|
231
243
|
};
|
package/cjs/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "2.0.0-beta.
|
|
2
|
+
export declare const version = "2.0.0-beta.11";
|
package/cjs/config/version.js
CHANGED
package/cjs/hooks/index.d.ts
CHANGED
|
@@ -15,12 +15,13 @@ export * from './useNavigateBack';
|
|
|
15
15
|
export * from './useProcessMessage';
|
|
16
16
|
export * from './useRouteExecution';
|
|
17
17
|
export * from './useScrollableContainer';
|
|
18
|
+
export * from './useSwapOnly';
|
|
18
19
|
export * from './useSwapRoutes';
|
|
19
20
|
export * from './useToken';
|
|
20
21
|
export * from './useTokenAddressBalance';
|
|
21
22
|
export * from './useTokenBalance';
|
|
22
23
|
export * from './useTokenBalances';
|
|
23
|
-
export * from './useTokens';
|
|
24
24
|
export * from './useTokenSearch';
|
|
25
|
+
export * from './useTokens';
|
|
25
26
|
export * from './useTools';
|
|
26
27
|
export * from './useWidgetEvents';
|
package/cjs/hooks/index.js
CHANGED
|
@@ -31,12 +31,13 @@ __exportStar(require("./useNavigateBack"), exports);
|
|
|
31
31
|
__exportStar(require("./useProcessMessage"), exports);
|
|
32
32
|
__exportStar(require("./useRouteExecution"), exports);
|
|
33
33
|
__exportStar(require("./useScrollableContainer"), exports);
|
|
34
|
+
__exportStar(require("./useSwapOnly"), exports);
|
|
34
35
|
__exportStar(require("./useSwapRoutes"), exports);
|
|
35
36
|
__exportStar(require("./useToken"), exports);
|
|
36
37
|
__exportStar(require("./useTokenAddressBalance"), exports);
|
|
37
38
|
__exportStar(require("./useTokenBalance"), exports);
|
|
38
39
|
__exportStar(require("./useTokenBalances"), exports);
|
|
39
|
-
__exportStar(require("./useTokens"), exports);
|
|
40
40
|
__exportStar(require("./useTokenSearch"), exports);
|
|
41
|
+
__exportStar(require("./useTokens"), exports);
|
|
41
42
|
__exportStar(require("./useTools"), exports);
|
|
42
43
|
__exportStar(require("./useWidgetEvents"), exports);
|
|
@@ -6,8 +6,8 @@ const utils_1 = require("../utils");
|
|
|
6
6
|
const useDefaultElementId_1 = require("./useDefaultElementId");
|
|
7
7
|
const useScrollableContainer_1 = require("./useScrollableContainer");
|
|
8
8
|
const getContentHeight = (elementId) => {
|
|
9
|
-
const headerElement = document.getElementById((0, utils_1.createElementId)(utils_1.ElementId.Header, elementId));
|
|
10
9
|
const containerElement = document.getElementById((0, utils_1.createElementId)(utils_1.ElementId.ScrollableContainer, elementId));
|
|
10
|
+
const headerElement = document.getElementById((0, utils_1.createElementId)(utils_1.ElementId.Header, elementId));
|
|
11
11
|
if (!containerElement || !headerElement) {
|
|
12
12
|
console.warn(`Can't find ${utils_1.ElementId.ScrollableContainer} or ${utils_1.ElementId.Header} id.`);
|
|
13
13
|
return 0;
|
|
@@ -18,11 +18,9 @@ const getContentHeight = (elementId) => {
|
|
|
18
18
|
};
|
|
19
19
|
const useContentHeight = () => {
|
|
20
20
|
const elementId = (0, useDefaultElementId_1.useDefaultElementId)();
|
|
21
|
-
const [contentHeight, setContentHeight] = (0, react_1.useState)(
|
|
21
|
+
const [contentHeight, setContentHeight] = (0, react_1.useState)(0);
|
|
22
22
|
(0, react_1.useLayoutEffect)(() => {
|
|
23
|
-
|
|
24
|
-
setContentHeight(getContentHeight(elementId));
|
|
25
|
-
}
|
|
23
|
+
setContentHeight(getContentHeight(elementId));
|
|
26
24
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
27
25
|
}, []);
|
|
28
26
|
return contentHeight;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useFeaturedTokens: (selectedChainId?: number) => import("@lifi/types").
|
|
1
|
+
export declare const useFeaturedTokens: (selectedChainId?: number) => import("@lifi/types").StaticToken[] | undefined;
|
|
@@ -10,8 +10,8 @@ const useGetTokenBalancesWithRetry_1 = require("./useGetTokenBalancesWithRetry")
|
|
|
10
10
|
const useTokenAddressBalance_1 = require("./useTokenAddressBalance");
|
|
11
11
|
const refetchInterval = 30000;
|
|
12
12
|
const useFundsSufficiency = (route) => {
|
|
13
|
-
const { account
|
|
14
|
-
const getTokenBalancesWithRetry = (0, useGetTokenBalancesWithRetry_1.useGetTokenBalancesWithRetry)(provider);
|
|
13
|
+
const { account } = (0, providers_1.useWallet)();
|
|
14
|
+
const getTokenBalancesWithRetry = (0, useGetTokenBalancesWithRetry_1.useGetTokenBalancesWithRetry)(account.signer?.provider);
|
|
15
15
|
const [fromChainId, fromTokenAddress, fromAmount] = (0, react_hook_form_1.useWatch)({
|
|
16
16
|
name: [
|
|
17
17
|
providers_1.SwapFormKey.FromChain,
|
|
@@ -3,5 +3,5 @@ export declare const useGasRefuel: () => {
|
|
|
3
3
|
availble: boolean | undefined;
|
|
4
4
|
isLoading: boolean;
|
|
5
5
|
chain: import("@lifi/types").ExtendedChain | undefined;
|
|
6
|
-
|
|
6
|
+
fromAmount: string | undefined;
|
|
7
7
|
};
|
|
@@ -10,12 +10,11 @@ const useGasRecommendation_1 = require("./useGasRecommendation");
|
|
|
10
10
|
const useTokenBalance_1 = require("./useTokenBalance");
|
|
11
11
|
const useGasRefuel = () => {
|
|
12
12
|
const { getChainById } = (0, _1.useChains)();
|
|
13
|
-
const [fromChainId, fromTokenAddress, toChainId,
|
|
13
|
+
const [fromChainId, fromTokenAddress, toChainId, toAddress] = (0, react_hook_form_1.useWatch)({
|
|
14
14
|
name: [
|
|
15
15
|
providers_1.SwapFormKey.FromChain,
|
|
16
16
|
providers_1.SwapFormKey.FromToken,
|
|
17
17
|
providers_1.SwapFormKey.ToChain,
|
|
18
|
-
providers_1.SwapFormKey.ToToken,
|
|
19
18
|
providers_1.SwapFormKey.ToAddress,
|
|
20
19
|
],
|
|
21
20
|
});
|
|
@@ -27,10 +26,7 @@ const useGasRefuel = () => {
|
|
|
27
26
|
// We don't allow same chain refuel.
|
|
28
27
|
// If a user runs out of gas, he can't send a source chain transaction.
|
|
29
28
|
fromChainId === toChainId ||
|
|
30
|
-
// We don't want to apply auto refuel when swapping to native tokens
|
|
31
|
-
toChain?.nativeToken.address === toTokenAddress ||
|
|
32
29
|
!gasRecommendation?.available ||
|
|
33
|
-
!gasRecommendation.recommended ||
|
|
34
30
|
!nativeToken) {
|
|
35
31
|
return false;
|
|
36
32
|
}
|
|
@@ -41,21 +37,15 @@ const useGasRefuel = () => {
|
|
|
41
37
|
.div(2);
|
|
42
38
|
const insufficientGas = tokenBalance.lt(recommendedAmount);
|
|
43
39
|
return insufficientGas;
|
|
44
|
-
}, [
|
|
45
|
-
fromChainId,
|
|
46
|
-
gasRecommendation?.available,
|
|
47
|
-
gasRecommendation?.recommended,
|
|
48
|
-
nativeToken,
|
|
49
|
-
toChain?.nativeToken.address,
|
|
50
|
-
toChainId,
|
|
51
|
-
toTokenAddress,
|
|
52
|
-
]);
|
|
40
|
+
}, [fromChainId, gasRecommendation, nativeToken, toChainId]);
|
|
53
41
|
return {
|
|
54
42
|
enabled: enabled,
|
|
55
43
|
availble: gasRecommendation?.available,
|
|
56
44
|
isLoading: isLoading,
|
|
57
45
|
chain: toChain,
|
|
58
|
-
gasRecommendation
|
|
46
|
+
fromAmount: gasRecommendation?.available
|
|
47
|
+
? gasRecommendation.fromAmount
|
|
48
|
+
: undefined,
|
|
59
49
|
};
|
|
60
50
|
};
|
|
61
51
|
exports.useGasRefuel = useGasRefuel;
|
|
@@ -5,15 +5,23 @@ const react_query_1 = require("@tanstack/react-query");
|
|
|
5
5
|
const big_js_1 = require("big.js");
|
|
6
6
|
const _1 = require(".");
|
|
7
7
|
const providers_1 = require("../providers");
|
|
8
|
+
const stores_1 = require("../stores");
|
|
8
9
|
const refetchInterval = 30000;
|
|
9
10
|
const useGasSufficiency = (route) => {
|
|
10
|
-
const { account
|
|
11
|
+
const { account } = (0, providers_1.useWallet)();
|
|
11
12
|
const { getChainById } = (0, _1.useChains)();
|
|
12
|
-
const getTokenBalancesWithRetry = (0, _1.useGetTokenBalancesWithRetry)(provider);
|
|
13
|
+
const getTokenBalancesWithRetry = (0, _1.useGetTokenBalancesWithRetry)(account.signer?.provider);
|
|
14
|
+
const { enabledAutoRefuel } = (0, stores_1.useSettings)(['enabledAutoRefuel']);
|
|
15
|
+
const { enabled, isLoading: isRefuelLoading } = (0, _1.useGasRefuel)();
|
|
16
|
+
const enabledRefuel = enabled && enabledAutoRefuel;
|
|
13
17
|
const { data: insufficientGas, isInitialLoading } = (0, react_query_1.useQuery)(['gas-sufficiency-check', account.address, route?.id], async () => {
|
|
14
18
|
if (!account.address || !route) {
|
|
15
19
|
return;
|
|
16
20
|
}
|
|
21
|
+
// TODO: include LI.Fuel into calculation once steps and tools are properly typed
|
|
22
|
+
// const refuelSteps = route.steps
|
|
23
|
+
// .flatMap((step) => step.includedSteps)
|
|
24
|
+
// .filter((includedStep) => includedStep.tool === 'lifuelProtocol');
|
|
17
25
|
const gasCosts = route.steps
|
|
18
26
|
.filter((step) => !step.execution || step.execution.status !== 'DONE')
|
|
19
27
|
.reduce((groupedGasCosts, step) => {
|
|
@@ -69,8 +77,9 @@ const useGasSufficiency = (route) => {
|
|
|
69
77
|
staleTime: refetchInterval,
|
|
70
78
|
cacheTime: refetchInterval,
|
|
71
79
|
});
|
|
80
|
+
const isInsufficientGas = Boolean(insufficientGas?.length) && !isRefuelLoading && !enabledRefuel;
|
|
72
81
|
return {
|
|
73
|
-
insufficientGas,
|
|
82
|
+
insufficientGas: isInsufficientGas ? insufficientGas : undefined,
|
|
74
83
|
isInitialLoading,
|
|
75
84
|
};
|
|
76
85
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useInitializer = void 0;
|
|
4
|
-
/* eslint-disable no-underscore-dangle */
|
|
5
4
|
const sdk_1 = require("@lifi/sdk");
|
|
6
5
|
const react_1 = require("react");
|
|
7
6
|
const version_1 = require("../config/version");
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { EVMChain, LifiStep, Process } from '@lifi/sdk';
|
|
2
2
|
import type { TFunction } from 'i18next';
|
|
3
|
+
import type { WidgetVariant } from '../types';
|
|
3
4
|
export declare const useProcessMessage: (step?: LifiStep, process?: Process) => {
|
|
4
5
|
title?: string | undefined;
|
|
5
6
|
message?: string | undefined;
|
|
6
7
|
};
|
|
7
|
-
export declare function getProcessMessage(t: TFunction, getChainById: (chainId: number) => EVMChain | undefined, step: LifiStep, process: Process): {
|
|
8
|
+
export declare function getProcessMessage(t: TFunction, getChainById: (chainId: number) => EVMChain | undefined, step: LifiStep, process: Process, variant?: WidgetVariant): {
|
|
8
9
|
title?: string;
|
|
9
10
|
message?: string;
|
|
10
11
|
};
|