@lifi/widget 3.6.2 → 3.7.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AppProvider.tsx +4 -4
- package/AppRoutes.tsx +2 -14
- package/CHANGELOG.md +0 -14
- package/_esm/AppProvider.js +1 -1
- package/_esm/AppProvider.js.map +1 -1
- package/_esm/AppRoutes.js +2 -9
- package/_esm/AppRoutes.js.map +1 -1
- package/_esm/components/ActiveTransactions/ActiveTransactions.style.js +1 -1
- package/_esm/components/ActiveTransactions/ActiveTransactions.style.js.map +1 -1
- package/_esm/components/AmountInput/AmountInputEndAdornment.js +1 -3
- package/_esm/components/AmountInput/AmountInputEndAdornment.js.map +1 -1
- package/_esm/components/AppContainer.js +0 -7
- package/_esm/components/AppContainer.js.map +1 -1
- package/_esm/components/Avatar/AccountAvatar.d.ts +1 -1
- package/_esm/components/Avatar/AccountAvatar.js +1 -1
- package/_esm/components/Avatar/AccountAvatar.js.map +1 -1
- package/_esm/components/Avatar/Avatar.d.ts +1 -0
- package/_esm/components/Avatar/Avatar.js +7 -4
- package/_esm/components/Avatar/Avatar.js.map +1 -1
- package/_esm/components/Avatar/Avatar.style.d.ts +6 -3
- package/_esm/components/Avatar/Avatar.style.js +19 -6
- package/_esm/components/Avatar/Avatar.style.js.map +1 -1
- package/_esm/components/Avatar/SmallAvatar.d.ts +4 -0
- package/_esm/components/Avatar/SmallAvatar.js +12 -0
- package/_esm/components/Avatar/SmallAvatar.js.map +1 -0
- package/_esm/components/Avatar/TokenAvatar.js +1 -1
- package/_esm/components/Avatar/TokenAvatar.js.map +1 -1
- package/_esm/components/BaseTransactionButton/BaseTransactionButton.js +3 -5
- package/_esm/components/BaseTransactionButton/BaseTransactionButton.js.map +1 -1
- package/_esm/components/ChainSelect/useChainSelect.js +5 -1
- package/_esm/components/ChainSelect/useChainSelect.js.map +1 -1
- package/_esm/components/FeeBreakdownTooltip.js +4 -1
- package/_esm/components/FeeBreakdownTooltip.js.map +1 -1
- package/_esm/components/Header/EVMDisconnectIconButton.js +5 -4
- package/_esm/components/Header/EVMDisconnectIconButton.js.map +1 -1
- package/_esm/components/Header/NavigationHeader.js +1 -1
- package/_esm/components/Header/NavigationHeader.js.map +1 -1
- package/_esm/components/Header/UTXODisconnectIconButton.d.ts +4 -0
- package/_esm/components/Header/UTXODisconnectIconButton.js +13 -0
- package/_esm/components/Header/UTXODisconnectIconButton.js.map +1 -0
- package/_esm/components/Header/WalletHeader.js +5 -9
- package/_esm/components/Header/WalletHeader.js.map +1 -1
- package/_esm/components/Header/WalletMenu.js +10 -15
- package/_esm/components/Header/WalletMenu.js.map +1 -1
- package/_esm/components/Header/WalletMenu.style.js +5 -1
- package/_esm/components/Header/WalletMenu.style.js.map +1 -1
- package/_esm/components/Routes/RoutesExpanded.js +1 -1
- package/_esm/components/Routes/RoutesExpanded.js.map +1 -1
- package/_esm/components/SendToWallet/SendToWalletButton.js +1 -1
- package/_esm/components/SendToWallet/SendToWalletButton.js.map +1 -1
- package/_esm/components/StepActions/StepActions.js +1 -1
- package/_esm/components/StepActions/StepActions.js.map +1 -1
- package/_esm/components/Tabs/Tabs.style.d.ts +1 -1
- package/_esm/components/Token/Token.js +1 -1
- package/_esm/components/Token/Token.js.map +1 -1
- package/_esm/components/TokenList/TokenList.js +1 -1
- package/_esm/components/TokenList/TokenList.js.map +1 -1
- package/_esm/components/TokenList/TokenListItem.js +11 -5
- package/_esm/components/TokenList/TokenListItem.js.map +1 -1
- package/_esm/components/TokenList/VirtualizedTokenList.js +1 -1
- package/_esm/components/TokenList/VirtualizedTokenList.js.map +1 -1
- package/_esm/components/TokenList/types.d.ts +3 -3
- package/_esm/components/TokenRate/TokenRate.js +2 -2
- package/_esm/components/TokenRate/TokenRate.js.map +1 -1
- package/_esm/config/version.d.ts +1 -1
- package/_esm/config/version.js +1 -1
- package/_esm/config/version.js.map +1 -1
- package/_esm/hooks/useAvailableChains.d.ts +2 -1
- package/_esm/hooks/useAvailableChains.js +9 -8
- package/_esm/hooks/useAvailableChains.js.map +1 -1
- package/_esm/hooks/useChains.d.ts +4 -3
- package/_esm/hooks/useChains.js +5 -3
- package/_esm/hooks/useChains.js.map +1 -1
- package/_esm/hooks/useFromTokenSufficiency.js +1 -1
- package/_esm/hooks/useFromTokenSufficiency.js.map +1 -1
- package/_esm/hooks/useGasSufficiency.js +3 -3
- package/_esm/hooks/useGasSufficiency.js.map +1 -1
- package/_esm/hooks/useProcessMessage.js +4 -0
- package/_esm/hooks/useProcessMessage.js.map +1 -1
- package/_esm/hooks/useRouteExecution.js +1 -1
- package/_esm/hooks/useRouteExecution.js.map +1 -1
- package/_esm/hooks/useRoutes.js +1 -1
- package/_esm/hooks/useRoutes.js.map +1 -1
- package/_esm/hooks/useScrollableContainer.d.ts +1 -0
- package/_esm/hooks/useScrollableContainer.js +2 -1
- package/_esm/hooks/useScrollableContainer.js.map +1 -1
- package/_esm/hooks/useSetContentHeight.js +6 -9
- package/_esm/hooks/useSetContentHeight.js.map +1 -1
- package/_esm/hooks/useTokenBalance.js +1 -1
- package/_esm/hooks/useTokenBalance.js.map +1 -1
- package/_esm/hooks/useTokenBalances.js +1 -1
- package/_esm/hooks/useTokenBalances.js.map +1 -1
- package/_esm/hooks/useTokens.js +1 -1
- package/_esm/hooks/useTokens.js.map +1 -1
- package/_esm/hooks/useTransactionDetails.js +1 -1
- package/_esm/hooks/useTransactionDetails.js.map +1 -1
- package/_esm/hooks/useTransactionHistory.js +1 -1
- package/_esm/hooks/useTransactionHistory.js.map +1 -1
- package/_esm/i18n/en.json +3 -4
- package/_esm/index.d.ts +0 -2
- package/_esm/index.js +0 -2
- package/_esm/index.js.map +1 -1
- package/_esm/pages/RoutesPage/RoutesPage.js +1 -1
- package/_esm/pages/RoutesPage/RoutesPage.js.map +1 -1
- package/_esm/pages/SelectTokenPage/useTokenListHeight.js +4 -7
- package/_esm/pages/SelectTokenPage/useTokenListHeight.js.map +1 -1
- package/_esm/pages/SendToWallet/ConnectedWalletsPage.js +1 -1
- package/_esm/pages/SendToWallet/ConnectedWalletsPage.js.map +1 -1
- package/_esm/pages/SendToWallet/SendToWalletPage.js +1 -1
- package/_esm/pages/SendToWallet/SendToWalletPage.js.map +1 -1
- package/_esm/pages/TransactionPage/StatusBottomSheet.js +5 -5
- package/_esm/pages/TransactionPage/StatusBottomSheet.js.map +1 -1
- package/_esm/providers/I18nProvider/types.d.ts +2 -2
- package/_esm/providers/WalletProvider/SDKProviders.js +15 -7
- package/_esm/providers/WalletProvider/SDKProviders.js.map +1 -1
- package/_esm/providers/WalletProvider/UTXOBaseProvider.d.ts +2 -0
- package/_esm/providers/WalletProvider/UTXOBaseProvider.js +17 -0
- package/_esm/providers/WalletProvider/UTXOBaseProvider.js.map +1 -0
- package/_esm/providers/WalletProvider/UTXOExternalContext.d.ts +1 -0
- package/_esm/providers/WalletProvider/UTXOExternalContext.js +3 -0
- package/_esm/providers/WalletProvider/UTXOExternalContext.js.map +1 -0
- package/_esm/providers/WalletProvider/UTXOProvider.d.ts +3 -0
- package/_esm/providers/WalletProvider/UTXOProvider.js +18 -0
- package/_esm/providers/WalletProvider/UTXOProvider.js.map +1 -0
- package/_esm/providers/WalletProvider/WalletProvider.d.ts +1 -0
- package/_esm/providers/WalletProvider/WalletProvider.js +14 -1
- package/_esm/providers/WalletProvider/WalletProvider.js.map +1 -1
- package/_esm/providers/WalletProvider/useHasExternalWalletProvider.d.ts +1 -1
- package/_esm/providers/WalletProvider/useHasExternalWalletProvider.js +8 -3
- package/_esm/providers/WalletProvider/useHasExternalWalletProvider.js.map +1 -1
- package/_esm/providers/WidgetProvider/WidgetProvider.js +2 -1
- package/_esm/providers/WidgetProvider/WidgetProvider.js.map +1 -1
- package/_esm/providers/WidgetProvider/types.d.ts +0 -2
- package/_esm/stores/form/FormUpdater.js +1 -1
- package/_esm/stores/form/FormUpdater.js.map +1 -1
- package/_esm/stores/form/types.d.ts +4 -4
- package/_esm/stores/routes/useExecutingRoutesIds.js +1 -1
- package/_esm/stores/routes/useExecutingRoutesIds.js.map +1 -1
- package/_esm/themes/createTheme.js +2 -1
- package/_esm/themes/createTheme.js.map +1 -1
- package/_esm/types/events.d.ts +6 -0
- package/_esm/types/events.js +3 -0
- package/_esm/types/events.js.map +1 -1
- package/_esm/utils/chainType.js +2 -3
- package/_esm/utils/chainType.js.map +1 -1
- package/_esm/utils/elements.d.ts +0 -4
- package/_esm/utils/elements.js +0 -6
- package/_esm/utils/elements.js.map +1 -1
- package/_esm/utils/fees.js +9 -5
- package/_esm/utils/fees.js.map +1 -1
- package/_esm/utils/format.js +1 -1
- package/_esm/utils/format.js.map +1 -1
- package/_esm/utils/navigationRoutes.d.ts +0 -1
- package/_esm/utils/navigationRoutes.js +0 -3
- package/_esm/utils/navigationRoutes.js.map +1 -1
- package/_esm/utils/wallet.js +1 -1
- package/components/ActiveTransactions/ActiveTransactions.style.ts +1 -1
- package/components/AmountInput/AmountInputEndAdornment.tsx +1 -5
- package/components/AppContainer.tsx +0 -8
- package/components/Avatar/AccountAvatar.tsx +2 -2
- package/components/Avatar/Avatar.style.tsx +20 -7
- package/components/Avatar/Avatar.tsx +12 -4
- package/components/Avatar/SmallAvatar.tsx +16 -0
- package/components/Avatar/TokenAvatar.tsx +1 -1
- package/components/BaseTransactionButton/BaseTransactionButton.tsx +3 -5
- package/components/ChainSelect/useChainSelect.ts +10 -1
- package/components/FeeBreakdownTooltip.tsx +4 -1
- package/components/Header/EVMDisconnectIconButton.tsx +5 -5
- package/components/Header/NavigationHeader.tsx +1 -1
- package/components/Header/UTXODisconnectIconButton.tsx +24 -0
- package/components/Header/WalletHeader.tsx +11 -12
- package/components/Header/WalletMenu.style.tsx +5 -1
- package/components/Header/WalletMenu.tsx +23 -24
- package/components/Routes/RoutesExpanded.tsx +1 -2
- package/components/SendToWallet/SendToWalletButton.tsx +1 -1
- package/components/StepActions/StepActions.tsx +1 -1
- package/components/Token/Token.tsx +1 -1
- package/components/TokenList/TokenList.tsx +1 -1
- package/components/TokenList/TokenListItem.tsx +15 -7
- package/components/TokenList/VirtualizedTokenList.tsx +1 -1
- package/components/TokenList/types.ts +3 -3
- package/components/TokenRate/TokenRate.tsx +2 -2
- package/config/version.ts +1 -1
- package/hooks/useAvailableChains.ts +9 -10
- package/hooks/useChains.ts +6 -3
- package/hooks/useFromTokenSufficiency.ts +1 -1
- package/hooks/useGasSufficiency.ts +5 -3
- package/hooks/useProcessMessage.ts +4 -0
- package/hooks/useRouteExecution.ts +1 -1
- package/hooks/useRoutes.ts +1 -1
- package/hooks/useScrollableContainer.ts +6 -1
- package/hooks/useSetContentHeight.ts +6 -10
- package/hooks/useTokenBalance.ts +1 -1
- package/hooks/useTokenBalances.ts +1 -1
- package/hooks/useTokens.ts +2 -1
- package/hooks/useTransactionDetails.ts +1 -1
- package/hooks/useTransactionHistory.ts +1 -1
- package/i18n/en.json +3 -4
- package/index.ts +0 -2
- package/package.json +5 -5
- package/pages/RoutesPage/RoutesPage.tsx +1 -1
- package/pages/SelectTokenPage/useTokenListHeight.ts +10 -13
- package/pages/SendToWallet/ConnectedWalletsPage.tsx +2 -2
- package/pages/SendToWallet/SendToWalletPage.tsx +1 -1
- package/pages/TransactionPage/StatusBottomSheet.tsx +8 -6
- package/providers/I18nProvider/types.ts +2 -2
- package/providers/WalletProvider/SDKProviders.tsx +25 -7
- package/providers/WalletProvider/UTXOBaseProvider.tsx +28 -0
- package/providers/WalletProvider/UTXOExternalContext.ts +3 -0
- package/providers/WalletProvider/UTXOProvider.tsx +26 -0
- package/providers/WalletProvider/WalletProvider.tsx +24 -3
- package/providers/WalletProvider/useHasExternalWalletProvider.ts +11 -5
- package/providers/WidgetProvider/WidgetProvider.tsx +2 -1
- package/providers/WidgetProvider/types.ts +0 -2
- package/stores/form/FormUpdater.tsx +1 -1
- package/stores/form/types.ts +4 -4
- package/stores/routes/useExecutingRoutesIds.ts +1 -1
- package/themes/createTheme.ts +3 -1
- package/types/events.ts +6 -0
- package/utils/chainType.ts +2 -3
- package/utils/elements.ts +0 -21
- package/utils/fees.ts +15 -13
- package/utils/format.ts +1 -1
- package/utils/navigationRoutes.ts +0 -3
- package/utils/wallet.ts +1 -1
- package/_esm/components/SmallAvatar.d.ts +0 -10
- package/_esm/components/SmallAvatar.js +0 -19
- package/_esm/components/SmallAvatar.js.map +0 -1
- package/_esm/hooks/useAccount.d.ts +0 -45
- package/_esm/hooks/useAccount.js +0 -56
- package/_esm/hooks/useAccount.js.map +0 -1
- package/_esm/hooks/useWallets.d.ts +0 -6
- package/_esm/hooks/useWallets.js +0 -80
- package/_esm/hooks/useWallets.js.map +0 -1
- package/_esm/pages/SelectWalletPage/EVMListItemButton.d.ts +0 -9
- package/_esm/pages/SelectWalletPage/EVMListItemButton.js +0 -39
- package/_esm/pages/SelectWalletPage/EVMListItemButton.js.map +0 -1
- package/_esm/pages/SelectWalletPage/SVMListItemButton.d.ts +0 -6
- package/_esm/pages/SelectWalletPage/SVMListItemButton.js +0 -32
- package/_esm/pages/SelectWalletPage/SVMListItemButton.js.map +0 -1
- package/_esm/pages/SelectWalletPage/SelectWalletPage.d.ts +0 -1
- package/_esm/pages/SelectWalletPage/SelectWalletPage.js +0 -41
- package/_esm/pages/SelectWalletPage/SelectWalletPage.js.map +0 -1
- package/_esm/utils/svm.d.ts +0 -1
- package/_esm/utils/svm.js +0 -11
- package/_esm/utils/svm.js.map +0 -1
- package/components/SmallAvatar.tsx +0 -25
- package/hooks/useAccount.ts +0 -109
- package/hooks/useWallets.ts +0 -147
- package/pages/SelectWalletPage/EVMListItemButton.tsx +0 -74
- package/pages/SelectWalletPage/SVMListItemButton.tsx +0 -47
- package/pages/SelectWalletPage/SelectWalletPage.tsx +0 -90
- package/utils/svm.ts +0 -10
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Account } from '@lifi/wallet-management';
|
|
2
|
+
import {
|
|
3
|
+
getConnectorIcon,
|
|
4
|
+
useAccount,
|
|
5
|
+
useWalletMenu,
|
|
6
|
+
} from '@lifi/wallet-management';
|
|
2
7
|
import { ExpandMore, Wallet } from '@mui/icons-material';
|
|
3
8
|
import { Avatar, Badge } from '@mui/material';
|
|
4
9
|
import { useState } from 'react';
|
|
5
10
|
import { useTranslation } from 'react-i18next';
|
|
6
|
-
import { useLocation, useNavigate } from 'react-router-dom';
|
|
7
|
-
import type { Account } from '../../hooks/useAccount.js';
|
|
8
|
-
import { useAccount } from '../../hooks/useAccount.js';
|
|
9
11
|
import { useChain } from '../../hooks/useChain.js';
|
|
10
12
|
import { useHasExternalWalletProvider } from '../../providers/WalletProvider/useHasExternalWalletProvider.js';
|
|
11
13
|
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js';
|
|
12
14
|
import { HiddenUI } from '../../types/widget.js';
|
|
13
|
-
import { navigationRoutes } from '../../utils/navigationRoutes.js';
|
|
14
15
|
import { shortenAddress } from '../../utils/wallet.js';
|
|
15
|
-
import { SmallAvatar } from '../SmallAvatar.js';
|
|
16
|
+
import { SmallAvatar } from '../Avatar/SmallAvatar.js';
|
|
16
17
|
import { CloseDrawerButton } from './CloseDrawerButton.js';
|
|
17
18
|
import {
|
|
18
19
|
DrawerWalletContainer,
|
|
@@ -70,16 +71,16 @@ export const WalletMenuButton: React.FC = () => {
|
|
|
70
71
|
|
|
71
72
|
const ConnectButton = () => {
|
|
72
73
|
const { t } = useTranslation();
|
|
73
|
-
const { pathname } = useLocation();
|
|
74
74
|
const { walletConfig, subvariant, variant } = useWidgetConfig();
|
|
75
|
-
const
|
|
75
|
+
const { openWalletMenu } = useWalletMenu();
|
|
76
76
|
const connect = async () => {
|
|
77
77
|
if (walletConfig?.onConnect) {
|
|
78
78
|
walletConfig.onConnect();
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
openWalletMenu();
|
|
82
82
|
};
|
|
83
|
+
|
|
83
84
|
return (
|
|
84
85
|
<WalletButton
|
|
85
86
|
subvariant={subvariant}
|
|
@@ -91,9 +92,7 @@ const ConnectButton = () => {
|
|
|
91
92
|
<Wallet sx={{ marginLeft: -0.25 }} />
|
|
92
93
|
) : undefined
|
|
93
94
|
}
|
|
94
|
-
onClick={
|
|
95
|
-
!pathname.includes(navigationRoutes.selectWallet) ? connect : undefined
|
|
96
|
-
}
|
|
95
|
+
onClick={connect}
|
|
97
96
|
>
|
|
98
97
|
{t(`button.connectWallet`)}
|
|
99
98
|
</WalletButton>
|
|
@@ -17,11 +17,15 @@ export const WalletMenuContainer = styled(MuiMenu)(({ theme }) => ({
|
|
|
17
17
|
},
|
|
18
18
|
[`& .${menuItemClasses.root}`]: {
|
|
19
19
|
borderRadius: theme.shape.borderRadiusSecondary,
|
|
20
|
-
padding: theme.spacing(1,
|
|
20
|
+
padding: theme.spacing(1, 0, 1, 1),
|
|
21
21
|
[`& .${svgIconClasses.root}`]: {
|
|
22
22
|
fontSize: 20,
|
|
23
23
|
color: theme.palette.text.primary,
|
|
24
24
|
},
|
|
25
|
+
':hover': {
|
|
26
|
+
background: 'none',
|
|
27
|
+
cursor: 'default',
|
|
28
|
+
},
|
|
25
29
|
},
|
|
26
30
|
},
|
|
27
31
|
}));
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { ChainType } from '@lifi/sdk';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
getConnectorIcon,
|
|
4
|
+
useAccount,
|
|
5
|
+
useWalletMenu,
|
|
6
|
+
} from '@lifi/wallet-management';
|
|
3
7
|
import {
|
|
4
8
|
ContentCopyRounded,
|
|
5
9
|
OpenInNewRounded,
|
|
@@ -14,25 +18,22 @@ import {
|
|
|
14
18
|
MenuItem,
|
|
15
19
|
} from '@mui/material';
|
|
16
20
|
import { useTranslation } from 'react-i18next';
|
|
17
|
-
import { useLocation, useNavigate } from 'react-router-dom';
|
|
18
|
-
import { useAccount } from '../../hooks/useAccount.js';
|
|
19
21
|
import { useAvailableChains } from '../../hooks/useAvailableChains.js';
|
|
20
22
|
import { useExplorer } from '../../hooks/useExplorer.js';
|
|
21
|
-
import { navigationRoutes } from '../../utils/navigationRoutes.js';
|
|
22
23
|
import { shortenAddress } from '../../utils/wallet.js';
|
|
23
24
|
import { AvatarMasked } from '../Avatar/Avatar.style.js';
|
|
24
|
-
import { SmallAvatar } from '../SmallAvatar.js';
|
|
25
|
+
import { SmallAvatar } from '../Avatar/SmallAvatar.js';
|
|
25
26
|
import { EVMDisconnectIconButton } from './EVMDisconnectIconButton.js';
|
|
26
27
|
import { SVMDisconnectIconButton } from './SVMDisconnectIconButton.js';
|
|
28
|
+
import { UTXODisconnectIconButton } from './UTXODisconnectIconButton.js';
|
|
27
29
|
|
|
28
30
|
export const WalletMenu = ({ onClose }: { onClose: () => void }) => {
|
|
29
31
|
const { t } = useTranslation();
|
|
30
|
-
const navigate = useNavigate();
|
|
31
|
-
const { pathname } = useLocation();
|
|
32
32
|
const { accounts } = useAccount();
|
|
33
33
|
const { getChainById } = useAvailableChains();
|
|
34
|
+
const { openWalletMenu } = useWalletMenu();
|
|
34
35
|
const connect = async () => {
|
|
35
|
-
|
|
36
|
+
openWalletMenu();
|
|
36
37
|
onClose();
|
|
37
38
|
};
|
|
38
39
|
const { getAddressLink } = useExplorer();
|
|
@@ -49,7 +50,7 @@ export const WalletMenu = ({ onClose }: { onClose: () => void }) => {
|
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
return (
|
|
52
|
-
<MenuItem key={account.address}>
|
|
53
|
+
<MenuItem key={account.address} disableTouchRipple>
|
|
53
54
|
<Box flex={1} display="flex" alignItems="center">
|
|
54
55
|
{chain?.logoURI ? (
|
|
55
56
|
<Badge
|
|
@@ -82,7 +83,7 @@ export const WalletMenu = ({ onClose }: { onClose: () => void }) => {
|
|
|
82
83
|
)}
|
|
83
84
|
{walletAddress}
|
|
84
85
|
</Box>
|
|
85
|
-
<Box ml={
|
|
86
|
+
<Box ml={2}>
|
|
86
87
|
<IconButton size="medium" onClick={handleCopyAddress}>
|
|
87
88
|
<ContentCopyRounded />
|
|
88
89
|
</IconButton>
|
|
@@ -103,26 +104,24 @@ export const WalletMenu = ({ onClose }: { onClose: () => void }) => {
|
|
|
103
104
|
<EVMDisconnectIconButton connector={account.connector} />
|
|
104
105
|
) : account.chainType === ChainType.SVM ? (
|
|
105
106
|
<SVMDisconnectIconButton />
|
|
107
|
+
) : account.chainType === ChainType.UTXO ? (
|
|
108
|
+
<UTXODisconnectIconButton connector={account.connector} />
|
|
106
109
|
) : null}
|
|
107
110
|
</Box>
|
|
108
111
|
</MenuItem>
|
|
109
112
|
);
|
|
110
113
|
})}
|
|
111
114
|
</Box>
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
? t(`button.changeWallet`)
|
|
123
|
-
: t(`button.connectWallet`)}
|
|
124
|
-
</Button>
|
|
125
|
-
) : null}
|
|
115
|
+
<Button
|
|
116
|
+
onClick={connect}
|
|
117
|
+
fullWidth
|
|
118
|
+
startIcon={<PowerSettingsNewRounded />}
|
|
119
|
+
sx={{
|
|
120
|
+
marginTop: 1,
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
{t(`button.connectAnotherWallet`)}
|
|
124
|
+
</Button>
|
|
126
125
|
</>
|
|
127
126
|
);
|
|
128
127
|
};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
/* eslint-disable react/no-array-index-key */
|
|
2
1
|
import type { Route } from '@lifi/sdk';
|
|
2
|
+
import { useAccount } from '@lifi/wallet-management';
|
|
3
3
|
import { Collapse, Grow, Stack, Typography } from '@mui/material';
|
|
4
4
|
import { useEffect, useRef } from 'react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
import type { RouteObject } from 'react-router-dom';
|
|
7
7
|
import { useRoutes as useDOMRoutes, useNavigate } from 'react-router-dom';
|
|
8
|
-
import { useAccount } from '../../hooks/useAccount.js';
|
|
9
8
|
import { useRoutes } from '../../hooks/useRoutes.js';
|
|
10
9
|
import { useToAddressRequirements } from '../../hooks/useToAddressRequirements.js';
|
|
11
10
|
import { useWidgetEvents } from '../../hooks/useWidgetEvents.js';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { useAccount } from '@lifi/wallet-management';
|
|
1
2
|
import { CloseRounded } from '@mui/icons-material';
|
|
2
3
|
import { Box, Collapse } from '@mui/material';
|
|
3
4
|
import { useEffect, useRef, type MouseEventHandler } from 'react';
|
|
4
5
|
import { useTranslation } from 'react-i18next';
|
|
5
6
|
import { useNavigate } from 'react-router-dom';
|
|
6
|
-
import { useAccount } from '../../hooks/useAccount.js';
|
|
7
7
|
import { useToAddressRequirements } from '../../hooks/useToAddressRequirements.js';
|
|
8
8
|
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js';
|
|
9
9
|
import { useBookmarkActions } from '../../stores/bookmarks/useBookmarkActions.js';
|
|
@@ -18,8 +18,8 @@ import { LiFiToolLogo } from '../../icons/lifi.js';
|
|
|
18
18
|
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js';
|
|
19
19
|
import { HiddenUI } from '../../types/widget.js';
|
|
20
20
|
import { formatTokenAmount } from '../../utils/format.js';
|
|
21
|
+
import { SmallAvatar } from '../Avatar/SmallAvatar.js';
|
|
21
22
|
import { CardIconButton } from '../Card/CardIconButton.js';
|
|
22
|
-
import { SmallAvatar } from '../SmallAvatar.js';
|
|
23
23
|
import {
|
|
24
24
|
StepAvatar,
|
|
25
25
|
StepConnector,
|
|
@@ -8,8 +8,8 @@ import { useChain } from '../../hooks/useChain.js';
|
|
|
8
8
|
import { useToken } from '../../hooks/useToken.js';
|
|
9
9
|
import { formatTokenAmount, formatTokenPrice } from '../../utils/format.js';
|
|
10
10
|
import { AvatarBadgedSkeleton } from '../Avatar/Avatar.js';
|
|
11
|
+
import { SmallAvatar } from '../Avatar/SmallAvatar.js';
|
|
11
12
|
import { TokenAvatar } from '../Avatar/TokenAvatar.js';
|
|
12
|
-
import { SmallAvatar } from '../SmallAvatar.js';
|
|
13
13
|
import { TextFitter } from '../TextFitter/TextFitter.js';
|
|
14
14
|
import { TextSecondary, TextSecondaryContainer } from './Token.style.js';
|
|
15
15
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { useAccount } from '@lifi/wallet-management';
|
|
1
2
|
import { Box } from '@mui/material';
|
|
2
3
|
import type { FC } from 'react';
|
|
3
|
-
import { useAccount } from '../../hooks/useAccount.js';
|
|
4
4
|
import { useChain } from '../../hooks/useChain.js';
|
|
5
5
|
import { useDebouncedWatch } from '../../hooks/useDebouncedWatch.js';
|
|
6
6
|
import { useTokenBalances } from '../../hooks/useTokenBalances.js';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ChainType } from '@lifi/sdk';
|
|
1
2
|
import { OpenInNewRounded } from '@mui/icons-material';
|
|
2
3
|
import {
|
|
3
4
|
Avatar,
|
|
@@ -26,7 +27,7 @@ export const TokenListItem: React.FC<TokenListItemProps> = ({
|
|
|
26
27
|
start,
|
|
27
28
|
token,
|
|
28
29
|
chain,
|
|
29
|
-
|
|
30
|
+
accountAddress,
|
|
30
31
|
isBalanceLoading,
|
|
31
32
|
startAdornment,
|
|
32
33
|
endAdornment,
|
|
@@ -46,7 +47,7 @@ export const TokenListItem: React.FC<TokenListItemProps> = ({
|
|
|
46
47
|
<TokenListItemButton
|
|
47
48
|
token={token}
|
|
48
49
|
chain={chain}
|
|
49
|
-
|
|
50
|
+
accountAddress={accountAddress}
|
|
50
51
|
isBalanceLoading={isBalanceLoading}
|
|
51
52
|
onClick={handleClick}
|
|
52
53
|
/>
|
|
@@ -59,7 +60,7 @@ export const TokenListItemButton: React.FC<TokenListItemButtonProps> = ({
|
|
|
59
60
|
onClick,
|
|
60
61
|
token,
|
|
61
62
|
chain,
|
|
62
|
-
|
|
63
|
+
accountAddress,
|
|
63
64
|
isBalanceLoading,
|
|
64
65
|
}) => {
|
|
65
66
|
const { t } = useTranslation();
|
|
@@ -75,8 +76,15 @@ export const TokenListItemButton: React.FC<TokenListItemButtonProps> = ({
|
|
|
75
76
|
const timeoutId = useRef<ReturnType<typeof setTimeout>>();
|
|
76
77
|
const [showAddress, setShowAddress] = useState(false);
|
|
77
78
|
|
|
79
|
+
const tokenAddress =
|
|
80
|
+
chain?.chainType === ChainType.UTXO ? accountAddress : token.address;
|
|
81
|
+
|
|
78
82
|
const onMouseEnter = () => {
|
|
79
|
-
timeoutId.current = setTimeout(() =>
|
|
83
|
+
timeoutId.current = setTimeout(() => {
|
|
84
|
+
if (tokenAddress) {
|
|
85
|
+
setShowAddress(true);
|
|
86
|
+
}
|
|
87
|
+
}, 350);
|
|
80
88
|
};
|
|
81
89
|
|
|
82
90
|
const onMouseLeave = () => {
|
|
@@ -128,12 +136,12 @@ export const TokenListItemButton: React.FC<TokenListItemButtonProps> = ({
|
|
|
128
136
|
>
|
|
129
137
|
<Box display="flex">
|
|
130
138
|
<Box display="flex" alignItems="center" pt={0.125}>
|
|
131
|
-
{shortenAddress(
|
|
139
|
+
{shortenAddress(tokenAddress)}
|
|
132
140
|
</Box>
|
|
133
141
|
<IconButton
|
|
134
142
|
size="small"
|
|
135
143
|
LinkComponent={Link}
|
|
136
|
-
href={getAddressLink(
|
|
144
|
+
href={getAddressLink(tokenAddress!, chain)}
|
|
137
145
|
target="_blank"
|
|
138
146
|
rel="nofollow noreferrer"
|
|
139
147
|
onClick={(e) => e.stopPropagation()}
|
|
@@ -145,7 +153,7 @@ export const TokenListItemButton: React.FC<TokenListItemButtonProps> = ({
|
|
|
145
153
|
</Box>
|
|
146
154
|
}
|
|
147
155
|
/>
|
|
148
|
-
{
|
|
156
|
+
{accountAddress ? (
|
|
149
157
|
isBalanceLoading ? (
|
|
150
158
|
<TokenAmountSkeleton />
|
|
151
159
|
) : (
|
|
@@ -127,7 +127,7 @@ export const VirtualizedTokenList: FC<VirtualizedTokenListProps> = ({
|
|
|
127
127
|
token={currentToken}
|
|
128
128
|
chain={chain}
|
|
129
129
|
isBalanceLoading={isBalanceLoading}
|
|
130
|
-
|
|
130
|
+
accountAddress={account.address}
|
|
131
131
|
startAdornment={
|
|
132
132
|
startAdornmentLabel ? (
|
|
133
133
|
<Typography
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ExtendedChain } from '@lifi/sdk';
|
|
2
|
+
import type { Account } from '@lifi/wallet-management';
|
|
2
3
|
import type { MouseEventHandler, MutableRefObject } from 'react';
|
|
3
|
-
import type { Account } from '../../hooks/useAccount.js';
|
|
4
4
|
import type { FormType } from '../../stores/form/types.js';
|
|
5
5
|
import type { TokenAmount } from '../../types/token.js';
|
|
6
6
|
|
|
@@ -30,7 +30,7 @@ export interface TokenListItemBaseProps {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export interface TokenListItemProps extends TokenListItemBaseProps {
|
|
33
|
-
|
|
33
|
+
accountAddress?: string;
|
|
34
34
|
token: TokenAmount;
|
|
35
35
|
chain?: ExtendedChain;
|
|
36
36
|
isBalanceLoading?: boolean;
|
|
@@ -40,7 +40,7 @@ export interface TokenListItemProps extends TokenListItemBaseProps {
|
|
|
40
40
|
|
|
41
41
|
export interface TokenListItemButtonProps {
|
|
42
42
|
onClick?: MouseEventHandler<HTMLDivElement>;
|
|
43
|
-
|
|
43
|
+
accountAddress?: string;
|
|
44
44
|
token: TokenAmount;
|
|
45
45
|
chain?: ExtendedChain;
|
|
46
46
|
isBalanceLoading?: boolean;
|
|
@@ -18,13 +18,13 @@ interface TokenRateState {
|
|
|
18
18
|
toggleIsForward(): void;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const useTokenRate = create<TokenRateState>((set) => ({
|
|
22
22
|
isForward: true,
|
|
23
23
|
toggleIsForward: () => set((state) => ({ isForward: !state.isForward })),
|
|
24
24
|
}));
|
|
25
25
|
|
|
26
26
|
export const TokenRate: React.FC<TokenRateProps> = ({ route }) => {
|
|
27
|
-
const { isForward, toggleIsForward } =
|
|
27
|
+
const { isForward, toggleIsForward } = useTokenRate();
|
|
28
28
|
|
|
29
29
|
const toggleRate: MouseEventHandler<HTMLSpanElement> = (e) => {
|
|
30
30
|
e.stopPropagation();
|
package/config/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '3.
|
|
2
|
+
export const version = '3.7.0-beta.0';
|
|
@@ -2,32 +2,31 @@ import type { ExtendedChain } from '@lifi/sdk';
|
|
|
2
2
|
import { ChainType, config, getChains } from '@lifi/sdk';
|
|
3
3
|
import { useQuery } from '@tanstack/react-query';
|
|
4
4
|
import { useCallback } from 'react';
|
|
5
|
-
import { useHasExternalWalletProvider } from '../providers/WalletProvider/useHasExternalWalletProvider.js';
|
|
6
5
|
import { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js';
|
|
7
6
|
import { isItemAllowed } from '../utils/item.js';
|
|
8
7
|
|
|
9
|
-
const supportedChainTypes = [ChainType.EVM, ChainType.SVM];
|
|
8
|
+
const supportedChainTypes = [ChainType.EVM, ChainType.SVM, ChainType.UTXO];
|
|
10
9
|
|
|
11
|
-
export const useAvailableChains = () => {
|
|
10
|
+
export const useAvailableChains = (chainTypes?: ChainType[]) => {
|
|
12
11
|
const { chains } = useWidgetConfig();
|
|
13
|
-
const { providers } = useHasExternalWalletProvider();
|
|
12
|
+
// const { providers } = useHasExternalWalletProvider();
|
|
14
13
|
const { data, isLoading } = useQuery({
|
|
15
14
|
queryKey: [
|
|
16
15
|
'chains',
|
|
17
|
-
providers,
|
|
16
|
+
// providers,
|
|
18
17
|
chains?.types,
|
|
19
18
|
chains?.allow,
|
|
20
19
|
chains?.deny,
|
|
21
20
|
chains?.from,
|
|
22
21
|
chains?.to,
|
|
23
22
|
] as const,
|
|
24
|
-
queryFn: async ({ queryKey: [,
|
|
25
|
-
const chainTypesRequest =
|
|
26
|
-
providers.length > 0 ? providers : supportedChainTypes
|
|
27
|
-
|
|
23
|
+
queryFn: async ({ queryKey: [, chainTypesConfig] }) => {
|
|
24
|
+
const chainTypesRequest = supportedChainTypes
|
|
25
|
+
// providers.length > 0 ? providers : supportedChainTypes
|
|
26
|
+
.filter((chainType) => isItemAllowed(chainType, chainTypesConfig));
|
|
28
27
|
|
|
29
28
|
const availableChains = await getChains({
|
|
30
|
-
chainTypes: chainTypesRequest,
|
|
29
|
+
chainTypes: chainTypes || chainTypesRequest,
|
|
31
30
|
});
|
|
32
31
|
config.setChains(availableChains);
|
|
33
32
|
return availableChains;
|
package/hooks/useChains.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import type { ChainType } from '@lifi/sdk';
|
|
1
2
|
import { useMemo } from 'react';
|
|
2
3
|
import { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js';
|
|
3
4
|
import type { FormType } from '../stores/form/types.js';
|
|
4
5
|
import { isItemAllowed } from '../utils/item.js';
|
|
5
6
|
import { useAvailableChains } from './useAvailableChains.js';
|
|
6
7
|
|
|
7
|
-
export const useChains = (type?: FormType) => {
|
|
8
|
+
export const useChains = (type?: FormType, chainTypes?: ChainType[]) => {
|
|
8
9
|
const { chains } = useWidgetConfig();
|
|
9
10
|
const {
|
|
10
11
|
chains: availableChains,
|
|
@@ -17,11 +18,13 @@ export const useChains = (type?: FormType) => {
|
|
|
17
18
|
? availableChains?.filter(
|
|
18
19
|
(chain) =>
|
|
19
20
|
isItemAllowed(chain.id, chains) &&
|
|
20
|
-
isItemAllowed(chain.id, chains?.[type])
|
|
21
|
+
isItemAllowed(chain.id, chains?.[type]) &&
|
|
22
|
+
// Check against chain types if they are provided
|
|
23
|
+
(chainTypes?.includes(chain.chainType) ?? true),
|
|
21
24
|
)
|
|
22
25
|
: availableChains?.filter((chain) => isItemAllowed(chain.id, chains));
|
|
23
26
|
return filteredChains;
|
|
24
|
-
}, [availableChains, chains, type]);
|
|
27
|
+
}, [availableChains, chainTypes, chains, type]);
|
|
25
28
|
|
|
26
29
|
return {
|
|
27
30
|
chains: filteredChains,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { RouteExtended } from '@lifi/sdk';
|
|
2
|
+
import { useAccount } from '@lifi/wallet-management';
|
|
2
3
|
import { keepPreviousData, useQuery } from '@tanstack/react-query';
|
|
3
4
|
import { parseUnits } from 'viem';
|
|
4
5
|
import { useFieldValues } from '../stores/form/useFieldValues.js';
|
|
5
6
|
import { isRouteDone } from '../stores/routes/utils.js';
|
|
6
|
-
import { useAccount } from './useAccount.js';
|
|
7
7
|
import { useTokenAddressBalance } from './useTokenAddressBalance.js';
|
|
8
8
|
import { getTokenBalancesWithRetry } from './useTokenBalance.js';
|
|
9
9
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type EVMChain, type RouteExtended, type Token } from '@lifi/sdk';
|
|
2
|
+
import { useAccount } from '@lifi/wallet-management';
|
|
2
3
|
import { useQuery } from '@tanstack/react-query';
|
|
3
4
|
import type { Connector } from 'wagmi';
|
|
4
|
-
import { useAccount } from './useAccount.js';
|
|
5
5
|
import { useAvailableChains } from './useAvailableChains.js';
|
|
6
6
|
import { getTokenBalancesWithRetry } from './useTokenBalance.js';
|
|
7
7
|
|
|
@@ -44,7 +44,8 @@ export const useGasSufficiency = (route?: RouteExtended) => {
|
|
|
44
44
|
) {
|
|
45
45
|
const { token } = step.estimate.gasCosts[0];
|
|
46
46
|
const gasCostAmount = step.estimate.gasCosts.reduce(
|
|
47
|
-
(amount, gasCost) =>
|
|
47
|
+
(amount, gasCost) =>
|
|
48
|
+
amount + BigInt(Number(gasCost.amount).toFixed(0)),
|
|
48
49
|
0n,
|
|
49
50
|
);
|
|
50
51
|
groupedGasCosts[token.chainId] = {
|
|
@@ -61,7 +62,8 @@ export const useGasSufficiency = (route?: RouteExtended) => {
|
|
|
61
62
|
if (nonIncludedFeeCosts?.length) {
|
|
62
63
|
const { token } = nonIncludedFeeCosts[0];
|
|
63
64
|
const feeCostAmount = nonIncludedFeeCosts.reduce(
|
|
64
|
-
(amount, feeCost) =>
|
|
65
|
+
(amount, feeCost) =>
|
|
66
|
+
amount + BigInt(Number(feeCost.amount).toFixed(0)),
|
|
65
67
|
0n,
|
|
66
68
|
);
|
|
67
69
|
groupedGasCosts[token.chainId] = {
|
|
@@ -193,6 +193,10 @@ export function getProcessMessage(
|
|
|
193
193
|
title = t(`error.title.transactionCanceled`);
|
|
194
194
|
message = getDefaultErrorMessage('error.message.transactionCanceled');
|
|
195
195
|
break;
|
|
196
|
+
case LiFiErrorCode.TransactionConflict:
|
|
197
|
+
title = t(`error.title.transactionConflict`);
|
|
198
|
+
message = getDefaultErrorMessage('error.message.transactionConflict');
|
|
199
|
+
break;
|
|
196
200
|
case LiFiErrorCode.ExchangeRateUpdateCanceled:
|
|
197
201
|
title = t(`error.title.exchangeRateUpdateCanceled`);
|
|
198
202
|
message = getDefaultErrorMessage();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import type { ExchangeRateUpdateParams, Route } from '@lifi/sdk';
|
|
3
3
|
import { executeRoute, resumeRoute, updateRouteExecution } from '@lifi/sdk';
|
|
4
|
+
import { useAccount } from '@lifi/wallet-management';
|
|
4
5
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
5
6
|
import { useCallback, useEffect, useRef } from 'react';
|
|
6
7
|
import { shallow } from 'zustand/shallow';
|
|
@@ -15,7 +16,6 @@ import {
|
|
|
15
16
|
isRouteFailed,
|
|
16
17
|
} from '../stores/routes/utils.js';
|
|
17
18
|
import { WidgetEvent } from '../types/events.js';
|
|
18
|
-
import { useAccount } from './useAccount.js';
|
|
19
19
|
import { useWidgetEvents } from './useWidgetEvents.js';
|
|
20
20
|
|
|
21
21
|
interface RouteExecutionProps {
|
package/hooks/useRoutes.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Route, RoutesResponse, Token } from '@lifi/sdk';
|
|
2
2
|
import { LiFiErrorCode, getContractCallsQuote, getRoutes } from '@lifi/sdk';
|
|
3
|
+
import { useAccount } from '@lifi/wallet-management';
|
|
3
4
|
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
4
5
|
import { v4 as uuidv4 } from 'uuid';
|
|
5
6
|
import { parseUnits } from 'viem';
|
|
@@ -10,7 +11,6 @@ import { useSettings } from '../stores/settings/useSettings.js';
|
|
|
10
11
|
import { defaultSlippage } from '../stores/settings/useSettingsStore.js';
|
|
11
12
|
import { WidgetEvent } from '../types/events.js';
|
|
12
13
|
import { getChainTypeFromAddress } from '../utils/chainType.js';
|
|
13
|
-
import { useAccount } from './useAccount.js';
|
|
14
14
|
import { useChain } from './useChain.js';
|
|
15
15
|
import { useDebouncedWatch } from './useDebouncedWatch.js';
|
|
16
16
|
import { useGasRefuel } from './useGasRefuel.js';
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { useCallback, useLayoutEffect, useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ElementId, createElementId } from '../utils/elements.js';
|
|
3
3
|
import { useDefaultElementId } from './useDefaultElementId.js';
|
|
4
4
|
|
|
5
|
+
export const getScrollableContainer = (elementId: string) =>
|
|
6
|
+
document.getElementById(
|
|
7
|
+
createElementId(ElementId.ScrollableContainer, elementId),
|
|
8
|
+
);
|
|
9
|
+
|
|
5
10
|
export const useGetScrollableContainer = () => {
|
|
6
11
|
const elementId = useDefaultElementId();
|
|
7
12
|
const getContainer = useCallback(
|
|
@@ -1,28 +1,24 @@
|
|
|
1
1
|
import type { MutableRefObject } from 'react';
|
|
2
2
|
import { useLayoutEffect } from 'react';
|
|
3
|
-
import { getRelativeContainer } from '../utils/elements.js';
|
|
4
3
|
import { useDefaultElementId } from './useDefaultElementId.js';
|
|
5
|
-
|
|
6
|
-
// NOTE: this hook is implicitly tied to the widget height functionality in the
|
|
7
|
-
// AppExpandedContainer, RelativeContainer and CssBaselineContainer components as defined in AppContainer.ts
|
|
8
|
-
// CSS changes in those components can have implications for the functionality in this hook
|
|
4
|
+
import { getScrollableContainer } from './useScrollableContainer.js';
|
|
9
5
|
|
|
10
6
|
export const useSetContentHeight = (
|
|
11
7
|
ref: MutableRefObject<HTMLElement | undefined>,
|
|
12
8
|
) => {
|
|
13
9
|
const elementId = useDefaultElementId();
|
|
14
10
|
useLayoutEffect(() => {
|
|
15
|
-
const
|
|
11
|
+
const scrollableContainer = getScrollableContainer(elementId);
|
|
16
12
|
if (
|
|
17
|
-
!
|
|
13
|
+
!scrollableContainer ||
|
|
18
14
|
!ref.current ||
|
|
19
|
-
ref.current?.clientHeight <=
|
|
15
|
+
ref.current?.clientHeight <= scrollableContainer?.clientHeight
|
|
20
16
|
) {
|
|
21
17
|
return;
|
|
22
18
|
}
|
|
23
|
-
|
|
19
|
+
scrollableContainer.style.height = `${ref.current.clientHeight}px`;
|
|
24
20
|
return () => {
|
|
25
|
-
|
|
21
|
+
scrollableContainer.style.removeProperty('height');
|
|
26
22
|
};
|
|
27
23
|
}, [elementId, ref]);
|
|
28
24
|
};
|
package/hooks/useTokenBalance.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ExtendedChain } from '@lifi/sdk';
|
|
2
2
|
import { getTokenBalances, type Token, type TokenAmount } from '@lifi/sdk';
|
|
3
|
+
import { useAccount } from '@lifi/wallet-management';
|
|
3
4
|
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
4
5
|
import { useCallback, useMemo } from 'react';
|
|
5
|
-
import { useAccount } from './useAccount.js';
|
|
6
6
|
|
|
7
7
|
const defaultRefetchInterval = 30_000;
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getTokenBalances } from '@lifi/sdk';
|
|
2
|
+
import { useAccount } from '@lifi/wallet-management';
|
|
2
3
|
import { useQuery } from '@tanstack/react-query';
|
|
3
4
|
import { formatUnits } from 'viem';
|
|
4
5
|
import type { TokenAmount } from '../types/token.js';
|
|
5
|
-
import { useAccount } from './useAccount.js';
|
|
6
6
|
import { useTokens } from './useTokens.js';
|
|
7
7
|
|
|
8
8
|
const defaultRefetchInterval = 32_000;
|
package/hooks/useTokens.ts
CHANGED
|
@@ -9,7 +9,8 @@ export const useTokens = (selectedChainId?: number) => {
|
|
|
9
9
|
const { tokens: configTokens } = useWidgetConfig();
|
|
10
10
|
const { data, isLoading } = useQuery({
|
|
11
11
|
queryKey: ['tokens'],
|
|
12
|
-
queryFn: () =>
|
|
12
|
+
queryFn: () =>
|
|
13
|
+
getTokens({ chainTypes: [ChainType.EVM, ChainType.SVM, ChainType.UTXO] }),
|
|
13
14
|
refetchInterval: 3_600_000,
|
|
14
15
|
staleTime: 3_600_000,
|
|
15
16
|
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { FullStatusData } from '@lifi/sdk';
|
|
2
2
|
import { getStatus, type StatusResponse } from '@lifi/sdk';
|
|
3
|
+
import { useAccount } from '@lifi/wallet-management';
|
|
3
4
|
import {
|
|
4
5
|
keepPreviousData,
|
|
5
6
|
useQuery,
|
|
6
7
|
useQueryClient,
|
|
7
8
|
} from '@tanstack/react-query';
|
|
8
|
-
import { useAccount } from './useAccount.js';
|
|
9
9
|
|
|
10
10
|
export const useTransactionDetails = (transactionHash?: string) => {
|
|
11
11
|
const { account, accounts } = useAccount();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { FullStatusData, StatusResponse } from '@lifi/sdk';
|
|
2
2
|
import { getTransactionHistory, type ExtendedTransactionInfo } from '@lifi/sdk';
|
|
3
|
+
import { useAccount } from '@lifi/wallet-management';
|
|
3
4
|
import type { QueryFunction } from '@tanstack/react-query';
|
|
4
5
|
import { useQueries } from '@tanstack/react-query';
|
|
5
|
-
import { useAccount } from './useAccount.js';
|
|
6
6
|
|
|
7
7
|
export const useTransactionHistory = () => {
|
|
8
8
|
const { accounts } = useAccount();
|