github.com/ethereum-optimism/optimism@v1.7.2/packages/contracts-bedrock/src/legacy/DeployerWhitelist.sol (about)

     1  // SPDX-License-Identifier: MIT
     2  pragma solidity 0.8.15;
     3  
     4  import { ISemver } from "src/universal/ISemver.sol";
     5  
     6  /// @custom:legacy
     7  /// @custom:proxied
     8  /// @custom:predeployed 0x4200000000000000000000000000000000000002
     9  /// @title DeployerWhitelist
    10  /// @notice DeployerWhitelist is a legacy contract that was originally used to act as a whitelist of
    11  ///         addresses allowed to the Optimism network. The DeployerWhitelist has since been
    12  ///         disabled, but the code is kept in state for the sake of full backwards compatibility.
    13  ///         As of the Bedrock upgrade, the DeployerWhitelist is completely unused by the Optimism
    14  ///         system and could, in theory, be removed entirely.
    15  contract DeployerWhitelist is ISemver {
    16      /// @notice Address of the owner of this contract. Note that when this address is set to
    17      ///         address(0), the whitelist is disabled.
    18      address public owner;
    19  
    20      /// @notice Mapping of deployer addresses to boolean whitelist status.
    21      mapping(address => bool) public whitelist;
    22  
    23      /// @notice Emitted when the owner of this contract changes.
    24      /// @param oldOwner Address of the previous owner.
    25      /// @param newOwner Address of the new owner.
    26      event OwnerChanged(address oldOwner, address newOwner);
    27  
    28      /// @notice Emitted when the whitelist status of a deployer changes.
    29      /// @param deployer    Address of the deployer.
    30      /// @param whitelisted Boolean indicating whether the deployer is whitelisted.
    31      event WhitelistStatusChanged(address deployer, bool whitelisted);
    32  
    33      /// @notice Emitted when the whitelist is disabled.
    34      /// @param oldOwner Address of the final owner of the whitelist.
    35      event WhitelistDisabled(address oldOwner);
    36  
    37      /// @notice Blocks functions to anyone except the contract owner.
    38      modifier onlyOwner() {
    39          require(msg.sender == owner, "DeployerWhitelist: function can only be called by the owner of this contract");
    40          _;
    41      }
    42  
    43      /// @notice Semantic version.
    44      /// @custom:semver 1.1.0
    45      string public constant version = "1.1.0";
    46  
    47      /// @notice Adds or removes an address from the deployment whitelist.
    48      /// @param _deployer      Address to update permissions for.
    49      /// @param _isWhitelisted Whether or not the address is whitelisted.
    50      function setWhitelistedDeployer(address _deployer, bool _isWhitelisted) external onlyOwner {
    51          whitelist[_deployer] = _isWhitelisted;
    52          emit WhitelistStatusChanged(_deployer, _isWhitelisted);
    53      }
    54  
    55      /// @notice Updates the owner of this contract.
    56      /// @param _owner Address of the new owner.
    57      function setOwner(address _owner) external onlyOwner {
    58          // Prevent users from setting the whitelist owner to address(0) except via
    59          // enableArbitraryContractDeployment. If you want to burn the whitelist owner, send it to
    60          // any other address that doesn't have a corresponding knowable private key.
    61          require(_owner != address(0), "DeployerWhitelist: can only be disabled via enableArbitraryContractDeployment");
    62  
    63          emit OwnerChanged(owner, _owner);
    64          owner = _owner;
    65      }
    66  
    67      /// @notice Permanently enables arbitrary contract deployment and deletes the owner.
    68      function enableArbitraryContractDeployment() external onlyOwner {
    69          emit WhitelistDisabled(owner);
    70          owner = address(0);
    71      }
    72  
    73      /// @notice Checks whether an address is allowed to deploy contracts.
    74      /// @param _deployer Address to check.
    75      /// @return Whether or not the address can deploy contracts.
    76      function isDeployerAllowed(address _deployer) external view returns (bool) {
    77          return (owner == address(0) || whitelist[_deployer]);
    78      }
    79  }