File tree 4 files changed +69
-0
lines changed
4 files changed +69
-0
lines changed Original file line number Diff line number Diff line change 55
55
- [ setNonce] ( ./cheatcodes/set_nonce.md )
56
56
- [ coinbase] ( ./cheatcodes/coinbase.md )
57
57
- [ prank] ( ./cheatcodes/prank.md )
58
+ - [ startPrank] ( ./cheatcodes/start_prank.md )
59
+ - [ stopPrank] ( ./cheatcodes/stop_prank.md )
58
60
- [ prankHere] ( ./cheatcodes/prank_here.md )
59
61
- [ ffi] ( ./cheatcodes/ffi.md )
60
62
- [ addr] ( ./cheatcodes/addr.md )
Original file line number Diff line number Diff line change @@ -42,6 +42,12 @@ interface StdCheats {
42
42
// Sets the *next* call's msg.sender to be the input address
43
43
function prank(address) external;
44
44
45
+ // Sets all subsequent call's msg.sender (until stopPrank is called) to be the input address
46
+ function startPrank(address) external;
47
+
48
+ // Stops a previously called startPrank
49
+ function stopPrank() external;
50
+
45
51
// Set msg.sender to the input address until the current call exits
46
52
function prankHere(address) external;
47
53
Original file line number Diff line number Diff line change
1
+ # ` startPrank `
2
+
3
+ ## Description
4
+
5
+ The ` startPrank ` cheatcode will set the ` msg.sender ` for all subsequent calls until ` stopPrank ` is called. This is in
6
+ contrast to [ ` prank ` ] ( ./prank.md ) where ` prank ` only applies to the _ next_ message call.
7
+
8
+ ## Example
9
+
10
+ ``` solidity
11
+ contract TestContract {
12
+ address owner = address(123);
13
+ ImportantContract ic;
14
+ AnotherImportantContract aic;
15
+
16
+ function deployImportantContract() public {
17
+ require(msg.sender == owner);
18
+
19
+ // Deploy important contract
20
+ ic = new ImportantContract(msg.sender);
21
+ }
22
+
23
+ function deployAnotherImportantContract() public {
24
+ require(msg.sender == owner);
25
+
26
+ // Deploy important contract
27
+ ic = new AnotherImportantContract(msg.sender);
28
+ }
29
+
30
+ function test() public {
31
+ // Obtain our cheat code contract reference.
32
+ IStdCheats cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
33
+
34
+ // Prank and deploy important contracts
35
+ cheats.startPrank(owner);
36
+ deployImportantContract();
37
+ deployAnotherImportantContract();
38
+ cheats.stopPrank();
39
+
40
+ assert(ic.owner() == owner);
41
+ assert(aic.owner() == owner);
42
+ }
43
+ }
44
+ ```
45
+
46
+ ## Function Signature
47
+
48
+ ``` solidity
49
+ function startPrank(address) external;
50
+ ```
Original file line number Diff line number Diff line change
1
+ # ` stopPrank `
2
+
3
+ ## Description
4
+
5
+ Stops an active prank started by [ ` startPrank ` ] ( ./start_prank.md ) , resetting ` msg.sender `
6
+
7
+ ## Function Signature
8
+
9
+ ``` solidity
10
+ function stopPrank() external;
11
+ ```
You can’t perform that action at this time.
0 commit comments