alloy-rs / core

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

[Feature] Rename attribute for structures generated through the `sol!` macro #570

Open makcandrov opened 6 months ago

makcandrov commented 6 months ago

Component

sol! macro

Describe the feature you would like

Currently, the structures generated through the sol! macro use the exact same naming as in the Solidity code, but it follows different naming conventions than Rust. For example, a Solidity function

function foo(uint256 fooBar) external;

would create the following Rust structure:

struct fooCall {
    fooBar: U256,
}

But we might prefer it to create a structure that follows Rust's naming conventions

struct FooCall {
    foo_bar: U256,
}

A serde-like #[rename(...)] attribute could be implemented here

Additional context

No response