diff --git a/src/delegate/DelegateEnsoShortcuts.sol b/src/delegate/DelegateEnsoShortcuts.sol index 0a42da9..6c26317 100644 --- a/src/delegate/DelegateEnsoShortcuts.sol +++ b/src/delegate/DelegateEnsoShortcuts.sol @@ -9,6 +9,6 @@ contract DelegateEnsoShortcuts is AbstractEnsoShortcuts { error OnlyDelegateCall(); function _checkMsgSender() internal view override { - if (msg.sender == __self) revert OnlyDelegateCall(); + if (address(this) == __self) revert OnlyDelegateCall(); } } diff --git a/test/DelegateEnsoShortcuts.t.sol b/test/DelegateEnsoShortcuts.t.sol index 149a5cd..b1226ee 100644 --- a/test/DelegateEnsoShortcuts.t.sol +++ b/test/DelegateEnsoShortcuts.t.sol @@ -95,4 +95,21 @@ contract DelegateEnsoShortcutsTest is Test, SafeTestTools { assertEq(weth.balanceOf(address(safeInstance.safe)), 10 ether); assertEq(safeBalanceBefore - 10 ether, address(safeInstance.safe).balance); } + + function testToDirectlyCallDelegateContract() public { + bytes32[] memory commands = new bytes32[](1); + commands[0] = WeirollPlanner.buildCommand( + weth.deposit.selector, + 0x03, // call with value + 0x00ffffffffff, // 1 input + 0xff, // no output + address(weth) + ); + + bytes[] memory state = new bytes[](1); + state[0] = abi.encode(10 ether); + + vm.expectRevert(DelegateEnsoShortcuts.OnlyDelegateCall.selector); + shortcuts.executeShortcut(bytes32(0), bytes32(0), commands, state); + } }