use new ens contractname + safety check in register + update auth
This commit is contained in:
parent
c0e34300ed
commit
eca2ecefca
|
@ -2,8 +2,8 @@ pragma solidity ^0.4.23;
|
||||||
|
|
||||||
import "../common/Controlled.sol";
|
import "../common/Controlled.sol";
|
||||||
import "../token/ERC20Token.sol";
|
import "../token/ERC20Token.sol";
|
||||||
import "../ens/AbstractENS.sol";
|
import "../ens/ENS.sol";
|
||||||
import "../ens/PublicResolverInterface.sol";
|
import "../ens/ResolverInterface.sol";
|
||||||
|
|
||||||
|
|
||||||
contract SubdomainRegistry is Controlled {
|
contract SubdomainRegistry is Controlled {
|
||||||
|
@ -18,8 +18,8 @@ contract SubdomainRegistry is Controlled {
|
||||||
mapping (bytes32 => address) public taken;
|
mapping (bytes32 => address) public taken;
|
||||||
|
|
||||||
ERC20Token public token;
|
ERC20Token public token;
|
||||||
AbstractENS public ENSroot;
|
ENS public ens;
|
||||||
PublicResolverInterface public resolver;
|
ResolverInterface public resolver;
|
||||||
|
|
||||||
event Registered(bytes32 indexed _subDomainHash, address _identity);
|
event Registered(bytes32 indexed _subDomainHash, address _identity);
|
||||||
|
|
||||||
|
@ -32,8 +32,8 @@ contract SubdomainRegistry is Controlled {
|
||||||
{
|
{
|
||||||
initialize(
|
initialize(
|
||||||
ERC20Token(_token),
|
ERC20Token(_token),
|
||||||
AbstractENS(_ens),
|
ENS(_ens),
|
||||||
PublicResolverInterface(_resolver),
|
ResolverInterface(_resolver),
|
||||||
address(msg.sender)
|
address(msg.sender)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,17 @@ contract SubdomainRegistry is Controlled {
|
||||||
Domain memory domain = domains[_domainHash];
|
Domain memory domain = domains[_domainHash];
|
||||||
require(domain.active);
|
require(domain.active);
|
||||||
|
|
||||||
|
subdomainHash = keccak256(_userHash, _domainHash);
|
||||||
|
require(taken[subdomainHash] == address(0));
|
||||||
|
taken[subdomainHash] = address(msg.sender);
|
||||||
|
|
||||||
|
address currentOwner = ens.owner(subdomainHash);
|
||||||
|
require(currentOwner == 0 || currentOwner == msg.sender);
|
||||||
|
|
||||||
|
ens.setSubnodeOwner(_domainHash, _userHash, address(this));
|
||||||
|
ens.setResolver(subdomainHash, resolver);
|
||||||
|
resolver.setAddr(subdomainHash, address(msg.sender));
|
||||||
|
|
||||||
require(
|
require(
|
||||||
token.transferFrom(
|
token.transferFrom(
|
||||||
address(msg.sender),
|
address(msg.sender),
|
||||||
|
@ -57,14 +68,6 @@ contract SubdomainRegistry is Controlled {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
subdomainHash = keccak256(_userHash, _domainHash);
|
|
||||||
require(taken[subdomainHash] == address(0));
|
|
||||||
taken[subdomainHash] = address(msg.sender);
|
|
||||||
|
|
||||||
ENSroot.setSubnodeOwner(_domainHash, _userHash, address(this));
|
|
||||||
ENSroot.setResolver(subdomainHash, resolver);
|
|
||||||
resolver.setAddr(subdomainHash, address(msg.sender));
|
|
||||||
|
|
||||||
emit Registered(subdomainHash, address(msg.sender));
|
emit Registered(subdomainHash, address(msg.sender));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,8 +81,7 @@ contract SubdomainRegistry is Controlled {
|
||||||
msg.sender == taken[_subdomainHash] ||
|
msg.sender == taken[_subdomainHash] ||
|
||||||
msg.sender == controller
|
msg.sender == controller
|
||||||
);
|
);
|
||||||
require(PublicResolverInterface(resolver).addr(_subdomainHash) == msg.sender);
|
ResolverInterface(resolver).setAddr(_subdomainHash, _newContract);
|
||||||
PublicResolverInterface(resolver).setAddr(_subdomainHash, _newContract);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function addDomain(
|
function addDomain(
|
||||||
|
@ -90,7 +92,7 @@ contract SubdomainRegistry is Controlled {
|
||||||
onlyController
|
onlyController
|
||||||
{
|
{
|
||||||
require(!domains[_domain].active);
|
require(!domains[_domain].active);
|
||||||
require(ENSroot.owner(_domain) == address(this));
|
require(ens.owner(_domain) == address(this));
|
||||||
domains[_domain] = Domain(true, _price);
|
domains[_domain] = Domain(true, _price);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,8 +103,8 @@ contract SubdomainRegistry is Controlled {
|
||||||
external
|
external
|
||||||
onlyController
|
onlyController
|
||||||
{
|
{
|
||||||
require(ENSroot.owner(_domain) == address(this));
|
require(ens.owner(_domain) == address(this));
|
||||||
ENSroot.setOwner(_domain, _newOwner);
|
ens.setOwner(_domain, _newOwner);
|
||||||
delete domains[_domain];
|
delete domains[_domain];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +114,7 @@ contract SubdomainRegistry is Controlled {
|
||||||
external
|
external
|
||||||
onlyController
|
onlyController
|
||||||
{
|
{
|
||||||
resolver = PublicResolverInterface(_resolver);
|
resolver = ResolverInterface(_resolver);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setDomainPrice(
|
function setDomainPrice(
|
||||||
|
@ -129,19 +131,19 @@ contract SubdomainRegistry is Controlled {
|
||||||
|
|
||||||
function initialize(
|
function initialize(
|
||||||
ERC20Token _token,
|
ERC20Token _token,
|
||||||
AbstractENS _ens,
|
ENS _ens,
|
||||||
PublicResolverInterface _resolver,
|
ResolverInterface _resolver,
|
||||||
address _controller
|
address _controller
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
{
|
{
|
||||||
require(controller == 0x0);
|
require(controller == 0x0);
|
||||||
require(address(ENSroot) == 0x0);
|
require(address(ens) == 0x0);
|
||||||
require(address(token) == 0x0);
|
require(address(token) == 0x0);
|
||||||
require(address(resolver) == 0x0);
|
require(address(resolver) == 0x0);
|
||||||
controller = _controller;
|
controller = _controller;
|
||||||
token = _token;
|
token = _token;
|
||||||
ENSroot = _ens;
|
ens = _ens;
|
||||||
resolver = _resolver;
|
resolver = _resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue