diff --git a/lib/modules/ens/embarkjs.js b/lib/modules/ens/embarkjs.js index be7cfe411..4ca66db0e 100644 --- a/lib/modules/ens/embarkjs.js +++ b/lib/modules/ens/embarkjs.js @@ -1,5 +1,4 @@ const namehash = require('eth-ens-namehash'); -const Web3 = require('web3'); /*global web3*/ let __embarkENS = {}; @@ -253,15 +252,6 @@ var registryAddresses = { __embarkENS.setProvider = function (options) { const self = this; - let provider; - if (options === undefined) { - provider = "localhost:8546"; - } else { - provider = options.server + ':' + options.port; - } - // TODO: take into account type - let web3 = new Web3(new Web3.providers.WebsocketProvider("ws://" + provider)); - self.web3 = web3; // get network id and then assign ENS contract based on that self.ens = web3.eth.net.getId().then(id => { if (registryAddresses[id] !== undefined) { @@ -274,14 +264,16 @@ __embarkENS.setProvider = function (options) { __embarkENS.resolve = function(name) { const self = this; - const web3 = this.web3; - if (this.ens === undefined) + + if (self.ens === undefined) return undefined; - let node = namehash(name) - this.ens.methods.resolver(node).call().then((resolverAddress) => { + + let node = namehash(name); + + self.ens.methods.resolver(node).call().then((resolverAddress) => { let resolverContract = new web3.eth.Contract(resolverInterface, resolverAddress); - return resolverContract.methods.addr(node).call() + return resolverContract.methods.addr(node).call(); }).then((addr) => { - return addr + return addr; }).catch(err => err); }; diff --git a/lib/modules/ens/index.js b/lib/modules/ens/index.js index ee5a0073c..5808231ef 100644 --- a/lib/modules/ens/index.js +++ b/lib/modules/ens/index.js @@ -6,11 +6,12 @@ class ENS { this.logger = embark.logger; this.events = embark.events; this.web3 = options.web3; + this.namesConfig = options.namesConfig; this.embark = embark; this.addENSToEmbarkJS(); this.addSetProvider(); - } + } addENSToEmbarkJS() { const self = this; @@ -23,7 +24,7 @@ class ENS { return; } - self.events.request("version:get:eth-ens-namehash", function(namehashVersion) { + self.events.request("version:get:eth-ens-namehash", function(EnsNamehashVersion) { let currentEnsNamehashVersion = require('../../../package.json').dependencies["eth-ens-namehash"]; if (EnsNamehashVersion !== currentEnsNamehashVersion) { self.events.request("version:getPackageLocation", "eth-ens-namehash", EnsNamehashVersion, function(err, location) { @@ -55,4 +56,4 @@ class ENS { } } -module.exports = ENS; \ No newline at end of file +module.exports = ENS;