alloy-rs / core

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

[Feature] Ability to specify a dynamic ABI file path for `sol!` #738

Open kayabaNerve opened 2 months ago

kayabaNerve commented 2 months ago

Component

sol! macro

Describe the feature you would like

I built my contracts to OUT_DIR. sol!(MyContract, concat!(env!("OUT_DIR"), "/contracts/MyContract.abi")) fails to compile with "expected ident". Reviewing the macro myself, the macro appears to be looking for a string literal for the path (preventing usage of so-derived paths).

This can be worked around by hooking into alloy-sol-macro-expander directly from a build script. That crate has weaker semver guarantees and building custom expanders is largely undocumented (though it was a small amount of code once I worked it out). I understand if this is closed as won't fix accordingly, I just wanted to explain why I thought the issue at least worth filing.

Additional context

No response