github.com/daeglee/go-ethereum@v0.0.0-20190504220456-cad3e8d18e9b/contracts/ens/contract/FIFSRegistrar.sol (about)

     1  pragma solidity ^0.5.0;
     2  
     3  import "./ENS.sol";
     4  
     5  /**
     6   * A registrar that allocates subdomains to the first person to claim them.
     7   */
     8  contract FIFSRegistrar {
     9      ENS ens;
    10      bytes32 rootNode;
    11  
    12      modifier only_owner(bytes32 label) {
    13          address currentOwner = ens.owner(keccak256(abi.encodePacked(rootNode, label)));
    14          require(currentOwner == address(0x0) || currentOwner == msg.sender);
    15          _;
    16      }
    17  
    18      /**
    19       * Constructor.
    20       * @param ensAddr The address of the ENS registry.
    21       * @param node The node that this registrar administers.
    22       */
    23      constructor(ENS ensAddr, bytes32 node) public {
    24          ens = ensAddr;
    25          rootNode = node;
    26      }
    27  
    28      /**
    29       * Register a name, or change the owner of an existing registration.
    30       * @param label The hash of the label to register.
    31       * @param owner The address of the new owner.
    32       */
    33      function register(bytes32 label, address owner) public only_owner(label) {
    34          ens.setSubnodeOwner(rootNode, label, owner);
    35      }
    36  }