Skip to content

Add event registration via emits attribute#18

Open
moCello wants to merge 4 commits intomocello/ai-friendlinessfrom
mocello/event-registration
Open

Add event registration via emits attribute#18
moCello wants to merge 4 commits intomocello/ai-friendlinessfrom
mocello/event-registration

Conversation

@moCello
Copy link
Copy Markdown
Member

@moCello moCello commented Apr 9, 2026

Summary

Add manual event registration for the #[contract] macro via three related features:

  • #[contract(emits = [...])] — method-level attribute that declares events emitted by trait default implementations (invisible to the macro's body scanner). Events listed in emits are included in the contract schema alongside those discovered from abi::emit() calls.
  • Compile error for silent mutations — public &mut self methods must now emit events or declare them via emits. Use #[contract(no_event)] to suppress the check for methods like init that intentionally skip emission.
  • Variable topic detection — detects lowercase single-segment identifiers used as abi::emit() topics (likely variables whose runtime value the macro can't capture). Warning is a no-op on stable Rust pending proc_macro_diagnostic stabilisation.

Stacks on #17.

moCello added 4 commits April 9, 2026 16:00
…tection

Add #[contract(emits = [...])] for manual event registration on trait
methods with default implementations. Add compile error for public
&mut self methods that emit no events, suppressible with
#[contract(no_event)]. Detect variable identifiers used as
abi::emit() topics (warning pending proc_macro_diagnostic stabilisation).
Add #[contract(emits = [...])] to Ownable trait methods and
#[contract(no_event)] to init. Add schema test verifying ownership
events appear via manual registration.
@moCello moCello requested a review from HDauven April 9, 2026 14:22
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