@lifi/widget 3.29.1 → 3.30.1
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/CHANGELOG.md +24 -0
- package/dist/esm/AppProvider.d.ts +0 -1
- package/dist/esm/AppProvider.js +1 -1
- package/dist/esm/AppProvider.js.map +1 -1
- package/dist/esm/components/AmountInput/AmountInput.d.ts +0 -9
- package/dist/esm/components/AmountInput/AmountInput.js +1 -1
- package/dist/esm/components/AmountInput/AmountInput.js.map +1 -1
- package/dist/esm/components/AmountInput/AmountInputAdornment.style.d.ts +0 -1
- package/dist/esm/components/AmountInput/AmountInputAdornment.style.js +1 -6
- package/dist/esm/components/AmountInput/AmountInputAdornment.style.js.map +1 -1
- package/dist/esm/components/AmountInput/AmountInputEndAdornment.d.ts +1 -1
- package/dist/esm/components/AmountInput/AmountInputEndAdornment.js +3 -2
- package/dist/esm/components/AmountInput/AmountInputEndAdornment.js.map +1 -1
- package/dist/esm/components/AmountInput/PriceFormHelperText.d.ts +1 -7
- package/dist/esm/components/AmountInput/PriceFormHelperText.js +4 -3
- package/dist/esm/components/AmountInput/PriceFormHelperText.js.map +1 -1
- package/dist/esm/components/Avatar/Avatar.d.ts +0 -4
- package/dist/esm/components/Avatar/Avatar.js +1 -1
- package/dist/esm/components/Avatar/Avatar.js.map +1 -1
- package/dist/esm/components/Avatar/TokenAvatar.d.ts +0 -15
- package/dist/esm/components/Avatar/TokenAvatar.js +2 -2
- package/dist/esm/components/Avatar/TokenAvatar.js.map +1 -1
- package/dist/esm/components/Card/CardButton.style.d.ts +0 -1
- package/dist/esm/components/Card/CardButton.style.js +0 -7
- package/dist/esm/components/Card/CardButton.style.js.map +1 -1
- package/dist/esm/components/ChainSelect/ChainSelect.js +35 -18
- package/dist/esm/components/ChainSelect/ChainSelect.js.map +1 -1
- package/dist/esm/components/ChainSelect/useChainSelect.d.ts +1 -1
- package/dist/esm/components/ChainSelect/useChainSelect.js +3 -3
- package/dist/esm/components/ChainSelect/useChainSelect.js.map +1 -1
- package/dist/esm/components/Chains/AllChainsAvatar.d.ts +7 -0
- package/dist/esm/components/Chains/AllChainsAvatar.js +77 -0
- package/dist/esm/components/Chains/AllChainsAvatar.js.map +1 -0
- package/dist/esm/components/Chains/ChainList.d.ts +2 -1
- package/dist/esm/components/Chains/ChainList.js +2 -2
- package/dist/esm/components/Chains/ChainList.js.map +1 -1
- package/dist/esm/components/Chains/ChainSearchInput.js +2 -2
- package/dist/esm/components/Chains/ChainSearchInput.js.map +1 -1
- package/dist/esm/components/Chains/SelectChainContent.js +1 -1
- package/dist/esm/components/Chains/SelectChainContent.js.map +1 -1
- package/dist/esm/components/Chains/VirtualizedChainList.d.ts +2 -1
- package/dist/esm/components/Chains/VirtualizedChainList.js +42 -10
- package/dist/esm/components/Chains/VirtualizedChainList.js.map +1 -1
- package/dist/esm/components/FeeBreakdownTooltip.d.ts +2 -3
- package/dist/esm/components/FeeBreakdownTooltip.js +1 -1
- package/dist/esm/components/FeeBreakdownTooltip.js.map +1 -1
- package/dist/esm/components/Header/Header.d.ts +1 -2
- package/dist/esm/components/Header/Header.js +1 -1
- package/dist/esm/components/Header/Header.js.map +1 -1
- package/dist/esm/components/Header/WalletHeader.d.ts +0 -1
- package/dist/esm/components/Header/WalletHeader.js +1 -1
- package/dist/esm/components/Header/WalletHeader.js.map +1 -1
- package/dist/esm/components/RouteCard/RouteCardEssentials.js +1 -1
- package/dist/esm/components/RouteCard/RouteCardEssentials.js.map +1 -1
- package/dist/esm/components/SendToWallet/SendToWalletButton.js.map +1 -1
- package/dist/esm/components/StepActions/StepActions.d.ts +1 -10
- package/dist/esm/components/StepActions/StepActions.js +6 -6
- package/dist/esm/components/StepActions/StepActions.js.map +1 -1
- package/dist/esm/components/Tabs/Tabs.style.d.ts +0 -1
- package/dist/esm/components/Tabs/Tabs.style.js +1 -1
- package/dist/esm/components/Tabs/Tabs.style.js.map +1 -1
- package/dist/esm/components/Timer/TimerContent.js +1 -2
- package/dist/esm/components/Timer/TimerContent.js.map +1 -1
- package/dist/esm/components/Token/Token.d.ts +0 -2
- package/dist/esm/components/Token/Token.js +2 -2
- package/dist/esm/components/Token/Token.js.map +1 -1
- package/dist/esm/components/TokenList/TokenDetailsSheet.d.ts +1 -5
- package/dist/esm/components/TokenList/TokenDetailsSheet.js +4 -2
- package/dist/esm/components/TokenList/TokenDetailsSheet.js.map +1 -1
- package/dist/esm/components/TokenList/TokenDetailsSheetContent.js +2 -2
- package/dist/esm/components/TokenList/TokenDetailsSheetContent.js.map +1 -1
- package/dist/esm/components/TokenList/TokenList.js +11 -53
- package/dist/esm/components/TokenList/TokenList.js.map +1 -1
- package/dist/esm/components/TokenList/TokenListItem.d.ts +1 -4
- package/dist/esm/components/TokenList/TokenListItem.js +30 -26
- package/dist/esm/components/TokenList/TokenListItem.js.map +1 -1
- package/dist/esm/components/TokenList/VirtualizedTokenList.js +56 -37
- package/dist/esm/components/TokenList/VirtualizedTokenList.js.map +1 -1
- package/dist/esm/components/TokenList/types.d.ts +8 -11
- package/dist/esm/components/TokenList/useTokenSelect.d.ts +0 -4
- package/dist/esm/components/TokenList/useTokenSelect.js +3 -4
- package/dist/esm/components/TokenList/useTokenSelect.js.map +1 -1
- package/dist/esm/components/TokenRate/TokenRate.js +1 -3
- package/dist/esm/components/TokenRate/TokenRate.js.map +1 -1
- package/dist/esm/components/TransactionDetails.js +2 -2
- package/dist/esm/components/TransactionDetails.js.map +1 -1
- package/dist/esm/config/version.d.ts +1 -1
- package/dist/esm/config/version.js +1 -1
- package/dist/esm/hooks/timer/time.d.ts +0 -8
- package/dist/esm/hooks/timer/time.js.map +1 -1
- package/dist/esm/hooks/timer/useTimer.d.ts +3 -2
- package/dist/esm/hooks/useAccountsBalancesData.d.ts +6 -0
- package/dist/esm/hooks/useAccountsBalancesData.js +64 -0
- package/dist/esm/hooks/useAccountsBalancesData.js.map +1 -0
- package/dist/esm/hooks/useAvailableChains.d.ts +2 -1
- package/dist/esm/hooks/useChain.d.ts +1 -1
- package/dist/esm/hooks/useChains.d.ts +1 -1
- package/dist/esm/hooks/useExplorer.d.ts +2 -1
- package/dist/esm/hooks/useFilteredByTokenBalances.d.ts +9 -0
- package/dist/esm/hooks/useFilteredByTokenBalances.js +78 -0
- package/dist/esm/hooks/useFilteredByTokenBalances.js.map +1 -0
- package/dist/esm/hooks/useListHeight.d.ts +0 -3
- package/dist/esm/hooks/useListHeight.js +2 -3
- package/dist/esm/hooks/useListHeight.js.map +1 -1
- package/dist/esm/hooks/useRoutes.js +2 -2
- package/dist/esm/hooks/useRoutes.js.map +1 -1
- package/dist/esm/hooks/useToAddressAutoPopulate.d.ts +2 -1
- package/dist/esm/hooks/useToken.d.ts +2 -2
- package/dist/esm/hooks/useToken.js +13 -10
- package/dist/esm/hooks/useToken.js.map +1 -1
- package/dist/esm/hooks/useTokenAddressBalance.d.ts +3 -3
- package/dist/esm/hooks/useTokenAddressBalance.js +10 -14
- package/dist/esm/hooks/useTokenAddressBalance.js.map +1 -1
- package/dist/esm/hooks/useTokenBalances.d.ts +6 -9
- package/dist/esm/hooks/useTokenBalances.js +57 -72
- package/dist/esm/hooks/useTokenBalances.js.map +1 -1
- package/dist/esm/hooks/useTokenBalancesQueries.d.ts +11 -0
- package/dist/esm/hooks/useTokenBalancesQueries.js +74 -0
- package/dist/esm/hooks/useTokenBalancesQueries.js.map +1 -0
- package/dist/esm/hooks/useTokenSearch.js +3 -3
- package/dist/esm/hooks/useTokenSearch.js.map +1 -1
- package/dist/esm/hooks/useTokens.d.ts +6 -6
- package/dist/esm/hooks/useTokens.js +98 -69
- package/dist/esm/hooks/useTokens.js.map +1 -1
- package/dist/esm/i18n/bn.json +3 -3
- package/dist/esm/i18n/de.json +3 -3
- package/dist/esm/i18n/en.json +3 -3
- package/dist/esm/i18n/es.json +3 -3
- package/dist/esm/i18n/fr.json +3 -3
- package/dist/esm/i18n/hi.json +3 -3
- package/dist/esm/i18n/id.json +3 -3
- package/dist/esm/i18n/it.json +3 -3
- package/dist/esm/i18n/ja.json +3 -3
- package/dist/esm/i18n/ko.json +3 -3
- package/dist/esm/i18n/pl.json +3 -3
- package/dist/esm/i18n/pt.json +5 -5
- package/dist/esm/i18n/th.json +3 -3
- package/dist/esm/i18n/tr.json +3 -3
- package/dist/esm/i18n/uk.json +3 -3
- package/dist/esm/i18n/vi.json +3 -3
- package/dist/esm/i18n/zh.json +3 -3
- package/dist/esm/pages/SelectTokenPage/SearchTokenInput.js +6 -1
- package/dist/esm/pages/SelectTokenPage/SearchTokenInput.js.map +1 -1
- package/dist/esm/pages/SelectTokenPage/SelectTokenPage.js +2 -4
- package/dist/esm/pages/SelectTokenPage/SelectTokenPage.js.map +1 -1
- package/dist/esm/pages/SettingsPage/SettingsCard/SettingCardExpandable.js.map +1 -1
- package/dist/esm/pages/SettingsPage/SlippageSettings/SlippageSettings.js +27 -17
- package/dist/esm/pages/SettingsPage/SlippageSettings/SlippageSettings.js.map +1 -1
- package/dist/esm/pages/TransactionPage/RouteTracker.d.ts +2 -1
- package/dist/esm/pages/TransactionPage/StatusBottomSheet.d.ts +0 -5
- package/dist/esm/pages/TransactionPage/StatusBottomSheet.js +1 -1
- package/dist/esm/pages/TransactionPage/StatusBottomSheet.js.map +1 -1
- package/dist/esm/pages/TransactionPage/TokenValueBottomSheet.js +1 -1
- package/dist/esm/pages/TransactionPage/TokenValueBottomSheet.js.map +1 -1
- package/dist/esm/providers/I18nProvider/types.d.ts +4 -3
- package/dist/esm/providers/WalletProvider/EVMProvider.d.ts +0 -1
- package/dist/esm/providers/WalletProvider/EVMProvider.js +1 -1
- package/dist/esm/providers/WalletProvider/EVMProvider.js.map +1 -1
- package/dist/esm/providers/WalletProvider/SVMProvider.d.ts +0 -1
- package/dist/esm/providers/WalletProvider/SVMProvider.js +1 -1
- package/dist/esm/providers/WalletProvider/SVMProvider.js.map +1 -1
- package/dist/esm/providers/WalletProvider/SuiProvider.d.ts +0 -1
- package/dist/esm/providers/WalletProvider/SuiProvider.js +1 -1
- package/dist/esm/providers/WalletProvider/SuiProvider.js.map +1 -1
- package/dist/esm/providers/WalletProvider/UTXOProvider.d.ts +0 -1
- package/dist/esm/providers/WalletProvider/UTXOProvider.js +1 -1
- package/dist/esm/providers/WalletProvider/UTXOProvider.js.map +1 -1
- package/dist/esm/providers/WalletProvider/WalletProvider.d.ts +0 -1
- package/dist/esm/providers/WalletProvider/WalletProvider.js +1 -1
- package/dist/esm/providers/WalletProvider/WalletProvider.js.map +1 -1
- package/dist/esm/stores/bookmarks/BookmarkStore.d.ts +1 -2
- package/dist/esm/stores/bookmarks/BookmarkStore.js +1 -1
- package/dist/esm/stores/bookmarks/BookmarkStore.js.map +1 -1
- package/dist/esm/stores/chains/ChainOrderStore.d.ts +0 -5
- package/dist/esm/stores/chains/ChainOrderStore.js +2 -2
- package/dist/esm/stores/chains/ChainOrderStore.js.map +1 -1
- package/dist/esm/stores/chains/createChainOrderStore.d.ts +3 -2
- package/dist/esm/stores/chains/createChainOrderStore.js +13 -8
- package/dist/esm/stores/chains/createChainOrderStore.js.map +1 -1
- package/dist/esm/stores/chains/types.d.ts +4 -1
- package/dist/esm/stores/chains/useChainOrder.js +5 -1
- package/dist/esm/stores/chains/useChainOrder.js.map +1 -1
- package/dist/esm/stores/header/types.d.ts +2 -1
- package/dist/esm/stores/header/useHeaderStore.d.ts +1 -4
- package/dist/esm/stores/header/useHeaderStore.js +3 -3
- package/dist/esm/stores/header/useHeaderStore.js.map +1 -1
- package/dist/esm/stores/inputMode/useInputModeStore.d.ts +1 -1
- package/dist/esm/stores/routes/RouteExecutionStore.d.ts +2 -2
- package/dist/esm/stores/routes/RouteExecutionStore.js +1 -1
- package/dist/esm/stores/routes/RouteExecutionStore.js.map +1 -1
- package/dist/esm/stores/settings/types.d.ts +3 -3
- package/dist/esm/stores/settings/types.js.map +1 -1
- package/dist/esm/stores/settings/useSettingsStore.d.ts +1 -2
- package/dist/esm/stores/settings/useSettingsStore.js +1 -1
- package/dist/esm/stores/settings/useSettingsStore.js.map +1 -1
- package/dist/esm/stores/settings/useSplitSubvariantStore.d.ts +1 -4
- package/dist/esm/stores/settings/useSplitSubvariantStore.js +3 -3
- package/dist/esm/stores/settings/useSplitSubvariantStore.js.map +1 -1
- package/dist/esm/types/events.d.ts +0 -4
- package/dist/esm/types/events.js +0 -4
- package/dist/esm/types/events.js.map +1 -1
- package/dist/esm/types/token.d.ts +7 -2
- package/dist/esm/utils/chainType.d.ts +1 -0
- package/dist/esm/utils/chainType.js +2 -0
- package/dist/esm/utils/chainType.js.map +1 -1
- package/dist/esm/utils/fees.d.ts +1 -4
- package/dist/esm/utils/fees.js +3 -3
- package/dist/esm/utils/fees.js.map +1 -1
- package/dist/esm/utils/format.js +1 -1
- package/dist/esm/utils/format.js.map +1 -1
- package/dist/esm/utils/navigationRoutes.d.ts +2 -1
- package/dist/esm/utils/token.d.ts +8 -0
- package/dist/esm/utils/token.js +29 -0
- package/dist/esm/utils/token.js.map +1 -0
- package/dist/esm/utils/tokenList.d.ts +9 -0
- package/dist/esm/utils/tokenList.js +106 -0
- package/dist/esm/utils/tokenList.js.map +1 -0
- package/package.json +10 -10
- package/package.json.tmp +9 -9
- package/src/AppProvider.tsx +1 -1
- package/src/components/AmountInput/AmountInput.tsx +1 -1
- package/src/components/AmountInput/AmountInputAdornment.style.tsx +1 -7
- package/src/components/AmountInput/AmountInputEndAdornment.tsx +3 -2
- package/src/components/AmountInput/PriceFormHelperText.tsx +4 -3
- package/src/components/Avatar/Avatar.tsx +1 -1
- package/src/components/Avatar/TokenAvatar.tsx +2 -2
- package/src/components/Card/CardButton.style.tsx +0 -8
- package/src/components/ChainSelect/ChainSelect.tsx +112 -40
- package/src/components/ChainSelect/useChainSelect.ts +3 -3
- package/src/components/Chains/AllChainsAvatar.tsx +113 -0
- package/src/components/Chains/ChainList.tsx +3 -0
- package/src/components/Chains/ChainSearchInput.tsx +2 -2
- package/src/components/Chains/SelectChainContent.tsx +1 -0
- package/src/components/Chains/VirtualizedChainList.tsx +80 -12
- package/src/components/FeeBreakdownTooltip.tsx +2 -5
- package/src/components/Header/Header.tsx +1 -1
- package/src/components/Header/WalletHeader.tsx +1 -1
- package/src/components/RouteCard/RouteCardEssentials.tsx +1 -1
- package/src/components/SendToWallet/SendToWalletButton.tsx +0 -1
- package/src/components/StepActions/StepActions.tsx +6 -6
- package/src/components/Tabs/Tabs.style.tsx +1 -1
- package/src/components/Timer/TimerContent.tsx +1 -2
- package/src/components/Token/Token.tsx +2 -2
- package/src/components/TokenList/TokenDetailsSheet.tsx +4 -9
- package/src/components/TokenList/TokenDetailsSheetContent.tsx +2 -6
- package/src/components/TokenList/TokenList.tsx +57 -129
- package/src/components/TokenList/TokenListItem.tsx +177 -154
- package/src/components/TokenList/VirtualizedTokenList.tsx +88 -48
- package/src/components/TokenList/types.ts +15 -11
- package/src/components/TokenList/useTokenSelect.ts +3 -9
- package/src/components/TokenRate/TokenRate.tsx +0 -1
- package/src/components/TransactionDetails.tsx +2 -3
- package/src/config/version.ts +1 -1
- package/src/hooks/timer/time.ts +0 -10
- package/src/hooks/timer/useTimer.ts +2 -2
- package/src/hooks/useAccountsBalancesData.ts +101 -0
- package/src/hooks/useAvailableChains.ts +1 -1
- package/src/hooks/useExplorer.ts +1 -1
- package/src/hooks/useFilteredByTokenBalances.ts +130 -0
- package/src/hooks/useListHeight.ts +2 -3
- package/src/hooks/useRoutes.ts +4 -2
- package/src/hooks/useToAddressAutoPopulate.ts +1 -1
- package/src/hooks/useToken.ts +31 -13
- package/src/hooks/useTokenAddressBalance.ts +15 -20
- package/src/hooks/useTokenBalances.ts +81 -80
- package/src/hooks/useTokenBalancesQueries.ts +94 -0
- package/src/hooks/useTokenSearch.ts +4 -7
- package/src/hooks/useTokens.ts +153 -87
- package/src/i18n/bn.json +3 -3
- package/src/i18n/de.json +3 -3
- package/src/i18n/en.json +3 -3
- package/src/i18n/es.json +3 -3
- package/src/i18n/fr.json +3 -3
- package/src/i18n/hi.json +3 -3
- package/src/i18n/id.json +3 -3
- package/src/i18n/it.json +3 -3
- package/src/i18n/ja.json +3 -3
- package/src/i18n/ko.json +3 -3
- package/src/i18n/pl.json +3 -3
- package/src/i18n/pt.json +5 -5
- package/src/i18n/th.json +3 -3
- package/src/i18n/tr.json +3 -3
- package/src/i18n/uk.json +3 -3
- package/src/i18n/vi.json +3 -3
- package/src/i18n/zh.json +3 -3
- package/src/pages/SelectTokenPage/SearchTokenInput.tsx +5 -0
- package/src/pages/SelectTokenPage/SelectTokenPage.tsx +7 -13
- package/src/pages/SettingsPage/SettingsCard/SettingCardExpandable.tsx +0 -1
- package/src/pages/SettingsPage/SlippageSettings/SlippageSettings.tsx +33 -30
- package/src/pages/TransactionPage/RouteTracker.tsx +1 -1
- package/src/pages/TransactionPage/StatusBottomSheet.tsx +5 -3
- package/src/pages/TransactionPage/TokenValueBottomSheet.tsx +1 -1
- package/src/providers/I18nProvider/types.ts +3 -3
- package/src/providers/WalletProvider/EVMProvider.tsx +1 -1
- package/src/providers/WalletProvider/SVMProvider.tsx +1 -1
- package/src/providers/WalletProvider/SuiProvider.tsx +1 -1
- package/src/providers/WalletProvider/UTXOProvider.tsx +1 -1
- package/src/providers/WalletProvider/WalletProvider.tsx +1 -1
- package/src/stores/bookmarks/BookmarkStore.tsx +1 -1
- package/src/stores/chains/ChainOrderStore.tsx +3 -7
- package/src/stores/chains/createChainOrderStore.ts +17 -8
- package/src/stores/chains/types.ts +3 -1
- package/src/stores/chains/useChainOrder.ts +5 -1
- package/src/stores/header/types.ts +1 -1
- package/src/stores/header/useHeaderStore.tsx +3 -3
- package/src/stores/inputMode/useInputModeStore.ts +1 -1
- package/src/stores/routes/RouteExecutionStore.tsx +4 -3
- package/src/stores/settings/types.ts +2 -6
- package/src/stores/settings/useSettingsStore.ts +1 -1
- package/src/stores/settings/useSplitSubvariantStore.tsx +5 -4
- package/src/types/events.ts +0 -4
- package/src/types/token.ts +11 -2
- package/src/utils/chainType.ts +2 -0
- package/src/utils/fees.ts +3 -3
- package/src/utils/format.ts +2 -1
- package/src/utils/navigationRoutes.ts +1 -1
- package/src/utils/token.ts +67 -0
- package/src/utils/tokenList.ts +172 -0
- package/dist/esm/AppDrawer.style.d.ts +0 -1
- package/dist/esm/AppDrawer.style.js +0 -12
- package/dist/esm/AppDrawer.style.js.map +0 -1
- package/dist/esm/components/Select.d.ts +0 -3
- package/dist/esm/components/Select.js +0 -35
- package/dist/esm/components/Select.js.map +0 -1
- package/dist/esm/components/StepActions/StepFees.d.ts +0 -5
- package/dist/esm/components/StepActions/StepFees.js +0 -32
- package/dist/esm/components/StepActions/StepFees.js.map +0 -1
- package/dist/esm/components/TokenList/utils.d.ts +0 -2
- package/dist/esm/components/TokenList/utils.js +0 -35
- package/dist/esm/components/TokenList/utils.js.map +0 -1
- package/dist/esm/pages/MainPage/MainPage.style.d.ts +0 -1
- package/dist/esm/pages/MainPage/MainPage.style.js +0 -8
- package/dist/esm/pages/MainPage/MainPage.style.js.map +0 -1
- package/dist/esm/pages/SelectNativeTokenPage.d.ts +0 -2
- package/dist/esm/pages/SelectNativeTokenPage.js +0 -23
- package/dist/esm/pages/SelectNativeTokenPage.js.map +0 -1
- package/dist/esm/pages/SelectTokenPage/SearchTokenInput.style.d.ts +0 -1
- package/dist/esm/pages/SelectTokenPage/SearchTokenInput.style.js +0 -6
- package/dist/esm/pages/SelectTokenPage/SearchTokenInput.style.js.map +0 -1
- package/dist/esm/pages/SelectTokenPage/types.d.ts +0 -4
- package/dist/esm/pages/SelectTokenPage/types.js +0 -6
- package/dist/esm/pages/SelectTokenPage/types.js.map +0 -1
- package/dist/esm/providers/WidgetProvider/utils.d.ts +0 -5
- package/dist/esm/providers/WidgetProvider/utils.js +0 -17
- package/dist/esm/providers/WidgetProvider/utils.js.map +0 -1
- package/dist/esm/stores/form/useFieldController.d.ts +0 -11
- package/dist/esm/stores/form/useFieldController.js +0 -20
- package/dist/esm/stores/form/useFieldController.js.map +0 -1
- package/dist/esm/stores/form/useValidation.d.ts +0 -2
- package/dist/esm/stores/form/useValidation.js +0 -14
- package/dist/esm/stores/form/useValidation.js.map +0 -1
- package/dist/esm/stores/form/useValidationActions.d.ts +0 -2
- package/dist/esm/stores/form/useValidationActions.js +0 -10
- package/dist/esm/stores/form/useValidationActions.js.map +0 -1
- package/src/AppDrawer.style.tsx +0 -12
- package/src/components/Select.tsx +0 -42
- package/src/components/StepActions/StepFees.tsx +0 -49
- package/src/components/TokenList/utils.ts +0 -42
- package/src/pages/MainPage/MainPage.style.tsx +0 -8
- package/src/pages/SelectNativeTokenPage.tsx +0 -47
- package/src/pages/SelectTokenPage/SearchTokenInput.style.tsx +0 -6
- package/src/pages/SelectTokenPage/types.ts +0 -4
- package/src/providers/WidgetProvider/utils.ts +0 -26
- package/src/stores/form/useFieldController.ts +0 -31
- package/src/stores/form/useValidation.ts +0 -15
- package/src/stores/form/useValidationActions.ts +0 -12
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { StaticToken } from '@lifi/sdk'
|
|
1
2
|
import { ChainType } from '@lifi/sdk'
|
|
2
3
|
import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'
|
|
3
4
|
import {
|
|
@@ -5,16 +6,18 @@ import {
|
|
|
5
6
|
Box,
|
|
6
7
|
ListItemAvatar,
|
|
7
8
|
ListItemText,
|
|
9
|
+
listItemSecondaryActionClasses,
|
|
8
10
|
Skeleton,
|
|
9
11
|
Slide,
|
|
10
12
|
Typography,
|
|
11
13
|
} from '@mui/material'
|
|
12
14
|
import type { MouseEventHandler } from 'react'
|
|
13
|
-
import { memo, useRef, useState } from 'react'
|
|
15
|
+
import { memo, useMemo, useRef, useState } from 'react'
|
|
14
16
|
import { useTranslation } from 'react-i18next'
|
|
15
17
|
import { useLongPress } from '../../hooks/useLongPress.js'
|
|
16
18
|
import { formatTokenAmount, formatTokenPrice } from '../../utils/format.js'
|
|
17
19
|
import { shortenAddress } from '../../utils/wallet.js'
|
|
20
|
+
import { TokenAvatar } from '../Avatar/TokenAvatar.js'
|
|
18
21
|
import { ListItemButton } from '../ListItem/ListItemButton.js'
|
|
19
22
|
import { IconButton, ListItem } from './TokenList.style.js'
|
|
20
23
|
import type {
|
|
@@ -30,17 +33,12 @@ export const TokenListItem: React.FC<TokenListItemProps> = memo(
|
|
|
30
33
|
start,
|
|
31
34
|
token,
|
|
32
35
|
chain,
|
|
33
|
-
accountAddress,
|
|
34
36
|
isBalanceLoading,
|
|
35
37
|
startAdornment,
|
|
36
38
|
endAdornment,
|
|
37
39
|
selected,
|
|
38
40
|
onShowTokenDetails,
|
|
39
41
|
}) => {
|
|
40
|
-
const handleClick: MouseEventHandler<HTMLDivElement> = (e) => {
|
|
41
|
-
e.stopPropagation()
|
|
42
|
-
onClick?.(token.address, chain?.id)
|
|
43
|
-
}
|
|
44
42
|
return (
|
|
45
43
|
<ListItem
|
|
46
44
|
style={{
|
|
@@ -52,10 +50,9 @@ export const TokenListItem: React.FC<TokenListItemProps> = memo(
|
|
|
52
50
|
{startAdornment}
|
|
53
51
|
<TokenListItemButton
|
|
54
52
|
token={token}
|
|
55
|
-
chain={chain}
|
|
56
|
-
accountAddress={accountAddress}
|
|
57
53
|
isBalanceLoading={isBalanceLoading}
|
|
58
|
-
onClick={
|
|
54
|
+
onClick={onClick}
|
|
55
|
+
chain={chain}
|
|
59
56
|
selected={selected}
|
|
60
57
|
onShowTokenDetails={onShowTokenDetails}
|
|
61
58
|
/>
|
|
@@ -65,10 +62,9 @@ export const TokenListItem: React.FC<TokenListItemProps> = memo(
|
|
|
65
62
|
}
|
|
66
63
|
)
|
|
67
64
|
|
|
68
|
-
|
|
69
|
-
token,
|
|
70
|
-
}) => {
|
|
65
|
+
const TokenListItemAvatar = memo(({ token }: TokenListItemAvatarProps) => {
|
|
71
66
|
const [isImageLoading, setIsImageLoading] = useState(true)
|
|
67
|
+
|
|
72
68
|
return (
|
|
73
69
|
<Avatar
|
|
74
70
|
src={token.logoURI}
|
|
@@ -81,17 +77,23 @@ export const TokenListItemAvatar: React.FC<TokenListItemAvatarProps> = ({
|
|
|
81
77
|
{token.symbol?.[0]}
|
|
82
78
|
</Avatar>
|
|
83
79
|
)
|
|
84
|
-
}
|
|
80
|
+
})
|
|
85
81
|
|
|
86
82
|
interface OpenTokenDetailsButtonProps {
|
|
87
83
|
tokenAddress: string | undefined
|
|
88
84
|
withoutContractAddress: boolean
|
|
89
|
-
|
|
85
|
+
chainId: number
|
|
86
|
+
onClick: (
|
|
87
|
+
tokenAddress: string,
|
|
88
|
+
withoutContractAddress: boolean,
|
|
89
|
+
chainId: number
|
|
90
|
+
) => void
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
const OpenTokenDetailsButton = ({
|
|
93
94
|
tokenAddress,
|
|
94
95
|
withoutContractAddress,
|
|
96
|
+
chainId,
|
|
95
97
|
onClick,
|
|
96
98
|
}: OpenTokenDetailsButtonProps) => {
|
|
97
99
|
if (!tokenAddress) {
|
|
@@ -103,7 +105,7 @@ const OpenTokenDetailsButton = ({
|
|
|
103
105
|
onClick={(e) => {
|
|
104
106
|
e.stopPropagation()
|
|
105
107
|
e.currentTarget.blur() // Remove focus to prevent accessibility issues when opening drawer
|
|
106
|
-
onClick(tokenAddress, withoutContractAddress)
|
|
108
|
+
onClick(tokenAddress, withoutContractAddress, chainId)
|
|
107
109
|
}}
|
|
108
110
|
>
|
|
109
111
|
<InfoOutlinedIcon />
|
|
@@ -111,92 +113,159 @@ const OpenTokenDetailsButton = ({
|
|
|
111
113
|
)
|
|
112
114
|
}
|
|
113
115
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}) => {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
116
|
+
const TokenListItemButton: React.FC<TokenListItemButtonProps> = memo(
|
|
117
|
+
({
|
|
118
|
+
onClick,
|
|
119
|
+
token,
|
|
120
|
+
chain,
|
|
121
|
+
isBalanceLoading,
|
|
122
|
+
selected,
|
|
123
|
+
onShowTokenDetails,
|
|
124
|
+
}) => {
|
|
125
|
+
const { t } = useTranslation()
|
|
126
|
+
const container = useRef(null)
|
|
127
|
+
const timeoutId = useRef<ReturnType<typeof setTimeout>>(undefined)
|
|
128
|
+
const [showAddress, setShowAddress] = useState(false)
|
|
127
129
|
|
|
128
|
-
|
|
130
|
+
const withoutContractAddress = chain?.chainType === ChainType.UTXO
|
|
131
|
+
|
|
132
|
+
const onMouseEnter = () => {
|
|
133
|
+
timeoutId.current = setTimeout(() => {
|
|
134
|
+
if (token.address) {
|
|
135
|
+
setShowAddress(true)
|
|
136
|
+
}
|
|
137
|
+
}, 350)
|
|
138
|
+
}
|
|
129
139
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if (
|
|
133
|
-
setShowAddress(
|
|
140
|
+
const onMouseLeave = () => {
|
|
141
|
+
clearTimeout(timeoutId.current)
|
|
142
|
+
if (showAddress) {
|
|
143
|
+
setShowAddress(false)
|
|
134
144
|
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
145
|
+
}
|
|
137
146
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
setShowAddress(false)
|
|
147
|
+
const handleClick: MouseEventHandler<HTMLDivElement> = (e) => {
|
|
148
|
+
e.stopPropagation()
|
|
149
|
+
onClick?.(token.address, token.chainId)
|
|
142
150
|
}
|
|
143
|
-
}
|
|
144
151
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
token.decimals
|
|
150
|
-
)
|
|
152
|
+
const tokenAmount = useMemo(
|
|
153
|
+
() => formatTokenAmount(token.amount, token.decimals),
|
|
154
|
+
[token.amount, token.decimals]
|
|
155
|
+
)
|
|
151
156
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
157
|
+
const tokenPrice = useMemo(
|
|
158
|
+
() => formatTokenPrice(token.amount, token.priceUSD, token.decimals),
|
|
159
|
+
[token.amount, token.priceUSD, token.decimals]
|
|
160
|
+
)
|
|
155
161
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
</ListItemAvatar>
|
|
172
|
-
<ListItemText
|
|
173
|
-
primary={token.symbol}
|
|
174
|
-
slotProps={{
|
|
175
|
-
secondary: {
|
|
176
|
-
component: 'div',
|
|
177
|
-
},
|
|
162
|
+
const longPressEvents = useLongPress(() =>
|
|
163
|
+
onShowTokenDetails(token.address, withoutContractAddress, token.chainId)
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
return (
|
|
167
|
+
<ListItemButton
|
|
168
|
+
onClick={handleClick}
|
|
169
|
+
onMouseEnter={onMouseEnter}
|
|
170
|
+
onMouseLeave={onMouseLeave}
|
|
171
|
+
{...longPressEvents}
|
|
172
|
+
dense
|
|
173
|
+
selected={selected}
|
|
174
|
+
sx={{
|
|
175
|
+
height: 60,
|
|
176
|
+
marginBottom: '4px',
|
|
178
177
|
}}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
|
|
178
|
+
>
|
|
179
|
+
<ListItemAvatar>
|
|
180
|
+
{chain ? (
|
|
181
|
+
<TokenAvatar
|
|
182
|
+
token={token as StaticToken}
|
|
183
|
+
chain={chain}
|
|
184
|
+
tokenAvatarSize={40}
|
|
185
|
+
chainAvatarSize={16}
|
|
186
|
+
/>
|
|
187
|
+
) : (
|
|
188
|
+
<TokenListItemAvatar token={token} />
|
|
189
|
+
)}
|
|
190
|
+
</ListItemAvatar>
|
|
191
|
+
<ListItemText
|
|
192
|
+
primary={token.symbol}
|
|
193
|
+
slotProps={{
|
|
194
|
+
secondary: {
|
|
195
|
+
component: 'div',
|
|
196
|
+
},
|
|
197
|
+
}}
|
|
198
|
+
secondary={
|
|
199
|
+
withoutContractAddress ? (
|
|
188
200
|
<Box
|
|
201
|
+
ref={container}
|
|
189
202
|
sx={{
|
|
190
|
-
|
|
203
|
+
height: 20,
|
|
204
|
+
display: 'flex',
|
|
191
205
|
}}
|
|
192
206
|
>
|
|
193
|
-
|
|
207
|
+
<Box
|
|
208
|
+
sx={{
|
|
209
|
+
pt: 0.25,
|
|
210
|
+
}}
|
|
211
|
+
>
|
|
212
|
+
{token.name}
|
|
213
|
+
</Box>
|
|
214
|
+
<Box
|
|
215
|
+
sx={{
|
|
216
|
+
position: 'relative',
|
|
217
|
+
}}
|
|
218
|
+
>
|
|
219
|
+
<Slide
|
|
220
|
+
direction="up"
|
|
221
|
+
in={showAddress}
|
|
222
|
+
container={container.current}
|
|
223
|
+
style={{
|
|
224
|
+
position: 'absolute',
|
|
225
|
+
}}
|
|
226
|
+
appear={false}
|
|
227
|
+
mountOnEnter
|
|
228
|
+
>
|
|
229
|
+
<Box
|
|
230
|
+
sx={{
|
|
231
|
+
display: 'flex',
|
|
232
|
+
}}
|
|
233
|
+
>
|
|
234
|
+
<OpenTokenDetailsButton
|
|
235
|
+
tokenAddress={token.address}
|
|
236
|
+
withoutContractAddress={withoutContractAddress}
|
|
237
|
+
chainId={token.chainId}
|
|
238
|
+
onClick={onShowTokenDetails}
|
|
239
|
+
/>
|
|
240
|
+
</Box>
|
|
241
|
+
</Slide>
|
|
242
|
+
</Box>
|
|
194
243
|
</Box>
|
|
244
|
+
) : (
|
|
195
245
|
<Box
|
|
246
|
+
ref={container}
|
|
196
247
|
sx={{
|
|
197
248
|
position: 'relative',
|
|
249
|
+
height: 20,
|
|
198
250
|
}}
|
|
199
251
|
>
|
|
252
|
+
<Slide
|
|
253
|
+
direction="down"
|
|
254
|
+
in={!showAddress}
|
|
255
|
+
container={container.current}
|
|
256
|
+
style={{
|
|
257
|
+
position: 'absolute',
|
|
258
|
+
}}
|
|
259
|
+
appear={false}
|
|
260
|
+
>
|
|
261
|
+
<Box
|
|
262
|
+
sx={{
|
|
263
|
+
pt: 0.25,
|
|
264
|
+
}}
|
|
265
|
+
>
|
|
266
|
+
{token.name}
|
|
267
|
+
</Box>
|
|
268
|
+
</Slide>
|
|
200
269
|
<Slide
|
|
201
270
|
direction="up"
|
|
202
271
|
in={showAddress}
|
|
@@ -212,77 +281,28 @@ export const TokenListItemButton: React.FC<TokenListItemButtonProps> = ({
|
|
|
212
281
|
display: 'flex',
|
|
213
282
|
}}
|
|
214
283
|
>
|
|
284
|
+
<Box
|
|
285
|
+
sx={{
|
|
286
|
+
display: 'flex',
|
|
287
|
+
alignItems: 'center',
|
|
288
|
+
pt: 0.125,
|
|
289
|
+
}}
|
|
290
|
+
>
|
|
291
|
+
{shortenAddress(token.address)}
|
|
292
|
+
</Box>
|
|
215
293
|
<OpenTokenDetailsButton
|
|
216
294
|
tokenAddress={token.address}
|
|
217
295
|
withoutContractAddress={withoutContractAddress}
|
|
296
|
+
chainId={token.chainId}
|
|
218
297
|
onClick={onShowTokenDetails}
|
|
219
298
|
/>
|
|
220
299
|
</Box>
|
|
221
300
|
</Slide>
|
|
222
301
|
</Box>
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
sx={{
|
|
228
|
-
position: 'relative',
|
|
229
|
-
height: 20,
|
|
230
|
-
}}
|
|
231
|
-
>
|
|
232
|
-
<Slide
|
|
233
|
-
direction="down"
|
|
234
|
-
in={!showAddress}
|
|
235
|
-
container={container.current}
|
|
236
|
-
style={{
|
|
237
|
-
position: 'absolute',
|
|
238
|
-
}}
|
|
239
|
-
appear={false}
|
|
240
|
-
>
|
|
241
|
-
<Box
|
|
242
|
-
sx={{
|
|
243
|
-
pt: 0.25,
|
|
244
|
-
}}
|
|
245
|
-
>
|
|
246
|
-
{token.name}
|
|
247
|
-
</Box>
|
|
248
|
-
</Slide>
|
|
249
|
-
<Slide
|
|
250
|
-
direction="up"
|
|
251
|
-
in={showAddress}
|
|
252
|
-
container={container.current}
|
|
253
|
-
style={{
|
|
254
|
-
position: 'absolute',
|
|
255
|
-
}}
|
|
256
|
-
appear={false}
|
|
257
|
-
mountOnEnter
|
|
258
|
-
>
|
|
259
|
-
<Box
|
|
260
|
-
sx={{
|
|
261
|
-
display: 'flex',
|
|
262
|
-
}}
|
|
263
|
-
>
|
|
264
|
-
<Box
|
|
265
|
-
sx={{
|
|
266
|
-
display: 'flex',
|
|
267
|
-
alignItems: 'center',
|
|
268
|
-
pt: 0.125,
|
|
269
|
-
}}
|
|
270
|
-
>
|
|
271
|
-
{shortenAddress(token.address)}
|
|
272
|
-
</Box>
|
|
273
|
-
<OpenTokenDetailsButton
|
|
274
|
-
tokenAddress={token.address}
|
|
275
|
-
withoutContractAddress={withoutContractAddress}
|
|
276
|
-
onClick={onShowTokenDetails}
|
|
277
|
-
/>
|
|
278
|
-
</Box>
|
|
279
|
-
</Slide>
|
|
280
|
-
</Box>
|
|
281
|
-
)
|
|
282
|
-
}
|
|
283
|
-
/>
|
|
284
|
-
{accountAddress ? (
|
|
285
|
-
isBalanceLoading ? (
|
|
302
|
+
)
|
|
303
|
+
}
|
|
304
|
+
/>
|
|
305
|
+
{isBalanceLoading ? (
|
|
286
306
|
<TokenAmountSkeleton />
|
|
287
307
|
) : (
|
|
288
308
|
<Box sx={{ textAlign: 'right' }}>
|
|
@@ -299,7 +319,7 @@ export const TokenListItemButton: React.FC<TokenListItemButtonProps> = ({
|
|
|
299
319
|
})}
|
|
300
320
|
</Typography>
|
|
301
321
|
) : null}
|
|
302
|
-
{
|
|
322
|
+
{token.amount && token.priceUSD ? (
|
|
303
323
|
<Typography
|
|
304
324
|
data-price={token.priceUSD}
|
|
305
325
|
sx={{
|
|
@@ -314,23 +334,26 @@ export const TokenListItemButton: React.FC<TokenListItemButtonProps> = ({
|
|
|
314
334
|
</Typography>
|
|
315
335
|
) : null}
|
|
316
336
|
</Box>
|
|
317
|
-
)
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
337
|
+
)}
|
|
338
|
+
</ListItemButton>
|
|
339
|
+
)
|
|
340
|
+
}
|
|
341
|
+
)
|
|
322
342
|
|
|
323
343
|
export const TokenListItemSkeleton = () => {
|
|
324
344
|
return (
|
|
325
345
|
<ListItem
|
|
326
346
|
secondaryAction={<TokenAmountSkeleton />}
|
|
327
347
|
disablePadding
|
|
328
|
-
sx={{
|
|
348
|
+
sx={(theme) => ({
|
|
329
349
|
position: 'relative',
|
|
330
350
|
flexDirection: 'row',
|
|
331
351
|
alignItems: 'center',
|
|
332
352
|
padding: 0,
|
|
333
|
-
|
|
353
|
+
[`& .${listItemSecondaryActionClasses.root}`]: {
|
|
354
|
+
right: theme.spacing(1.5),
|
|
355
|
+
},
|
|
356
|
+
})}
|
|
334
357
|
>
|
|
335
358
|
<ListItemAvatar>
|
|
336
359
|
<Skeleton
|
|
@@ -348,7 +371,7 @@ export const TokenListItemSkeleton = () => {
|
|
|
348
371
|
)
|
|
349
372
|
}
|
|
350
373
|
|
|
351
|
-
|
|
374
|
+
const TokenAmountSkeleton: React.FC = () => {
|
|
352
375
|
return (
|
|
353
376
|
<Box
|
|
354
377
|
sx={{
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Typography } from '@mui/material'
|
|
2
2
|
import { useVirtualizer } from '@tanstack/react-virtual'
|
|
3
3
|
import type { FC } from 'react'
|
|
4
|
-
import { useCallback, useEffect, useRef } from 'react'
|
|
4
|
+
import { useCallback, useEffect, useMemo, useRef } from 'react'
|
|
5
5
|
import { useTranslation } from 'react-i18next'
|
|
6
|
+
import { useAvailableChains } from '../../hooks/useAvailableChains.js'
|
|
6
7
|
import type { TokenAmount } from '../../types/token.js'
|
|
7
8
|
import { TokenDetailsSheet } from './TokenDetailsSheet.js'
|
|
8
9
|
import { List } from './TokenList.style.js'
|
|
@@ -12,50 +13,64 @@ import type {
|
|
|
12
13
|
VirtualizedTokenListProps,
|
|
13
14
|
} from './types.js'
|
|
14
15
|
|
|
16
|
+
const tokenItemHeight = 64 // 60 + 4px margin-bottom
|
|
17
|
+
|
|
15
18
|
export const VirtualizedTokenList: FC<VirtualizedTokenListProps> = ({
|
|
16
|
-
account,
|
|
17
19
|
tokens,
|
|
18
20
|
scrollElementRef,
|
|
19
21
|
chainId,
|
|
20
|
-
chain,
|
|
21
22
|
selectedTokenAddress,
|
|
22
23
|
isLoading,
|
|
23
24
|
isBalanceLoading,
|
|
24
25
|
showCategories,
|
|
25
26
|
onClick,
|
|
27
|
+
isAllNetworks,
|
|
26
28
|
}) => {
|
|
27
29
|
const { t } = useTranslation()
|
|
28
30
|
|
|
31
|
+
const { chains } = useAvailableChains()
|
|
32
|
+
|
|
33
|
+
// Create Set for O(1) chain lookup instead of O(n) find
|
|
34
|
+
const chainsSet = useMemo(() => {
|
|
35
|
+
if (!chains) {
|
|
36
|
+
return undefined
|
|
37
|
+
}
|
|
38
|
+
return new Map(chains.map((chain) => [chain.id, chain]))
|
|
39
|
+
}, [chains])
|
|
40
|
+
|
|
29
41
|
const tokenDetailsSheetRef = useRef<TokenDetailsSheetBase>(null)
|
|
30
42
|
|
|
31
43
|
const onShowTokenDetails = useCallback(
|
|
32
|
-
(tokenAddress: string, noContractAddress: boolean) => {
|
|
33
|
-
tokenDetailsSheetRef.current?.open(
|
|
44
|
+
(tokenAddress: string, noContractAddress: boolean, chainId: number) => {
|
|
45
|
+
tokenDetailsSheetRef.current?.open(
|
|
46
|
+
tokenAddress,
|
|
47
|
+
noContractAddress,
|
|
48
|
+
chainId
|
|
49
|
+
)
|
|
34
50
|
},
|
|
35
51
|
[]
|
|
36
52
|
)
|
|
37
53
|
|
|
38
54
|
const getItemKey = useCallback(
|
|
39
55
|
(index: number) => {
|
|
40
|
-
|
|
56
|
+
const token = tokens[index]
|
|
57
|
+
return `${token.chainId}-${token.address}-${index}`
|
|
41
58
|
},
|
|
42
59
|
[tokens]
|
|
43
60
|
)
|
|
44
61
|
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
getScrollElement: () => scrollElementRef.current,
|
|
50
|
-
estimateSize: (index) => {
|
|
62
|
+
const estimateSize = useCallback(
|
|
63
|
+
(index: number) => {
|
|
64
|
+
const currentToken = tokens[index]
|
|
65
|
+
|
|
51
66
|
// Base size for TokenListItem
|
|
52
|
-
let size =
|
|
67
|
+
let size = tokenItemHeight
|
|
68
|
+
|
|
53
69
|
// Early return if categories are not shown
|
|
54
70
|
if (!showCategories) {
|
|
55
71
|
return size
|
|
56
72
|
}
|
|
57
73
|
|
|
58
|
-
const currentToken = tokens[index]
|
|
59
74
|
const previousToken = tokens[index - 1]
|
|
60
75
|
|
|
61
76
|
// Adjust size for the first featured token
|
|
@@ -75,8 +90,30 @@ export const VirtualizedTokenList: FC<VirtualizedTokenListProps> = ({
|
|
|
75
90
|
|
|
76
91
|
return size
|
|
77
92
|
},
|
|
78
|
-
|
|
79
|
-
|
|
93
|
+
[tokens, showCategories]
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
// Chunk the tokens for infinite loading simulation
|
|
97
|
+
const virtualizerConfig = useMemo(
|
|
98
|
+
() => ({
|
|
99
|
+
count: tokens.length,
|
|
100
|
+
overscan: 5,
|
|
101
|
+
getScrollElement: () => scrollElementRef.current,
|
|
102
|
+
estimateSize,
|
|
103
|
+
getItemKey,
|
|
104
|
+
}),
|
|
105
|
+
[tokens.length, estimateSize, getItemKey, scrollElementRef]
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
const { getVirtualItems, getTotalSize, scrollToIndex, measure } =
|
|
109
|
+
useVirtualizer(virtualizerConfig)
|
|
110
|
+
|
|
111
|
+
// Address the issue of disappearing tokens on rerender
|
|
112
|
+
useEffect(() => {
|
|
113
|
+
if (scrollElementRef.current) {
|
|
114
|
+
measure()
|
|
115
|
+
}
|
|
116
|
+
}, [measure, scrollElementRef.current])
|
|
80
117
|
|
|
81
118
|
// biome-ignore lint/correctness/useExhaustiveDependencies: run only when chainId changes
|
|
82
119
|
useEffect(() => {
|
|
@@ -86,17 +123,7 @@ export const VirtualizedTokenList: FC<VirtualizedTokenListProps> = ({
|
|
|
86
123
|
}
|
|
87
124
|
// Close the token details sheet when switching the chains
|
|
88
125
|
tokenDetailsSheetRef.current?.close()
|
|
89
|
-
}, [scrollToIndex, chainId, getVirtualItems])
|
|
90
|
-
|
|
91
|
-
if (isLoading) {
|
|
92
|
-
return (
|
|
93
|
-
<List disablePadding>
|
|
94
|
-
{Array.from({ length: 3 }).map((_, index) => (
|
|
95
|
-
<TokenListItemSkeleton key={index} />
|
|
96
|
-
))}
|
|
97
|
-
</List>
|
|
98
|
-
)
|
|
99
|
-
}
|
|
126
|
+
}, [scrollToIndex, isAllNetworks, chainId, getVirtualItems])
|
|
100
127
|
|
|
101
128
|
return (
|
|
102
129
|
<>
|
|
@@ -109,6 +136,8 @@ export const VirtualizedTokenList: FC<VirtualizedTokenListProps> = ({
|
|
|
109
136
|
const currentToken = tokens[item.index]
|
|
110
137
|
const previousToken: TokenAmount | undefined = tokens[item.index - 1]
|
|
111
138
|
|
|
139
|
+
const chain = chainsSet?.get(currentToken.chainId)
|
|
140
|
+
|
|
112
141
|
const isFirstFeaturedToken = currentToken.featured && item.index === 0
|
|
113
142
|
|
|
114
143
|
const isTransitionFromFeaturedTokens =
|
|
@@ -129,23 +158,28 @@ export const VirtualizedTokenList: FC<VirtualizedTokenListProps> = ({
|
|
|
129
158
|
isTransitionFromFeaturedTokens ||
|
|
130
159
|
(previousToken?.popular && !currentToken.popular)
|
|
131
160
|
|
|
132
|
-
const startAdornmentLabel =
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
161
|
+
const startAdornmentLabel =
|
|
162
|
+
!isAllNetworks && showCategories
|
|
163
|
+
? (() => {
|
|
164
|
+
if (isFirstFeaturedToken) {
|
|
165
|
+
return t('main.featuredTokens')
|
|
166
|
+
}
|
|
167
|
+
if (isTransitionToMyTokens) {
|
|
168
|
+
return t('main.myTokens')
|
|
169
|
+
}
|
|
170
|
+
if (isTransitionToPopularTokens) {
|
|
171
|
+
return t('main.popularTokens')
|
|
172
|
+
}
|
|
173
|
+
if (shouldShowAllTokensCategory) {
|
|
174
|
+
return t('main.allTokens')
|
|
175
|
+
}
|
|
176
|
+
return null
|
|
177
|
+
})()
|
|
178
|
+
: null
|
|
179
|
+
|
|
180
|
+
const isSelected =
|
|
181
|
+
selectedTokenAddress === currentToken.address &&
|
|
182
|
+
chainId === currentToken.chainId
|
|
149
183
|
|
|
150
184
|
return (
|
|
151
185
|
<TokenListItem
|
|
@@ -154,11 +188,10 @@ export const VirtualizedTokenList: FC<VirtualizedTokenListProps> = ({
|
|
|
154
188
|
size={item.size}
|
|
155
189
|
start={item.start}
|
|
156
190
|
token={currentToken}
|
|
157
|
-
chain={chain}
|
|
158
|
-
selected={
|
|
191
|
+
chain={isAllNetworks ? chain : undefined}
|
|
192
|
+
selected={isSelected}
|
|
159
193
|
onShowTokenDetails={onShowTokenDetails}
|
|
160
194
|
isBalanceLoading={isBalanceLoading}
|
|
161
|
-
accountAddress={account.address}
|
|
162
195
|
startAdornment={
|
|
163
196
|
startAdornmentLabel ? (
|
|
164
197
|
<Typography
|
|
@@ -179,7 +212,14 @@ export const VirtualizedTokenList: FC<VirtualizedTokenListProps> = ({
|
|
|
179
212
|
)
|
|
180
213
|
})}
|
|
181
214
|
</List>
|
|
182
|
-
<TokenDetailsSheet ref={tokenDetailsSheetRef}
|
|
215
|
+
<TokenDetailsSheet ref={tokenDetailsSheetRef} />
|
|
216
|
+
{isLoading && (
|
|
217
|
+
<List disablePadding sx={{ cursor: 'default' }}>
|
|
218
|
+
{Array.from({ length: 3 }).map((_, index) => (
|
|
219
|
+
<TokenListItemSkeleton key={index} />
|
|
220
|
+
))}
|
|
221
|
+
</List>
|
|
222
|
+
)}
|
|
183
223
|
</>
|
|
184
224
|
)
|
|
185
225
|
}
|