2018-07-25 20:01:42 +00:00
|
|
|
pragma solidity ^0.4.18;
|
|
|
|
|
|
|
|
import './ENS.sol';
|
|
|
|
import './Resolver.sol';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A registrar that allocates subdomains to the first person to claim them.
|
|
|
|
*/
|
|
|
|
contract FIFSRegistrar {
|
|
|
|
ENS ens;
|
|
|
|
bytes32 rootNode;
|
|
|
|
|
|
|
|
modifier only_owner(bytes32 subnode) {
|
2018-08-16 15:34:47 +00:00
|
|
|
bytes32 node = keccak256(abi.encodePacked(rootNode, subnode));
|
2018-07-25 20:01:42 +00:00
|
|
|
address currentOwner = ens.owner(node);
|
|
|
|
require(currentOwner == 0 || currentOwner == msg.sender);
|
|
|
|
_;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
* @param ensAddr The address of the ENS registry.
|
|
|
|
* @param node The node that this registrar administers.
|
|
|
|
*/
|
2018-08-16 15:34:47 +00:00
|
|
|
constructor(ENS ensAddr, bytes32 node) public {
|
2018-07-25 20:01:42 +00:00
|
|
|
ens = ensAddr;
|
|
|
|
rootNode = node;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register a name, or change the owner of an existing registration.
|
|
|
|
* @param subnode The hash of the label to register.
|
|
|
|
* @param owner The address of the new owner.
|
|
|
|
*/
|
|
|
|
function register(bytes32 subnode, address owner) public only_owner(subnode) {
|
|
|
|
ens.setSubnodeOwner(rootNode, subnode, owner);
|
|
|
|
}
|
|
|
|
}
|