Skip to content

Manual Event Registration to Contract Macro #10

@moCello

Description

@moCello

Summary

The macro extracts events by walking the AST of impl block methods looking for abi::emit() calls. This misses events emitted by:

  1. Helper functions outside the impl block
  2. Trait default implementations (e.g., OwnableUpgradeable::transfer_ownership emits OwnershipTransferred)

Possible Solution

Add an emits attribute to manually register events on trait impl blocks:

#[contract(expose = [owner, transfer_ownership, renounce_ownership],
           emits = [
               (events::OwnershipTransferred::OWNERSHIP_TRANSFERRED, events::OwnershipTransferred),
               (events::OwnershipTransferred::OWNERSHIP_RENOUNCED, events::OwnershipTransferred),
           ])]
impl OwnableUpgradeable for TestBridge { ... }

Each tuple is (topic_path, EventType) where topic can be a const path or string literal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions