fix(caip): allow hyphen in CAIP-2 namespace per spec - #176
Conversation
caip2NamespacePattern was "[a-z0-9]{3,8}", but the CAIP-2 spec defines
namespace as "[-a-z0-9]{3,8}" (hyphen allowed). The sibling
caip19AssetNamespacePattern already used the hyphenated form, and this
file's own doc comment repeated the wrong pattern.
Also updates a did:pkh resolver test whose "invalid URI" fixture relied
on the old, hyphen-rejecting namespace regex as its only source of
invalidity; it now uses an uppercase namespace, which is invalid for an
unrelated, still-enforced reason.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. WalkthroughThe CAIP-2 namespace pattern now permits hyphens within 3–8-character namespaces. Tests cover valid hyphenated namespaces and invalid underscores. A related ChangesCAIP-2 Namespace Support
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This patch permits spec-compliant hyphenated CAIP-2 namespaces while continuing to reject invalid characters, with focused test updates. No actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 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 |
caip2NamespacePattern(packages/caip/src/caips/caip-2.ts) was"[a-z0-9]{3,8}", but the CAIP-2 spec defines the namespace grammar as[-a-z0-9]{3,8}, hyphen included. The siblingcaip19AssetNamespacePatternincaip-19.tsalready uses the hyphenated form, and this file's own doc comment repeated the same wrong pattern, so the fix also corrects the comment for internal consistency. Added regression tests for a hyphenated namespace being accepted and an invalid character still being rejected, and a changeset for@agentcommercekit/caip(patch). One existingdid:pkhresolver test's "invalid URI" fixture depended on the old regex rejecting a hyphenated namespace as its only source of invalidity; it's updated to use an uppercase namespace instead, which stays invalid for its own, unrelated, still-enforced reason.AI assistance disclosure: This contribution was AI-assisted using Claude Code. AI was used to identify the spec discrepancy, implement the pattern/doc-comment fix, write the regression tests, and update the affected
did:pkhtest fixture. I reviewed the full diff and test output, understand the change and why thedid:pkhtest needed updating, and take responsibility for what's submitted here.Summary by CodeRabbit
Bug Fixes
Tests
Release