solang icon indicating copy to clipboard operation
solang copied to clipboard

solang needs to accept solidity standard json as input

Open seanyoung opened this issue 2 years ago • 16 comments

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 avatar May 03 '22 14:05 seanyoung

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

seanyoung avatar May 03 '22 14:05 seanyoung

@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

devratapuri avatar May 14 '22 05:05 devratapuri

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

seanyoung avatar May 14 '22 07:05 seanyoung

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

Genysys avatar Jun 16 '22 13:06 Genysys

Hi @Genysys, are you still on it?

xermicus avatar Jul 18 '22 09:07 xermicus

@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)

5hv5hvnk avatar May 05 '23 14:05 5hv5hvnk

@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

devratapuri avatar May 05 '23 14:05 devratapuri

@devratapuri are you still working on this?

xermicus avatar May 05 '23 14:05 xermicus

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

xermicus avatar May 05 '23 14:05 xermicus

@devratapuri are you still working on this?

Nope sry i almost forgot about it .

devratapuri avatar May 05 '23 14:05 devratapuri

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

5hv5hvnk avatar May 10 '23 04:05 5hv5hvnk

@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

seanyoung avatar May 10 '23 07:05 seanyoung

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

5hv5hvnk avatar May 14 '23 15:05 5hv5hvnk

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?

seanyoung avatar May 14 '23 17:05 seanyoung

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

5hv5hvnk avatar May 24 '23 07:05 5hv5hvnk

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.

seanyoung avatar May 24 '23 08:05 seanyoung