Skip to content

fix(svm): redirect native SOL placeholder mint to /native endpoint#478

Merged
0237h merged 2 commits intomainfrom
fix/svm-native-mint-redirect
Apr 16, 2026
Merged

fix(svm): redirect native SOL placeholder mint to /native endpoint#478
0237h merged 2 commits intomainfrom
fix/svm-native-mint-redirect

Conversation

@0237h
Copy link
Copy Markdown
Collaborator

@0237h 0237h commented Apr 16, 2026

Summary

The redirect middleware for SVM native endpoints only matched the system program address (11111...1). Our /v1/svm/*/native endpoints return So11111111111111111111111111111111111111111 as the mint placeholder, so users copying that value back into a regular endpoint would fall through to the SPL path and get zero results.

This PR:

  • Adds the So1..111 placeholder to the redirect match list
  • Consolidates aliases into a single Set and normalizes to lowercase once
  • Leaves real wSOL (So1..112) falling through to the normal SPL path (unchanged)

Changes

src/middleware/nativeContractRedirect.ts: accept system program, So1..111, and sol1..1 aliases case-insensitively.
src/middleware/nativeContractRedirect.spec.ts: extend coverage to all aliases and case variants, plus comma-separated and wSOL negative cases.


🤖 Generated with Claude Code

The native SVM endpoints return `So11111111111111111111111111111111111111111`
as the mint placeholder, but the redirect middleware only matched the
system program address `11111...1`. Users copying the mint from a native
response would fall through to the SPL transfers/balances/holders paths
and get zero results.

Consolidate aliases into a single case-insensitive Set and add the
`So1..111` placeholder. Real wSOL (`So1..112`) still falls through to
the normal SPL path.
Copy link
Copy Markdown
Contributor

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

Updates the SVM native-mint redirect middleware so requests using common native SOL “placeholder mint” aliases are redirected to the /native sub-route, preventing users from falling into SPL-token routes with zero results.

Changes:

  • Adds a shared alias Set to recognize the system program address, the So111...111 placeholder, and the sol111... legacy alias case-insensitively.
  • Simplifies the redirect condition to a single membership check against the alias set.
  • Extends unit tests to cover multiple alias variants, case variants, comma-separated cases, and the wSOL negative case.

Reviewed changes

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

File Description
src/middleware/nativeContractRedirect.ts Expands SVM native mint alias detection and consolidates matching logic via a Set.
src/middleware/nativeContractRedirect.spec.ts Adds/expands test coverage for new mint aliases and non-redirect scenarios.

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

Comment thread src/middleware/nativeContractRedirect.ts
…leware

The middleware used `searchParams.get()` which returns only the first value,
so a request like `?mint=<native>&mint=<other>` would redirect to /native and
silently drop the additional filter. Switch to `getAll()` and only redirect
when there is exactly one value and it matches an alias.

Applies the same treatment to `nativeContractRedirect` for EVM.
@YaroShkvorets YaroShkvorets temporarily deployed to fix/svm-native-mint-redirect - token-api PR #478 April 16, 2026 17:14 — with Render Destroyed
@0237h 0237h merged commit d4001aa into main Apr 16, 2026
2 of 3 checks passed
@0237h 0237h deleted the fix/svm-native-mint-redirect branch April 16, 2026 17:16
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.

3 participants