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

improve cdd json parsing #9928

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

improve cdd json parsing #9928

wants to merge 8 commits into from

Conversation

tclemos
Copy link

@tclemos tclemos commented Feb 20, 2025

Motivation

Below is a call to cast cdd to decode this particular transaction:
https://etherscan.io/tx/0x59b8625421982e22ec159ad4f5c32c2352b9185e3e4d0f8771e25c77719e2391

cast cdd --json 'sequenceBatchesValidium((bytes32,bytes32,uint64,bytes32)[],uint64,uint64,address,bytes)' 0xdb5b0ed700000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006772bf190000000000000000000000000000000000000000000000000000000000020716000000000000000000000000af9d27ffe4d51ed54ac8eec78f2785d7e11e5ab100000000000000000000000000000000000000000000000000000000000002c0000000000000000000000000000000000000000000000000000000000000000404366a6dc4b2f348a85e0066e46f0cc206fca6512e0ed7f17ca7afb88e9a4c27000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000093922dee6e380c28a50c008ab167b7800bb24c2026cd1b22f1c6fb884ceed7400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060f85e59ecad6c1a6be343a945abedb7d5b5bfad7817c4d8cc668da7d391faf700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000093dfbf04395fbec1f1aed4ad0f9d3ba880ff58a60485df5d33f8f5e0fb73188600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aa334a426ea9e21d5f84eb2d4723ca56b92382b9260ab2b6769b7c23d437b6b512322a25cecc954127e60cf91ef056ac1da25f90b73be81c3ff1872fa48d10c7ef1ccb4087bbeedb54b1417a24abbb76f6cd57010a65bb03c7b6602b1eaf0e32c67c54168232d4edc0bfa1b815b2af2a2d0a5c109d675a4f2de684e51df9abb324ab1b19a81bac80f9ce3a45095f3df3a7cf69ef18fc08e94ac3cbc1c7effeacca68e3bfe5d81e26a659b500000000000000000000000000000000000000000000

Ideally, the first argument here, which is a tuple, would be JSON encoded as an array rather than a string:
Image

My workaround for now has been use something like jq -r '.[0]' | tr "()" "[]" | sed -e 's/\(0x[0-9a-f]*\)/"\1"/gi' | jq '.' to parse the first argument.

Image

Solution

Changed ./crates/cast/main.rs print_token(tokens) to parse fields into JSON objects instead of strings

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Sorry, something went wrong.

tclemos and others added 6 commits February 20, 2025 13:59

Verified

This commit was signed with the committer’s verified signature.
tclemos Thiago Coimbra Lemos
…stead of string

Verified

This commit was signed with the committer’s verified signature.
tclemos Thiago Coimbra Lemos

Verified

This commit was signed with the committer’s verified signature.
tclemos Thiago Coimbra Lemos

Verified

This commit was signed with the committer’s verified signature.
tclemos Thiago Coimbra Lemos

Verified

This commit was signed with the committer’s verified signature.
tclemos Thiago Coimbra Lemos

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@tclemos tclemos marked this pull request as ready for review February 21, 2025 13:47

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@tclemos
Copy link
Author

tclemos commented Feb 26, 2025

@mattsse @zerosnacks would you mind checking this PR?
does it make sense from your perspective?
anything else I could help with?

@zerosnacks
Copy link
Member

Hi @tclemos thanks for your PR!

Whilst I understand the need to parse this as suggested I don't think the proposed solution is the one we are looking for as it effectively reverts the formatting applied in https://github.com/foundry-rs/foundry/blob/5c6b9ae8143bce995e52e927297429257d354ffd/crates/common/fmt/src/dynamic.rs. If we wanted to make a change to the formatting that would be place to make the change.

Personally I think the current formatting for tuples using ( .. ) is correct and consistent.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

None yet

2 participants