Skip to content

feat(sol-macro): helper builders for errors and events#1080

Open
0xrusowsky wants to merge 4 commits intoalloy-rs:mainfrom
0xrusowsky:rus/helper-builders
Open

feat(sol-macro): helper builders for errors and events#1080
0xrusowsky wants to merge 4 commits intoalloy-rs:mainfrom
0xrusowsky:rus/helper-builders

Conversation

@0xrusowsky
Copy link
Contributor

@0xrusowsky 0xrusowsky commented Mar 12, 2026

Motivation

Constructing error/event enum variants is verbose — you repeat the variant name as both the enum discriminant and the inner struct constructor.

Solution

Generate snake_case constructor helpers, on {Contract}Errors and {Contract}Events enums, which flatten that into a single call with the fields as arguments.

  // before
  let err = IExampleErrors::ErrorWithFields(ErrorWithFields { available: val, token: addr });
  let event = IExampleEvents::EventWithoutArgs(ErrorWithoutArgs {});

  // after
  let err = IExampleErrors::error_with_fields(val, addr);
  let event = IExampleEvents::event_without_args();

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@0xrusowsky 0xrusowsky changed the title Rus/helper builders feat(sol-macro): helper builders for errors and events Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant