Skip to content

feat: add bytearray: calldata prefix#47

Merged
broody merged 1 commit intomainfrom
feat/bytearray-prefix
Feb 22, 2026
Merged

feat: add bytearray: calldata prefix#47
broody merged 1 commit intomainfrom
feat/bytearray-prefix

Conversation

@broody
Copy link
Collaborator

@broody broody commented Feb 22, 2026

Summary

  • Add bytearray: prefix to parse_calldata_value() for Cairo ByteArray multi-felt serialization
  • Support string mode (bytearray:hello), quoted string mode (bytearray:"hello world"), and raw bytes mode (bytearray:[0x48,0x65,0x6c,0x6c,0x6f])
  • Quoted strings strip surrounding double quotes before encoding, allowing strings with spaces
  • Uses cainome_cairo_serde::ByteArray and CairoSerde::cairo_serialize() for correct serialization
  • Add 7 tests covering short strings, empty strings, long strings (multi-chunk), raw bytes, empty raw bytes, quoted strings, and quoted empty strings
  • Update SKILL.md and LLM_USAGE.md with documentation for the new prefix

Test plan

  • cargo build succeeds
  • cargo fmt and cargo clippy pass cleanly
  • cargo test passes (all 50 tests, including 7 new bytearray tests)
  • Short string serialization produces correct felts (0 chunks + pending word)
  • Empty string produces [0, 0, 0]
  • Long string (>31 bytes) produces correct multi-chunk output
  • Raw bytes mode produces identical output to equivalent string mode
  • Empty raw bytes [] produces [0, 0, 0]
  • Quoted string "hello world" strips quotes and encodes correctly
  • Quoted empty string "" produces [0, 0, 0]

🤖 Generated with Claude Code

@broody broody force-pushed the feat/bytearray-prefix branch from dfb3dd1 to 44662ed Compare February 22, 2026 20:50
Add support for Cairo ByteArray serialization in calldata via a
bytearray: prefix. Supports two modes: string encoding (bytearray:hello)
and raw bytes encoding (bytearray:[0x48,0x65,0x6c,0x6c,0x6f]). Uses
cainome_cairo_serde::ByteArray for correct multi-felt serialization.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@broody broody force-pushed the feat/bytearray-prefix branch from 44662ed to ec0a86e Compare February 22, 2026 20:53
@broody broody merged commit 13afed3 into main Feb 22, 2026
3 checks 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.

1 participant