// SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import {BaseGuard} from "../guard/BaseGuard.sol"; import {IGuard} from "../interfaces/IGuard.sol"; /// @title Guardable - A contract that manages fallback calls made to this contract contract Guardable is OwnableUpgradeable { address public guard; event ChangedGuard(address guard); /// `guard_` does not implement IERC165. error NotIERC165Compliant(address guard_); /// @dev Set a guard that checks transactions before execution. /// @param _guard The address of the guard to be used or the 0 address to disable the guard. function setGuard(address _guard) external onlyOwner { if (_guard != address(0)) { if (!BaseGuard(_guard).supportsInterface(type(IGuard).interfaceId)) revert NotIERC165Compliant(_guard); } guard = _guard; emit ChangedGuard(guard); } function getGuard() external view returns (address _guard) { return guard; } }