Skip to content

fix: event filter typespec generation for events with interleaved indexed and non-indexed fields#249

Merged
alisinabh merged 2 commits intoExWeb3:mainfrom
ricomateo:fix/event-filter-typespec-indexed-types
Apr 14, 2026
Merged

fix: event filter typespec generation for events with interleaved indexed and non-indexed fields#249
alisinabh merged 2 commits intoExWeb3:mainfrom
ricomateo:fix/event-filter-typespec-indexed-types

Conversation

@ricomateo
Copy link
Copy Markdown
Contributor

@ricomateo ricomateo commented Apr 13, 2026

Description

The generate_event_typespecs function calls Enum.take(selector.types, arity) to extract the types of the indexed fields from an event selector. The problem with this is that Enum.take(selector.types, arity) grabs the first arity types from the full ABI field list, but when an event has interleaved indexed and non-indexed fields, this produces wrong typespecs (the generated spec contains the type of a non-indexed field instead of the actual indexed field).

Example

Take for example the following event

event Transfer(uint256 amount, address indexed sender, bool isFinal, address indexed receiver)

The arity of this event is 2 (there are 2 indexed fields), so in this case the generate_event_typespecs function will select the first 2 fields to determine the type of the indexed fields.

As a result, the generate_event_typespecs function will return [uint256, address]. However, the types of the indexed fields are actually [address, address].

This PR fixes this error by updating the generate_event_typespecs function so that it uses the event_indexed_types function to select the types for the event typespec. This ensures the typespec is generated with the right types.

@ricomateo ricomateo marked this pull request as ready for review April 13, 2026 19:44
Copy link
Copy Markdown
Member

@alisinabh alisinabh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution <3

@alisinabh alisinabh merged commit e472924 into ExWeb3:main Apr 14, 2026
4 of 5 checks passed
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.

2 participants