Support named tuple components in event signatures#1211
Merged
Conversation
Custom event signatures with named tuple components — e.g. `Event((uint40 a, uint24 b) info)` — fail to parse via `AlloyEvent::parse`, blocking codegen without an ABI file path.
Fixes #1206. alloy's `Event::parse` rejects component names inside tuple types (e.g. `(uint40 a, uint24 b) info`), forcing users with nested-tuple events to provide an `abi_file_path`. Add a permissive fallback parser that builds an `AlloyEvent` with the named components populated. Selector and ABI signature derive from the canonical (unnamed) form, so existing call sites are unaffected.
Always route human-readable event signatures through our parser instead of trying alloy's first. JSON ABI deserialization keeps using alloy. Eliminates the branch where users could see two stacked error messages and removes the silent-divergence risk between two parsers.
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR replaces the event signature parsing mechanism to support named tuple components. A new ChangesEvent signature parsing with named tuple components
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Comment |
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.
Summary
Adds a custom event signature parser that accepts named tuple components, enabling event signatures like
event E((uint a, uint b) data)to work without requiring an ABI file. Previously, alloy's signature parser rejected these, causing codegen to fail when noabi_file_pathwas provided.Key Changes
parse_event_signature_to_alloy()function that delegates to a newsig_parsermodulesig_parser) that:eventkeyword andanonymousmodifier[],[N]) on any typeAlloyEventfor downstream codegenparse_event()inabi_compat.rsto use the new parserEvent::get_abi_event()insystem_config.rsto use the new parser as fallbackImplementation Details
The
sig_parsermodule uses aCursorstruct for position tracking and implements:parse(): Entry point handling event keyword, name, parameters, and anonymous modifierparse_event_param(): Parses top-level parameters with optionalindexedkeywordparse_param(): Parses tuple component parameters (noindexedallowed)parse_type(): Recursively handles leaf types, tuples, and array suffixesCursorfor character/whitespace/identifier/digit parsingComponent names are preserved through
AlloyParamandAlloyEventParamstructures, allowing the ABI conversion pipeline to emit named record fields in codegen output.https://claude.ai/code/session_017kSBtmRyLh7wPM89p29LXM
Summary by CodeRabbit
Bug Fixes
Tests