feat(events): add #[event] macro and IDL event support - #84
Open
bristinWild wants to merge 3 commits into
Open
Conversation
- Add IdlEvent struct to SpelIdl with name, discriminant, fields - Add events: Vec<IdlEvent> field to SpelIdl (backward-compatible) - Add #[event(discriminant = N)] proc macro attribute - Add with_events() builder to SpelOutput - Wire event parsing into generate_idl_json and generate_idl_fn - Add lez-events dependency to spel-framework-core - Update spel-client-gen tests for new SpelIdl field - All 90 tests passing This enables programs to annotate event payload structs with enabling spel tx decode to do full typed event decoding. Related: logos-blockchain/logos-execution-zone LP-0012
bristinWild
force-pushed
the
feat/event-idl-extension
branch
from
May 25, 2026 21:54
9bbc692 to
f9b235a
Compare
Author
|
Rebased onto upstream/main (d24dbaa, v0.4.0). Conflicts resolved , removed the lez-events crate dependency, keeping IdlEvent and #[event] as self-contained additions to spel-framework-core and spel-framework-macros. All 225 unit tests passing, 0 failures. |
bristinWild
marked this pull request as ready for review
June 8, 2026 10:38
vpavlin
requested changes
Jul 14, 2026
vpavlin
left a comment
Collaborator
There was a problem hiding this comment.
Thanks @bristinWild — the schema design here is clean (additive events: Vec<IdlEvent> with skip_serializing_if, no-op #[event] marker consistent with #[account_type]). But as it stands the feature is scaffolding only and doesn't function end-to-end:
- Nothing on the branch ever collects
#[event]-annotated structs intoSpelIdl.events. Both constructors (SpelIdl::new,generate_idl_inner) and the test literals setevents: vec![], and there's no scan ingenerate_idl!/#[lez_program]/ the account-type collector. So#[event]is a no-op and the IDL'seventsarray is always empty. - The test changes are just mechanical
events: vec![]additions to satisfy the new field — none assert that a program with#[event]structs actually produces populated events.
To land this I'd want:
- Collection logic that scans
#[event]structs (discriminant + fields) and populatesSpelIdl.events, wired into the same paths that collect#[account_type](spel-framework-core/src/account_types.rs/idl_gen.rs/ thelez_programexpansion). - A regression test: a source with an
#[event(discriminant = N)]struct → assert the generated IDL contains the event with correct name/discriminant/fields.
Happy to help wire the collection into the account-type scanner if useful. Branch is updated onto the LEZ v0.2.0 main; holding merge until the collection + test are in.
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.
Adds #[event] macro and IDL event schema support, enabling spel tx decode to do full typed event decoding from transaction receipts.
Changes:
IdlEvent struct added to SpelIdl (name, discriminant, fields: Vec)
events: Vec field in SpelIdl — backward-compatible, skipped if empty
#[event(discriminant = N)] proc macro to annotate event payload structs
SpelOutput::with_events() builder that auto-drains the lez-events buffer
generate_idl_json and generate_idl_fn pick up #[event] structs alongside #[instruction] functions
All 90 existing tests passing
Usage:
rust#[event(discriminant = 1)]
pub struct InsufficientFunds {
pub requested: u128,
pub available: u128,
}
Relates to: logos-blockchain/logos-execution-zone LP-0012 event system