Skip to content

[#7] Content Utilities#47

Merged
realproject7 merged 1 commit intomainfrom
task/7-content-utilities
Mar 13, 2026
Merged

[#7] Content Utilities#47
realproject7 merged 1 commit intomainfrom
task/7-content-utilities

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • P1-2a: lib/content.tshashContent(content): Hex (keccak256 via viem) and validateContentLength(content): { valid, charCount } (Unicode-aware, 500–10,000 range)
  • P1-2b: lib/content.test.ts — 13 unit tests covering Korean text, emoji, mixed content, boundary values, and determinism
  • Adds viem dependency (needed for keccak256; will also be used for contract interactions in later tickets)
  • Adds vitest dev dependency and npm test script

Fixes #7

Test plan

  • vitest run — 13/13 passing
  • tsc --noEmit passes
  • Verify hashContent output matches Solidity keccak256(abi.encodePacked(content))

🤖 Generated with Claude Code

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>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. JSDoc says toBytes but code uses toHex (both valid, cosmetic only)
  2. [...str].length counts code points not grapheme clusters -- acceptable for this use case but worth noting

@realproject7 realproject7 merged commit ec04acb into main Mar 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1-2] Content Utilities

2 participants