Skip to content

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

Merged
0xrusowsky merged 5 commits into
alloy-rs:mainfrom
0xrusowsky:rus/helper-builders
Apr 24, 2026
Merged

0xrusowsky merged 5 commits into
alloy-rs:mainfrom
0xrusowsky:rus/helper-builders

Conversation

@0xrusowsky

@0xrusowsky 0xrusowsky commented Mar 12, 2026 •

Copy link
Copy Markdown
Contributor

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
@github-project-automation github-project-automation Bot moved this to Reviewed in Alloy Apr 20, 2026
@0xrusowsky
0xrusowsky merged commit 68b1c44 into alloy-rs:main Apr 24, 2026
31 checks passed
@github-project-automation github-project-automation Bot moved this from Reviewed to Done in Alloy Apr 24, 2026
@0xrusowsky
0xrusowsky deleted the rus/helper-builders branch April 24, 2026 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants