Repository navigation
feat(zod-solana): add signatureSchema and blockhashSchema - #204
Conversation
Adds Zod schemas for Solana transaction signatures and blockhashes, each in its own file to keep the package tree-shakeable.
Reviewer's GuideThis PR adds two new Zod schemas to @macalinao/zod-solana for validating and transforming Solana signatures and blockhashes into their branded @solana/kit types, along with tests, README documentation, and a minor changeset entry. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Review limit reached
Next review available in: 15 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
WalkthroughAdds branded Zod schemas for Solana signatures and blockhashes. Centralizes branded-string validation, updates address validation, exports the new schemas, and adds tests, documentation, and a release changeset. ChangesSolana schema validation
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The
signatureSchemaandblockhashSchemaare typed asz.ZodType<..., string>, butZodType’s second generic parameter is the definition type, not the input type; consider switching toZodEffects<z.ZodString, Signature, string>/ZodEffects<z.ZodString, Blockhash, string>or correcting the generics so the input/output typing matches Zod’s signatures. - The signature and blockhash schemas share nearly identical transform-and-error-handling logic; consider extracting a small helper for the common pattern to reduce duplication and keep behavior consistent if you adjust validation in the future.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `signatureSchema` and `blockhashSchema` are typed as `z.ZodType<..., string>`, but `ZodType`’s second generic parameter is the definition type, not the input type; consider switching to `ZodEffects<z.ZodString, Signature, string>` / `ZodEffects<z.ZodString, Blockhash, string>` or correcting the generics so the input/output typing matches Zod’s signatures.
- The signature and blockhash schemas share nearly identical transform-and-error-handling logic; consider extracting a small helper for the common pattern to reduce duplication and keep behavior consistent if you adjust validation in the future.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
grill-example-dapp | f57e783 | Commit Preview URL Branch Preview URL |
Aug 12 2026, 03:13 AM |
Addresses review feedback about duplicated transform/error-handling logic across the address, signature, and blockhash schemas. Each schema keeps its own module so tree shaking is unaffected.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
packages/zod-solana/src/create-branded-string-schema.ts (1)
1-1: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse the required
zodnamespace import.The repository rule requires
import * as zod from "zod". Rename these imports and their namespace references.
packages/zod-solana/src/create-branded-string-schema.ts#L1-L1: rename the runtime namespace import and allz.*references.packages/zod-solana/src/address-schema.ts#L2-L2: rename the type-only namespace import andz.ZodType.packages/zod-solana/src/signature-schema.ts#L2-L2: rename the type-only namespace import andz.ZodType.packages/zod-solana/src/blockhash-schema.ts#L2-L2: rename the type-only namespace import andz.ZodType.As per coding guidelines, use namespace imports for Zod:
import * as zod from "zod".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/zod-solana/src/create-branded-string-schema.ts` at line 1, Replace the Zod namespace imports with import * as zod from "zod" and rename every corresponding namespace reference. In packages/zod-solana/src/create-branded-string-schema.ts lines 1-1, update the runtime import and all z.* usages; in packages/zod-solana/src/address-schema.ts lines 2-2, packages/zod-solana/src/signature-schema.ts lines 2-2, and packages/zod-solana/src/blockhash-schema.ts lines 2-2, update the type-only imports and z.ZodType references.Source: Coding guidelines
packages/zod-solana/src/signature-schema.test.ts (1)
1-1: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse
zodas the Zod namespace import.Rename the namespace import and its type references in both test files.
packages/zod-solana/src/signature-schema.test.ts#L1-L1: Change the import toimport type * as zod from "zod"and updatez.outputon Line 67.packages/zod-solana/src/blockhash-schema.test.ts#L1-L1: Change the import toimport type * as zod from "zod"and updatez.outputon Line 64.As per coding guidelines, use namespace imports for Zod:
import * as zod from "zod".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/zod-solana/src/signature-schema.test.ts` at line 1, Rename the Zod namespace import to zod and update all corresponding type references in packages/zod-solana/src/signature-schema.test.ts (including z.output) and packages/zod-solana/src/blockhash-schema.test.ts (including z.output); use the prescribed namespace import form consistently in both files.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/zod-solana/src/create-branded-string-schema.ts`:
- Around line 14-18: Align the Zod compatibility contract across
createBrandedStringSchema in
packages/zod-solana/src/create-branded-string-schema.ts (lines 14-18),
address-schema.ts (lines 11-12), signature-schema.ts (lines 12-13), and
blockhash-schema.ts (lines 12-13): either widen the peer dependency to support
Zod v3 and use the shared z.ZodType<T> annotation, or remove the Zod v3
compatibility claims from all four schema comments.
---
Nitpick comments:
In `@packages/zod-solana/src/create-branded-string-schema.ts`:
- Line 1: Replace the Zod namespace imports with import * as zod from "zod" and
rename every corresponding namespace reference. In
packages/zod-solana/src/create-branded-string-schema.ts lines 1-1, update the
runtime import and all z.* usages; in packages/zod-solana/src/address-schema.ts
lines 2-2, packages/zod-solana/src/signature-schema.ts lines 2-2, and
packages/zod-solana/src/blockhash-schema.ts lines 2-2, update the type-only
imports and z.ZodType references.
In `@packages/zod-solana/src/signature-schema.test.ts`:
- Line 1: Rename the Zod namespace import to zod and update all corresponding
type references in packages/zod-solana/src/signature-schema.test.ts (including
z.output) and packages/zod-solana/src/blockhash-schema.test.ts (including
z.output); use the prescribed namespace import form consistently in both files.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 639918c2-a214-4909-bf61-8b32c30b1688
📒 Files selected for processing (9)
.changeset/zod-solana-signature-blockhash.mdpackages/zod-solana/README.mdpackages/zod-solana/src/address-schema.tspackages/zod-solana/src/blockhash-schema.test.tspackages/zod-solana/src/blockhash-schema.tspackages/zod-solana/src/create-branded-string-schema.tspackages/zod-solana/src/index.tspackages/zod-solana/src/signature-schema.test.tspackages/zod-solana/src/signature-schema.ts
The package's peer dependency is zod ^4 and the schemas use the v4 ZodType<Output, Input> typing, which does not compile against v3.
Adds two new schemas to
@macalinao/zod-solana:signatureSchema— parses a string into aSignature(base58, 64 bytes) viasignature()from@solana/kit. Invalid input yields"Invalid Solana signature".blockhashSchema— parses a string into aBlockhash(base58, 32 bytes) viablockhash()from@solana/kit. Invalid input yields"Invalid Solana blockhash".Each schema lives in its own file (
signature-schema.ts,blockhash-schema.ts) and is re-exported fromindex.ts, matching the existing one-schema-per-file layout so bundlers can tree-shake unused schemas.Also includes tests for both (valid/invalid, length mismatches, base58 charset,
safeParse, type inference), README API entries, and a minor changeset.Test plan
bun run build— passesbun run lint:fix— cleanbun testinpackages/zod-solana— 253 pass, 0 failSummary by Sourcery
Add new Zod schemas for validating and transforming Solana transaction signatures and blockhashes, and expose them from the zod-solana package.
New Features:
Documentation:
Tests:
Chores:
Summary by CodeRabbit
New Features
Documentation
Bug Fixes