Skip to content

fix: resolve token block explorer from network configurations#29686

Merged
wachunei merged 2 commits into
mainfrom
fix/TMCU-709-token-details-block-explorer
May 5, 2026
Merged

fix: resolve token block explorer from network configurations#29686
wachunei merged 2 commits into
mainfrom
fix/TMCU-709-token-details-block-explorer

Conversation

@wachunei

@wachunei wachunei commented May 4, 2026

Copy link
Copy Markdown
Member

Description

Token details (for example View on block explorer from the More menu) pass the asset chain id, but useBlockExplorer only used built-in / PopularList explorers, then fell back to Etherscan using the globally selected network. Chains such as Gnosis (0x64) can have a block explorer in NetworkController while the user stays on Ethereum; those URLs were ignored.

After the built-in / PopularList lookup, the hook now calls findBlockExplorerUrlForChain(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

Feature: Token details block explorer

  Scenario: Custom network token opens correct explorer
    Given the wallet has a custom or non–PopularList EVM network with a block explorer (e.g. Gnosis)
    And the globally selected network is Ethereum Mainnet
    And the user opens token details for a token on the custom network

    When the user opens the More menu and taps View on block explorer

    Then the in-app browser opens the block explorer for the token's chain, not Etherscan

Screenshots/Recordings

Before

After

blockexplorer.mp4

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

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 useBlockExplorer consult findBlockExplorerUrlForChain(currentChainId, networkConfigurations) when built-in/PopularList mappings 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, and getBlockExplorerName use the configured Gnosis explorer for a token on 0x64.

Reviewed by Cursor Bugbot for commit 8ea2d35. Bugbot is set up for automated code reviews on this repo. Configure here.

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.
@wachunei wachunei self-assigned this May 4, 2026
@metamaskbotv2 metamaskbotv2 Bot added the team-money-movement issues related to Money Movement features label May 4, 2026
@github-actions github-actions Bot added the size-S label May 4, 2026
@wachunei wachunei marked this pull request as ready for review May 4, 2026 19:26
@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeWalletPlatform, SmokeAccounts, SmokeSwap, SmokeConfirmations
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 82%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes add a fallback mechanism in useBlockExplorer.ts that uses findBlockExplorerUrlForChain to resolve block explorer URLs from networkConfigurations when the primary lookup fails. This is an additive change (fallback only) that doesn't break existing behavior.

Impacted components:

  • UnifiedTransactionsView - uses useBlockExplorer for transaction history links → SmokeWalletPlatform
  • HardwareWallet/AccountSelector - uses toBlockExplorer → SmokeAccounts
  • MultichainAccounts/ShareAddressQR - uses toBlockExplorer and getBlockExplorerName → SmokeAccounts
  • Bridge/useMultichainBlockExplorerTxUrl - uses useBlockExplorer for bridge tx links → SmokeSwap + SmokeConfirmations
  • TokenDetails/MoreTokenActionsMenu - uses useBlockExplorer for token details → SmokeWalletPlatform
  • AssetOptions - uses useBlockExplorer → SmokeWalletPlatform

Why these tags:

  • SmokeWalletPlatform: Transaction history and token details views use this hook
  • SmokeAccounts: Hardware wallet account selector and share address QR use this hook
  • SmokeSwap: Bridge hooks use this hook for block explorer URLs after swaps/bridges
  • SmokeConfirmations: Confirmations link to block explorers; SmokeSwap requires SmokeConfirmations per tag description

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:
The changes are limited to block explorer URL resolution logic (a utility hook). This is a fallback lookup mechanism that doesn't affect rendering performance, data loading, or any performance-critical paths. No performance tests are warranted.

View GitHub Actions results

@sonarqubecloud

sonarqubecloud Bot commented May 5, 2026

Copy link
Copy Markdown

@wachunei wachunei added this pull request to the merge queue May 5, 2026
Merged via the queue into main with commit dbfe481 May 5, 2026
102 checks passed
@wachunei wachunei deleted the fix/TMCU-709-token-details-block-explorer branch May 5, 2026 19:53
@github-actions github-actions Bot locked and limited conversation to collaborators May 5, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.77.0 Issue or pull request that will be included in release 7.77.0 label May 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.77.0 Issue or pull request that will be included in release 7.77.0 size-S team-money-movement issues related to Money Movement features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: View on block explorer for custom networks token details More button leads to Etherscan

2 participants