alloy-rs / core

High-performance, well-tested & documented core libraries for Ethereum, in Rust
https://alloy.rs
Apache License 2.0
763 stars 137 forks source link

[Bug] Bindings Incorrect for Non-Primitive Indexed Types #734

Closed jnoorchashm37 closed 1 week ago

jnoorchashm37 commented 1 week ago

Component

primitives, sol-types

What version of Alloy are you on?

0.7.2

Operating System

macOS (Apple Silicon)

Describe the bug

When indexing non-primitive, custom types in a log event, is the rust binding that is generated in the topic the abi encoded hash for the custom type? I'm looking at the Initialize log in the v4 contracts. The indexed Currency type is an address but the rust binding is declaring it a FixedBytes<32>.

I am generating the bindings using foundry with the v4 contracts as git submodule working on rev e74c9bbd42fe0fb1c20e2560e72d5c2e62fb45f1.


event Initialize(PoolId indexed id, Currency indexed currency0, Currency indexed currency1, uint24 fee, int24 tickSpacing, address hooks, uint160 sqrtPriceX96, int24 tick);

generated bindings:

#[allow(non_camel_case_types, non_snake_case, clippy::style)]
#[derive(Clone)]
pub struct Initialize {
  #[allow(missing_docs)]
  pub id: alloy::sol_types::private::FixedBytes<32>,
  #[allow(missing_docs)]
  pub currency0: alloy::sol_types::private::FixedBytes<32>,
  #[allow(missing_docs)]
  pub currency1: alloy::sol_types::private::FixedBytes<32>,
  #[allow(missing_docs)]
  pub fee: <alloy::sol_types::sol_data::Uint<
      24,
  > as alloy::sol_types::SolType>::RustType,
  #[allow(missing_docs)]
  pub tickSpacing: <alloy::sol_types::sol_data::Int<
      24,
  > as alloy::sol_types::SolType>::RustType,
  #[allow(missing_docs)]
  pub hooks: alloy::sol_types::private::Address,
  #[allow(missing_docs)]
  pub sqrtPriceX96: <alloy::sol_types::sol_data::Uint<
      160,
  > as alloy::sol_types::SolType>::RustType,
  #[allow(missing_docs)]
  pub tick: <alloy::sol_types::sol_data::Int<
      24,
  > as alloy::sol_types::SolType>::RustType,
}