Skip to content

Add bytes support for 1 length prefix#18

Merged
JohnChangUK merged 1 commit intomainfrom
bytes-1-len
Mar 10, 2026
Merged

Add bytes support for 1 length prefix#18
JohnChangUK merged 1 commit intomainfrom
bytes-1-len

Conversation

@JohnChangUK
Copy link
Contributor

Summary

Adds support for hex:"bytes" struct tags for fields that require uint8 (1-byte) length prefix encoding, complementing the existing hex:"bytes16" support for uint16 (2-byte) length prefix encoding.

The Daml compiler erases type synonyms. When you define a field as BytesHex in Daml, the compiler expands it to its underlying type (Text) in the compiled Daml-LF output. By the time go-daml parses the .dalf files, all it sees is:

signerAddress: Text
operationData: Text
root: Text

There's no way to distinguish which Text fields were originally BytesHex and require special encoding. The hardcoded maps (BytesFieldNames, BytesHexFieldNames) work around this limitation by explicitly listing field names that need hex encoding tags.

@JohnChangUK JohnChangUK requested a review from stackman27 March 10, 2026 14:10
@JohnChangUK JohnChangUK requested a review from a team as a code owner March 10, 2026 14:10
@github-actions
Copy link

👋 JohnChangUK, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

@JohnChangUK JohnChangUK enabled auto-merge (squash) March 10, 2026 14:11
"signerAddress": true,
"chainFamilySelector": true,
"root": true,
"newRoot": true,
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this very domain (CCIP/MCMS) specific? I see we also have another specific type Uint32ListFieldNames. I feel this shouldn't belong to this lib

@JohnChangUK JohnChangUK merged commit efcbfde into main Mar 10, 2026
7 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.

2 participants