From 4958304a5016a1a5ce0ca27f4d09057f8606fd51 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 25 Jul 2018 11:05:27 -0400 Subject: [PATCH] fix using only_owner --- lib/modules/ens/contracts/FIFSRegistrar.sol | 10 +--------- lib/modules/ens/embarkjs.js | 2 ++ lib/modules/ens/index.js | 7 +++---- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/lib/modules/ens/contracts/FIFSRegistrar.sol b/lib/modules/ens/contracts/FIFSRegistrar.sol index eeb32a6e..77acbbdf 100644 --- a/lib/modules/ens/contracts/FIFSRegistrar.sol +++ b/lib/modules/ens/contracts/FIFSRegistrar.sol @@ -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); - } } } diff --git a/lib/modules/ens/embarkjs.js b/lib/modules/ens/embarkjs.js index 7fb7fb8d..71d6173b 100644 --- a/lib/modules/ens/embarkjs.js +++ b/lib/modules/ens/embarkjs.js @@ -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; diff --git a/lib/modules/ens/index.js b/lib/modules/ens/index.js index 945b8154..615beb32 100644 --- a/lib/modules/ens/index.js +++ b/lib/modules/ens/index.js @@ -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();