From a4b70cb5687731bac785d779af045c8fb0fd2d9c Mon Sep 17 00:00:00 2001 From: Nguyen Van Viet Date: Mon, 31 Jul 2023 15:11:33 +0700 Subject: [PATCH] lp earning: enable all chains (#2123) * enable all chains * update env * disable polygon on legacy * revert env --------- Co-authored-by: Nam Nguyen --- src/constants/networks.ts | 14 ++--------- src/pages/MyEarnings/ElasticPools/index.tsx | 6 ++++- .../MultipleChainSelect/PopoverBody.tsx | 23 +++++++++++++++---- src/pages/MyEarnings/MyEarningStats/index.tsx | 6 ++++- 4 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/constants/networks.ts b/src/constants/networks.ts index 68b14c90c1..dcae7dff8e 100644 --- a/src/constants/networks.ts +++ b/src/constants/networks.ts @@ -199,17 +199,6 @@ export const SUPPORTED_NETWORKS_FOR_MY_EARNINGS = [ ChainId.MAINNET, ChainId.ARBITRUM, ChainId.OPTIMISM, - // ChainId.MATIC, - // ChainId.BSCMAINNET, - // ChainId.AVAXMAINNET, - // ChainId.FANTOM, - // ChainId.CRONOS, - // ChainId.BTTC, - // ChainId.VELAS, - // ChainId.AURORA, - // ChainId.OASIS, -] -export const COMING_SOON_NETWORKS_FOR_MY_EARNINGS = [ ChainId.MATIC, ChainId.BSCMAINNET, ChainId.AVAXMAINNET, @@ -219,8 +208,9 @@ export const COMING_SOON_NETWORKS_FOR_MY_EARNINGS = [ ChainId.VELAS, ChainId.AURORA, ChainId.OASIS, - ChainId.ZKSYNC, ] +export const COMING_SOON_NETWORKS_FOR_MY_EARNINGS: ChainId[] = [] +export const COMING_SOON_NETWORKS_FOR_MY_EARNINGS_LEGACY: ChainId[] = [ChainId.MATIC] // by pass invalid price impact/unable to calculate price impact/price impact too large export const CHAINS_BYPASS_PRICE_IMPACT = [ChainId.LINEA_TESTNET] diff --git a/src/pages/MyEarnings/ElasticPools/index.tsx b/src/pages/MyEarnings/ElasticPools/index.tsx index 7ce34d8335..5c93ce23ea 100644 --- a/src/pages/MyEarnings/ElasticPools/index.tsx +++ b/src/pages/MyEarnings/ElasticPools/index.tsx @@ -11,6 +11,7 @@ import styled from 'styled-components' import InfoHelper from 'components/InfoHelper' import LoaderWithKyberLogo from 'components/LocalLoader' import { EMPTY_ARRAY } from 'constants/index' +import { COMING_SOON_NETWORKS_FOR_MY_EARNINGS_LEGACY } from 'constants/networks' import { VERSION } from 'constants/v2' import { useActiveWeb3React } from 'hooks' import useDebounce from 'hooks/useDebounce' @@ -81,7 +82,10 @@ const ElasticPools = () => { const searchText = useDebounce(originalSearchText, 300).toLowerCase().trim() const elasticEarningQueryResponse = useGetElasticEarningQuery({ account, chainIds: selectedChainIds }) - const elasticLegacyEarningQueryResponse = useGetElasticLegacyEarningQuery({ account, chainIds: selectedChainIds }) + const elasticLegacyEarningQueryResponse = useGetElasticLegacyEarningQuery({ + account, + chainIds: selectedChainIds.filter(item => !COMING_SOON_NETWORKS_FOR_MY_EARNINGS_LEGACY.includes(item)), + }) const earningResponse = useMemo(() => { let data = elasticEarningQueryResponse.data diff --git a/src/pages/MyEarnings/MultipleChainSelect/PopoverBody.tsx b/src/pages/MyEarnings/MultipleChainSelect/PopoverBody.tsx index fd24808320..81706f63dc 100644 --- a/src/pages/MyEarnings/MultipleChainSelect/PopoverBody.tsx +++ b/src/pages/MyEarnings/MultipleChainSelect/PopoverBody.tsx @@ -11,12 +11,15 @@ import Checkbox from 'components/CheckBox' import { MouseoverTooltip } from 'components/Tooltip' import { COMING_SOON_NETWORKS_FOR_MY_EARNINGS, + COMING_SOON_NETWORKS_FOR_MY_EARNINGS_LEGACY, NETWORKS_INFO, SUPPORTED_NETWORKS_FOR_MY_EARNINGS, } from 'constants/networks' +import { VERSION } from 'constants/v2' import useMixpanel, { MIXPANEL_TYPE } from 'hooks/useMixpanel' import useTheme from 'hooks/useTheme' import { AppState } from 'state' +import { useAppSelector } from 'state/hooks' import { selectChains } from 'state/myEarnings/actions' import { StyledLogo } from '.' @@ -103,9 +106,17 @@ const PopoverBody: React.FC = ({ onClose }) => { const selectedChains = useSelector((state: AppState) => state.myEarnings.selectedChains) const dispatch = useDispatch() - const [localSelectedChains, setLocalSelectedChains] = useState(selectedChains) + const isLegacy = useAppSelector(state => state.myEarnings.activeTab === VERSION.ELASTIC_LEGACY) - const isAllSelected = localSelectedChains.length === SUPPORTED_NETWORKS_FOR_MY_EARNINGS.length + const comingSoonList = isLegacy ? COMING_SOON_NETWORKS_FOR_MY_EARNINGS_LEGACY : COMING_SOON_NETWORKS_FOR_MY_EARNINGS + + const [localSelectedChains, setLocalSelectedChains] = useState(() => + selectedChains.filter(item => !comingSoonList.includes(item)), + ) + + const networkList = SUPPORTED_NETWORKS_FOR_MY_EARNINGS.filter(item => !comingSoonList.includes(item)) + + const isAllSelected = localSelectedChains.length === networkList.length const handleChangeChains = (chains: ChainId[]) => { dispatch(selectChains(chains)) } @@ -124,7 +135,8 @@ const PopoverBody: React.FC = ({ onClose }) => { selectAllRef.current.indeterminate = indeterminate }, [localSelectedChains]) - const allNetworks = [...SUPPORTED_NETWORKS_FOR_MY_EARNINGS, ...COMING_SOON_NETWORKS_FOR_MY_EARNINGS] + const allNetworks = [...networkList, ...comingSoonList] + return ( = ({ onClose }) => { setLocalSelectedChains([]) } else { mixpanelHandler(MIXPANEL_TYPE.EARNING_DASHBOARD_CLICK_ALL_CHAINS_BUTTON) - setLocalSelectedChains(SUPPORTED_NETWORKS_FOR_MY_EARNINGS) + setLocalSelectedChains(networkList) } }} /> @@ -180,7 +192,8 @@ const PopoverBody: React.FC = ({ onClose }) => { {allNetworks.map((network, i) => { const config = NETWORKS_INFO[network] - const isComingSoon = COMING_SOON_NETWORKS_FOR_MY_EARNINGS.includes(network) + + const isComingSoon = comingSoonList.includes(network) const isSelected = isComingSoon ? false : localSelectedChains.includes(network) const handleClick = () => { diff --git a/src/pages/MyEarnings/MyEarningStats/index.tsx b/src/pages/MyEarnings/MyEarningStats/index.tsx index b206b73820..6193881964 100644 --- a/src/pages/MyEarnings/MyEarningStats/index.tsx +++ b/src/pages/MyEarnings/MyEarningStats/index.tsx @@ -5,6 +5,7 @@ import { Flex, Text } from 'rebass' import { useGetElasticEarningQuery, useGetElasticLegacyEarningQuery } from 'services/earning' import styled from 'styled-components' +import { COMING_SOON_NETWORKS_FOR_MY_EARNINGS_LEGACY } from 'constants/networks' import { useActiveWeb3React } from 'hooks' import useTheme from 'hooks/useTheme' import ChainSelect from 'pages/MyEarnings/ChainSelect' @@ -79,7 +80,10 @@ const MyEarningStats = () => { const tokensByChainId = useAppSelector(state => state.lists.mapWhitelistTokens) const elasticEarningQueryResponse = useGetElasticEarningQuery({ account, chainIds: selectedChainIds }) - const elasticLegacyEarningQueryResponse = useGetElasticLegacyEarningQuery({ account, chainIds: selectedChainIds }) + const elasticLegacyEarningQueryResponse = useGetElasticLegacyEarningQuery({ + account, + chainIds: selectedChainIds.filter(item => !COMING_SOON_NETWORKS_FOR_MY_EARNINGS_LEGACY.includes(item)), + }) // const classicEarningQueryResponse = useGetClassicEarningQuery({ account, chainIds: selectedChainIds }) const isLoading = elasticEarningQueryResponse.isFetching || elasticLegacyEarningQueryResponse.isFetching