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

forge inspect <contract> errors/events #3142

Closed
ultrasecreth opened this issue Sep 8, 2022 · 8 comments
Closed

forge inspect <contract> errors/events #3142

ultrasecreth opened this issue Sep 8, 2022 · 8 comments
Labels
C-forge Command: forge Cmd-forge-inspect Command: forge inspect T-feature Type: feature

Comments

@ultrasecreth
Copy link

Component

Forge

Describe the feature you would like

When working with custom errors, sometimes for whatever reason the chain will spit out the raw bytes instead of the parsed error.
In those cases, it'd be very useful to be able to list the bytes4 sig of all the errors a contract may throw so then I can parse the raw bytes with cast.
I think that for completeness, I'd do the same for events, which would be useful when sometimes, even if the contract is verified, etherscan shows the raw byes.

Thanks!

Additional context

No response

@ultrasecreth ultrasecreth added the T-feature Type: feature label Sep 8, 2022
@rkrasiuk rkrasiuk added C-forge Command: forge Cmd-forge-inspect Command: forge inspect labels Sep 9, 2022
@PaulRBerg
Copy link
Contributor

+1

sometimes for whatever reason

One reason is this bug in the invariants: #4178

@PaulRBerg
Copy link
Contributor

In the meantime, you can use cast sig to calculate the 4-byte selector for any function or custom error.

$ cast sig "transfer(address,uint256)"
# Outputs 0xa9059cbb

$ cast sig "Unauthorized(address)"
# Outputs 0x8e4a23d6

@ultrasecreth
Copy link
Author

In the meantime, you can use cast sig to calculate the 4-byte selector for any function or custom error.

$ cast sig "transfer(address,uint256)"
# Outputs 0xa9059cbb

$ cast sig "Unauthorized(address)"
# Outputs 0x8e4a23d6

Yeah, I know, but have to manually do it for all the errors in my contract, which is not hard, but's annoying af

@grandizzy
Copy link
Collaborator

think this can be closed, forge inspect errors is available in latest versions

@PaulRBerg
Copy link
Contributor

That's amazing, thanks for the heads-up @grandizzy!

@KholdStare
Copy link
Contributor

@grandizzy That's awesome - could you link to the PR for the feature? This should also solve this: #3656 . Thank you.

@grandizzy
Copy link
Collaborator

@grandizzy That's awesome - could you link to the PR for the feature? This should also solve this: #3656 . Thank you.

here it is #5228

@grandizzy
Copy link
Collaborator

@mattsse this one can be closed

@mattsse mattsse closed this as completed Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge Cmd-forge-inspect Command: forge inspect T-feature Type: feature
Projects
Status: Completed
Development

No branches or pull requests

6 participants