Closed snd closed 6 years ago
ethabi itself might be a good place for this
that code is difficult to "imagine". i found it very helpful to see the generated code.
agreed, while we're still dealing with generated code from ethabi, seeing the actual code is crucial for debugging.
when debugging a similar issue in another example, we used cargo-expand
(relies on nightly). not sure how easy it would be to instrument ethabi with similar tooling directly, or if it is possible without a nightly build.
don't know what the roadmap looks like for removing/replacing generated code in ethabi.
so far i've used https://github.com/dtolnay/cargo-expand to achieve this. still requires some manual setup though.
something like cargo ethabi-derive-expand path-to-solidity-file.sol > path-to-generated-rust.rs
would be great
something like cargo ethabi-derive path-to-solidity-file.sol > path-to-generated-rust.rs would be great
absolutely, not sure how to tie into the cargo scripting system to achieve that. after quick search, we could possibly package ethabi-derive
as cargo-ethabi-derive
.
if cargo-ethabi-derive
is on path, we should be able to run cargo ethabi-derive contract.sol > path-to-generated.rs
. going to do a quick experiment to see if this works.
Update: ran the experiment with the ethabi
binary, and it works :) So now just need to create the ethabi-derive
binary, and put it on path as cargo-ethabi-derive
.
cargo doc
creates documentation for the module generated by use_contract!
. imho that's a great way to browse that module for now
i'm now using the following solution:
for a project using ethabi-derive
have the contracts in a seperate crate (in the workspace) that only contains the contracts. example https://github.com/paritytech/parity-bridge/tree/9dfa37f02a462947da85f23a422e55109a4904d8/contracts
run cargo doc
within that crate's directory. voila documentation of derived contracts.
closing this as i no longer think there needs to be additional tooling for this
writing tests in rust with sol-rs involves dealing with a lot of generated code (generated by ethabi-derive). that code is difficult to "imagine". i found it very helpful to see the generated code.
it would be great to have something like a cargo command to easily generate the ethabi rust code from a solidity file.
here are two examples of generated code:
validators: textup.fr/231979a6
foreign bridge: https://gist.github.com/snd/8dad886c6acdf057a18e2c29b6255c48