add resolver contract

This commit is contained in:
Jonathan Rainville 2018-07-13 12:37:34 -04:00 committed by Iuri Matias
parent d0e14096c3
commit 188d6afa19
3 changed files with 36 additions and 9 deletions

View File

@ -48,6 +48,13 @@ contract ENSRegistry is ENS {
emit NewOwner(node, label, owner);
records[subnode].owner = owner;
}
*/
function setSubnodeOwner(bytes32 node, bytes32 label, address owner) public {
var subnode = sha3(node, label);
NewOwner(node, label, owner);
records[subnode].owner = owner;
}
/**
* @dev Sets the resolver address for the specified node.

View File

@ -9,6 +9,7 @@ import './Resolver.sol';
contract FIFSRegistrar {
ENS ens;
bytes32 rootNode;
Resolver resolver;
modifier only_owner(bytes32 subnode) {
bytes32 node = keccak256(abi.encodePacked(rootNode, subnode));
@ -25,6 +26,7 @@ contract FIFSRegistrar {
constructor(ENS ensAddr, bytes32 node) public {
ens = ensAddr;
rootNode = node;
resolver = resolverAddr;
}
/**
@ -32,12 +34,13 @@ contract FIFSRegistrar {
* @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);
}
*/
function register(bytes32 subnode, address owner) public only_owner(subnode) {
function register(bytes32 subnode, address owner, address _account) public only_owner(subnode) {
bytes32 subdomainHash = sha3(rootNode, subnode);
ens.setSubnodeOwner(rootNode, subnode, owner);
ens.setResolver(subdomainHash, resolver); //default resolver
bool resolveAccount = _account != address(0);
if (resolveAccount) {
resolver.setAddr(subdomainHash, _account);
}
}
}

View File

@ -329,13 +329,21 @@ class ENS {
"contracts": {
"FIFSRegistrar": {
"deploy": true,
"args": ["$ENSRegistry", rootNode],
"onDeploy": ["ENSRegistry.methods.setOwner('"+rootNode+"', web3.eth.defaultAccount).send()"]
"args": ["$ENSRegistry", rootNode, "$Resolver"],
"onDeploy": [
`ENSRegistry.methods.setOwner('${rootNode}', web3.eth.defaultAccount).send().then(() => {
ENSRegistry.methods.setResolver('${rootNode}', "$Resolver").send();
Resolver.methods.setAddr('${rootNode}', web3.eth.defaultAccount).send();
})`
]
}
}
},
"ropsten": {
"contracts": {
"ENSRegistry": {
"address": "0x112234455c3a32fd11230c42e7bccd4a84e02010"
},
"FIFSRegistrar": {
"deploy": false
}
@ -343,6 +351,9 @@ class ENS {
},
"rinkeby": {
"contracts": {
"ENSRegistry": {
"address": "0xe7410170f87102DF0055eB195163A03B7F2Bff4A"
},
"FIFSRegistrar": {
"deploy": false
}
@ -350,13 +361,19 @@ class ENS {
},
"livenet": {
"contracts": {
"ENSRegistry": {
"address": "0x314159265dd8dbb310642f98f50c066173c1259b"
},
"FIFSRegistrar": {
"deploy": false
}
}
}
});
self.embark.events.request("config:contractsFiles:add", self.embark.pathToFile('./contracts/FIFSRegistrar.sol'));
this.embark.events.request("config:contractsFiles:add", this.embark.pathToFile('./contracts/ENSRegistry.sol'));
this.embark.events.request("config:contractsFiles:add", this.embark.pathToFile('./contracts/FIFSRegistrar.sol'));
this.embark.events.request("config:contractsFiles:add", this.embark.pathToFile('./contracts/Resolver.sol'));
}
addSetProvider(config) {