foundry-rs / foundry-rs/foundry

Add `vm.getRecordedLogs(bytes4 selector)` + `vm.getRecordedLogs(bytes4[] selectors)` cheatcode to return only the logs that match the given selector

Open
#5,959 0 comments 2 reactions 0 assignees View on GitHub
A-cheatcodes T-feature T-post-V1
Dominant language
Rust
Stars
10.6k
Forks
2.6k
Avg merge
18h 20m
Merged PRs (30d)
510

Description

### Component

Forge

### Describe the feature you would like

It will be beneficial to have a feature where we can filter the logs based on the selector.

The use of `getRecordedLogs` is generally done when the first emitted event is not the one that you want to match.
But the problem is sometimes the event to be matched is deep inside multiple other logs, which makes the developer either run a loop or have to "guess" the correct index!

So, having a filter to get only the logs the user wants will eliminate the problem.

```solidity
function getRecordedLogs(bytes4 selector) external returns(Log[] memory)
```

I will happily contribute by opening the PR.

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.