Closed MaxMustermann2 closed 6 days ago
thank you! left some comments, please also add a test similar with
https://github.com/foundry-rs/foundry/blob/a79dfaed6fc6f88cda5f314a25d1b484d9d8c051/crates/cast/tests/cli/main.rs#L1116 but for json format
@grandizzy Thanks for your review. Updated with your suggestions.
Looks good, but checking the test you just added there's only the layout printed because of the early return on json format (and missing some important fields as the storage values), I guess we want to include them as well, or only the layout?
I added a values
entry to the JSON. Let me know if that works; thanks!
The nextest
fails because the Alchemy API key is rate limited.
I have fixed the clippy workflow.
cargo clippy --workspace \
--all-targets \
--all-features > /dev/null 2>/dev/null && echo $?
0
Thanks @MaxMustermann2! Merged
Thank you both @grandizzy and @zerosnacks for your feedback and the commit. This will help with a Github workflow that I am working on; much appreciated.
Motivation
Prior to this change,
cast storage $ADDRESS --rpc-url $RPC_URL --etherscan-api-key $ETHERSCAN_API_KEY
always provided a prettified output, ignoring the--json
flag.Solution
This change makes
cast storage
respect the--json
flag. If--slot
is omitted and this flag is provided, the storage layout JSON is printed to stdout, instead of the pretty layout. The values are printed as a separate list within the JSON.Example
This example is included as a test named
storage_layout_simple_json
.stdout.txt
stderr.txt