github.com/ethereum-optimism/optimism@v1.7.2/packages/contracts-bedrock/scripts/Deployer.sol (about)

     1  // SPDX-License-Identifier: MIT
     2  pragma solidity ^0.8.0;
     3  
     4  import { Script } from "forge-std/Script.sol";
     5  import { Artifacts } from "scripts/Artifacts.s.sol";
     6  import { Config } from "scripts/Config.sol";
     7  import { DeployConfig } from "scripts/DeployConfig.s.sol";
     8  import { USE_FAULT_PROOFS_SLOT } from "scripts/DeployConfig.s.sol";
     9  
    10  /// @title Deployer
    11  /// @author tynes
    12  /// @notice A contract that can make deploying and interacting with deployments easy.
    13  abstract contract Deployer is Script, Artifacts {
    14      DeployConfig public constant cfg =
    15          DeployConfig(address(uint160(uint256(keccak256(abi.encode("optimism.deployconfig"))))));
    16  
    17      /// @notice Sets up the artifacts contract.
    18      function setUp() public virtual override {
    19          Artifacts.setUp();
    20  
    21          // Load the `useFaultProofs` slot value prior to etching the DeployConfig's bytecode and reading the deploy
    22          // config file. If this slot has already been set, it will override the preference in the deploy config.
    23          bytes32 useFaultProofsOverride = vm.load(address(cfg), USE_FAULT_PROOFS_SLOT);
    24  
    25          vm.etch(address(cfg), vm.getDeployedCode("DeployConfig.s.sol:DeployConfig"));
    26          vm.label(address(cfg), "DeployConfig");
    27          vm.allowCheatcodes(address(cfg));
    28          cfg.read(Config.deployConfigPath());
    29  
    30          if (useFaultProofsOverride != 0) {
    31              vm.store(address(cfg), USE_FAULT_PROOFS_SLOT, useFaultProofsOverride);
    32          }
    33      }
    34  
    35      /// @notice Returns the name of the deployment script. Children contracts
    36      ///         must implement this to ensure that the deploy artifacts can be found.
    37      ///         This should be the same as the name of the script and is used as the file
    38      ///         name inside of the `broadcast` directory when looking up deployment artifacts.
    39      function name() public pure virtual returns (string memory);
    40  }