Skip to content

feat: apply uniform event schema versioning and named decoding (#496) - #532

Merged
Cedarich merged 8 commits into
ZyntariHQ:mainfrom
drah9991:feat/496-event-schema-versioning
Aug 29, 2026
Merged

Cedarich merged 8 commits into
ZyntariHQ:mainfrom
drah9991:feat/496-event-schema-versioning

Conversation

@drah9991

Copy link
Copy Markdown
Contributor

Summary

This PR implements a uniform event-versioning policy across all Soroban contract events. It migrates the TypeScript client away from fragile positional decoding toward strict, name-based schema validation, ensuring that reordered or malformed payloads are explicitly rejected rather than silently misparsed.

Related Issue(s)

Closes #496

Type of Change

  • Feature
  • Fix
  • Refactor
  • Documentation
  • Chore

Description

1. Smart Contract (Rust)

  • Added schema_version: u32 to all previously unversioned events (e.g., AssetAllowlisted, ContractPaused, AdminTransferProposed, etc.).
  • Injected the global EVENT_SCHEMA_VERSION constant into every emit_* function.
  • Updated all Rust assertions in test.rs to account for the new payload shape.
  • Documented the event-versioning policy in events.rs alongside the ABI stability notes.

2. TypeScript Client & Decoder

  • Removed Positional Decoding: Completely stripped index-based parsing (payload[0]). The client now requires named ScMap payloads resolved by Soroban symbols.
  • Centralized Validation: decodeSorobanEvent and the codec now enforce schemaVersion against the expected constant. Unsupported versions or missing fields trigger a structured rejection ({ type: 'unknown', name: '...' }).

3. CI & Tooling

  • Updated schema.json and tightened the generator template to make schema_version mandatory.
  • Extended the ABI drift script (check-client-drift.mjs) to strictly compare ordered Rust fields, schema properties, and client declarations.

Testing Evidence

  • Rust Smart Contract: Executed cargo test. All 202 tests passed successfully.
  • TypeScript Client: Wrote a table-driven test suite in events.test.ts covering 3 scenarios (success, unsupported version, and malformed/reordered payload) for all 14 contract events. Executed npm test locally, with all 105 tests passing.
  • CI Drift: Executed node soroban/scripts/check-client-drift.mjs without errors, ensuring ABI schema matches the Rust source and TS client definitions.

Screenshots

Not applicable (Smart contract, client library, and CI tooling changes only).

Checklist

  • Code builds successfully
  • Tests added/updated where applicable
  • Documentation updated if needed
  • Linked issue referenced
  • Ready for review

@Cedarich
Cedarich merged commit 29e72e4 into ZyntariHQ:main Aug 29, 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