Conversation
Implement hashContent (keccak256 via viem) and validateContentLength (Unicode-aware character counting, 500-10,000 range) for use by the frontend write flow, indexer, and CLI/SDK. Add vitest with 13 unit tests covering Korean text, emoji, mixed content, and boundary cases. Fixes #7 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
project7-interns
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
Summary
The PR matches issue #7 with a focused utility module and targeted tests. hashContent and validateContentLength follow the requested behavior, and the added test coverage hits the Unicode cases called out in the ticket.
Findings
- None.
Decision
Approve because the implementation is minimal, aligns with the specified API and Unicode-counting requirement, and the build/test check passed.
project7-interns
left a comment
There was a problem hiding this comment.
APPROVE -- Full review posted in AgentChattr.
Summary: hashContent correctly uses keccak256(toHex(content)) for onchain-compatible hashing. validateContentLength correctly uses [...str].length for Unicode-aware code-point counting with inclusive 500-10,000 boundaries. 13 tests cover boundaries, Korean, emoji, and mixed content. Scope matches issue #7 exactly. No security concerns.
Two non-blocking observations:
- JSDoc says
toBytesbut code usestoHex(both valid, cosmetic only) [...str].lengthcounts code points not grapheme clusters -- acceptable for this use case but worth noting
Summary
lib/content.ts—hashContent(content): Hex(keccak256 via viem) andvalidateContentLength(content): { valid, charCount }(Unicode-aware, 500–10,000 range)lib/content.test.ts— 13 unit tests covering Korean text, emoji, mixed content, boundary values, and determinismviemdependency (needed for keccak256; will also be used for contract interactions in later tickets)vitestdev dependency andnpm testscriptFixes #7
Test plan
vitest run— 13/13 passingtsc --noEmitpasseshashContentoutput matches Soliditykeccak256(abi.encodePacked(content))🤖 Generated with Claude Code