Skip to content
This repository has been archived by the owner on May 4, 2023. It is now read-only.

use/include contract with a single step #13

Open
snd opened this issue Dec 18, 2017 · 6 comments
Open

use/include contract with a single step #13

snd opened this issue Dec 18, 2017 · 6 comments

Comments

@snd
Copy link
Contributor

snd commented Dec 18, 2017

currently to test a contract with sol-rs one needs to:

compile it in a build script: https://github.com/paritytech/sol-rs/blob/aed4bb377db6bf7459e5ee3792e1d7cddfb45cef/example/build.rs#L4

use_contract! on the ABI file: https://github.com/paritytech/sol-rs/blob/aed4bb377db6bf7459e5ee3792e1d7cddfb45cef/example/src/main.rs#L15

load code from the bin file: https://github.com/paritytech/sol-rs/blob/aed4bb377db6bf7459e5ee3792e1d7cddfb45cef/example/src/main.rs#L20

ideally it would require a single step. wishful thinking:

use_contract!(badgereg, "BadgeReg", "res/BadgeReg.sol");

let contract = badgereg::BadgeReg::default();

let mut evm = solaris::evm();

let owner = 3.into();
let _address = evm.with_sender(owner).deploy(&contract);

the API should allow support the convenient single step as well as the individual steps.

@snd
Copy link
Contributor Author

snd commented Dec 18, 2017

related #8

@tomusdrw
Copy link
Collaborator

use_contract! on the ABI file:
load code from the bin file:

Last two steps can be indeed simplified, although I can't see how we can get rid of the build script - the solidity ABI needs to be generated before the compilation of Rust code is performed (since the staticly-typed contract interface is generated out of it), so we need to have a way to compile contracts before compiling rust tests.

@snd
Copy link
Contributor Author

snd commented Dec 18, 2017

could we have a procedural macro that shells out to the solidity compiler?

@tomusdrw
Copy link
Collaborator

Good point. Yeah I suppose it would be possible.

@kirushik
Copy link
Collaborator

I really like the way pest_derive does this (procedural macros, all magic happens during compile time):

https://github.com/pest-parser/pest/blob/61c1c8981ca18c611bfa94b73893ae52602c5af1/pest_derive/tests/grammar.rs#L13-L15

@snd
Copy link
Contributor Author

snd commented Jun 7, 2018

working on https://github.com/snd/rust_solc which will use the JSON I/O API of solc/solcjs and will get us one step closer to this

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants
@snd @kirushik @tomusdrw and others