Skip to content

Commit 507f4d9

Browse files
Merge pull request #56 from EnsoBuild/delegate-fix
fix delegate self check
2 parents 07bfbe0 + 044c626 commit 507f4d9

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/delegate/DelegateEnsoShortcuts.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ contract DelegateEnsoShortcuts is AbstractEnsoShortcuts {
99
error OnlyDelegateCall();
1010

1111
function _checkMsgSender() internal view override {
12-
if (msg.sender == __self) revert OnlyDelegateCall();
12+
if (address(this) == __self) revert OnlyDelegateCall();
1313
}
1414
}

test/DelegateEnsoShortcuts.t.sol

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,21 @@ contract DelegateEnsoShortcutsTest is Test, SafeTestTools {
9595
assertEq(weth.balanceOf(address(safeInstance.safe)), 10 ether);
9696
assertEq(safeBalanceBefore - 10 ether, address(safeInstance.safe).balance);
9797
}
98+
99+
function testToDirectlyCallDelegateContract() public {
100+
bytes32[] memory commands = new bytes32[](1);
101+
commands[0] = WeirollPlanner.buildCommand(
102+
weth.deposit.selector,
103+
0x03, // call with value
104+
0x00ffffffffff, // 1 input
105+
0xff, // no output
106+
address(weth)
107+
);
108+
109+
bytes[] memory state = new bytes[](1);
110+
state[0] = abi.encode(10 ether);
111+
112+
vm.expectRevert(DelegateEnsoShortcuts.OnlyDelegateCall.selector);
113+
shortcuts.executeShortcut(bytes32(0), bytes32(0), commands, state);
114+
}
98115
}

0 commit comments

Comments
 (0)