Description
Loading the app surfaces Error: Native token not found for chain ID: 3 and Error: Native token not found for chain ID: 4 in the browser console. Chains 3 and 4 (Ropsten, Rinkeby) are deprecated testnets that viem/chains no longer ships, but @uniswap/default-token-list still includes tokens for them. combineTokenLists catches the buildNativeToken throw but calls console.error(err) before ignoring it, producing the noise on every cold load.
Origin trace: buildNativeToken (src/hooks/useTokenLists.ts:214) -> combineTokenLists (src/hooks/useTokenLists.ts:131) -> useTokenLists (src/hooks/useTokenLists.ts:63) -> home page TokenInput demo (src/components/pageComponents/home/Examples/demos/TokenInput/index.tsx:57).
Steps to reproduce
cp .env.example .env.local (leaves PUBLIC_USE_DEFAULT_TOKENS=true, the default)
pnpm install && pnpm dev
- Open the app on the home page (the TokenInput demo calls
useTokenLists)
- Open the browser devtools console
Expected vs actual behavior
Expected: No console errors when the fallback branch is intentional (the catch block already comments "ignore the error").
Actual: Two Error: Native token not found for chain ID: 3 and ... chain ID: 4 entries logged via console.error on every cold load.
Environment
@uniswap/default-token-list: 18.13.0
viem: per current pnpm-lock.yaml
Config: default .env.example (PUBLIC_USE_DEFAULT_TOKENS=true)
Additional context
The bundled list contains 4 tokens for chainId 3 and 227 for chainId 4, all unreachable because the app does not configure Ropsten/Rinkeby. Current impact is cosmetic (2 console errors), but the map also ends up with empty tokensByChainId[3] and tokensByChainId[4] buckets populated with unusable tokens.
Suggested fix paths:
- Option A (minimal): Drop the
console.error(err) at src/hooks/useTokenLists.ts:137. The branch already states "ignore the error" and falls back to an empty array; the log is inconsistent with that intent. Tradeoff: tokensByChainId[3] / tokensByChainId[4] still get populated with unusable tokens from the default list.
- Option B (recommended): Extend the filter at
src/hooks/useTokenLists.ts:115-119 to also drop tokens whose chainId is not present in viem/chains. Mirrors the existing non-EVM drop, removes the error at source, and keeps the map free of unreachable chain buckets. Add a test to src/hooks/useTokenLists.test.ts covering a token with a chainId absent from viem/chains.
Acceptance criteria:
- No
Native token not found errors logged when loading the app with default config.
tokensByChainId contains only chains supported by viem/chains.
- Tests cover the unsupported-chainId case.
pnpm lint, pnpm test, pnpm build all pass.
Description
Loading the app surfaces
Error: Native token not found for chain ID: 3andError: Native token not found for chain ID: 4in the browser console. Chains 3 and 4 (Ropsten, Rinkeby) are deprecated testnets thatviem/chainsno longer ships, but@uniswap/default-token-liststill includes tokens for them.combineTokenListscatches thebuildNativeTokenthrow but callsconsole.error(err)before ignoring it, producing the noise on every cold load.Origin trace:
buildNativeToken(src/hooks/useTokenLists.ts:214) ->combineTokenLists(src/hooks/useTokenLists.ts:131) ->useTokenLists(src/hooks/useTokenLists.ts:63) -> home page TokenInput demo (src/components/pageComponents/home/Examples/demos/TokenInput/index.tsx:57).Steps to reproduce
cp .env.example .env.local(leavesPUBLIC_USE_DEFAULT_TOKENS=true, the default)pnpm install && pnpm devuseTokenLists)Expected vs actual behavior
Expected: No console errors when the fallback branch is intentional (the catch block already comments "ignore the error").
Actual: Two
Error: Native token not found for chain ID: 3and... chain ID: 4entries logged viaconsole.erroron every cold load.Environment
Additional context
The bundled list contains 4 tokens for chainId 3 and 227 for chainId 4, all unreachable because the app does not configure Ropsten/Rinkeby. Current impact is cosmetic (2 console errors), but the map also ends up with empty
tokensByChainId[3]andtokensByChainId[4]buckets populated with unusable tokens.Suggested fix paths:
console.error(err)atsrc/hooks/useTokenLists.ts:137. The branch already states "ignore the error" and falls back to an empty array; the log is inconsistent with that intent. Tradeoff:tokensByChainId[3]/tokensByChainId[4]still get populated with unusable tokens from the default list.src/hooks/useTokenLists.ts:115-119to also drop tokens whosechainIdis not present inviem/chains. Mirrors the existing non-EVM drop, removes the error at source, and keeps the map free of unreachable chain buckets. Add a test tosrc/hooks/useTokenLists.test.tscovering a token with a chainId absent fromviem/chains.Acceptance criteria:
Native token not founderrors logged when loading the app with default config.tokensByChainIdcontains only chains supported byviem/chains.pnpm lint,pnpm test,pnpm buildall pass.