Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solang needs to accept solidity standard json as input #791

Open
seanyoung opened this issue May 3, 2022 · 16 comments
Open

solang needs to accept solidity standard json as input #791

seanyoung opened this issue May 3, 2022 · 16 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@seanyoung
Copy link
Contributor

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 seanyoung added enhancement New feature or request good first issue Good for newcomers labels May 3, 2022
@seanyoung
Copy link
Contributor Author

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

@devratapuri
Copy link

@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
Copy link
Contributor Author

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
Copy link

Genysys commented Jun 16, 2022

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

@xermicus
Copy link
Contributor

Hi @Genysys, are you still on it?

@5hv5hvnk
Copy link

5hv5hvnk commented May 5, 2023

@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
Copy link

@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
Copy link
Contributor

xermicus commented May 5, 2023

@devratapuri are you still working on this?

@xermicus
Copy link
Contributor

xermicus commented May 5, 2023

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

@devratapuri
Copy link

@devratapuri are you still working on this?

Nope sry i almost forgot about it .

@5hv5hvnk
Copy link

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
Copy link
Contributor Author

@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 added a commit to 5hv5hvnk/solang that referenced this issue May 14, 2023
@5hv5hvnk
Copy link

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
Copy link
Contributor Author

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
Copy link

5hv5hvnk commented May 24, 2023

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

@seanyoung
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

5 participants