Skip to content

feat: parse solscan and orb markets URLs in search bar#891

Open
arihantbansal wants to merge 4 commits intosolana-foundation:masterfrom
arihantbansal:feat/external-explorer-url-search
Open

feat: parse solscan and orb markets URLs in search bar#891
arihantbansal wants to merge 4 commits intosolana-foundation:masterfrom
arihantbansal:feat/external-explorer-url-search

Conversation

@arihantbansal
Copy link

Description

  • Adds support for pasting Solscan and Orb Markets URLs into the search bar
  • Automatically resolves to the corresponding local account/tx/block/epoch page
  • Preserves cluster context from the source URL (e.g. devnet links navigate to devnet)

Type of change

  • Bug fix
  • New feature
  • Protocol integration
  • Documentation update
  • Other (please describe):

Screenshots

Testing

Related Issues

Checklist

  • My code follows the project's style guidelines
  • I have added tests that prove my fix/feature works
  • All tests pass locally and in CI
  • I have updated documentation as needed
  • I have run build:info script to update build information
  • CI/CD checks pass
  • I have included screenshots for protocol screens (if applicable)
  • For security-related features, I have included links to related information

Additional Notes

@vercel
Copy link

vercel bot commented Mar 19, 2026

@arihantbansal is attempting to deploy a commit to the Solana Foundation Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 19, 2026

Greptile Summary

This PR adds support for pasting Solscan and Orb Markets URLs directly into the search bar, automatically resolving them to the corresponding local explorer pages for accounts, transactions, blocks, and epochs. The implementation is well-structured: a new parseExternalExplorerUrl utility handles URL parsing and cluster extraction, a new preserveSearchParams flag on SearchElement signals when the external URL's cluster should override the user's current cluster, and SearchBar correctly inverts the pickClusterParams argument order for that case.

Key findings:

  • Mainnet-beta cluster not preserved when explicitly specified — When a source URL carries an explicit ?cluster=mainnet-beta, hasNonDefaultCluster is false (because mainnet-beta is treated as the default), so preserveSearchParams is never set. A user currently browsing devnet who pastes such a URL will stay on devnet instead of being redirected to mainnet, potentially viewing devnet data for a mainnet-only address or transaction. The devnet/testnet symmetry is incomplete.
  • Missing test for explicit ?cluster=mainnet-beta — The test suite covers the no-param mainnet case and unknown clusters like localnet, but not the explicit ?cluster=mainnet-beta case.
  • No validation/decoding of the URL identifier — The raw percent-encoded path segment is used as-is; a pathological URL like https://solscan.io/account/%20 would navigate to /address/%20.

Confidence Score: 3/5

  • Safe to merge for devnet/testnet URL handling, but the mainnet-beta cluster gap can silently misdirect users browsing devnet who paste mainnet links.
  • Core feature (devnet/testnet cluster preservation) works correctly and is well-tested. However, the explicit ?cluster=mainnet-beta edge case is unhandled and untested, which violates the stated goal of "preserving cluster context from the source URL" for the most common cluster (mainnet). This is a logic gap rather than a catastrophic bug, but it can cause real user confusion.
  • app/utils/external-explorer-url.ts — the hasNonDefaultCluster logic on line 81 needs to handle explicit mainnet-beta; app/utils/tests/external-explorer-url.test.ts — missing test case for ?cluster=mainnet-beta

Important Files Changed

Filename Overview
app/utils/external-explorer-url.ts New utility that parses Solscan and Orb Markets URLs into local SearchElement objects. Core logic is sound, but the mainnet-beta cluster handling is incomplete: an explicit ?cluster=mainnet-beta param is silently dropped, meaning a user browsing devnet who pastes a mainnet link stays on devnet instead of being redirected to mainnet.
app/utils/tests/external-explorer-url.test.ts Good coverage of happy-path and edge cases (www prefix, sub-paths, unknown clusters, protocol variants). Missing one test: explicit ?cluster=mainnet-beta in the source URL.
app/components/SearchBar.tsx Integration of parseExternalExplorerUrl into the search pipeline is clean. The preserveSearchParams flag correctly inverts the pickClusterParams argument order to give the external URL's cluster priority. Only affected by the mainnet-beta gap in the utility function.
app/utils/token-search.ts Only change is the addition of the optional preserveSearchParams field to the SearchElement type. Well-documented with a JSDoc comment.

Sequence Diagram

sequenceDiagram
    participant User
    participant SearchBar
    participant parseExternalExplorerUrl
    participant pickClusterParams
    participant Router

    User->>SearchBar: paste external URL (e.g. solscan.io/account/xxx?cluster=devnet)
    SearchBar->>parseExternalExplorerUrl: buildOptions(search)
    parseExternalExplorerUrl-->>SearchBar: SearchElement { pathname: "/address/xxx?cluster=devnet", preserveSearchParams: true }

    User->>SearchBar: select option
    SearchBar->>SearchBar: pathname.includes("?") → true
    SearchBar->>pickClusterParams: (path, currentClusterParams, pathnameParams) [preserveSearchParams swaps arg order]
    Note over pickClusterParams: pathnameParams (cluster=devnet) overrides<br/>currentClusterParams (user's current cluster)
    pickClusterParams-->>SearchBar: "/address/xxx?cluster=devnet"
    SearchBar->>Router: router.push("/address/xxx?cluster=devnet")

    Note over SearchBar,Router: If source URL has no cluster param (mainnet-beta default),<br/>preserveSearchParams is NOT set and user's current cluster is preserved
Loading

Last reviewed commit: "chore: update build ..."


// When preserveSearchParams is set (external explorer URLs), the pathname's
// params take priority over the current cluster context.
const nextPath = preserveSearchParams
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: There is a bug. Reproduce:

  1. Go http://localhost:3000/?cluster=devnet
  2. Paste https://solscan.io/account/AU971DrPyhhrpRnmEBp5pDTWL2ny7nofb5vYBjDJkR2E?cluster=mainnet-beta OR https://solscan.io/account/AU971DrPyhhrpRnmEBp5pDTWL2ny7nofb5vYBjDJkR2E
  3. It will preserve devnet cluster (but should redirect to the main cluster) for each case

@askov
Copy link
Contributor

askov commented Mar 20, 2026

Hey, @arihantbansal! Thank you for your contribution, this is a valuable feature to have! A few general notes in addition to the review comments:

  1. Please remove the unrelated change to pnpm-lock.yaml
  2. Please add some instructions in the testing section (e.g., visit page A, paste string B, etc.) along with a screenshot that showcases your change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants