Skip to content

Add encodeCallMsg field-context errors and logTriggerConfig helper#201

Draft
wentzeld wants to merge 3 commits intomainfrom
reducePanics
Draft

Add encodeCallMsg field-context errors and logTriggerConfig helper#201
wentzeld wants to merge 3 commits intomainfrom
reducePanics

Conversation

@wentzeld
Copy link
Contributor

@wentzeld wentzeld commented Mar 2, 2026

Summary

  • encodeCallMsg now wraps hexToBase64 errors with field name context (e.g., Invalid hex in 'to' field of CallMsg: ...)
  • Add logTriggerConfig() helper for building validated log trigger configs from hex-encoded addresses and topics
  • Add validateHexByteLength for address (20 bytes) and topic (32 bytes) validation
  • 17 new tests

Why

Proto bytes fields use base64 in JSON form. Passing raw hex strings directly causes silent data corruption — hex chars get interpreted as base64, producing wrong bytes with no
error. These helpers ensure correct encoding and catch mistakes at build time.

Test plan

  • All 51 blockchain-helpers tests pass (34 existing + 17 new)
  • All 243 utils tests pass
  • Biome lint passes

  - encodeCallMsg now wraps hexToBase64 errors with field name context
  - Add logTriggerConfig() helper for validated hex-to-base64 log trigger config
  - Add validateHexByteLength for address (20 bytes) and topic (32 bytes) validation
  - Add 17 new tests for encodeCallMsg error context and logTriggerConfig
@wentzeld wentzeld changed the title Improve SDK error messages for common WASM panics Add encodeCallMsg field-context errors and logTriggerConfig helper Mar 2, 2026
@wentzeld
Copy link
Contributor Author

wentzeld commented Mar 2, 2026

accompanying docs pr smartcontractkit/documentation#3517

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