@lifi/widget 2.0.0-beta.7 → 2.0.0-beta.9
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 +1 -1
- package/AppDrawer.d.ts +1 -1
- package/cjs/App.d.ts +1 -1
- package/cjs/AppDrawer.d.ts +1 -1
- package/cjs/components/ChainSelect/ChainSelect.d.ts +1 -1
- package/cjs/components/GasMessage/FundsSufficiencyMessage.d.ts +1 -1
- package/cjs/components/GasMessage/GasMessage.js +1 -6
- package/cjs/components/Header/Header.style.d.ts +10 -3
- package/cjs/components/Header/NavigationHeader.js +1 -1
- package/cjs/components/Header/NavigationTabs.d.ts +1 -1
- package/cjs/components/Header/NavigationTabs.style.d.ts +4 -71
- package/cjs/components/Header/WalletHeader.js +1 -1
- package/cjs/components/Insurance/InsuranceCollapsed.js +2 -8
- package/cjs/components/SelectChainAndToken.js +8 -7
- package/cjs/components/SendToWallet/SendToWallet.js +2 -2
- package/cjs/components/SmallAvatar.d.ts +1 -1
- package/cjs/components/Step/CircularProgress.d.ts +1 -1
- package/cjs/components/Step/Step.js +1 -1
- package/cjs/components/Step/StepList.d.ts +1 -1
- package/cjs/components/StepActions/StepActions.js +2 -1
- package/cjs/components/SwapInput/SwapInputEndAdornment.d.ts +1 -1
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.d.ts +2 -2
- package/cjs/components/TokenList/TokenList.js +5 -2
- 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 +27 -4
- package/cjs/components/TokenList/VirtualizedTokenList.js +3 -3
- package/cjs/components/TokenList/types.d.ts +4 -0
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +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/useProcessMessage.js +4 -0
- package/cjs/hooks/useRouteExecution.js +3 -3
- package/cjs/hooks/useSwapRoutes.d.ts +1 -2
- package/cjs/hooks/useSwapRoutes.js +5 -6
- package/cjs/hooks/useTokenBalance.js +2 -2
- package/cjs/i18n/en.json +3 -1
- 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/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +1 -1
- package/cjs/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -1
- package/cjs/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -1
- package/cjs/pages/SettingsPage/GasPriceSelect.d.ts +1 -1
- package/cjs/pages/SettingsPage/SettingsPage.d.ts +1 -1
- package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -1
- package/cjs/pages/SettingsPage/SlippageInput.d.ts +1 -1
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +1 -1
- package/cjs/pages/SwapPage/StatusBottomSheet.js +3 -3
- package/cjs/providers/SDKProvider/SDKProvider.js +2 -0
- package/cjs/providers/WalletProvider/WalletProvider.js +73 -47
- package/cjs/providers/WalletProvider/types.d.ts +0 -2
- package/cjs/stores/routes/RouteExecutionStore.d.ts +1 -1
- package/cjs/stores/settings/useSplitSubvariantStore.d.ts +1 -1
- package/cjs/types/widget.d.ts +1 -0
- package/cjs/types/widget.js +1 -0
- package/cjs/utils/wallet.d.ts +1 -1
- package/cjs/utils/wallet.js +3 -3
- package/components/ChainSelect/ChainSelect.d.ts +1 -1
- package/components/GasMessage/FundsSufficiencyMessage.d.ts +1 -1
- package/components/GasMessage/GasMessage.js +2 -7
- package/components/Header/Header.style.d.ts +10 -3
- package/components/Header/NavigationHeader.js +1 -1
- package/components/Header/NavigationTabs.d.ts +1 -1
- package/components/Header/NavigationTabs.style.d.ts +4 -71
- package/components/Header/WalletHeader.js +2 -2
- package/components/Insurance/InsuranceCollapsed.js +2 -8
- package/components/SelectChainAndToken.js +9 -8
- package/components/SendToWallet/SendToWallet.js +2 -2
- package/components/SmallAvatar.d.ts +1 -1
- package/components/Step/CircularProgress.d.ts +1 -1
- package/components/Step/Step.js +2 -2
- package/components/Step/StepList.d.ts +1 -1
- package/components/StepActions/StepActions.js +2 -1
- package/components/SwapInput/SwapInputEndAdornment.d.ts +1 -1
- package/components/SwapRoutes/SwapRoutesExpanded.d.ts +2 -2
- package/components/TokenList/TokenList.js +6 -3
- 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 +31 -8
- package/components/TokenList/VirtualizedTokenList.js +3 -3
- package/components/TokenList/types.d.ts +4 -0
- package/config/version.d.ts +1 -1
- package/config/version.js +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/useProcessMessage.js +4 -0
- package/hooks/useRouteExecution.js +3 -3
- package/hooks/useSwapRoutes.d.ts +1 -2
- package/hooks/useSwapRoutes.js +5 -6
- package/hooks/useTokenBalance.js +2 -2
- package/i18n/en.json +3 -1
- 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/package.json +8 -8
- package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +1 -1
- package/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -1
- package/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -1
- package/pages/SettingsPage/GasPriceSelect.d.ts +1 -1
- package/pages/SettingsPage/SettingsPage.d.ts +1 -1
- package/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -1
- package/pages/SettingsPage/SlippageInput.d.ts +1 -1
- package/pages/SwapDetailsPage/SwapDetailsPage.js +1 -1
- package/pages/SwapPage/StatusBottomSheet.js +4 -4
- package/providers/SDKProvider/SDKProvider.js +2 -0
- package/providers/WalletProvider/WalletProvider.js +74 -48
- package/providers/WalletProvider/types.d.ts +0 -2
- package/stores/routes/RouteExecutionStore.d.ts +1 -1
- package/stores/settings/useSplitSubvariantStore.d.ts +1 -1
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/widget.d.ts +1 -0
- package/types/widget.js +1 -0
- package/utils/wallet.d.ts +1 -1
- package/utils/wallet.js +1 -1
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const HeaderAppBar: import("@emotion/styled").StyledComponent<
|
|
2
|
+
export declare const HeaderAppBar: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
classes?: Partial<import("@mui/material").AppBarClasses> | undefined;
|
|
4
4
|
color?: import("@mui/types").OverridableStringUnion<"transparent" | import("@mui/material").PropTypes.Color, import("@mui/material").AppBarPropsColorOverrides> | undefined;
|
|
5
5
|
enableColorOnDark?: boolean | undefined;
|
|
6
6
|
position?: "fixed" | "absolute" | "relative" | "static" | "sticky" | undefined;
|
|
7
7
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
8
|
-
} &
|
|
8
|
+
} & Omit<{
|
|
9
|
+
children?: import("react").ReactNode;
|
|
10
|
+
classes?: Partial<import("@mui/material").PaperClasses> | undefined;
|
|
11
|
+
elevation?: number | undefined;
|
|
12
|
+
square?: boolean | undefined;
|
|
13
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
14
|
+
variant?: import("@mui/types").OverridableStringUnion<"outlined" | "elevation", import("@mui/material").PaperPropsVariantOverrides> | undefined;
|
|
15
|
+
}, "classes" | "color" | "position"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & {
|
|
9
16
|
ref?: ((instance: HTMLElement | null) => void) | import("react").RefObject<HTMLElement> | null | undefined;
|
|
10
|
-
}, keyof import("@mui/material/OverridableComponent").CommonProps | "
|
|
17
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "color" | "children" | "sx" | "position" | "variant" | "square" | "elevation" | "enableColorOnDark"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
11
18
|
export declare const Container: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
12
19
|
children?: import("react").ReactNode;
|
|
13
20
|
component?: import("react").ElementType<any> | undefined;
|
|
@@ -15,7 +15,7 @@ import { WalletMenuButton } from './WalletHeader';
|
|
|
15
15
|
import { useHeaderActionStore } from './useHeaderActionStore';
|
|
16
16
|
export const NavigationHeader = () => {
|
|
17
17
|
const { t } = useTranslation();
|
|
18
|
-
const { variant, subvariant, hiddenUI
|
|
18
|
+
const { variant, subvariant, hiddenUI } = useWidgetConfig();
|
|
19
19
|
const { navigate, navigateBack } = useNavigateBack();
|
|
20
20
|
const { account } = useWallet();
|
|
21
21
|
const { element } = useHeaderActionStore();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const NavigationTabs: () => JSX.Element;
|
|
1
|
+
export declare const NavigationTabs: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,75 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
'aria-labelledby'?: string | undefined;
|
|
7
|
-
centered?: boolean | undefined;
|
|
8
|
-
children?: import("react").ReactNode;
|
|
9
|
-
classes?: Partial<import("@mui/material").TabsClasses> | undefined;
|
|
10
|
-
slots?: {
|
|
11
|
-
StartScrollButtonIcon?: import("react").ElementType<any> | undefined;
|
|
12
|
-
EndScrollButtonIcon?: import("react").ElementType<any> | undefined;
|
|
13
|
-
} | undefined;
|
|
14
|
-
slotProps?: {
|
|
15
|
-
startScrollButtonIcon?: import("@mui/base").SlotComponentProps<import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material").SvgIconTypeMap<{}, "svg">> & {
|
|
16
|
-
muiName: string;
|
|
17
|
-
}, import("@mui/material").TabsStartScrollButtonIconSlotPropsOverrides, import("@mui/material").TabsOwnerState> | undefined;
|
|
18
|
-
endScrollButtonIcon?: import("@mui/base").SlotComponentProps<import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material").SvgIconTypeMap<{}, "svg">> & {
|
|
19
|
-
muiName: string;
|
|
20
|
-
}, import("@mui/material").TabsEndScrollButtonIconSlotPropsOverrides, import("@mui/material").TabsOwnerState> | undefined;
|
|
21
|
-
} | undefined;
|
|
22
|
-
indicatorColor?: import("@mui/types").OverridableStringUnion<"primary" | "secondary", import("@mui/material").TabsPropsIndicatorColorOverrides> | undefined;
|
|
23
|
-
onChange?: ((event: import("react").SyntheticEvent<Element, Event>, value: any) => void) | undefined;
|
|
24
|
-
orientation?: "horizontal" | "vertical" | undefined;
|
|
25
|
-
ScrollButtonComponent?: import("react").ElementType<any> | undefined;
|
|
26
|
-
scrollButtons?: boolean | "auto" | undefined;
|
|
27
|
-
selectionFollowsFocus?: boolean | undefined;
|
|
28
|
-
TabIndicatorProps?: (import("react").HTMLAttributes<HTMLDivElement> & {
|
|
29
|
-
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
30
|
-
}) | undefined;
|
|
31
|
-
TabScrollButtonProps?: Partial<import("@mui/material").TabScrollButtonProps> | undefined;
|
|
32
|
-
textColor?: "inherit" | "primary" | "secondary" | undefined;
|
|
33
|
-
value?: any;
|
|
34
|
-
variant?: "fullWidth" | "standard" | "scrollable" | undefined;
|
|
35
|
-
visibleScrollbar?: boolean | undefined;
|
|
36
|
-
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
37
|
-
} & import("@mui/material/OverridableComponent").CommonProps & Omit<{
|
|
38
|
-
action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
|
|
39
|
-
centerRipple?: boolean | undefined;
|
|
40
|
-
children?: import("react").ReactNode;
|
|
41
|
-
classes?: Partial<import("@mui/material").ButtonBaseClasses> | undefined;
|
|
42
|
-
disabled?: boolean | undefined;
|
|
43
|
-
disableRipple?: boolean | undefined;
|
|
44
|
-
disableTouchRipple?: boolean | undefined;
|
|
45
|
-
focusRipple?: boolean | undefined;
|
|
46
|
-
focusVisibleClassName?: string | undefined;
|
|
47
|
-
LinkComponent?: import("react").ElementType<any> | undefined;
|
|
48
|
-
onFocusVisible?: import("react").FocusEventHandler<any> | undefined;
|
|
49
|
-
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
50
|
-
tabIndex?: number | undefined;
|
|
51
|
-
TouchRippleProps?: Partial<import("@mui/material/ButtonBase/TouchRipple").TouchRippleProps> | undefined;
|
|
52
|
-
touchRippleRef?: import("react").Ref<import("@mui/material/ButtonBase/TouchRipple").TouchRippleActions> | undefined;
|
|
53
|
-
} & Omit<{
|
|
54
|
-
action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
|
|
55
|
-
centerRipple?: boolean | undefined;
|
|
56
|
-
children?: import("react").ReactNode;
|
|
57
|
-
classes?: Partial<import("@mui/material").ButtonBaseClasses> | undefined;
|
|
58
|
-
disabled?: boolean | undefined;
|
|
59
|
-
disableRipple?: boolean | undefined;
|
|
60
|
-
disableTouchRipple?: boolean | undefined;
|
|
61
|
-
focusRipple?: boolean | undefined;
|
|
62
|
-
focusVisibleClassName?: string | undefined;
|
|
63
|
-
LinkComponent?: import("react").ElementType<any> | undefined;
|
|
64
|
-
onFocusVisible?: import("react").FocusEventHandler<any> | undefined;
|
|
65
|
-
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
66
|
-
tabIndex?: number | undefined;
|
|
67
|
-
TouchRippleProps?: Partial<import("@mui/material/ButtonBase/TouchRipple").TouchRippleProps> | undefined;
|
|
68
|
-
touchRippleRef?: import("react").Ref<import("@mui/material/ButtonBase/TouchRipple").TouchRippleActions> | undefined;
|
|
69
|
-
}, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
70
|
-
ref?: ((instance: HTMLButtonElement | null) => void) | import("react").RefObject<HTMLButtonElement> | null | undefined;
|
|
71
|
-
}, keyof import("@mui/material/OverridableComponent").CommonProps | "tabIndex" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef">, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "aria-label" | "aria-labelledby" | "onChange" | "action" | "sx" | "variant" | "value" | "slotProps" | "slots" | "orientation" | "allowScrollButtonsMobile" | "centered" | "indicatorColor" | "ScrollButtonComponent" | "scrollButtons" | "selectionFollowsFocus" | "TabIndicatorProps" | "TabScrollButtonProps" | "textColor" | "visibleScrollbar"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
72
|
-
export declare const NavbarTab: import("@emotion/styled").StyledComponent<{
|
|
2
|
+
import type { StyledComponent } from '@emotion/styled';
|
|
3
|
+
import type { TabsProps } from '@mui/material';
|
|
4
|
+
export declare const NavbarTabs: StyledComponent<TabsProps>;
|
|
5
|
+
export declare const NavbarTab: StyledComponent<{
|
|
73
6
|
children?: null | undefined;
|
|
74
7
|
classes?: Partial<import("@mui/material").TabClasses> | undefined;
|
|
75
8
|
disabled?: boolean | undefined;
|
|
@@ -10,7 +10,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
10
10
|
import { useLocation, useNavigate } from 'react-router-dom';
|
|
11
11
|
import { useChain } from '../../hooks';
|
|
12
12
|
import { useWallet, useWidgetConfig } from '../../providers';
|
|
13
|
-
import { navigationRoutes,
|
|
13
|
+
import { navigationRoutes, shortenAddress } from '../../utils';
|
|
14
14
|
import { HeaderAppBar, WalletButton } from './Header.style';
|
|
15
15
|
import { WalletMenu } from './WalletMenu';
|
|
16
16
|
export const WalletHeader = () => {
|
|
@@ -42,7 +42,7 @@ const ConnectedButton = () => {
|
|
|
42
42
|
const { t } = useTranslation();
|
|
43
43
|
const { subvariant } = useWidgetConfig();
|
|
44
44
|
const { account, disconnect } = useWallet();
|
|
45
|
-
const walletAddress =
|
|
45
|
+
const walletAddress = shortenAddress(account.address);
|
|
46
46
|
const { chain } = useChain(account.chainId);
|
|
47
47
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
48
48
|
const handleClick = (event) => {
|
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Collapse } from '@mui/material';
|
|
3
|
-
import { useState } from 'react';
|
|
4
3
|
import { useSwapRoutes } from '../../hooks';
|
|
5
4
|
import { RouteExecutionStatus, useRouteExecutionStore, useSetExecutableRoute, } from '../../stores';
|
|
6
5
|
import { InsuranceCard } from './InsuranceCard';
|
|
7
6
|
export const InsuranceCollapsed = ({ status, insurableRouteId, insuranceCoverageId, feeAmountUsd, onChange, ...props }) => {
|
|
8
|
-
const [insuredRoute, setInsuredRoute] = useState();
|
|
9
7
|
const setExecutableRoute = useSetExecutableRoute();
|
|
10
8
|
const routeExecution = useRouteExecutionStore((state) => state.routes[insurableRouteId]);
|
|
11
|
-
useSwapRoutes({
|
|
9
|
+
const { routes } = useSwapRoutes({
|
|
12
10
|
insurableRoute: routeExecution?.route,
|
|
13
|
-
onSettled(data) {
|
|
14
|
-
if (data?.routes?.[0]) {
|
|
15
|
-
setInsuredRoute(data.routes[0]);
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
11
|
});
|
|
12
|
+
const insuredRoute = routes?.[0];
|
|
19
13
|
const toggleInsurance = (checked) => {
|
|
20
14
|
if (insuredRoute) {
|
|
21
15
|
if (checked) {
|
|
@@ -4,10 +4,10 @@ import { useWatch } from 'react-hook-form';
|
|
|
4
4
|
import { ReverseTokensButton } from '../components/ReverseTokensButton';
|
|
5
5
|
import { SelectTokenButton } from '../components/SelectTokenButton';
|
|
6
6
|
import { SwapFormKey, useWidgetConfig } from '../providers';
|
|
7
|
-
import { DisabledUI } from '../types';
|
|
7
|
+
import { DisabledUI, HiddenUI } from '../types';
|
|
8
8
|
export const SelectChainAndToken = (props) => {
|
|
9
9
|
const prefersNarrowView = useMediaQuery((theme) => theme.breakpoints.down('sm'));
|
|
10
|
-
const { disabledUI, variant } = useWidgetConfig();
|
|
10
|
+
const { disabledUI, hiddenUI, variant } = useWidgetConfig();
|
|
11
11
|
const [fromChain, toChain, fromToken, toToken] = useWatch({
|
|
12
12
|
name: [
|
|
13
13
|
SwapFormKey.FromChain,
|
|
@@ -16,19 +16,20 @@ export const SelectChainAndToken = (props) => {
|
|
|
16
16
|
SwapFormKey.ToToken,
|
|
17
17
|
],
|
|
18
18
|
});
|
|
19
|
-
const
|
|
19
|
+
const hiddenReverse = variant === 'refuel' ||
|
|
20
20
|
disabledUI?.includes(DisabledUI.FromToken) ||
|
|
21
|
-
disabledUI?.includes(DisabledUI.ToToken)
|
|
22
|
-
|
|
21
|
+
disabledUI?.includes(DisabledUI.ToToken) ||
|
|
22
|
+
hiddenUI?.includes(HiddenUI.ToToken);
|
|
23
|
+
const hiddenToToken = variant === 'nft' || hiddenUI?.includes(HiddenUI.ToToken);
|
|
23
24
|
const isCompact = fromChain &&
|
|
24
25
|
toChain &&
|
|
25
26
|
fromToken &&
|
|
26
27
|
toToken &&
|
|
27
28
|
!prefersNarrowView &&
|
|
28
|
-
!
|
|
29
|
-
return (_jsxs(Box, { sx: { display: 'flex', flexDirection: isCompact ? 'row' : 'column' }, ...props, children: [_jsx(SelectTokenButton, { formType: "from", compact: isCompact }), !
|
|
29
|
+
!hiddenToToken;
|
|
30
|
+
return (_jsxs(Box, { sx: { display: 'flex', flexDirection: isCompact ? 'row' : 'column' }, ...props, children: [_jsx(SelectTokenButton, { formType: "from", compact: isCompact }), !hiddenToToken ? (_jsx(Box, { sx: {
|
|
30
31
|
display: 'flex',
|
|
31
32
|
justifyContent: 'center',
|
|
32
33
|
alignItems: 'center',
|
|
33
|
-
}, m: !
|
|
34
|
+
}, m: !hiddenReverse ? -1.125 : 1, children: !hiddenReverse ? (_jsx(ReverseTokensButton, { vertical: !isCompact })) : null })) : null, !hiddenToToken ? (_jsx(SelectTokenButton, { formType: "to", compact: isCompact })) : null] }));
|
|
34
35
|
};
|
|
@@ -12,7 +12,7 @@ import { FormControl, Input } from './SendToWallet.style';
|
|
|
12
12
|
export const SendToWallet = forwardRef((props, ref) => {
|
|
13
13
|
const { t } = useTranslation();
|
|
14
14
|
const { trigger, getValues, clearErrors } = useFormContext();
|
|
15
|
-
const { account
|
|
15
|
+
const { account } = useWallet();
|
|
16
16
|
const { disabledUI, hiddenUI, requiredUI, toAddress } = useWidgetConfig();
|
|
17
17
|
const { showSendToWallet, showSendToWalletDirty, setSendToWallet } = useSendToWalletStore();
|
|
18
18
|
const { showDestinationWallet } = useSettings(['showDestinationWallet']);
|
|
@@ -30,7 +30,7 @@ export const SendToWallet = forwardRef((props, ref) => {
|
|
|
30
30
|
if (!value) {
|
|
31
31
|
return true;
|
|
32
32
|
}
|
|
33
|
-
const address = await provider?.resolveName(value);
|
|
33
|
+
const address = await account.signer?.provider?.resolveName(value);
|
|
34
34
|
return (isAddress(address || value) ||
|
|
35
35
|
t('swap.error.title.walletAddressInvalid'));
|
|
36
36
|
}
|
|
@@ -33,4 +33,4 @@ export declare const SmallAvatarSkeletonContainer: import("@emotion/styled").Sty
|
|
|
33
33
|
} & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
34
34
|
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
35
35
|
}, "children" | "sx" | "ref" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "component"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
36
|
-
export declare const SmallAvatarSkeleton: () => JSX.Element;
|
|
36
|
+
export declare const SmallAvatarSkeleton: () => import("react/jsx-runtime").JSX.Element;
|
package/components/Step/Step.js
CHANGED
|
@@ -6,7 +6,7 @@ import { StepActions } from '../../components/StepActions';
|
|
|
6
6
|
import { Token } from '../../components/Token';
|
|
7
7
|
import { useChains } from '../../hooks';
|
|
8
8
|
import { useWidgetConfig } from '../../providers';
|
|
9
|
-
import {
|
|
9
|
+
import { shortenAddress } from '../../utils';
|
|
10
10
|
import { DestinationWalletAddress } from './DestinationWalletAddress';
|
|
11
11
|
import { GasStepProcess } from './GasStepProcess';
|
|
12
12
|
import { StepProcess } from './StepProcess';
|
|
@@ -40,7 +40,7 @@ export const Step = ({ step, fromToken, toToken, toAddress }) => {
|
|
|
40
40
|
: t('swap.stepSwap');
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
-
const formattedToAddress =
|
|
43
|
+
const formattedToAddress = shortenAddress(toAddress);
|
|
44
44
|
const toAddressLink = toAddress
|
|
45
45
|
? `${getChainById(step.action.toChainId)?.metamask.blockExplorerUrls[0]}address/${toAddress}`
|
|
46
46
|
: undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Route } from '@lifi/sdk';
|
|
2
|
-
export declare const getStepList: (route?: Route) => JSX.Element[] | undefined;
|
|
2
|
+
export declare const getStepList: (route?: Route) => import("react/jsx-runtime").JSX.Element[] | undefined;
|
|
@@ -50,7 +50,8 @@ export const StepDetailsContent = ({ step, variant }) => {
|
|
|
50
50
|
if (sameTokenProtocolStep) {
|
|
51
51
|
fromAmount = Big(step.estimate.fromAmount)
|
|
52
52
|
.div(10 ** step.action.fromToken.decimals)
|
|
53
|
-
.minus(Big(step.estimate.toAmount).div(10 ** step.action.toToken.decimals))
|
|
53
|
+
.minus(Big(step.estimate.toAmount).div(10 ** step.action.toToken.decimals))
|
|
54
|
+
.toString();
|
|
54
55
|
}
|
|
55
56
|
else {
|
|
56
57
|
fromAmount = formatTokenAmount(step.estimate.fromAmount, step.action.fromToken.decimals);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { SwapFormTypeProps } from '../../providers';
|
|
2
|
-
export declare const SwapInputEndAdornment: ({ formType }: SwapFormTypeProps) => JSX.Element;
|
|
2
|
+
export declare const SwapInputEndAdornment: ({ formType }: SwapFormTypeProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const SwapRoutesExpanded: () => JSX.Element;
|
|
2
|
-
export declare const SwapRoutesExpandedElement: () => JSX.Element;
|
|
1
|
+
export declare const SwapRoutesExpanded: () => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const SwapRoutesExpandedElement: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Box } from '@mui/material';
|
|
3
3
|
import { useRef } from 'react';
|
|
4
4
|
import { useWatch } from 'react-hook-form';
|
|
5
|
-
import { useDebouncedWatch, useTokenBalances, useTokenSearch, } from '../../hooks';
|
|
5
|
+
import { useChain, useDebouncedWatch, useTokenBalances, useTokenSearch, } from '../../hooks';
|
|
6
6
|
import { SwapFormKey, SwapFormKeyHelper, useWallet } from '../../providers';
|
|
7
7
|
import { TokenNotFound } from './TokenNotFound';
|
|
8
8
|
import { VirtualizedTokenList } from './VirtualizedTokenList';
|
|
@@ -14,6 +14,7 @@ export const TokenList = ({ formType, height, onClick, }) => {
|
|
|
14
14
|
name: [SwapFormKeyHelper.getChainKey(formType)],
|
|
15
15
|
});
|
|
16
16
|
const [tokenSearchFilter] = useDebouncedWatch([SwapFormKey.TokenSearchFilter], 320);
|
|
17
|
+
const { chain, isLoading: isChainLoading } = useChain(selectedChainId);
|
|
17
18
|
const { tokens: chainTokens, tokensWithBalance, isLoading: isTokensLoading, isBalanceLoading, featuredTokens, } = useTokenBalances(selectedChainId);
|
|
18
19
|
let filteredTokens = (tokensWithBalance ??
|
|
19
20
|
chainTokens ??
|
|
@@ -29,12 +30,14 @@ export const TokenList = ({ formType, height, onClick, }) => {
|
|
|
29
30
|
!!tokenSearchFilter &&
|
|
30
31
|
!!selectedChainId;
|
|
31
32
|
const { token: searchedToken, isLoading: isSearchedTokenLoading } = useTokenSearch(selectedChainId, tokenSearchFilter, tokenSearchEnabled);
|
|
32
|
-
const isLoading = isTokensLoading ||
|
|
33
|
+
const isLoading = isTokensLoading ||
|
|
34
|
+
isChainLoading ||
|
|
35
|
+
(tokenSearchEnabled && isSearchedTokenLoading);
|
|
33
36
|
const tokens = filteredTokens.length
|
|
34
37
|
? filteredTokens
|
|
35
38
|
: searchedToken
|
|
36
39
|
? [searchedToken]
|
|
37
40
|
: filteredTokens;
|
|
38
41
|
const handleTokenClick = useTokenSelect(formType, onClick);
|
|
39
|
-
return (_jsxs(Box, { ref: parentRef, style: { height, overflow: 'auto' }, children: [!tokens.length && !isLoading ? (_jsx(TokenNotFound, { formType: formType })) : null, _jsx(VirtualizedTokenList, { tokens: tokens, featuredTokensLength: featuredTokens?.length, scrollElementRef: parentRef, chainId: selectedChainId, isLoading: isLoading, isBalanceLoading: isBalanceLoading, showBalance: account.isActive, showFeatured: !tokenSearchFilter, onClick: handleTokenClick })] }));
|
|
42
|
+
return (_jsxs(Box, { ref: parentRef, style: { height, overflow: 'auto' }, children: [!tokens.length && !isLoading ? (_jsx(TokenNotFound, { formType: formType })) : null, _jsx(VirtualizedTokenList, { tokens: tokens, featuredTokensLength: featuredTokens?.length, scrollElementRef: parentRef, chainId: selectedChainId, chain: chain, isLoading: isLoading, isBalanceLoading: isBalanceLoading, showBalance: account.isActive, showFeatured: !tokenSearchFilter, onClick: handleTokenClick })] }));
|
|
40
43
|
};
|
|
@@ -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,7 +1,7 @@
|
|
|
1
|
-
import { ListItem as MuiListItem } from '@mui/material';
|
|
1
|
+
import { Button, ListItem as MuiListItem, buttonClasses } from '@mui/material';
|
|
2
2
|
import { listItemSecondaryActionClasses } from '@mui/material/ListItemSecondaryAction';
|
|
3
3
|
import { listItemTextClasses } from '@mui/material/ListItemText';
|
|
4
|
-
import { styled } from '@mui/material/styles';
|
|
4
|
+
import { alpha, styled } from '@mui/material/styles';
|
|
5
5
|
import { ListItemButton as ListItemButtonBase } from '../ListItemButton';
|
|
6
6
|
export const ListItemButton = styled(ListItemButtonBase)(({ theme }) => ({
|
|
7
7
|
paddingLeft: theme.spacing(1.5),
|
|
@@ -26,3 +26,22 @@ export const ListItem = styled(MuiListItem)(({ theme }) => ({
|
|
|
26
26
|
whiteSpace: 'nowrap',
|
|
27
27
|
},
|
|
28
28
|
}));
|
|
29
|
+
export const LinkButton = styled(Button)(({ theme }) => ({
|
|
30
|
+
lineHeight: 1,
|
|
31
|
+
fontSize: '0.75rem',
|
|
32
|
+
fontWeight: 400,
|
|
33
|
+
padding: theme.spacing(0.375, 0.75),
|
|
34
|
+
color: 'inherit',
|
|
35
|
+
backgroundColor: 'unset',
|
|
36
|
+
'&:hover': {
|
|
37
|
+
backgroundColor: theme.palette.mode === 'light'
|
|
38
|
+
? alpha(theme.palette.common.black, 0.04)
|
|
39
|
+
: alpha(theme.palette.common.white, 0.08),
|
|
40
|
+
},
|
|
41
|
+
[`.${buttonClasses.endIcon}`]: {
|
|
42
|
+
marginLeft: theme.spacing(0.25),
|
|
43
|
+
},
|
|
44
|
+
[`.${buttonClasses.endIcon} > *:nth-of-type(1)`]: {
|
|
45
|
+
fontSize: '0.75rem',
|
|
46
|
+
},
|
|
47
|
+
}));
|
|
@@ -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;
|
|
@@ -1,20 +1,43 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import OpenInNewIcon from '@mui/icons-material/OpenInNewRounded';
|
|
3
|
+
import { Avatar, Box, Link, ListItemAvatar, ListItemText, Skeleton, Slide, Typography, } from '@mui/material';
|
|
4
|
+
import { memo, useRef, useState } from 'react';
|
|
4
5
|
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import { formatTokenPrice } from '../../utils';
|
|
6
|
-
import { ListItem, ListItemButton } from './TokenList.style';
|
|
7
|
-
export const TokenListItem = memo(({ onClick, size, start, token, showBalance, isBalanceLoading, startAdornment, endAdornment, }) => {
|
|
6
|
+
import { formatTokenPrice, shortenAddress } from '../../utils';
|
|
7
|
+
import { LinkButton, ListItem, ListItemButton } from './TokenList.style';
|
|
8
|
+
export const TokenListItem = memo(({ onClick, size, start, token, chain, showBalance, isBalanceLoading, startAdornment, endAdornment, }) => {
|
|
8
9
|
const handleClick = () => onClick?.(token.address);
|
|
9
10
|
return (_jsxs(ListItem, { disablePadding: true, style: {
|
|
10
11
|
height: `${size}px`,
|
|
11
12
|
transform: `translateY(${start}px)`,
|
|
12
|
-
}, children: [startAdornment, _jsx(TokenListItemButton, { token: token, showBalance: showBalance, isBalanceLoading: isBalanceLoading, onClick: handleClick }), endAdornment] }));
|
|
13
|
+
}, children: [startAdornment, _jsx(TokenListItemButton, { token: token, chain: chain, showBalance: showBalance, isBalanceLoading: isBalanceLoading, onClick: handleClick }), endAdornment] }));
|
|
13
14
|
});
|
|
14
|
-
export const TokenListItemButton = ({ onClick, token, showBalance, isBalanceLoading, }) => {
|
|
15
|
+
export const TokenListItemButton = ({ onClick, token, chain, showBalance, isBalanceLoading, }) => {
|
|
15
16
|
const { t } = useTranslation();
|
|
16
17
|
const tokenPrice = formatTokenPrice(token.amount, token.priceUSD);
|
|
17
|
-
|
|
18
|
+
const container = useRef(null);
|
|
19
|
+
const timeoutId = useRef();
|
|
20
|
+
const [showAddress, setShowAddress] = useState(false);
|
|
21
|
+
const onMouseEnter = () => {
|
|
22
|
+
timeoutId.current = setTimeout(() => setShowAddress(true), 350);
|
|
23
|
+
};
|
|
24
|
+
const onMouseLeave = () => {
|
|
25
|
+
clearTimeout(timeoutId.current);
|
|
26
|
+
if (showAddress) {
|
|
27
|
+
setShowAddress(false);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
return (_jsxs(ListItemButton, { onClick: onClick, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, dense: true, children: [_jsx(ListItemAvatar, { children: _jsx(Avatar, { src: token.logoURI, alt: token.symbol, children: token.symbol[0] }) }), _jsx(ListItemText, { primary: token.symbol, secondaryTypographyProps: {
|
|
31
|
+
component: 'div',
|
|
32
|
+
sx: {
|
|
33
|
+
overflow: 'auto',
|
|
34
|
+
marginLeft: -0.75,
|
|
35
|
+
},
|
|
36
|
+
}, secondary: _jsxs(Box, { position: "relative", height: 18, ref: container, children: [_jsx(Slide, { direction: "down", in: !showAddress, container: container.current, style: {
|
|
37
|
+
position: 'absolute',
|
|
38
|
+
}, appear: false, children: _jsx(Box, { pl: 0.75, children: token.name }) }), _jsx(Slide, { direction: "up", in: showAddress, container: container.current, style: {
|
|
39
|
+
position: 'absolute',
|
|
40
|
+
}, appear: false, mountOnEnter: true, children: _jsx(LinkButton, { size: "small", LinkComponent: Link, href: `${chain?.metamask.blockExplorerUrls[0]}address/${token.address}`, target: "_blank", rel: "nofollow noreferrer", onClick: (e) => e.stopPropagation(), endIcon: _jsx(OpenInNewIcon, {}), children: shortenAddress(token.address) }) })] }) }), showBalance ? (isBalanceLoading ? (_jsx(TokenAmountSkeleton, {})) : (_jsxs(Box, { sx: { textAlign: 'right' }, children: [Number(token.amount) ? (_jsx(Typography, { variant: "body1", noWrap: true, children: t('format.number', {
|
|
18
41
|
value: token.amount,
|
|
19
42
|
}) })) : null, tokenPrice ? (_jsx(Typography, { fontWeight: 400, fontSize: 12, color: "text.secondary", "data-price": token.priceUSD, children: t(`format.currency`, {
|
|
20
43
|
value: tokenPrice,
|
|
@@ -4,7 +4,7 @@ import { useVirtualizer } from '@tanstack/react-virtual';
|
|
|
4
4
|
import { useEffect } from 'react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
import { TokenListItem, TokenListItemSkeleton } from './TokenListItem';
|
|
7
|
-
export const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollElementRef, chainId, isLoading, isBalanceLoading, showBalance, showFeatured, onClick, }) => {
|
|
7
|
+
export const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollElementRef, chainId, chain, isLoading, isBalanceLoading, showBalance, showFeatured, onClick, }) => {
|
|
8
8
|
const { t } = useTranslation();
|
|
9
9
|
const hasFeaturedTokens = !!featuredTokensLength && showFeatured;
|
|
10
10
|
const featuredTokensLastIndex = (featuredTokensLength ?? 0) - 1;
|
|
@@ -32,7 +32,7 @@ export const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollEleme
|
|
|
32
32
|
}
|
|
33
33
|
return size;
|
|
34
34
|
},
|
|
35
|
-
getItemKey: (index) => tokens[index].address
|
|
35
|
+
getItemKey: (index) => `${tokens[index].address}-${index}`,
|
|
36
36
|
});
|
|
37
37
|
useEffect(() => {
|
|
38
38
|
if (getVirtualItems().length) {
|
|
@@ -46,7 +46,7 @@ export const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollEleme
|
|
|
46
46
|
}
|
|
47
47
|
return (_jsx(List, { style: { height: getTotalSize() }, disablePadding: true, children: getVirtualItems().map((item) => {
|
|
48
48
|
const token = tokens[item.index];
|
|
49
|
-
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, { fontSize: 14, fontWeight: 600, lineHeight: 1, px: 2, pb: 1.25, children: t('swap.featuredTokens') })) : null, endAdornment: hasFeaturedTokens &&
|
|
49
|
+
return (_jsx(TokenListItem, { onClick: onClick, size: item.size, start: item.start, token: token, chain: chain, isBalanceLoading: isBalanceLoading, showBalance: showBalance, startAdornment: hasFeaturedTokens && token.featured && item.index === 0 ? (_jsx(Typography, { fontSize: 14, fontWeight: 600, lineHeight: 1, px: 2, pb: 1.25, children: t('swap.featuredTokens') })) : null, endAdornment: hasFeaturedTokens &&
|
|
50
50
|
token.featured &&
|
|
51
51
|
item.index === featuredTokensLastIndex &&
|
|
52
52
|
item.index !== tokensLastIndex ? (_jsx(Typography, { fontSize: 14, fontWeight: 600, lineHeight: 1, px: 2, py: 1.25, children: t('swap.otherTokens') })) : null }, item.key));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ExtendedChain } from '@lifi/sdk';
|
|
1
2
|
import type { MutableRefObject } from 'react';
|
|
2
3
|
import type { SwapFormType } from '../../providers';
|
|
3
4
|
import type { TokenAmount } from '../../types';
|
|
@@ -13,6 +14,7 @@ export interface VirtualizedTokenListProps {
|
|
|
13
14
|
isLoading: boolean;
|
|
14
15
|
isBalanceLoading: boolean;
|
|
15
16
|
chainId: number;
|
|
17
|
+
chain?: ExtendedChain;
|
|
16
18
|
showBalance?: boolean;
|
|
17
19
|
showFeatured?: boolean;
|
|
18
20
|
onClick(tokenAddress: string): void;
|
|
@@ -25,6 +27,7 @@ export interface TokenListItemBaseProps {
|
|
|
25
27
|
export interface TokenListItemProps extends TokenListItemBaseProps {
|
|
26
28
|
showBalance?: boolean;
|
|
27
29
|
token: TokenAmount;
|
|
30
|
+
chain?: ExtendedChain;
|
|
28
31
|
isBalanceLoading?: boolean;
|
|
29
32
|
startAdornment?: React.ReactNode;
|
|
30
33
|
endAdornment?: React.ReactNode;
|
|
@@ -33,5 +36,6 @@ export interface TokenListItemButtonProps {
|
|
|
33
36
|
onClick?(): void;
|
|
34
37
|
showBalance?: boolean;
|
|
35
38
|
token: TokenAmount;
|
|
39
|
+
chain?: ExtendedChain;
|
|
36
40
|
isBalanceLoading?: boolean;
|
|
37
41
|
}
|
package/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.9";
|
package/config/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '2.0.0-beta.
|
|
2
|
+
export const version = '2.0.0-beta.9';
|
|
@@ -7,8 +7,8 @@ import { useGetTokenBalancesWithRetry } from './useGetTokenBalancesWithRetry';
|
|
|
7
7
|
import { useTokenAddressBalance } from './useTokenAddressBalance';
|
|
8
8
|
const refetchInterval = 30000;
|
|
9
9
|
export const useFundsSufficiency = (route) => {
|
|
10
|
-
const { account
|
|
11
|
-
const getTokenBalancesWithRetry = useGetTokenBalancesWithRetry(provider);
|
|
10
|
+
const { account } = useWallet();
|
|
11
|
+
const getTokenBalancesWithRetry = useGetTokenBalancesWithRetry(account.signer?.provider);
|
|
12
12
|
const [fromChainId, fromTokenAddress, fromAmount] = useWatch({
|
|
13
13
|
name: [
|
|
14
14
|
SwapFormKey.FromChain,
|
package/hooks/useGasRefuel.d.ts
CHANGED
|
@@ -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
|
};
|
package/hooks/useGasRefuel.js
CHANGED
|
@@ -7,12 +7,11 @@ import { useGasRecommendation } from './useGasRecommendation';
|
|
|
7
7
|
import { useTokenBalance } from './useTokenBalance';
|
|
8
8
|
export const useGasRefuel = () => {
|
|
9
9
|
const { getChainById } = useChains();
|
|
10
|
-
const [fromChainId, fromTokenAddress, toChainId,
|
|
10
|
+
const [fromChainId, fromTokenAddress, toChainId, toAddress] = useWatch({
|
|
11
11
|
name: [
|
|
12
12
|
SwapFormKey.FromChain,
|
|
13
13
|
SwapFormKey.FromToken,
|
|
14
14
|
SwapFormKey.ToChain,
|
|
15
|
-
SwapFormKey.ToToken,
|
|
16
15
|
SwapFormKey.ToAddress,
|
|
17
16
|
],
|
|
18
17
|
});
|
|
@@ -24,10 +23,7 @@ export const useGasRefuel = () => {
|
|
|
24
23
|
// We don't allow same chain refuel.
|
|
25
24
|
// If a user runs out of gas, he can't send a source chain transaction.
|
|
26
25
|
fromChainId === toChainId ||
|
|
27
|
-
// We don't want to apply auto refuel when swapping to native tokens
|
|
28
|
-
toChain?.nativeToken.address === toTokenAddress ||
|
|
29
26
|
!gasRecommendation?.available ||
|
|
30
|
-
!gasRecommendation.recommended ||
|
|
31
27
|
!nativeToken) {
|
|
32
28
|
return false;
|
|
33
29
|
}
|
|
@@ -38,20 +34,14 @@ export const useGasRefuel = () => {
|
|
|
38
34
|
.div(2);
|
|
39
35
|
const insufficientGas = tokenBalance.lt(recommendedAmount);
|
|
40
36
|
return insufficientGas;
|
|
41
|
-
}, [
|
|
42
|
-
fromChainId,
|
|
43
|
-
gasRecommendation?.available,
|
|
44
|
-
gasRecommendation?.recommended,
|
|
45
|
-
nativeToken,
|
|
46
|
-
toChain?.nativeToken.address,
|
|
47
|
-
toChainId,
|
|
48
|
-
toTokenAddress,
|
|
49
|
-
]);
|
|
37
|
+
}, [fromChainId, gasRecommendation, nativeToken, toChainId]);
|
|
50
38
|
return {
|
|
51
39
|
enabled: enabled,
|
|
52
40
|
availble: gasRecommendation?.available,
|
|
53
41
|
isLoading: isLoading,
|
|
54
42
|
chain: toChain,
|
|
55
|
-
gasRecommendation
|
|
43
|
+
fromAmount: gasRecommendation?.available
|
|
44
|
+
? gasRecommendation.fromAmount
|
|
45
|
+
: undefined,
|
|
56
46
|
};
|
|
57
47
|
};
|