fix: resolve NaN chainId when networkId is a slug#288
Merged
AugustoL merged 1 commit intoopenscan-explorer:devfrom Mar 10, 2026
Merged
Conversation
|
🚀 Preview: https://pr-288--openscan.netlify.app |
The address page passes the route parameter (e.g. 'eth') as networkId to
display components, which call Number(networkId). Number('eth') returns NaN,
causing metadata fetches to use NaN as chainId (404s).
Fix: use existing getNetworkById() + getChainIdFromNetwork() to properly
resolve the slug to a numeric chainId before passing to display components.
516626e to
785ffcd
Compare
Collaborator
Author
✅ Fix verifiedTested on Before (dev): Token Info section showed empty After (this fix):
Root cause: |
AugustoL
approved these changes
Mar 10, 2026
12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The address page receives the route parameter (e.g.
eth,base,arb) asnetworkIdand passes it to display components. Those components then callNumber(networkId)to get a numeric chainId.Number('eth')returnsNaN, causing metadata fetches to build URLs withNaNas the chainId:This means Token Info shows empty on address pages when accessed via slug routes (which is the default).
Fix
resolveChainId()utility tonetworkResolver.tsthat properly resolves slugs, numeric strings, and CAIP-2 networkIds to a numeric chainIdAddresscomponent to useresolveChainId()and pass the resolved numeric chainId (as string) to all display componentsChanges
src/utils/networkResolver.ts— newresolveChainId()functionsrc/components/pages/evm/address/index.tsx— useresolveChainId()instead ofNumber(networkId) || 1