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

feat(cast): decode-error with sig, local cache and openchain api #9428

Merged
merged 6 commits into from
Nov 29, 2024

Conversation

grandizzy
Copy link
Collaborator

@grandizzy grandizzy commented Nov 28, 2024

Motivation

  • add cast decode-error [OPTIONS] <DATA> command: if --sig arg specified then it tries to decode data with given signature; if no --sig then tries to identify error in local cache or openchain API and decode with. For identified errors, the signature is printed in response
  • error sigs can be exported in cache using forge selectors cache within project

image

Solution

@grandizzy grandizzy changed the title feat(cast): Add custom error decoding support feat(cast): Add decode-error with sig and local cache Nov 28, 2024
@grandizzy grandizzy changed the title feat(cast): Add decode-error with sig and local cache feat(cast): decode-error with sig and local cache Nov 28, 2024
@grandizzy grandizzy marked this pull request as ready for review November 28, 2024 09:28
crates/cast/bin/args.rs Outdated Show resolved Hide resolved
@grandizzy grandizzy requested a review from zerosnacks November 28, 2024 15:22
Copy link
Member

@zerosnacks zerosnacks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! 💯

@grandizzy grandizzy changed the title feat(cast): decode-error with sig and local cache feat(cast): decode-error with sig, local cache and openchain api Nov 28, 2024
@grandizzy grandizzy requested a review from DaniPopes November 28, 2024 19:03
@grandizzy grandizzy enabled auto-merge (squash) November 28, 2024 19:06
Copy link
Member

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm nits

.await
.identify_error(&hex::decode(selector)?)
.await;
if err.is_none() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let Some ... else

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed in 1834215

DecodeError {
/// The error signature. If none provided then tries to decode from local cache or `https://api.openchain.xyz`.
#[arg(long, visible_alias = "error-sig")]
sig: Option<String>,
Copy link
Member

@DaniPopes DaniPopes Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make this optional for decode event too? followup

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, will follow up with a PR, have to figure out how to parse with topics

@grandizzy grandizzy disabled auto-merge November 28, 2024 19:54
@grandizzy grandizzy requested a review from DaniPopes November 29, 2024 07:39
@grandizzy grandizzy enabled auto-merge (squash) November 29, 2024 07:39
@grandizzy grandizzy merged commit 0d76df5 into foundry-rs:master Nov 29, 2024
21 checks passed
@grandizzy grandizzy deleted the cast-cust-err branch November 29, 2024 07:52
rplusq pushed a commit to rplusq/foundry that referenced this pull request Nov 29, 2024
…oundry-rs#9428)

* feat(cast): Add custom error decoding support

* Review changes

* Changes after review: decode with Openchain too, add test

* Review changes: nit, handle incomplete selectors
@grandizzy grandizzy added T-feature Type: feature C-cast Command: cast labels Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cast Command: cast T-feature Type: feature
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants