fix(svm): redirect native SOL placeholder mint to /native endpoint#478
Merged
fix(svm): redirect native SOL placeholder mint to /native endpoint#478
Conversation
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.
Contributor
There was a problem hiding this comment.
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
Setto recognize the system program address, theSo111...111placeholder, and thesol111...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.
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The redirect middleware for SVM native endpoints only matched the system program address (
11111...1). Our/v1/svm/*/nativeendpoints returnSo11111111111111111111111111111111111111111as 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:
So1..111placeholder to the redirect match listSetand normalizes to lowercase onceSo1..112) falling through to the normal SPL path (unchanged)Changes
src/middleware/nativeContractRedirect.ts: accept system program,So1..111, andsol1..1aliases 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