Skip to content

Generate BCS schemas for emitted event structs#2

Merged
avbel merged 2 commits into
mainfrom
claude/sui-dependencies-update-YNz31
May 26, 2026
Merged

Generate BCS schemas for emitted event structs#2
avbel merged 2 commits into
mainfrom
claude/sui-dependencies-update-YNz31

Conversation

@avbel

@avbel avbel commented May 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • Emit export const <Event> = bcs.struct(...) for every emitted event (with --events), alongside the existing parsedJson string export type, so callers can decode raw event BCS bytes (SuiEvent.bcs) into typed values.
  • Field keys use the same camelCase convention as param-struct BCS schemas (reuses the existing to_bcs_struct_schema helper). The schema const coexists with the snake_case export type (TS keeps type and value namespaces separate, so sharing the event name is legal).
  • Extended bcs/Address import detection so event-only modules still import what they need.

Test plan

  • cargo fmt && cargo clippy --all-targets -- -D warnings && cargo test — green (136 unit + 7 integration)
  • New unit tests: camelCase BCS schema emission, event-only bcs import, no schema when --events disabled, single schema const when event is also a param (no name clash)
  • Extended full_pipeline_events integration assertions for exact export const ... bcs.struct(...) output
  • generated_ts_compiles_with_tsc run for real against @mysten/sui v2.9 — generated event BCS schemas typecheck

https://claude.ai/code/session_01TxbXDWyMzE7ELdoETqQ5MH


Generated by Claude Code

claude added 2 commits May 26, 2026 18:04
Bump all move-compiler git dependencies from ca31568261 to
585d7a076f990fa1ba8760e39883ddfc99b9276e (latest MystenLabs/sui main).
Build, clippy, fmt, and full test suite all pass with no source changes
required.

https://claude.ai/code/session_01TxbXDWyMzE7ELdoETqQ5MH
Emit `export const <Event> = bcs.struct(...)` alongside the existing
parsedJson string `export type`, so callers can decode raw event BCS
bytes (SuiEvent.bcs) into typed values. Reuses the existing
to_bcs_struct_schema helper (camelCase field keys), gated on --events,
and extends the bcs/Address import detection to cover event-only modules.

https://claude.ai/code/session_01TxbXDWyMzE7ELdoETqQ5MH
Copilot AI review requested due to automatic review settings May 26, 2026 19:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the TypeScript generator to emit BCS schema constants for Move structs that are detected as emitted events (when --events is enabled), enabling callers to decode raw SuiEvent.bcs bytes into typed values using bcs.struct(...).

Changes:

  • Generate export const <EventName> = bcs.struct(...) for each emitted event struct, using camelCase field keys (via the existing to_bcs_struct_schema helper).
  • Extend bcs / bcs.Address import detection so event schemas trigger the correct @mysten/* import even when events are the only reason BCS is needed.
  • Add/extend unit + integration test assertions for schema emission, naming/collision behavior, and import selection; update pinned Sui Move compiler git rev.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

File Description
src/codegen.rs Adds event BCS schema emission and updates BCS/Address import detection to account for emitted events.
tests/integration_test.rs Extends full_pipeline_events integration assertions to validate emitted export const ... = bcs.struct(...) output and imports.
Cargo.toml Updates pinned sui.git rev for Move compiler crates.
Cargo.lock Lockfile updates reflecting the Move compiler rev bump and dependency graph changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@avbel avbel merged commit fae529c into main May 26, 2026
2 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.

3 participants