fix: resolve token block explorer from network configurations#29686
Conversation
After built-in and PopularList lookups, resolve EVM explorers via findBlockExplorerUrlForChain so token details use the asset chain's NetworkController config when the global provider is another network.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: Impacted components:
Why these tags:
Risk assessment: Medium - the change is a fallback path that only activates when the primary lookup fails, so it's unlikely to break existing flows. However, it touches a widely-used hook that affects multiple user-facing features. Performance Test Selection: |
|



Description
Token details (for example View on block explorer from the More menu) pass the asset chain id, but
useBlockExploreronly used built-in /PopularListexplorers, then fell back to Etherscan using the globally selected network. Chains such as Gnosis (0x64) can have a block explorer inNetworkControllerwhile the user stays on Ethereum; those URLs were ignored.After the built-in /
PopularListlookup, the hook now callsfindBlockExplorerUrlForChain(currentChainId, networkConfigurations)so URLs match the token's chain.Changelog
CHANGELOG entry: Fixed token details opening Etherscan instead of the correct block explorer for tokens on custom or non–PopularList networks when another EVM network was selected.
Related issues
Fixes: #26211
Refs: https://consensyssoftware.atlassian.net/browse/TMCU-709
Manual testing steps
Screenshots/Recordings
Before
After
blockexplorer.mp4
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Low Risk
Low risk: change is limited to block-explorer URL/name resolution order and adds targeted tests; main impact is which external explorer URL is opened for certain chains.
Overview
Fixes token-chain explorer resolution by having
useBlockExplorerconsultfindBlockExplorerUrlForChain(currentChainId, networkConfigurations)when built-in/PopularListmappings don’t cover the chain, before falling back to RPC or Etherscan.Adds tests that simulate Ethereum selected with Gnosis configured to verify
getBlockExplorerBaseUrl,getBlockExplorerUrl, andgetBlockExplorerNameuse the configured Gnosis explorer for a token on0x64.Reviewed by Cursor Bugbot for commit 8ea2d35. Bugbot is set up for automated code reviews on this repo. Configure here.