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.28k stars 1.75k forks source link

feat(`cheatcodes`): add `vm.expectTransfer` #8845

Open CodeSandwich opened 1 month ago

CodeSandwich commented 1 month ago

Currently there are multiple flavors of expectCall, but all of them treat empty data as a request to not check the calldata content. The problem is that there's no way to check if calldata is empty, e.g. because a native token transfer was made. The current expectCall API surface doesn't leave much space for adding this feature.

I propose adding a new set of expectTransfer functions. They would be identical to expectCall with all their variants, but they wouldn't have the data parameter, and they would expect that the address is called with zero-length calldata.

zerosnacks commented 1 month ago

Perhaps there is a way we can add this behavior to the existing expectCall, worth exploring

cc @mds1 / @grandizzy