foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.09k stars 1.67k forks source link

feat: `forge inspect` should show event topics #7947

Closed drortirosh closed 1 month ago

drortirosh commented 3 months ago

Component

Forge

Have you ensured that all of these are up to date?

What version of Foundry are you on?

No response

What command(s) is the bug in?

No response

Operating System

None

Describe the bug

When using forge inspect to get methods, you get a list of methods and their identifiers.

$ forge inspect Ownable  methodIdentifiers

{
  "owner()": "8da5cb5b",
  "renounceOwnership()": "715018a6",
  "transferOwnership(address)": "f2fde38b"
}

But when using it to get events, you get a list of events - with their events string repeated...

$ forge inspect Ownable  events

{
  "OwnershipTransferred(address,address)": "\"OwnershipTransferred(address,address)\""
}

seems much more useful to return the topic (keccak) as value, instead of repeating the string representation.

zerosnacks commented 1 month ago

Hi @drortirosh thanks for your suggestion

I agree that it would be more useful to display the hash than an escaped string (perhaps as eventIdentifiers to not break backwards compatibility?)

forge inspect simply introspects the artifact which does not contain this information directly but it looks like we are already doing this for errors

https://github.com/foundry-rs/foundry/blob/dad390189d0a2b3861e074f3d49d22c9e2e8fd7e/crates/forge/bin/cmd/inspect.rs#L130-L162

leovct commented 1 month ago

Hi @zerosnacks, I'd like to work on this issue