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: print event definitions #4455

Merged
merged 7 commits into from
Aug 17, 2023
Merged

feat: print event definitions #4455

merged 7 commits into from
Aug 17, 2023

Conversation

Bobface
Copy link
Contributor

@Bobface Bobface commented Mar 1, 2023

Motivation

Getting information about events, such as their signature, is a useful feature. Cast already offers that through cast sig-event, and this PR adds a similar feature for Chisel.

Solution

When parsing the latest line with let line = format!("bytes memory inspectoor = abi.encode({input});"); fails, do not return early but instead check whether the latest line is the name of an event and if that's the case, print information about the event.

Example

Welcome to Chisel! Type `!help` to show available commands.
➜ event SomeEvent(uint256 indexed amount, address indexed user, uint32 index);
➜ SomeEvent
Type: event
├ Name: SomeEvent
└ Signature: 0xc7b1e4c8001505f9934d5ee0d745935c3b1cf0a9eef39860f497c15f9ec9a1be
➜ event SomeOtherEvent(address);
➜ SomeOtherEvent
Type: event
├ Name: SomeOtherEvent
└ Signature: 0xe311a95f689f1b8f6494d8ff8243f05aae06ecc0d44b37b56e8d704901cac8bb
➜

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

tbh not exactly sure what this does.

@clabby @DaniPopes would appreciate a review

chisel/src/executor.rs Outdated Show resolved Hide resolved
@mattsse mattsse added the C-chisel Command: chisel label Mar 1, 2023
@Bobface
Copy link
Contributor Author

Bobface commented Mar 4, 2023

The idea is that you can print information about events.

For example, for variables you can already do

uint a = 123;
a

and it will give you information about the variable.

If you do

event SomeEvent(address user)
SomeEvent

nothing is printed. This PR adds support for printing the event's name and most importantly its signature.

Regarding requested changes I would wait until all reviews are complete and then do them in a single commit.

@mattsse
Copy link
Member

mattsse commented Mar 7, 2023

@clabby friendly ping :)

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.

Also needs cargo +nightly fmt

chisel/src/executor.rs Outdated Show resolved Hide resolved
chisel/src/executor.rs Outdated Show resolved Hide resolved
@Bobface
Copy link
Contributor Author

Bobface commented Mar 16, 2023

Implemented the changes.

Copy link
Contributor

@clabby clabby left a comment

Choose a reason for hiding this comment

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

nice work!

chisel/src/executor.rs Outdated Show resolved Hide resolved
chisel/src/executor.rs Outdated Show resolved Hide resolved
chisel/src/executor.rs Outdated Show resolved Hide resolved
Co-authored-by: clabby <[email protected]>
Copy link
Contributor

@clabby clabby left a comment

Choose a reason for hiding this comment

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

LGTM

@Bobface
Copy link
Contributor Author

Bobface commented Mar 18, 2023

Added the missing SolidityHelper import which caused the build to fail.

@Bobface
Copy link
Contributor Author

Bobface commented Mar 25, 2023

Hey, checking in on this :)

Copy link
Member

@Evalir Evalir left a comment

Choose a reason for hiding this comment

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

lgtm! finally getting this in. we can improve on verbosity in subsequent prs

@Evalir Evalir requested a review from mattsse August 15, 2023 23:26
@Evalir Evalir merged commit f64fe13 into foundry-rs:master Aug 17, 2023
20 checks passed
@Bobface Bobface deleted the print-events branch December 15, 2023 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-chisel Command: chisel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants