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

[Feature] Support sol outputting to a file #601

Open kayabaNerve opened 5 months ago

kayabaNerve commented 5 months ago

Component

sol! macro

Describe the feature you would like

As ethers-contract allowed, alloy-contract should allow outputting the generated code to a file to allow manual inspection.

This allows anyone curious about how their specific contract had code generated (exact function API/type signatures) trivially inspect it, and can make the sol macro functionality a one-time dependency (to output to code once) or solely a build-time dependency.

Additional context

No response

DaniPopes commented 5 months ago

You can inspect any generated code with cargo-expand.

I might still add it for the build script use case though.

kayabaNerve commented 5 months ago

AFAICT, this would be... 'trivially' resolved if SolMacroExpander were made public (enable functionally calling it, like one can with Abigen). I'm unsure I want to make a PR with that amount of an API commitment though. Happy to hear opinions/suggestions.

EDIT: SolMacroExpander would have to be moved to a new crate/into the sol-macro-input crate, unless the file exporting was part of the macro (and not functional like with Abigen) :/ I did get a PoC of what I'd like though.

prestwich commented 3 months ago

after #626 this should be pretty straightforward. cc @yash-atreya