sablier-labs / v2-core

⏳ Core smart contracts of the Sablier V2 token distribution protocol
https://sablier.com
Other
289 stars 38 forks source link

Deprecate `changePrank` #866

Closed smol-ninja closed 3 months ago

smol-ninja commented 3 months ago

The foundry cheatcode changePrank has been deprecated and will likely be removed in the future release.

Replacing it with vm.startPrank seems like a straightforward solution but it has introduced a new requirement that the prank must have been applied atleast once before overriding. This has also been raised by @PaulRBerg in https://github.com/foundry-rs/foundry/issues/4942 but a shame that they decided to close it in favour of the suggestion to handle it using readCallers.

Since we decided to update forge-std, the tests now throw a deprecation warning. There are two solutions I can think of:

  1. Carefully replace it with vm.startPrank.
  2. Implement a changePrank function ourselves which calls vm.stopPrank followed by vm.startPrank.

Wdyt @PaulRBerg @andreivladbrg.

Related

andreivladbrg commented 3 months ago

IMO it would be better if we implement a function ourselves that replicates the changePrank (i would name it differently)

smol-ninja commented 3 months ago

I agree with you Andrei. On the name how about resetPrank?

smol-ninja commented 3 months ago

Addressed in https://github.com/sablier-labs/v2-core/pull/865/commits/169947eebab9975fbc736af259475546610633de.

smol-ninja commented 3 months ago

Do you like the name @andreivladbrg or want to suggest something else?

PaulRBerg commented 3 months ago

I agree with @andreivladbrg, let's go with the path of least resistance and re-implement changePrank ourselves.

resetPrank works!