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

     1  // SPDX-License-Identifier: MIT
     2  pragma solidity ^0.8.0;
     3  
     4  import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
     5  import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol";
     6  
     7  /// @title CrossDomainOwnable
     8  /// @notice This contract extends the OpenZeppelin `Ownable` contract for L2 contracts to be owned
     9  ///         by contracts on L1. Note that this contract is only safe to be used if the
    10  ///         CrossDomainMessenger system is bypassed and the caller on L1 is calling the
    11  ///         OptimismPortal directly.
    12  abstract contract CrossDomainOwnable is Ownable {
    13      /// @notice Overrides the implementation of the `onlyOwner` modifier to check that the unaliased
    14      ///         `msg.sender` is the owner of the contract.
    15      function _checkOwner() internal view override {
    16          require(
    17              owner() == AddressAliasHelper.undoL1ToL2Alias(msg.sender), "CrossDomainOwnable: caller is not the owner"
    18          );
    19      }
    20  }