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

clean up json length parsing #12

Open
tynes opened this issue Oct 11, 2023 · 0 comments
Open

clean up json length parsing #12

tynes opened this issue Oct 11, 2023 · 0 comments

Comments

@tynes
Copy link
Contributor

tynes commented Oct 11, 2023

If you are open to enabling ffi, it is possible to use jq to get the length of a JSON array. It would allow for the removal of this code:

// A hacky way to get the total number of elements in a JSON
// object array because Forge does not support this natively.

There is a lot of usage of jq in the monorepo forge scripts.

Also the solidity team has talked about removing abi.encodePacked in a future version of solidity, so string.concat should be preferred over string(abi.encodePacked(...))

try vm.parseJsonAddress(json, string(abi.encodePacked("$.transactions[", vm.toString(i), "].to"))) returns (address) {

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

No branches or pull requests

1 participant