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
- 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
Assessment
This issue has not been assessed yet.