hyperledger / solang

Solidity Compiler for Solana and Polkadot
https://solang.readthedocs.io/
Apache License 2.0
1.22k stars 207 forks source link

solang needs to accept solidity standard json as input #791

Open seanyoung opened 2 years ago

seanyoung commented 2 years ago

When solang --standard-json is run, the output from the compiler is in the standard json format. However, the input is not.

1) Parse input on stdin as json using the standard json format 2) Make sure the input described in 1) is compiled and result is printed using standard json (that last part is already implemented). 3) Write tests for this feature

Note that changing this feature will break the burrow tests. The burrow tests can be disabled for now, since burrow is a dead project.

seanyoung commented 2 years ago

This feature is needed for #715 so that the json input can be used from javascript.

devratapuri commented 2 years ago

@seanyoung I will like to take this issue so what exactly I need to do can you guide me as it is my first time

seanyoung commented 2 years ago

The json format is described in the solc documentation.

The output format is already implemented. The input format needs implementing.

The output format is described here: https://github.com/hyperledger-labs/solang/blob/main/src/bin/solang.rs#L20-L41 There will need to be an a similar definition of the input format, but with #[derive(Deserialize)] rather than #[derive(Serialize)] because we will be decoding it.

Maybe it's time to put both definitions of the json format in its own rust file/module and then import it.

Once the definition is written, then the command line of solang must be modified. If the option --standard-json is specified, which you can check with matches.is_present("STD-JSON" then read the input from stdin to the end, then the deserialize it using serde using the json definitions you've written. This should be described in https://serde.rs/derive.html

Then process the files in the json, just like it is done now for files which are specified on the command line. So, call fn process_file() for each file in the json. Note! The contents of the file may be specified in the json itself, so fn process_file() needs to be updated to not read the file if the contents is given in the json.

Once that is done, some tests need to be written, and a PR opened. Please let me us know how you get on, we're always here to help. Also find us on discord.

Thank you @devratapuri

Genysys commented 2 years ago

@devratapuri are you still doing this? If not I would love to take it out.

xermicus commented 1 year ago

Hi @Genysys, are you still on it?

5hv5hvnk commented 1 year ago

@xermicus Should I get on it?

Just let me know where in the repository we can do these changes (sorry I am a first time contributor here)

devratapuri commented 1 year ago

@xermicus Should I get on it?

Just let me know where in the repository we can do these changes (sorry I am a first time contributor here)

He has linked it in his ans

xermicus commented 1 year ago

@devratapuri are you still working on this?

xermicus commented 1 year ago

If not, @5hv5hvnk feel free to tackle this issue

devratapuri commented 1 year ago

@devratapuri are you still working on this?

Nope sry i almost forgot about it .

5hv5hvnk commented 1 year ago

As far as I understand the test it is to go through output format here and create similar input format. So the changes have to be made here right? Sorry took me so many days I was just brushing up my rust skills

seanyoung commented 1 year ago

@5hv5hvnk the json input format needs to defined in this file https://github.com/hyperledger/solang/blob/main/src/standard_json.rs Then this file https://github.com/hyperledger/solang/blob/main/src/lib.rs needs a function which takes this format and process it. It should be called from https://github.com/hyperledger/solang/blob/a371ea21bde8278c9c967a27251abcf5aa2712f2/src/bin/solang.rs#LL45C25-L49C43

5hv5hvnk commented 1 year ago

I am facing some issues with adding a function in lib.rs should I raise a PR and discuss there or you can check my recent commit here

seanyoung commented 1 year ago

I am facing some issues with adding a function in lib.rs should I raise a PR and discuss there or you can check my recent commit here

What's the problem?

5hv5hvnk commented 1 year ago

I am not very clear how the function should process the data. (I even couldn't find analogous function for output.josn)

seanyoung commented 1 year ago

solang should compile the source files provided in json in the format described here: https://docs.soliditylang.org/en/v0.8.13/using-tthe-compiler.html#compiler-input-and-output-json-description rather than files provided on the command line.

See section Input Description.