Generate BCS schemas for emitted event structs#2
Merged
Conversation
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
There was a problem hiding this comment.
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 existingto_bcs_struct_schemahelper). - Extend
bcs/bcs.Addressimport 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
export const <Event> = bcs.struct(...)for every emitted event (with--events), alongside the existingparsedJsonstringexport type, so callers can decode raw event BCS bytes (SuiEvent.bcs) into typed values.to_bcs_struct_schemahelper). The schemaconstcoexists with the snake_caseexport type(TS keeps type and value namespaces separate, so sharing the event name is legal).bcs/Addressimport 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)bcsimport, no schema when--eventsdisabled, single schema const when event is also a param (no name clash)full_pipeline_eventsintegration assertions for exactexport const ... bcs.struct(...)outputgenerated_ts_compiles_with_tscrun for real against@mysten/suiv2.9 — generated event BCS schemas typecheckhttps://claude.ai/code/session_01TxbXDWyMzE7ELdoETqQ5MH
Generated by Claude Code