// SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; import "../../common/Enum.sol"; import "../../base/GuardManager.sol"; import "../../Safe.sol"; /** * @title DelegateCallTransactionGuard - Limits delegate calls to a specific target. * @author Richard Meissner - @rmeissner */ contract DelegateCallTransactionGuard is BaseGuard { address public immutable allowedTarget; constructor(address target) { allowedTarget = target; } // solhint-disable-next-line payable-fallback fallback() external { // We don't revert on fallback to avoid issues in case of a Safe upgrade // E.g. The expected check method might change and then the Safe would be locked. } /** * @notice Called by the Safe contract before a transaction is executed. * @dev Reverts if the transaction is a delegate call to contract other than the allowed one. * @param to Destination address of Safe transaction. * @param operation Operation type of Safe transaction. */ function checkTransaction( address to, uint256, bytes memory, Enum.Operation operation, uint256, uint256, uint256, address, // solhint-disable-next-line no-unused-vars address payable, bytes memory, address ) external view override { require(operation != Enum.Operation.DelegateCall || to == allowedTarget, "This call is restricted"); } function checkAfterExecution(bytes32, bool) external view override {} }