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

     1  // SPDX-License-Identifier: MIT
     2  pragma solidity 0.8.15;
     3  
     4  import { OptimismMintableERC721 } from "src/universal/OptimismMintableERC721.sol";
     5  import { ISemver } from "src/universal/ISemver.sol";
     6  
     7  /// @title OptimismMintableERC721Factory
     8  /// @notice Factory contract for creating OptimismMintableERC721 contracts.
     9  contract OptimismMintableERC721Factory is ISemver {
    10      /// @notice Address of the ERC721 bridge on this network.
    11      address public immutable BRIDGE;
    12  
    13      /// @notice Chain ID for the remote network.
    14      uint256 public immutable REMOTE_CHAIN_ID;
    15  
    16      /// @notice Tracks addresses created by this factory.
    17      mapping(address => bool) public isOptimismMintableERC721;
    18  
    19      /// @notice Emitted whenever a new OptimismMintableERC721 contract is created.
    20      /// @param localToken  Address of the token on the this domain.
    21      /// @param remoteToken Address of the token on the remote domain.
    22      /// @param deployer    Address of the initiator of the deployment
    23      event OptimismMintableERC721Created(address indexed localToken, address indexed remoteToken, address deployer);
    24  
    25      /// @notice Semantic version.
    26      /// @custom:semver 1.4.0
    27      string public constant version = "1.4.0";
    28  
    29      /// @notice The semver MUST be bumped any time that there is a change in
    30      ///         the OptimismMintableERC721 token contract since this contract
    31      ///         is responsible for deploying OptimismMintableERC721 contracts.
    32      /// @param _bridge Address of the ERC721 bridge on this network.
    33      /// @param _remoteChainId Chain ID for the remote network.
    34      constructor(address _bridge, uint256 _remoteChainId) {
    35          BRIDGE = _bridge;
    36          REMOTE_CHAIN_ID = _remoteChainId;
    37      }
    38  
    39      /// @notice Creates an instance of the standard ERC721.
    40      /// @param _remoteToken Address of the corresponding token on the other domain.
    41      /// @param _name        ERC721 name.
    42      /// @param _symbol      ERC721 symbol.
    43      function createOptimismMintableERC721(
    44          address _remoteToken,
    45          string memory _name,
    46          string memory _symbol
    47      )
    48          external
    49          returns (address)
    50      {
    51          require(_remoteToken != address(0), "OptimismMintableERC721Factory: L1 token address cannot be address(0)");
    52  
    53          bytes32 salt = keccak256(abi.encode(_remoteToken, _name, _symbol));
    54          address localToken =
    55              address(new OptimismMintableERC721{ salt: salt }(BRIDGE, REMOTE_CHAIN_ID, _remoteToken, _name, _symbol));
    56  
    57          isOptimismMintableERC721[localToken] = true;
    58          emit OptimismMintableERC721Created(localToken, _remoteToken, msg.sender);
    59  
    60          return localToken;
    61      }
    62  }