[Nexus] Fix: Reject partially numeric network IDs#8830
Conversation
|
@royalpinto007 is attempting to deploy a commit to the thirdweb Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: a1a3943 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (4)
WalkthroughAdds a strict ChangesStrict Network ID Parsing
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant networkToChainId
participant parseChainId
Caller->>networkToChainId: network string
networkToChainId->>parseChainId: parse numeric portion
parseChainId-->>networkToChainId: number or undefined
alt invalid or partially numeric
networkToChainId-->>Caller: throw Invalid network error
else valid safe integer
networkToChainId-->>Caller: return chain id
end
Related Issues: Suggested labels: patch, nexus Suggested reviewers: none identified 🎭 A digit that limps mid-string, 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Notes for the reviewer
Fixes #8829.
networkToChainIdpreviously used loose numeric parsing, so malformed values likeeip155:1abc,eip155:1.5, and1abccould be accepted as chain ID1. This PR adds strict chain ID parsing for CAIP-style and plain numeric network IDs before falling back to named networks.I also added a package-local Vitest script for
@thirdweb-dev/nexusso this parser behavior can be covered directly.How to test
pnpm --filter @thirdweb-dev/nexus testpnpm --filter @thirdweb-dev/nexus buildpnpm --filter @thirdweb-dev/nexus lintNote: lint passes and reports one existing warning in
packages/nexus/src/encode.tsaboutlet safebeing assignable asconst; I did not touch that unrelated file.PR-Codex overview
This PR focuses on enhancing the
networkToChainIdfunction in thenexuspackage to reject partially numeric network IDs, ensuring stricter validation for network identifiers.Detailed summary
networkToChainIdto reject partially numeric network IDs.parseChainIdfor improved validation.schemas.test.ts.vitestas a testing dependency inpackage.json.Summary by CodeRabbit