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