-
Notifications
You must be signed in to change notification settings - Fork 613
[X402] Simplify FacilitatorNetworkSchema to accept any string #8331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[X402] Simplify FacilitatorNetworkSchema to accept any string #8331
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: cba9f79 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
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 |
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
af9a0e7 to
cba9f79
Compare
WalkthroughAdded a patch release changeset. Modified the FacilitatorNetworkSchema in thirdweb package to accept any string value instead of a constrained union of specific network literals, removing prior network validation constraints. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
.changeset/five-plums-kiss.md(1 hunks)packages/thirdweb/src/x402/schemas.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from@/typesor localtypes.tsbarrels
Prefer type aliases over interface except for nominal shapes
Avoidanyandunknownunless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial,Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from@/typeswhere applicable
Prefertypealiases overinterfaceexcept for nominal shapes
Avoidanyandunknownunless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size
Files:
packages/thirdweb/src/x402/schemas.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)
Files:
packages/thirdweb/src/x402/schemas.ts
packages/thirdweb/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
packages/thirdweb/**/*.{ts,tsx}: Every public symbol must have comprehensive TSDoc with at least one compiling@exampleand a custom tag (@beta,@internal,@experimental, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
Lazy‑load heavy dependencies inside async paths (e.g.,const { jsPDF } = await import("jspdf"))
Files:
packages/thirdweb/src/x402/schemas.ts
.changeset/*.md
📄 CodeRabbit inference engine (AGENTS.md)
.changeset/*.md: Each change inpackages/*must include a changeset for the appropriate package
Version bump rules: patch for non‑API changes; minor for new/modified public API
Files:
.changeset/five-plums-kiss.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: Lint Packages
- GitHub Check: E2E Tests (pnpm, esbuild)
- GitHub Check: Size
- GitHub Check: E2E Tests (pnpm, webpack)
- GitHub Check: E2E Tests (pnpm, vite)
- GitHub Check: Unit Tests
- GitHub Check: Build Packages
- GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
.changeset/five-plums-kiss.md (1)
1-5: Verify the version bump level for this public API change.While loosening the
FacilitatorNetworkSchemaconstraint is backwards-compatible, it technically modifies a public API. The coding guidelines state "minor for new/modified public API" versus "patch for non‑API changes." Consider whether this should be a minor version bump instead of a patch.As per coding guidelines.
| const FacilitatorNetworkSchema = z.string(); | ||
|
|
||
| export type FacilitatorNetwork = z.infer<typeof FacilitatorNetworkSchema>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Add required TSDoc and verify runtime validation coverage.
The FacilitatorNetworkSchema is a public symbol (exported via the FacilitatorNetwork type) but lacks TSDoc documentation. According to the coding guidelines, every public symbol in packages/thirdweb/** must have comprehensive TSDoc with at least one compiling @example and a custom tag.
Additionally, this change shifts validation from schema-time to runtime (via the networkToChainId function at lines 95-116). Ensure that all code paths consuming FacilitatorNetwork values properly call networkToChainId or otherwise validate the network string before use.
As per coding guidelines.
Consider adding TSDoc like:
+/**
+ * Schema for facilitator network identifiers.
+ * Accepts any string value; runtime validation via `networkToChainId` is required.
+ *
+ * @example
+ * ```ts
+ * const network = FacilitatorNetworkSchema.parse("eip155:1");
+ * const chainId = networkToChainId(network);
+ * ```
+ *
+ * @public
+ */
const FacilitatorNetworkSchema = z.string();Run the following script to verify that network values are validated before use:
🏁 Script executed:
#!/bin/bash
# Description: Find usages of FacilitatorNetwork or properties named 'network' from these schemas
# to verify runtime validation is applied
echo "=== Searching for FacilitatorNetwork type usage ==="
rg -n "FacilitatorNetwork" --type ts -C 3
echo -e "\n=== Searching for networkToChainId calls ==="
rg -n "networkToChainId" --type ts -C 2
echo -e "\n=== Searching for .network property access on x402 types ==="
rg -nP --type ts "\.network\b" -g '**/x402/**' -C 2Length of output: 11966
Add required TSDoc—runtime validation coverage is properly handled.
The FacilitatorNetworkSchema and FacilitatorNetwork type lack TSDoc documentation, violating the coding guidelines requiring comprehensive TSDoc with @example and a custom tag for all public symbols in packages/thirdweb/**.
Runtime validation via networkToChainId() is properly applied across all critical code paths (sign.ts, fetchWithPayment.ts, common.ts).
Add TSDoc:
+/**
+ * Schema for facilitator network identifiers.
+ * Accepts any string value; runtime validation via `networkToChainId` is required.
+ *
+ * @example
+ * ```ts
+ * const network = FacilitatorNetworkSchema.parse("eip155:1");
+ * const chainId = networkToChainId(network);
+ * ```
+ *
+ * @public
+ */
const FacilitatorNetworkSchema = z.string();
+/** @public */
export type FacilitatorNetwork = z.infer<typeof FacilitatorNetworkSchema>;🤖 Prompt for AI Agents
In packages/thirdweb/src/x402/schemas.ts around lines 14 to 16, the public
symbols FacilitatorNetworkSchema and FacilitatorNetwork are missing required
TSDoc; add a TSDoc block above FacilitatorNetworkSchema showing an example usage
(e.g., parsing "eip155:1" and passing to networkToChainId) and include the
@public tag, and add a short TSDoc with @public above the exported
FacilitatorNetwork type; ensure the comments follow existing project style and
include the example snippet shown in the review comment.
size-limit report 📦
|

PR-Codex overview
This PR focuses on loosening the
FacilitatorNetworkSchemain thepackages/thirdweb/src/x402/schemas.tsfile, changing it from a union of specific literals to a more general string type.Detailed summary
FacilitatorNetworkSchemafrom a union of specific network literals toz.string().FacilitatorNetworktype remains inferred from the updated schema.Summary by CodeRabbit