Skip to content

fix(chains): build explorer api requests with URL params#4602

Open
tn0vak wants to merge 1 commit into
wevm:mainfrom
tn0vak:chains-explorer-apiurl-searchparams
Open

fix(chains): build explorer api requests with URL params#4602
tn0vak wants to merge 1 commit into
wevm:mainfrom
tn0vak:chains-explorer-apiurl-searchparams

Conversation

@tn0vak
Copy link
Copy Markdown

@tn0vak tn0vak commented May 12, 2026

What is this PR solving?

This PR fixes how blockExplorer.apiUrl requests are built in test/scripts/chains.test.ts.

Previously, the test appended query params via string concatenation:

  • ${blockExplorer.apiUrl}?module=...

That breaks or becomes ambiguous when apiUrl already contains query params (for example ?chainid=...) or ends with ?.
As a result, URL construction could be incorrect and chain metadata validation could produce false failures.

This PR updates the request construction to use URL + searchParams, which safely merges params and preserves existing query values.

Additionally, it normalizes one malformed definition:

  • src/chains/definitions/morphHolesky.ts
  • apiUrl changed from https://explorer-api-holesky.morphl2.io/api? to https://explorer-api-holesky.morphl2.io/api

Alternatives considered

  • Keep string concatenation and special-case ? handling with manual conditionals.
    • Rejected: still fragile and easy to regress.
  • Rewrite all chain apiUrl entries to enforce a no-query convention.
    • Rejected: unnecessary scope increase, and some URLs intentionally include required query params (e.g. chainid for Etherscan v2).
  • Use URLSearchParams over URL.
    • Chosen: robust, minimal, and standards-based.

Areas for reviewer attention

Please focus on:

  • The blockExplorer.apiUrl test path in test/scripts/chains.test.ts.
  • Whether preserving pre-existing query params (like chainid) is the expected behavior.
  • The single normalization in morphHolesky.ts and that no unrelated chain definitions were changed.

Tests

  • Updated path is covered by existing test/scripts/chains.test.ts blockExplorer.apiUrl checks.
  • No new test file added; this PR fixes the request-construction logic in the existing test path.

Documentation impact

No documentation changes are required.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 12, 2026

@tn0vak is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 12, 2026

⚠️ No Changeset found

Latest commit: a15020e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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.

1 participant