openethereum / sol-rs

Solaris - Solidity testing framework in Rust.
GNU General Public License v3.0
54 stars 14 forks source link

Compilation & EVM integration #3

Closed tomusdrw closed 6 years ago

axelchalon commented 6 years ago

really good stuff!

just something I thought (might be nitpicky): I find the syntax a bit counter-intuitive (also due to the current ethabi syntax). For example in:

reg.register().transact(sol::address(10), sol::bytes32("test"),
         evm
         .with_value(unit::ether(2))
         .with_sender(5.into())
         .ensure_funds()
         )?;

we're calling functions on reg, the contract encoder/decoder helper, but it's the CALLER (evm) passed as parameter that is actually doing the main job.

Don't you think that making the evm function call go first would be a good idea? Not yet sure how to implement this; it would be *roughly* something in this direction: (maybe using macros somehow)

evm
    .with_value(unit::ether(2))
    .with_sender(5.into())
    .ensure_funds()
    .transact2(reg.register(), sol::address(10), sol::bytes32("test"))?;

fn transact2<...>(caller: CALLER, cfn: ContractFunction, inputs...) {
/* ... */
}

// On the other hand this order of argument doesn't make sense
transact2(|input_bytes| { /* interact with blockchain */ }, reg.register(), input1, input2)
// while this one does (input gets encoded, then callback gets called)
transact2(reg.register(), input1, input2, |input_bytes| { /* interact with blockchain */ })
tomusdrw commented 6 years ago

@axelchalon totally agree wrt to API, have a look at the proposal of changes to ethabi: https://gist.github.com/tomusdrw/e8b6b3fa448a9935b35858e1aa6ceaa9

This would allow use to do:

evm.transact(|contract| contract.register(sol::address(10), sol::bytes32("test"))?;