Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sol-macro): correctly determine whether event parameters are hashes #735

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

DaniPopes
Copy link
Member

Currently we're determining whether an indexed parameter is encoded as a hash (B256) by checking whether it is abi-dynamic. However this:

  1. does not account for custom types, so UDVTs are treated as a hash when they shouldn't;
  2. is not entirely correct as it will accept elementary fixed arrays such as address[2].

This is fixed by accounting for custom types and using is_value_type instead of whether it is ABI-dynamic. The Solidity ABI spec states:

For all types of length at most 32 bytes, the EVENT_INDEXED_ARGS array contains the value directly, padded or sign-extended (for signed integers) to 32 bytes, just as for regular ABI encoding. However, for all “complex” types or types of dynamic length, including all arrays, string, bytes and structs, EVENT_INDEXED_ARGS will contain the Keccak hash of a special in-place encoded value (see Encoding of Indexed Event Parameters), rather than the encoded value directly.

Fixes #734.

@DaniPopes DaniPopes merged commit 3861199 into main Sep 10, 2024
31 checks passed
@DaniPopes DaniPopes deleted the dani/sol-event-udvts-arrays branch September 10, 2024 01:19
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.

[Bug] Bindings Incorrect for Non-Primitive Indexed Types
2 participants