@lifi/widget 3.7.0-beta.6 → 3.7.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 +6 -4
- package/AppRoutes.tsx +14 -2
- package/CHANGELOG.md +22 -0
- package/_esm/AppProvider.js +3 -2
- package/_esm/AppProvider.js.map +1 -1
- package/_esm/AppRoutes.js +9 -2
- 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 +3 -1
- package/_esm/components/AmountInput/AmountInputEndAdornment.js.map +1 -1
- package/_esm/components/AppContainer.js +10 -5
- 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 +0 -1
- package/_esm/components/Avatar/Avatar.js +4 -7
- package/_esm/components/Avatar/Avatar.js.map +1 -1
- package/_esm/components/Avatar/Avatar.style.d.ts +3 -6
- package/_esm/components/Avatar/Avatar.style.js +6 -19
- package/_esm/components/Avatar/Avatar.style.js.map +1 -1
- package/_esm/components/Avatar/TokenAvatar.js +1 -1
- package/_esm/components/Avatar/TokenAvatar.js.map +1 -1
- package/_esm/components/BaseTransactionButton/BaseTransactionButton.js +5 -3
- package/_esm/components/BaseTransactionButton/BaseTransactionButton.js.map +1 -1
- package/_esm/components/Card/InputCard.d.ts +1 -1
- package/_esm/components/ChainSelect/useChainSelect.js +1 -5
- package/_esm/components/ChainSelect/useChainSelect.js.map +1 -1
- package/_esm/components/FeeBreakdownTooltip.js +1 -4
- package/_esm/components/FeeBreakdownTooltip.js.map +1 -1
- package/_esm/components/FullPageContainer.d.ts +2 -0
- package/_esm/components/FullPageContainer.js +9 -0
- package/_esm/components/FullPageContainer.js.map +1 -0
- package/_esm/components/Header/EVMDisconnectIconButton.d.ts +4 -0
- package/_esm/components/Header/EVMDisconnectIconButton.js +12 -0
- package/_esm/components/Header/EVMDisconnectIconButton.js.map +1 -0
- package/_esm/components/Header/Header.js +23 -3
- package/_esm/components/Header/Header.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/SVMDisconnectIconButton.d.ts +1 -0
- package/_esm/components/Header/SVMDisconnectIconButton.js +12 -0
- package/_esm/components/Header/SVMDisconnectIconButton.js.map +1 -0
- package/_esm/components/Header/WalletHeader.js +9 -5
- package/_esm/components/Header/WalletHeader.js.map +1 -1
- package/_esm/components/Header/WalletMenu.js +18 -10
- package/_esm/components/Header/WalletMenu.js.map +1 -1
- package/_esm/components/Header/WalletMenu.style.js +1 -5
- package/_esm/components/Header/WalletMenu.style.js.map +1 -1
- package/_esm/components/PageContainer.d.ts +2 -1
- package/_esm/components/PageContainer.js.map +1 -1
- package/_esm/components/PageEntered.d.ts +1 -0
- package/_esm/components/PageEntered.js +13 -0
- package/_esm/components/PageEntered.js.map +1 -0
- package/_esm/components/Routes/RoutesExpanded.js +1 -1
- package/_esm/components/Routes/RoutesExpanded.js.map +1 -1
- package/_esm/components/Search/SearchInput.d.ts +11 -0
- package/_esm/components/Search/SearchInput.js +21 -0
- package/_esm/components/Search/SearchInput.js.map +1 -0
- package/_esm/components/Search/SearchInput.style.d.ts +12 -0
- package/_esm/components/Search/SearchInput.style.js +38 -0
- package/_esm/components/Search/SearchInput.style.js.map +1 -0
- package/_esm/components/Search/SearchNotFound.d.ts +6 -0
- package/_esm/components/Search/SearchNotFound.js +5 -0
- package/_esm/components/Search/SearchNotFound.js.map +1 -0
- package/_esm/components/Search/SearchNotFound.style.d.ts +14 -0
- package/_esm/components/Search/SearchNotFound.style.js +29 -0
- package/_esm/components/Search/SearchNotFound.style.js.map +1 -0
- package/_esm/components/SendToWallet/SendToWalletButton.js +1 -1
- package/_esm/components/SendToWallet/SendToWalletButton.js.map +1 -1
- package/_esm/components/Skeleton/WidgetSkeleton.js +3 -4
- package/_esm/components/Skeleton/WidgetSkeleton.js.map +1 -1
- package/_esm/components/Skeleton/WidgetSkeleton.style.d.ts +4 -1
- package/_esm/components/Skeleton/WidgetSkeleton.style.js +20 -1
- package/_esm/components/Skeleton/WidgetSkeleton.style.js.map +1 -1
- package/_esm/components/SmallAvatar.d.ts +10 -0
- package/_esm/components/SmallAvatar.js +19 -0
- package/_esm/components/SmallAvatar.js.map +1 -0
- 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 +2 -5
- package/_esm/components/TokenList/TokenList.js.map +1 -1
- package/_esm/components/TokenList/TokenListItem.js +5 -11
- package/_esm/components/TokenList/TokenListItem.js.map +1 -1
- package/_esm/components/TokenList/TokenNotFound.js +5 -13
- package/_esm/components/TokenList/TokenNotFound.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/useAccount.d.ts +45 -0
- package/_esm/hooks/useAccount.js +56 -0
- package/_esm/hooks/useAccount.js.map +1 -0
- package/_esm/hooks/useAvailableChains.d.ts +1 -2
- package/_esm/hooks/useAvailableChains.js +8 -9
- package/_esm/hooks/useAvailableChains.js.map +1 -1
- package/_esm/hooks/useChains.d.ts +3 -4
- package/_esm/hooks/useChains.js +3 -5
- 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 +0 -4
- 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 +0 -1
- package/_esm/hooks/useScrollableContainer.js +1 -2
- package/_esm/hooks/useScrollableContainer.js.map +1 -1
- package/_esm/hooks/useSetContentHeight.js +9 -6
- 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/hooks/useWallets.d.ts +6 -0
- package/_esm/hooks/useWallets.js +80 -0
- package/_esm/hooks/useWallets.js.map +1 -0
- package/_esm/i18n/en.json +11 -4
- package/_esm/index.d.ts +2 -0
- package/_esm/index.js +2 -0
- 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/SelectChainPage/SelectChainPage.js +27 -8
- package/_esm/pages/SelectChainPage/SelectChainPage.js.map +1 -1
- package/_esm/pages/SelectEnabledToolsPage.js +38 -16
- package/_esm/pages/SelectEnabledToolsPage.js.map +1 -1
- package/_esm/pages/SelectTokenPage/SearchTokenInput.js +2 -12
- package/_esm/pages/SelectTokenPage/SearchTokenInput.js.map +1 -1
- package/_esm/pages/SelectTokenPage/SelectTokenPage.js +2 -2
- package/_esm/pages/SelectTokenPage/SelectTokenPage.js.map +1 -1
- package/_esm/pages/SelectTokenPage/useTokenListHeight.js +8 -14
- package/_esm/pages/SelectTokenPage/useTokenListHeight.js.map +1 -1
- package/_esm/pages/SelectWalletPage/EVMListItemButton.d.ts +9 -0
- package/_esm/pages/SelectWalletPage/EVMListItemButton.js +39 -0
- package/_esm/pages/SelectWalletPage/EVMListItemButton.js.map +1 -0
- package/_esm/pages/SelectWalletPage/SVMListItemButton.d.ts +6 -0
- package/_esm/pages/SelectWalletPage/SVMListItemButton.js +32 -0
- package/_esm/pages/SelectWalletPage/SVMListItemButton.js.map +1 -0
- package/_esm/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -0
- package/_esm/pages/SelectWalletPage/SelectWalletPage.js +41 -0
- package/_esm/pages/SelectWalletPage/SelectWalletPage.js.map +1 -0
- 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/SendToWallet/SendToWalletPage.style.d.ts +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 +7 -15
- package/_esm/providers/WalletProvider/SDKProviders.js.map +1 -1
- package/_esm/providers/WalletProvider/WalletProvider.d.ts +0 -1
- package/_esm/providers/WalletProvider/WalletProvider.js +1 -14
- package/_esm/providers/WalletProvider/WalletProvider.js.map +1 -1
- package/_esm/providers/WalletProvider/useHasExternalWalletProvider.d.ts +1 -1
- package/_esm/providers/WalletProvider/useHasExternalWalletProvider.js +3 -8
- package/_esm/providers/WalletProvider/useHasExternalWalletProvider.js.map +1 -1
- package/_esm/providers/WidgetProvider/WidgetProvider.js +1 -2
- package/_esm/providers/WidgetProvider/WidgetProvider.js.map +1 -1
- package/_esm/providers/WidgetProvider/types.d.ts +2 -0
- 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/header/types.d.ts +2 -0
- package/_esm/stores/header/useHeaderStore.d.ts +7 -1
- package/_esm/stores/header/useHeaderStore.js +26 -2
- package/_esm/stores/header/useHeaderStore.js.map +1 -1
- package/_esm/stores/routes/useExecutingRoutesIds.js +1 -1
- package/_esm/stores/routes/useExecutingRoutesIds.js.map +1 -1
- package/_esm/stores/settings/types.d.ts +1 -1
- package/_esm/stores/settings/useSettingsStore.js +22 -9
- package/_esm/stores/settings/useSettingsStore.js.map +1 -1
- package/_esm/themes/createTheme.js +1 -2
- package/_esm/themes/createTheme.js.map +1 -1
- package/_esm/types/events.d.ts +6 -6
- package/_esm/types/events.js +3 -2
- package/_esm/types/events.js.map +1 -1
- package/_esm/utils/chainType.js +3 -2
- package/_esm/utils/chainType.js.map +1 -1
- package/_esm/utils/elements.d.ts +5 -2
- package/_esm/utils/elements.js +6 -1
- package/_esm/utils/elements.js.map +1 -1
- package/_esm/utils/fees.js +5 -9
- 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 +3 -1
- package/_esm/utils/navigationRoutes.js +3 -0
- package/_esm/utils/navigationRoutes.js.map +1 -1
- package/_esm/utils/svm.d.ts +1 -0
- package/_esm/utils/svm.js +11 -0
- package/_esm/utils/svm.js.map +1 -0
- package/_esm/utils/wallet.js +1 -1
- package/components/ActiveTransactions/ActiveTransactions.style.ts +1 -1
- package/components/AmountInput/AmountInputEndAdornment.tsx +5 -1
- package/components/AppContainer.tsx +15 -10
- package/components/Avatar/AccountAvatar.tsx +2 -2
- package/components/Avatar/Avatar.style.tsx +7 -20
- package/components/Avatar/Avatar.tsx +4 -12
- package/components/Avatar/TokenAvatar.tsx +1 -1
- package/components/BaseTransactionButton/BaseTransactionButton.tsx +5 -3
- package/components/ChainSelect/useChainSelect.ts +1 -10
- package/components/FeeBreakdownTooltip.tsx +1 -4
- package/components/FullPageContainer.tsx +14 -0
- package/components/Header/EVMDisconnectIconButton.tsx +24 -0
- package/components/Header/Header.tsx +28 -3
- package/components/Header/NavigationHeader.tsx +1 -1
- package/components/Header/SVMDisconnectIconButton.tsx +19 -0
- package/components/Header/WalletHeader.tsx +12 -11
- package/components/Header/WalletMenu.style.tsx +1 -5
- package/components/Header/WalletMenu.tsx +32 -22
- package/components/PageContainer.ts +2 -1
- package/components/PageEntered.ts +14 -0
- package/components/Routes/RoutesExpanded.tsx +2 -1
- package/components/Search/SearchInput.style.tsx +46 -0
- package/components/Search/SearchInput.tsx +57 -0
- package/components/Search/SearchNotFound.style.tsx +36 -0
- package/components/Search/SearchNotFound.tsx +23 -0
- package/components/SendToWallet/SendToWalletButton.tsx +1 -1
- package/components/Skeleton/WidgetSkeleton.style.tsx +21 -1
- package/components/Skeleton/WidgetSkeleton.tsx +10 -9
- package/components/SmallAvatar.tsx +25 -0
- package/components/StepActions/StepActions.tsx +1 -1
- package/components/Token/Token.tsx +1 -1
- package/components/TokenList/TokenList.tsx +2 -9
- package/components/TokenList/TokenListItem.tsx +7 -15
- package/components/TokenList/TokenNotFound.tsx +7 -27
- 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/useAccount.ts +109 -0
- package/hooks/useAvailableChains.ts +10 -9
- package/hooks/useChains.ts +3 -6
- package/hooks/useFromTokenSufficiency.ts +1 -1
- package/hooks/useGasSufficiency.ts +3 -5
- package/hooks/useProcessMessage.ts +0 -4
- package/hooks/useRouteExecution.ts +1 -1
- package/hooks/useRoutes.ts +1 -1
- package/hooks/useScrollableContainer.ts +1 -6
- package/hooks/useSetContentHeight.ts +10 -6
- package/hooks/useTokenBalance.ts +1 -1
- package/hooks/useTokenBalances.ts +1 -1
- package/hooks/useTokens.ts +1 -2
- package/hooks/useTransactionDetails.ts +1 -1
- package/hooks/useTransactionHistory.ts +1 -1
- package/hooks/useWallets.ts +147 -0
- package/i18n/en.json +11 -4
- package/index.ts +2 -0
- package/package.json +6 -6
- package/pages/RoutesPage/RoutesPage.tsx +1 -1
- package/pages/SelectChainPage/SelectChainPage.tsx +62 -23
- package/pages/SelectEnabledToolsPage.tsx +94 -37
- package/pages/SelectTokenPage/SearchTokenInput.tsx +8 -26
- package/pages/SelectTokenPage/SelectTokenPage.tsx +3 -3
- package/pages/SelectTokenPage/useTokenListHeight.ts +14 -21
- package/pages/SelectWalletPage/EVMListItemButton.tsx +74 -0
- package/pages/SelectWalletPage/SVMListItemButton.tsx +47 -0
- package/pages/SelectWalletPage/SelectWalletPage.tsx +90 -0
- package/pages/SendToWallet/ConnectedWalletsPage.tsx +2 -2
- package/pages/SendToWallet/SendToWalletPage.tsx +1 -1
- package/pages/TransactionPage/StatusBottomSheet.tsx +6 -8
- package/providers/I18nProvider/types.ts +2 -2
- package/providers/WalletProvider/SDKProviders.tsx +7 -25
- package/providers/WalletProvider/WalletProvider.tsx +3 -24
- package/providers/WalletProvider/useHasExternalWalletProvider.ts +5 -11
- package/providers/WidgetProvider/WidgetProvider.tsx +1 -2
- package/providers/WidgetProvider/types.ts +2 -0
- package/stores/form/FormUpdater.tsx +1 -1
- package/stores/form/types.ts +4 -4
- package/stores/header/types.ts +2 -0
- package/stores/header/useHeaderStore.tsx +40 -2
- package/stores/routes/useExecutingRoutesIds.ts +1 -1
- package/stores/settings/types.ts +1 -1
- package/stores/settings/useSettingsStore.ts +30 -9
- package/themes/createTheme.ts +1 -3
- package/types/events.ts +5 -5
- package/utils/chainType.ts +3 -2
- package/utils/elements.ts +21 -1
- package/utils/fees.ts +13 -15
- package/utils/format.ts +1 -1
- package/utils/navigationRoutes.ts +7 -1
- package/utils/svm.ts +10 -0
- package/utils/wallet.ts +1 -1
- package/_esm/components/Avatar/SmallAvatar.d.ts +0 -4
- package/_esm/components/Avatar/SmallAvatar.js +0 -12
- package/_esm/components/Avatar/SmallAvatar.js.map +0 -1
- package/_esm/components/Header/DisconnectIconButton.d.ts +0 -4
- package/_esm/components/Header/DisconnectIconButton.js +0 -12
- package/_esm/components/Header/DisconnectIconButton.js.map +0 -1
- package/_esm/hooks/useHeaderHeight.d.ts +0 -6
- package/_esm/hooks/useHeaderHeight.js +0 -23
- package/_esm/hooks/useHeaderHeight.js.map +0 -1
- package/_esm/providers/WalletProvider/UTXOBaseProvider.d.ts +0 -2
- package/_esm/providers/WalletProvider/UTXOBaseProvider.js +0 -17
- package/_esm/providers/WalletProvider/UTXOBaseProvider.js.map +0 -1
- package/_esm/providers/WalletProvider/UTXOExternalContext.d.ts +0 -1
- package/_esm/providers/WalletProvider/UTXOExternalContext.js +0 -3
- package/_esm/providers/WalletProvider/UTXOExternalContext.js.map +0 -1
- package/_esm/providers/WalletProvider/UTXOProvider.d.ts +0 -3
- package/_esm/providers/WalletProvider/UTXOProvider.js +0 -18
- package/_esm/providers/WalletProvider/UTXOProvider.js.map +0 -1
- package/components/Avatar/SmallAvatar.tsx +0 -16
- package/components/Header/DisconnectIconButton.tsx +0 -18
- package/hooks/useHeaderHeight.ts +0 -27
- package/providers/WalletProvider/UTXOBaseProvider.tsx +0 -28
- package/providers/WalletProvider/UTXOExternalContext.ts +0 -3
- package/providers/WalletProvider/UTXOProvider.tsx +0 -26
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { BoxProps } from '@mui/material';
|
|
2
|
+
import { Box, styled, Typography } from '@mui/material';
|
|
3
|
+
import { searchContainerHeight } from './SearchInput.style.js';
|
|
4
|
+
|
|
5
|
+
interface NotFoundContainerProps extends BoxProps {
|
|
6
|
+
adjustForStickySearchInput?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const NotFoundContainer = styled(Box, {
|
|
10
|
+
shouldForwardProp: (prop) => prop !== 'adjustForStickySearchInput',
|
|
11
|
+
})<NotFoundContainerProps>(({ theme, adjustForStickySearchInput }) => ({
|
|
12
|
+
display: 'flex',
|
|
13
|
+
justifyContent: 'center',
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
flexDirection: 'column',
|
|
16
|
+
flex: 1,
|
|
17
|
+
padding: theme.spacing(3),
|
|
18
|
+
...(adjustForStickySearchInput && theme.header?.position === 'fixed'
|
|
19
|
+
? { paddingTop: `calc(${searchContainerHeight}px + ${theme.spacing(3)})` }
|
|
20
|
+
: {}),
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
export const NotFoundMessage = styled(Typography)(({ theme }) => ({
|
|
24
|
+
fontSize: 14,
|
|
25
|
+
color: theme.palette.text.secondary,
|
|
26
|
+
textAlign: 'center',
|
|
27
|
+
flex: 1,
|
|
28
|
+
marginTop: theme.spacing(2),
|
|
29
|
+
paddingLeft: theme.spacing(2),
|
|
30
|
+
paddingRight: theme.spacing(2),
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
export const NotFoundIconContainer = styled(Typography)(({ theme }) => ({
|
|
34
|
+
fontSize: 48,
|
|
35
|
+
lineHeight: 1,
|
|
36
|
+
}));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SearchOff } from '@mui/icons-material';
|
|
2
|
+
import {
|
|
3
|
+
NotFoundContainer,
|
|
4
|
+
NotFoundIconContainer,
|
|
5
|
+
NotFoundMessage,
|
|
6
|
+
} from './SearchNotFound.style.js';
|
|
7
|
+
|
|
8
|
+
interface SearchNotFoundProps {
|
|
9
|
+
message: string;
|
|
10
|
+
adjustForStickySearchInput?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const SearchNotFound = ({
|
|
14
|
+
message,
|
|
15
|
+
adjustForStickySearchInput,
|
|
16
|
+
}: SearchNotFoundProps) => (
|
|
17
|
+
<NotFoundContainer adjustForStickySearchInput={adjustForStickySearchInput}>
|
|
18
|
+
<NotFoundIconContainer>
|
|
19
|
+
<SearchOff fontSize="inherit" />
|
|
20
|
+
</NotFoundIconContainer>
|
|
21
|
+
<NotFoundMessage>{message}</NotFoundMessage>
|
|
22
|
+
</NotFoundContainer>
|
|
23
|
+
);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { useAccount } from '@lifi/wallet-management';
|
|
2
1
|
import { CloseRounded } from '@mui/icons-material';
|
|
3
2
|
import { Box, Collapse } from '@mui/material';
|
|
4
3
|
import { useEffect, useRef, type MouseEventHandler } from 'react';
|
|
5
4
|
import { useTranslation } from 'react-i18next';
|
|
6
5
|
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';
|
|
@@ -57,7 +57,27 @@ export const SkeletonSendToWalletButton = styled(Button)({
|
|
|
57
57
|
pointerEvents: 'none',
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
export const SkeletonPoweredByContainer = styled(Box)({
|
|
60
|
+
export const SkeletonPoweredByContainer = styled(Box)(({ theme }) => ({
|
|
61
61
|
display: 'flex',
|
|
62
|
+
flexGrow: 1,
|
|
62
63
|
justifyContent: 'flex-end',
|
|
64
|
+
alignItems: 'flex-end',
|
|
65
|
+
paddingBottom: theme.spacing(2),
|
|
66
|
+
paddingLeft: theme.spacing(3),
|
|
67
|
+
paddingRight: theme.spacing(3),
|
|
68
|
+
}));
|
|
69
|
+
|
|
70
|
+
export const SkeletonHeaderContainer = styled(Box)(({ theme }) => {
|
|
71
|
+
return {
|
|
72
|
+
display: 'flex',
|
|
73
|
+
flexDirection: 'column',
|
|
74
|
+
backgroundColor: theme.palette.background.default,
|
|
75
|
+
backdropFilter: 'blur(12px)',
|
|
76
|
+
position: 'relative',
|
|
77
|
+
top: 0,
|
|
78
|
+
zIndex: 1200,
|
|
79
|
+
gap: theme.spacing(0.5),
|
|
80
|
+
padding: theme.spacing(1.5, 3, 1.5, 3),
|
|
81
|
+
overflow: 'auto',
|
|
82
|
+
};
|
|
63
83
|
});
|
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
FlexContainer,
|
|
8
8
|
RelativeContainer,
|
|
9
9
|
} from '../AppContainer.js';
|
|
10
|
-
import { Container as HeaderContainer } from '../Header/Header.style.js';
|
|
11
10
|
import {
|
|
12
11
|
SkeletonAmountContainer,
|
|
13
12
|
SkeletonCard,
|
|
14
13
|
SkeletonCardRow,
|
|
15
14
|
SkeletonHeaderAppBar,
|
|
15
|
+
SkeletonHeaderContainer,
|
|
16
16
|
SkeletonInputCard,
|
|
17
17
|
SkeletonPoweredByContainer,
|
|
18
18
|
SkeletonReviewButton,
|
|
@@ -87,8 +87,8 @@ export const WidgetSkeleton = ({ config }: WidgetConfigPartialProps) => {
|
|
|
87
87
|
return (
|
|
88
88
|
<ThemeProvider theme={theme}>
|
|
89
89
|
<AppExpandedContainer>
|
|
90
|
-
<RelativeContainer>
|
|
91
|
-
<
|
|
90
|
+
<RelativeContainer sx={{ display: 'flex', flexDirection: 'column' }}>
|
|
91
|
+
<SkeletonHeaderContainer>
|
|
92
92
|
{!hiddenUI.includes('walletMenu') ? (
|
|
93
93
|
<SkeletonHeaderAppBar>
|
|
94
94
|
<SkeletonWalletMenuButton />
|
|
@@ -100,7 +100,8 @@ export const WidgetSkeleton = ({ config }: WidgetConfigPartialProps) => {
|
|
|
100
100
|
<Skeleton width={126} height={34} variant="text" />
|
|
101
101
|
<SkeletonIcon />
|
|
102
102
|
</SkeletonHeaderAppBar>
|
|
103
|
-
</
|
|
103
|
+
</SkeletonHeaderContainer>
|
|
104
|
+
|
|
104
105
|
<FlexContainer
|
|
105
106
|
sx={{
|
|
106
107
|
gap: 2,
|
|
@@ -123,12 +124,12 @@ export const WidgetSkeleton = ({ config }: WidgetConfigPartialProps) => {
|
|
|
123
124
|
</SkeletonSendToWalletButton>
|
|
124
125
|
) : null}
|
|
125
126
|
</SkeletonReviewButtonContainer>
|
|
126
|
-
{!hiddenUI.includes('poweredBy') ? (
|
|
127
|
-
<SkeletonPoweredByContainer>
|
|
128
|
-
<Skeleton width={96} height={18} variant="text" />
|
|
129
|
-
</SkeletonPoweredByContainer>
|
|
130
|
-
) : null}
|
|
131
127
|
</FlexContainer>
|
|
128
|
+
{!hiddenUI.includes('poweredBy') ? (
|
|
129
|
+
<SkeletonPoweredByContainer>
|
|
130
|
+
<Skeleton width={96} height={18} variant="text" />
|
|
131
|
+
</SkeletonPoweredByContainer>
|
|
132
|
+
) : null}
|
|
132
133
|
</RelativeContainer>
|
|
133
134
|
</AppExpandedContainer>
|
|
134
135
|
</ThemeProvider>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Avatar, Box, Skeleton, styled } from '@mui/material';
|
|
2
|
+
|
|
3
|
+
export const SmallAvatar = styled(Avatar)(({ theme }) => ({
|
|
4
|
+
background: theme.palette.background.paper,
|
|
5
|
+
width: 16,
|
|
6
|
+
height: 16,
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
export const SmallAvatarSkeletonBase = styled(Skeleton)(({ theme }) => ({
|
|
10
|
+
width: 16,
|
|
11
|
+
height: 16,
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
export const SmallAvatarSkeletonContainer = styled(Box)(({ theme }) => ({
|
|
15
|
+
background: theme.palette.background.paper,
|
|
16
|
+
borderRadius: '50%',
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
export const SmallAvatarSkeleton = () => {
|
|
20
|
+
return (
|
|
21
|
+
<SmallAvatarSkeletonContainer>
|
|
22
|
+
<SmallAvatarSkeletonBase variant="circular" />
|
|
23
|
+
</SmallAvatarSkeletonContainer>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
@@ -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';
|
|
22
21
|
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';
|
|
12
11
|
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,15 +1,13 @@
|
|
|
1
|
-
import { useAccount } from '@lifi/wallet-management';
|
|
2
1
|
import { Box } from '@mui/material';
|
|
3
2
|
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';
|
|
7
7
|
import { useTokenSearch } from '../../hooks/useTokenSearch.js';
|
|
8
|
-
import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js';
|
|
9
8
|
import { FormKeyHelper } from '../../stores/form/types.js';
|
|
10
9
|
import { useFieldValues } from '../../stores/form/useFieldValues.js';
|
|
11
10
|
import type { TokenAmount } from '../../types/token.js';
|
|
12
|
-
import { createElementId, ElementId } from '../../utils/elements.js';
|
|
13
11
|
import { TokenNotFound } from './TokenNotFound.js';
|
|
14
12
|
import { VirtualizedTokenList } from './VirtualizedTokenList.js';
|
|
15
13
|
import type { TokenListProps } from './types.js';
|
|
@@ -27,7 +25,6 @@ export const TokenList: FC<TokenListProps> = ({
|
|
|
27
25
|
320,
|
|
28
26
|
'tokenSearchFilter',
|
|
29
27
|
);
|
|
30
|
-
const { elementId } = useWidgetConfig();
|
|
31
28
|
|
|
32
29
|
const { chain, isLoading: isChainLoading } = useChain(selectedChainId);
|
|
33
30
|
const { account } = useAccount({ chainType: chain?.chainType });
|
|
@@ -84,11 +81,7 @@ export const TokenList: FC<TokenListProps> = ({
|
|
|
84
81
|
!tokenSearchFilter;
|
|
85
82
|
|
|
86
83
|
return (
|
|
87
|
-
<Box
|
|
88
|
-
ref={parentRef}
|
|
89
|
-
style={{ height, overflow: 'auto' }}
|
|
90
|
-
id={createElementId(ElementId.TokenList, elementId)}
|
|
91
|
-
>
|
|
84
|
+
<Box ref={parentRef} style={{ height, overflow: 'auto' }}>
|
|
92
85
|
{!tokens.length && !isLoading ? (
|
|
93
86
|
<TokenNotFound formType={formType} />
|
|
94
87
|
) : null}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ChainType } from '@lifi/sdk';
|
|
2
1
|
import { OpenInNewRounded } from '@mui/icons-material';
|
|
3
2
|
import {
|
|
4
3
|
Avatar,
|
|
@@ -27,7 +26,7 @@ export const TokenListItem: React.FC<TokenListItemProps> = ({
|
|
|
27
26
|
start,
|
|
28
27
|
token,
|
|
29
28
|
chain,
|
|
30
|
-
|
|
29
|
+
showBalance,
|
|
31
30
|
isBalanceLoading,
|
|
32
31
|
startAdornment,
|
|
33
32
|
endAdornment,
|
|
@@ -47,7 +46,7 @@ export const TokenListItem: React.FC<TokenListItemProps> = ({
|
|
|
47
46
|
<TokenListItemButton
|
|
48
47
|
token={token}
|
|
49
48
|
chain={chain}
|
|
50
|
-
|
|
49
|
+
showBalance={showBalance}
|
|
51
50
|
isBalanceLoading={isBalanceLoading}
|
|
52
51
|
onClick={handleClick}
|
|
53
52
|
/>
|
|
@@ -60,7 +59,7 @@ export const TokenListItemButton: React.FC<TokenListItemButtonProps> = ({
|
|
|
60
59
|
onClick,
|
|
61
60
|
token,
|
|
62
61
|
chain,
|
|
63
|
-
|
|
62
|
+
showBalance,
|
|
64
63
|
isBalanceLoading,
|
|
65
64
|
}) => {
|
|
66
65
|
const { t } = useTranslation();
|
|
@@ -76,15 +75,8 @@ export const TokenListItemButton: React.FC<TokenListItemButtonProps> = ({
|
|
|
76
75
|
const timeoutId = useRef<ReturnType<typeof setTimeout>>();
|
|
77
76
|
const [showAddress, setShowAddress] = useState(false);
|
|
78
77
|
|
|
79
|
-
const tokenAddress =
|
|
80
|
-
chain?.chainType === ChainType.UTXO ? accountAddress : token.address;
|
|
81
|
-
|
|
82
78
|
const onMouseEnter = () => {
|
|
83
|
-
timeoutId.current = setTimeout(() =>
|
|
84
|
-
if (tokenAddress) {
|
|
85
|
-
setShowAddress(true);
|
|
86
|
-
}
|
|
87
|
-
}, 350);
|
|
79
|
+
timeoutId.current = setTimeout(() => setShowAddress(true), 350);
|
|
88
80
|
};
|
|
89
81
|
|
|
90
82
|
const onMouseLeave = () => {
|
|
@@ -136,12 +128,12 @@ export const TokenListItemButton: React.FC<TokenListItemButtonProps> = ({
|
|
|
136
128
|
>
|
|
137
129
|
<Box display="flex">
|
|
138
130
|
<Box display="flex" alignItems="center" pt={0.125}>
|
|
139
|
-
{shortenAddress(
|
|
131
|
+
{shortenAddress(token.address)}
|
|
140
132
|
</Box>
|
|
141
133
|
<IconButton
|
|
142
134
|
size="small"
|
|
143
135
|
LinkComponent={Link}
|
|
144
|
-
href={getAddressLink(
|
|
136
|
+
href={getAddressLink(token.address, chain)}
|
|
145
137
|
target="_blank"
|
|
146
138
|
rel="nofollow noreferrer"
|
|
147
139
|
onClick={(e) => e.stopPropagation()}
|
|
@@ -153,7 +145,7 @@ export const TokenListItemButton: React.FC<TokenListItemButtonProps> = ({
|
|
|
153
145
|
</Box>
|
|
154
146
|
}
|
|
155
147
|
/>
|
|
156
|
-
{
|
|
148
|
+
{showBalance ? (
|
|
157
149
|
isBalanceLoading ? (
|
|
158
150
|
<TokenAmountSkeleton />
|
|
159
151
|
) : (
|
|
@@ -1,40 +1,20 @@
|
|
|
1
|
-
import { SearchOff } from '@mui/icons-material';
|
|
2
|
-
import { Box, Typography } from '@mui/material';
|
|
3
1
|
import { useTranslation } from 'react-i18next';
|
|
4
2
|
import { useAvailableChains } from '../../hooks/useAvailableChains.js';
|
|
5
3
|
import type { FormTypeProps } from '../../stores/form/types.js';
|
|
6
4
|
import { FormKeyHelper } from '../../stores/form/types.js';
|
|
7
5
|
import { useFieldValues } from '../../stores/form/useFieldValues.js';
|
|
6
|
+
import { SearchNotFound } from '../Search/SearchNotFound.js';
|
|
8
7
|
|
|
9
8
|
export const TokenNotFound: React.FC<FormTypeProps> = ({ formType }) => {
|
|
10
9
|
const { t } = useTranslation();
|
|
11
10
|
const [selectedChainId] = useFieldValues(FormKeyHelper.getChainKey(formType));
|
|
12
11
|
const { getChainById } = useAvailableChains();
|
|
12
|
+
|
|
13
13
|
return (
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
flexDirection: 'column',
|
|
20
|
-
flex: 1,
|
|
21
|
-
padding: 3,
|
|
22
|
-
}}
|
|
23
|
-
>
|
|
24
|
-
<Typography fontSize={48} lineHeight={1}>
|
|
25
|
-
<SearchOff fontSize="inherit" />
|
|
26
|
-
</Typography>
|
|
27
|
-
<Typography
|
|
28
|
-
fontSize={14}
|
|
29
|
-
color="text.secondary"
|
|
30
|
-
textAlign="center"
|
|
31
|
-
mt={2}
|
|
32
|
-
px={2}
|
|
33
|
-
>
|
|
34
|
-
{t('info.message.emptyTokenList', {
|
|
35
|
-
chainName: getChainById(selectedChainId)?.name,
|
|
36
|
-
})}
|
|
37
|
-
</Typography>
|
|
38
|
-
</Box>
|
|
14
|
+
<SearchNotFound
|
|
15
|
+
message={t('info.message.emptyTokenList', {
|
|
16
|
+
chainName: getChainById(selectedChainId)?.name,
|
|
17
|
+
})}
|
|
18
|
+
/>
|
|
39
19
|
);
|
|
40
20
|
};
|
|
@@ -127,7 +127,7 @@ export const VirtualizedTokenList: FC<VirtualizedTokenListProps> = ({
|
|
|
127
127
|
token={currentToken}
|
|
128
128
|
chain={chain}
|
|
129
129
|
isBalanceLoading={isBalanceLoading}
|
|
130
|
-
|
|
130
|
+
showBalance={account.isConnected}
|
|
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';
|
|
3
2
|
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
|
+
showBalance?: boolean;
|
|
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
|
+
showBalance?: boolean;
|
|
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 useTokenRateStore = 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 } = useTokenRateStore();
|
|
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.7.0
|
|
2
|
+
export const version = '3.7.0';
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { ChainId, ChainType } from '@lifi/sdk';
|
|
2
|
+
import type { WalletAdapter } from '@solana/wallet-adapter-base';
|
|
3
|
+
import { useWallet } from '@solana/wallet-adapter-react';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
import type { Chain } from 'viem';
|
|
6
|
+
import type { Connector } from 'wagmi';
|
|
7
|
+
import { useAccount as useWagmiAccount } from 'wagmi';
|
|
8
|
+
|
|
9
|
+
export interface AccountBase {
|
|
10
|
+
address?: string;
|
|
11
|
+
addresses?: readonly string[];
|
|
12
|
+
chain?: Chain;
|
|
13
|
+
chainId?: number;
|
|
14
|
+
chainType?: ChainType;
|
|
15
|
+
isConnected: boolean;
|
|
16
|
+
isConnecting: boolean;
|
|
17
|
+
isDisconnected: boolean;
|
|
18
|
+
isReconnecting: boolean;
|
|
19
|
+
status: 'connected' | 'reconnecting' | 'connecting' | 'disconnected';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface EVMAccount extends AccountBase {
|
|
23
|
+
chainType: ChainType.EVM;
|
|
24
|
+
connector?: Connector;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface SVMAccount extends AccountBase {
|
|
28
|
+
chainType: ChainType.SVM;
|
|
29
|
+
connector?: WalletAdapter;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface DefaultAccount extends AccountBase {
|
|
33
|
+
connector?: never;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type Account = EVMAccount | SVMAccount | DefaultAccount;
|
|
37
|
+
|
|
38
|
+
export interface AccountResult {
|
|
39
|
+
account: Account;
|
|
40
|
+
/**
|
|
41
|
+
* Connected accounts
|
|
42
|
+
*/
|
|
43
|
+
accounts: Account[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface UseAccountArgs {
|
|
47
|
+
chainType?: ChainType;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const defaultAccount: AccountBase = {
|
|
51
|
+
isConnected: false,
|
|
52
|
+
isConnecting: false,
|
|
53
|
+
isReconnecting: false,
|
|
54
|
+
isDisconnected: true,
|
|
55
|
+
status: 'disconnected',
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @param args When we provide args we want to return either account with corresponding chainType or default disconnected one
|
|
61
|
+
* @returns - Account result
|
|
62
|
+
*/
|
|
63
|
+
export const useAccount = (args?: UseAccountArgs): AccountResult => {
|
|
64
|
+
const account = useWagmiAccount();
|
|
65
|
+
const { wallet } = useWallet();
|
|
66
|
+
|
|
67
|
+
// We create a simple variable from the args object
|
|
68
|
+
// to avoid re-render useMemo on every object reference change.
|
|
69
|
+
const hasChainTypeArgs = Boolean(args);
|
|
70
|
+
|
|
71
|
+
return useMemo(() => {
|
|
72
|
+
const svm: Account = wallet?.adapter.publicKey
|
|
73
|
+
? {
|
|
74
|
+
address: wallet?.adapter.publicKey.toString(),
|
|
75
|
+
chainId: ChainId.SOL,
|
|
76
|
+
chainType: ChainType.SVM,
|
|
77
|
+
connector: wallet?.adapter,
|
|
78
|
+
isConnected: Boolean(wallet?.adapter.publicKey),
|
|
79
|
+
isConnecting: false,
|
|
80
|
+
isReconnecting: false,
|
|
81
|
+
isDisconnected: !wallet,
|
|
82
|
+
status: 'connected',
|
|
83
|
+
}
|
|
84
|
+
: {
|
|
85
|
+
chainType: ChainType.SVM,
|
|
86
|
+
isConnected: false,
|
|
87
|
+
isConnecting: false,
|
|
88
|
+
isReconnecting: false,
|
|
89
|
+
isDisconnected: true,
|
|
90
|
+
status: 'disconnected',
|
|
91
|
+
};
|
|
92
|
+
const evm: Account = { ...account, chainType: ChainType.EVM };
|
|
93
|
+
const accounts = [evm, svm];
|
|
94
|
+
const connectedAccounts = [evm, svm].filter(
|
|
95
|
+
(account) => account.isConnected && account.address,
|
|
96
|
+
);
|
|
97
|
+
return {
|
|
98
|
+
account:
|
|
99
|
+
accounts.find(
|
|
100
|
+
(account) =>
|
|
101
|
+
(!hasChainTypeArgs || account.chainType === args?.chainType) &&
|
|
102
|
+
account.isConnected &&
|
|
103
|
+
account.address,
|
|
104
|
+
) ?? defaultAccount,
|
|
105
|
+
// We need to return only connected account list
|
|
106
|
+
accounts: connectedAccounts,
|
|
107
|
+
};
|
|
108
|
+
}, [account, args?.chainType, hasChainTypeArgs, wallet]);
|
|
109
|
+
};
|
|
@@ -2,31 +2,32 @@ 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';
|
|
5
6
|
import { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js';
|
|
6
7
|
import { isItemAllowed } from '../utils/item.js';
|
|
7
8
|
|
|
8
|
-
const supportedChainTypes = [ChainType.EVM, ChainType.SVM
|
|
9
|
+
const supportedChainTypes = [ChainType.EVM, ChainType.SVM];
|
|
9
10
|
|
|
10
|
-
export const useAvailableChains = (
|
|
11
|
+
export const useAvailableChains = () => {
|
|
11
12
|
const { chains } = useWidgetConfig();
|
|
12
|
-
|
|
13
|
+
const { providers } = useHasExternalWalletProvider();
|
|
13
14
|
const { data, isLoading } = useQuery({
|
|
14
15
|
queryKey: [
|
|
15
16
|
'chains',
|
|
16
|
-
|
|
17
|
+
providers,
|
|
17
18
|
chains?.types,
|
|
18
19
|
chains?.allow,
|
|
19
20
|
chains?.deny,
|
|
20
21
|
chains?.from,
|
|
21
22
|
chains?.to,
|
|
22
23
|
] as const,
|
|
23
|
-
queryFn: async ({ queryKey: [,
|
|
24
|
-
const chainTypesRequest =
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
queryFn: async ({ queryKey: [, providers, chainTypes] }) => {
|
|
25
|
+
const chainTypesRequest = (
|
|
26
|
+
providers.length > 0 ? providers : supportedChainTypes
|
|
27
|
+
).filter((chainType) => isItemAllowed(chainType, chainTypes));
|
|
27
28
|
|
|
28
29
|
const availableChains = await getChains({
|
|
29
|
-
chainTypes:
|
|
30
|
+
chainTypes: chainTypesRequest,
|
|
30
31
|
});
|
|
31
32
|
config.setChains(availableChains);
|
|
32
33
|
return availableChains;
|
package/hooks/useChains.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { ChainType } from '@lifi/sdk';
|
|
2
1
|
import { useMemo } from 'react';
|
|
3
2
|
import { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js';
|
|
4
3
|
import type { FormType } from '../stores/form/types.js';
|
|
5
4
|
import { isItemAllowed } from '../utils/item.js';
|
|
6
5
|
import { useAvailableChains } from './useAvailableChains.js';
|
|
7
6
|
|
|
8
|
-
export const useChains = (type?: FormType
|
|
7
|
+
export const useChains = (type?: FormType) => {
|
|
9
8
|
const { chains } = useWidgetConfig();
|
|
10
9
|
const {
|
|
11
10
|
chains: availableChains,
|
|
@@ -18,13 +17,11 @@ export const useChains = (type?: FormType, chainTypes?: ChainType[]) => {
|
|
|
18
17
|
? availableChains?.filter(
|
|
19
18
|
(chain) =>
|
|
20
19
|
isItemAllowed(chain.id, chains) &&
|
|
21
|
-
isItemAllowed(chain.id, chains?.[type])
|
|
22
|
-
// Check against chain types if they are provided
|
|
23
|
-
(chainTypes?.includes(chain.chainType) ?? true),
|
|
20
|
+
isItemAllowed(chain.id, chains?.[type]),
|
|
24
21
|
)
|
|
25
22
|
: availableChains?.filter((chain) => isItemAllowed(chain.id, chains));
|
|
26
23
|
return filteredChains;
|
|
27
|
-
}, [availableChains,
|
|
24
|
+
}, [availableChains, chains, type]);
|
|
28
25
|
|
|
29
26
|
return {
|
|
30
27
|
chains: filteredChains,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { RouteExtended } from '@lifi/sdk';
|
|
2
|
-
import { useAccount } from '@lifi/wallet-management';
|
|
3
2
|
import { keepPreviousData, useQuery } from '@tanstack/react-query';
|
|
4
3
|
import { parseUnits } from 'viem';
|
|
5
4
|
import { useFieldValues } from '../stores/form/useFieldValues.js';
|
|
6
5
|
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';
|
|
3
2
|
import { useQuery } from '@tanstack/react-query';
|
|
4
3
|
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,8 +44,7 @@ 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) =>
|
|
48
|
-
amount + BigInt(Number(gasCost.amount).toFixed(0)),
|
|
47
|
+
(amount, gasCost) => amount + BigInt(gasCost.amount),
|
|
49
48
|
0n,
|
|
50
49
|
);
|
|
51
50
|
groupedGasCosts[token.chainId] = {
|
|
@@ -62,8 +61,7 @@ export const useGasSufficiency = (route?: RouteExtended) => {
|
|
|
62
61
|
if (nonIncludedFeeCosts?.length) {
|
|
63
62
|
const { token } = nonIncludedFeeCosts[0];
|
|
64
63
|
const feeCostAmount = nonIncludedFeeCosts.reduce(
|
|
65
|
-
(amount, feeCost) =>
|
|
66
|
-
amount + BigInt(Number(feeCost.amount).toFixed(0)),
|
|
64
|
+
(amount, feeCost) => amount + BigInt(feeCost.amount),
|
|
67
65
|
0n,
|
|
68
66
|
);
|
|
69
67
|
groupedGasCosts[token.chainId] = {
|
|
@@ -193,10 +193,6 @@ 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;
|
|
200
196
|
case LiFiErrorCode.ExchangeRateUpdateCanceled:
|
|
201
197
|
title = t(`error.title.exchangeRateUpdateCanceled`);
|
|
202
198
|
message = getDefaultErrorMessage();
|