mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-11 14:24:24 +00:00
linting fixes and import fixes and some cleanup of the logic
Signed-off-by: VoR0220 <catalanor0220@gmail.com>
This commit is contained in:
parent
ea17e235f3
commit
bf40bdb93b
@ -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);
|
||||
};
|
||||
|
@ -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;
|
||||
module.exports = ENS;
|
||||
|
Loading…
x
Reference in New Issue
Block a user