fix: make eth in search bar navigate to eth token details (#4812)

* make eth in search bar navigate to eth token details

* use local resolving functions
This commit is contained in:
lynn 2022-10-05 22:44:27 -04:00 committed by GitHub
parent aaf105ef51
commit 19f175ba89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +1,6 @@
import { NATIVE_CHAIN_ID } from 'analytics/constants'
import { SupportedChainId } from 'constants/chains'
import { ZERO_ADDRESS } from 'constants/misc'
import { useAppSelector } from 'state/hooks'
import { Chain, HistoryDuration } from './__generated__/TokenQuery.graphql'
@ -79,7 +81,9 @@ export function isValidBackendChainName(chainName: string | undefined): chainNam
}
export function getTokenDetailsURL(address: string, chainName?: Chain, chainId?: number) {
if (chainName) {
if (address === ZERO_ADDRESS && chainId && chainId === SupportedChainId.MAINNET) {
return `/tokens/${CHAIN_ID_TO_BACKEND_NAME[chainId].toLowerCase()}/${NATIVE_CHAIN_ID}`
} else if (chainName) {
return `/tokens/${chainName.toLowerCase()}/${address}`
} else if (chainId) {
const chainName = CHAIN_ID_TO_BACKEND_NAME[chainId]