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(forge): cheatcode for getting the current prank #4875

Closed
PaulRBerg opened this issue May 4, 2023 · 5 comments
Closed

feat(forge): cheatcode for getting the current prank #4875

PaulRBerg opened this issue May 4, 2023 · 5 comments
Assignees
Labels
A-cheatcodes Area: cheatcodes C-forge Command: forge Cmd-forge-test Command: forge test T-feature Type: feature

Comments

@PaulRBerg
Copy link
Contributor

PaulRBerg commented May 4, 2023

Component

Forge

Describe the feature you would like

It would be helpful to have a cheatcode for reading the current prank. The use case is testing utilities that don't have knowledge of when the current prank was started, but which require tweaking the msg.sender to perform a particular action in the contracts.

Suggested names:

  • getPrank
  • currentPrank
  • readPrank
@PaulRBerg PaulRBerg added the T-feature Type: feature label May 4, 2023
@gakonst gakonst added this to Foundry May 4, 2023
@github-project-automation github-project-automation bot moved this to Todo in Foundry May 4, 2023
@mds1 mds1 added Cmd-forge-test Command: forge test C-forge Command: forge A-cheatcodes Area: cheatcodes labels May 4, 2023
@xeno097
Copy link
Contributor

xeno097 commented May 5, 2023

If no one is working on this I'd be happy to give this a try. Any tip or suggestion on how to get this done would be more than welcome

@Evalir
Copy link
Member

Evalir commented May 5, 2023

Hey @xeno097, awesome. For adding a cheatcode, this article can be really useful. Be mindful that after adding a cheatcode we usually ask for a follow up PR for forge-std and the foundry book (i'll point this out again on the PR)

Before you're fully off to the races, I'd like to loop in @mds1 to see if he has any opinions about this cheatcode's design

@xeno097
Copy link
Contributor

xeno097 commented May 5, 2023

Considering that the prank cheat code allows impersonating the 0 address I think that the function signature should be something like this:

function readPrank() external returns (bool, address, address)

The first bool would indicate if a prank is active, the first address would be the new msg.sender, and the last one the new tx.origin used to set the prank. The boolean helps in removing the ambiguity of a prank being active in an edge case like calling vm.prank(address(0), address(0)).

@Evalir
Copy link
Member

Evalir commented Jun 25, 2023

Closing—fixed by #4884

@Evalir Evalir closed this as completed Jun 25, 2023
@github-project-automation github-project-automation bot moved this from Todo to Done in Foundry Jun 25, 2023
@PaulRBerg
Copy link
Contributor Author

wicked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cheatcodes Area: cheatcodes C-forge Command: forge Cmd-forge-test Command: forge test T-feature Type: feature
Projects
Archived in project
Development

No branches or pull requests

4 participants