Skip to content

Commit

Permalink
disable polygon on legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
viet-nv committed Jul 31, 2023
1 parent 40ad9a1 commit 98a9a59
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/constants/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ export const SUPPORTED_NETWORKS_FOR_MY_EARNINGS = [
ChainId.OASIS,
]
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]
6 changes: 5 additions & 1 deletion src/pages/MyEarnings/ElasticPools/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down
23 changes: 18 additions & 5 deletions src/pages/MyEarnings/MultipleChainSelect/PopoverBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 '.'
Expand Down Expand Up @@ -103,9 +106,17 @@ const PopoverBody: React.FC<Props> = ({ 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))
}
Expand All @@ -124,7 +135,8 @@ const PopoverBody: React.FC<Props> = ({ onClose }) => {
selectAllRef.current.indeterminate = indeterminate
}, [localSelectedChains])

const allNetworks = [...SUPPORTED_NETWORKS_FOR_MY_EARNINGS, ...COMING_SOON_NETWORKS_FOR_MY_EARNINGS]
const allNetworks = [...networkList, ...comingSoonList]

return (
<Flex
sx={{
Expand Down Expand Up @@ -155,7 +167,7 @@ const PopoverBody: React.FC<Props> = ({ onClose }) => {
setLocalSelectedChains([])
} else {
mixpanelHandler(MIXPANEL_TYPE.EARNING_DASHBOARD_CLICK_ALL_CHAINS_BUTTON)
setLocalSelectedChains(SUPPORTED_NETWORKS_FOR_MY_EARNINGS)
setLocalSelectedChains(networkList)
}
}}
/>
Expand All @@ -180,7 +192,8 @@ const PopoverBody: React.FC<Props> = ({ onClose }) => {
<ChainListWrapper>
{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 = () => {
Expand Down
6 changes: 5 additions & 1 deletion src/pages/MyEarnings/MyEarningStats/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 98a9a59

Please sign in to comment.