Commit 2736d944 authored by Charles Bachmeier's avatar Charles Bachmeier Committed by GitHub

feat: Add base support to Explore & Search (#7165)

* filter search results

* feat: add full base TDP support

* add base to uni wallet supported chains
parent 57b098f3
...@@ -362,9 +362,6 @@ function ComingSoonText({ chainId }: { chainId: ChainId }) { ...@@ -362,9 +362,6 @@ function ComingSoonText({ chainId }: { chainId: ChainId }) {
return <Trans>Coming soon: search and explore tokens on BNB Chain</Trans> return <Trans>Coming soon: search and explore tokens on BNB Chain</Trans>
case ChainId.AVALANCHE: case ChainId.AVALANCHE:
return <Trans>Coming soon: search and explore tokens on Avalanche Chain</Trans> return <Trans>Coming soon: search and explore tokens on Avalanche Chain</Trans>
case ChainId.BASE:
case ChainId.BASE_GOERLI:
return <Trans>Coming soon: search and explore tokens on Base</Trans>
default: default:
return null return null
} }
......
...@@ -8,4 +8,4 @@ export const SMALL_MEDIA_BREAKPOINT = '540px' ...@@ -8,4 +8,4 @@ export const SMALL_MEDIA_BREAKPOINT = '540px'
export const MOBILE_MEDIA_BREAKPOINT = '420px' export const MOBILE_MEDIA_BREAKPOINT = '420px'
// includes chains that the backend does not current source off-chain metadata for // includes chains that the backend does not current source off-chain metadata for
export const UNSUPPORTED_METADATA_CHAINS = [ChainId.BNB, ChainId.AVALANCHE, ChainId.BASE_GOERLI, ChainId.BASE] export const UNSUPPORTED_METADATA_CHAINS = [ChainId.BNB, ChainId.AVALANCHE]
import { ChainId, SUPPORTED_CHAINS, SupportedChainsType } from '@uniswap/sdk-core' import { ChainId, SUPPORTED_CHAINS, SupportedChainsType } from '@uniswap/sdk-core'
export const UniWalletSupportedChains = [ChainId.MAINNET, ChainId.ARBITRUM_ONE, ChainId.OPTIMISM, ChainId.POLYGON] export const UniWalletSupportedChains = [
ChainId.MAINNET,
ChainId.ARBITRUM_ONE,
ChainId.OPTIMISM,
ChainId.POLYGON,
ChainId.BASE,
]
export const CHAIN_IDS_TO_NAMES = { export const CHAIN_IDS_TO_NAMES = {
[ChainId.MAINNET]: 'mainnet', [ChainId.MAINNET]: 'mainnet',
......
...@@ -4,7 +4,7 @@ import { useMemo } from 'react' ...@@ -4,7 +4,7 @@ import { useMemo } from 'react'
import invariant from 'tiny-invariant' import invariant from 'tiny-invariant'
import { Chain, SearchTokensQuery, useSearchTokensQuery } from './__generated__/types-and-hooks' import { Chain, SearchTokensQuery, useSearchTokensQuery } from './__generated__/types-and-hooks'
import { chainIdToBackendName } from './util' import { BACKEND_SUPPORTED_CHAINS, chainIdToBackendName } from './util'
gql` gql`
query SearchTokens($searchQuery: String!) { query SearchTokens($searchQuery: String!) {
...@@ -96,7 +96,10 @@ export function useSearchTokens(searchQuery: string, chainId: number) { ...@@ -96,7 +96,10 @@ export function useSearchTokens(searchQuery: string, chainId: number) {
const searchChain = chainIdToBackendName(chainId) const searchChain = chainIdToBackendName(chainId)
// Stores results, allowing overwriting cross-chain tokens w/ more 'relevant token' // Stores results, allowing overwriting cross-chain tokens w/ more 'relevant token'
const selectionMap: { [projectId: string]: SearchToken } = {} const selectionMap: { [projectId: string]: SearchToken } = {}
data?.searchTokens?.forEach((token) => { const filteredTokens = data?.searchTokens?.filter((token) =>
(BACKEND_SUPPORTED_CHAINS as ReadonlyArray<Chain>).includes(token.chain)
)
filteredTokens?.forEach((token) => {
if (token.project?.id) { if (token.project?.id) {
const existing = selectionMap[token.project.id] const existing = selectionMap[token.project.id]
selectionMap[token.project.id] = dedupeCrosschainTokens(token, existing, searchChain) selectionMap[token.project.id] = dedupeCrosschainTokens(token, existing, searchChain)
......
...@@ -87,6 +87,7 @@ export const CHAIN_ID_TO_BACKEND_NAME: { [key: number]: InterfaceGqlChain } = { ...@@ -87,6 +87,7 @@ export const CHAIN_ID_TO_BACKEND_NAME: { [key: number]: InterfaceGqlChain } = {
[ChainId.OPTIMISM_GOERLI]: Chain.Optimism, [ChainId.OPTIMISM_GOERLI]: Chain.Optimism,
[ChainId.BNB]: Chain.Bnb, [ChainId.BNB]: Chain.Bnb,
[ChainId.AVALANCHE]: Chain.Avalanche, [ChainId.AVALANCHE]: Chain.Avalanche,
[ChainId.BASE]: Chain.Base,
} }
export function chainIdToBackendName(chainId: number | undefined) { export function chainIdToBackendName(chainId: number | undefined) {
...@@ -128,6 +129,7 @@ const URL_CHAIN_PARAM_TO_BACKEND: { [key: string]: InterfaceGqlChain } = { ...@@ -128,6 +129,7 @@ const URL_CHAIN_PARAM_TO_BACKEND: { [key: string]: InterfaceGqlChain } = {
optimism: Chain.Optimism, optimism: Chain.Optimism,
bnb: Chain.Bnb, bnb: Chain.Bnb,
avalanche: Chain.Avalanche, avalanche: Chain.Avalanche,
base: Chain.Base,
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment