Skip to content

Support both chain slug and chain id in multichain page parameters#3338

Merged
tom2drum merged 3 commits intomainfrom
tom2drum/issue-3320
Apr 3, 2026
Merged

Support both chain slug and chain id in multichain page parameters#3338
tom2drum merged 3 commits intomainfrom
tom2drum/issue-3320

Conversation

@tom2drum
Copy link
Copy Markdown
Collaborator

@tom2drum tom2drum commented Apr 2, 2026

Description and Related Issue(s)

Resolves #3320

In multichain explorer mode, path segments and query parameters that identify a chain can use either the chain slug or the chain id, so links stay stable when slugs or display names change and stay aligned with backends that key on chain id.

Proposed Changes

  • Introduced getChainIdFromSlugOrId (replacing slug-only resolution) so a single path/query value is matched against configured chains by slug or id.
  • Updated getChainValueFromQuery so chain_slug_or_id (and related flow) resolves when the value is either a slug or an id.
  • Wired multichain routes, Multichain* page entry points, search redirect, token details, navigation, server-side props, and metadata/mixpanel page typing to use the shared resolution consistently.

Breaking or Incompatible Changes

None intended. Existing slug-based URLs should behave as before; additional acceptance of chain id is additive.

Additional Information

Checklist for PR author

  • I have tested these changes locally.
  • I added tests to cover any new functionality, following this guide
  • Whenever I fix a bug, I include a regression test to ensure that the bug does not reappear silently.
  • If I have added a feature or functionality that is not privacy-compliant (e.g., tracking, analytics, third-party services), I have disabled it for private mode.
  • If I have added, changed, renamed, or removed an environment variable
    • I updated the list of environment variables in the documentation
    • I made the necessary changes to the validator script according to the guide
    • I added "ENVs" label to this pull request

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 2, 2026

Important

Review skipped

Auto reviews are disabled on this repository. To trigger a review, include @coderabbitai review in the PR description. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b0a9faf4-e9cc-41f1-baf6-84146171fad9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@tom2drum tom2drum added the enhancement New feature or request label Apr 2, 2026
@tom2drum tom2drum requested a review from Copilot April 2, 2026 15:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds multichain routing support so chain identifiers in path/query can be resolved by either chain slug or chain id, improving link stability when slugs change.

Changes:

  • Introduces a shared resolver (getChainIdFromSlugOrId) and updates multichain context + SSR chain resolution to accept slug-or-id.
  • Renames multichain route param from chain_slug to chain_slug_or_id across routes, navigation highlighting, Mixpanel page typing, and metadata template maps.
  • Updates multichain page entry points and search redirects to generate/use the new route param.

Reviewed changes

Copilot reviewed 25 out of 29 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ui/token/TokenDetails.tsx Updates token tab navigation to push multichain token route using chain_slug_or_id.
ui/multichain/tx/MultichainTx.tsx Resolves chain by slug or id from chain_slug_or_id param before providing chain context.
ui/multichain/tokenInstance/MultichainTokenInstance.tsx Resolves chain by slug or id from chain_slug_or_id param for NFT instance page.
ui/multichain/token/MultichainToken.tsx Resolves chain by slug or id from chain_slug_or_id param for token page.
ui/multichain/searchResults/useSearchRedirect.tsx Updates redirects to use /chain/[chain_slug_or_id]/... routes and query key.
ui/multichain/block/MultichainBlock.tsx Resolves chain by slug or id from chain_slug_or_id param for block page.
pages/chain/[chain_slug_or_id]/visualize/sol2uml.tsx Adds multichain Sol2UML route entry point.
pages/chain/[chain_slug_or_id]/tx/[hash]/index.tsx Updates multichain tx page wrapper to use the new param name in pathname.
pages/chain/[chain_slug_or_id]/token/[hash]/instance/[id].tsx Adds multichain token instance route wrapper under new param name.
pages/chain/[chain_slug_or_id]/token/[hash]/index.tsx Adds multichain token route wrapper under new param name.
pages/chain/[chain_slug_or_id]/op/[hash].tsx Updates multichain user-op page wrapper pathname.
pages/chain/[chain_slug_or_id]/csv-export/index.tsx Updates multichain CSV export page wrapper pathname.
pages/chain/[chain_slug_or_id]/block/countdown/index.tsx Updates multichain block countdown index wrapper pathname.
pages/chain/[chain_slug_or_id]/block/countdown/[height].tsx Updates multichain block countdown wrapper pathname.
pages/chain/[chain_slug_or_id]/block/[height_or_hash].tsx Updates multichain block page wrapper pathname.
pages/chain/[chain_slug_or_id]/advanced-filter/index.tsx Updates multichain advanced filter wrapper pathname.
pages/chain/[chain_slug_or_id]/accounts/label/[slug].tsx Updates multichain accounts-by-label wrapper pathname.
nextjs/routes.ts Updates route helper to generate multichain-prefixed paths using chain_slug_or_id.
nextjs/nextjs-routes.d.ts Regenerates route typings to replace chain_slug with chain_slug_or_id.
nextjs/getServerSideProps/utils.ts Updates SSR multichain factory to resolve chain by slug or id from params.
lib/multichain/getChainValueFromQuery.ts Updates query-to-chain resolution to use chain_slug_or_id and match by slug or id.
lib/multichain/getChainIdFromSlugOrId.ts New shared helper to resolve chain id from slug-or-id input.
lib/multichain/getChainIdFromSlug.ts Removes old slug-only resolver.
lib/mixpanel/getPageType.ts Updates multichain route keys for Mixpanel page typing.
lib/metadata/templates/title.ts Updates metadata title template keys to new multichain route param name.
lib/metadata/templates/description.ts Updates metadata description template keys to new multichain route param name.
lib/metadata/getPageOgType.ts Updates OG page type map keys to new multichain route param name.
lib/hooks/useNavItems.tsx Updates nav active-route checks for multichain pathnames.
lib/contexts/multichain.tsx Updates context initialization to resolve chain id from chain_slug_or_id via new helper.
Comments suppressed due to low confidence (1)

lib/multichain/getChainValueFromQuery.ts:30

  • The new slug-or-id resolution behavior here is untested. Adding unit tests for getChainValueFromQuery (covering chain_id, chain_slug_or_id as slug, chain_slug_or_id as id, and invalid values/precedence) would help prevent regressions in multichain routing/query handling.
  const chainId = getQueryParamString(query.chain_id);
  const chainSlugOrId = getQueryParamString(query.chain_slug_or_id);

  if (chainId) {
    if (config.chains.some((chain) => chain.id === chainId)) {
      return chainId;
    }
  }

  if (chainSlugOrId) {
    const chain = config.chains.find((chain) => chain.slug === chainSlugOrId || chain.id === chainSlugOrId);
    if (chain) {
      return chain.id;
    }
  }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/multichain/getChainValueFromQuery.ts
@tom2drum tom2drum merged commit f15de5d into main Apr 3, 2026
12 checks passed
@tom2drum tom2drum deleted the tom2drum/issue-3320 branch April 3, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support both chain slug and chain id in page parameters in multichain explorer mode

2 participants