fix using only_owner

This commit is contained in:
Jonathan Rainville 2018-07-25 11:05:27 -04:00 committed by Iuri Matias
parent 9eb6e9a949
commit 4958304a50
3 changed files with 6 additions and 13 deletions

View File

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

View File

@ -162,6 +162,8 @@ __embarkENS.setProvider = function (config) {
self.env = config.env;
EmbarkJS.onReady(() => {
self.registration = config.registration;
web3.eth.net.getId()
.then((id) => {
const registryAddress = self.registryAddresses[id] || config.registryAddress;

View File

@ -196,8 +196,7 @@ class ENS {
{abi: config.registrarAbi, address: config.registrarAddress},
(registrar) => {
async.each(Object.keys(self.registration.domains), (subDomainName, eachCb) => {
const toSend = registrar.methods.register(utils.sha3(subDomainName),
defaultAccount, self.registration.domains[subDomainName]);
const toSend = registrar.methods.register(utils.soliditySha3(subDomainName), defaultAccount);
toSend.estimateGas().then(gasEstimated => {
return toSend.send({gas: gasEstimated + 1000, from: defaultAccount}).then(transaction => {
@ -346,11 +345,11 @@ class ENS {
"contracts": {
"FIFSRegistrar": {
"deploy": true,
"args": ["$ENSRegistry", rootNode, "$Resolver"],
"args": ["$ENSRegistry", rootNode],
"onDeploy": [
`ENSRegistry.methods.setOwner('${rootNode}', web3.eth.defaultAccount).send().then(() => {
ENSRegistry.methods.setResolver('${rootNode}', "$Resolver").send();
var reverseNode = web3.utils.sha3(web3.eth.defaultAccount.toLowerCase().substr(2) + '.addr.reverse');
var reverseNode = web3.utils.soliditySha3(web3.eth.defaultAccount.toLowerCase().substr(2) + '.addr.reverse');
ENSRegistry.methods.setResolver(reverseNode, "$Resolver").send();
Resolver.methods.setAddr('${rootNode}', web3.eth.defaultAccount).send();
Resolver.methods.setName(reverseNode, '${this.registration.rootDomain}').send();