fix indentations for linting purposes

Signed-off-by: VoR0220 <catalanor0220@gmail.com>
This commit is contained in:
VoR0220 2018-05-23 11:46:02 -05:00
parent 73720b6978
commit 8748084a6b
2 changed files with 58 additions and 57 deletions

View File

@ -1,5 +1,5 @@
const namehash = require('eth-ens-namehash');
const Web3 = require('web3');
/*global web3*/
let __embarkENS = {};
@ -248,8 +248,8 @@ var registryAddresses = {
// Ropsten
"3": "0x112234455c3a32fd11230c42e7bccd4a84e02010",
// Rinkeby
"4": "0xe7410170f87102DF0055eB195163A03B7F2Bff4A",
}
"4": "0xe7410170f87102DF0055eB195163A03B7F2Bff4A"
};
__embarkENS.setProvider = function (options) {
const self = this;
@ -264,24 +264,24 @@ __embarkENS.setProvider = function (options) {
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) {
return new web3.eth.Contract(registryInterface, registryAddresses[id]);
}
// todo: deploy at this point
return undefined;
})
}
if (registryAddresses[id] !== undefined) {
return new web3.eth.Contract(registryInterface, registryAddresses[id]);
}
// todo: deploy at this point
return undefined;
});
};
__embarkENS.resolve = function(name) {
const self = this;
const web3 = this.web3;
if (this.ens === undefined)
return undefined;
let node = namehash(name)
this.ens.methods.resolver(node).call().then((resolverAddress) => {
let resolverContract = new web3.eth.Contract(resolverInterface, resolverAddress);
return resolverContract.methods.addr(node).call()
}).then((addr) => {
return addr
}).catch(err => err);
}
const self = this;
const web3 = this.web3;
if (this.ens === undefined)
return undefined;
let node = namehash(name)
this.ens.methods.resolver(node).call().then((resolverAddress) => {
let resolverContract = new web3.eth.Contract(resolverInterface, resolverAddress);
return resolverContract.methods.addr(node).call()
}).then((addr) => {
return addr
}).catch(err => err);
};

View File

@ -2,53 +2,54 @@ const fs = require('../../core/fs.js');
const utils = require('../../utils/utils.js');
class ENS {
constructor(embark, options) {
this.logger = embark.logger;
this.events = embark.events;
this.web3 = options.web3;
this.embark = embark;
constructor(embark, options) {
this.logger = embark.logger;
this.events = embark.events;
this.web3 = options.web3;
this.embark = embark;
this.addENSToEmbarkJS();
this.addSetProvider();
this.addENSToEmbarkJS();
this.addSetProvider();
}
addENSToEmbarkJS() {
const self = this;
// TODO: make this a shouldAdd condition
if (this.namesConfig === {}) {
return;
}
addENSToEmbarkJS() {
const self = this;
// TODO: make this a shouldAdd condition
if (this.namesConfig === {}) {
return;
}
if ((this.namesConfig.available_providers.indexOf('ens') < 0) && (this.namesConfig.provider !== 'ens' || this.namesConfig.enabled !== true)) {
return;
}
if ((this.namesConfig.available_providers.indexOf('ens') < 0) && (this.namesConfig.provider !== 'ens' || this.namesConfig.enabled !== true)) {
return;
}
self.events.request("version:get:eth-ens-namehash", function(namehashVersion) {
let currentEnsNamehashVersion = require('../../../package.json').dependencies["eth-ens-namehash"];
if (EnsNamehashVersion !== currentEnsNamehashVersion) {
self.events.request("version:getPackageLocation", "eth-ens-namehash", EnsNamehashVersion, function(err, location) {
self.embark.registerImportFile("eth-ens-namehash", fs.dappPath(location));
});
}
});
self.events.request("version:get:eth-ens-namehash", function(namehashVersion) {
let currentEnsNamehashVersion = require('../../../package.json').dependencies["eth-ens-namehash"];
if (EnsNamehashVersion !== currentEnsNamehashVersion) {
self.events.request("version:getPackageLocation", "eth-ens-namehash", EnsNamehashVersion, function(err, location) {
self.embark.registerImportFile("eth-ens-namehash", fs.dappPath(location));
});
}
});
let code = "";
code += "\n" + fs.readFileSync(utils.joinPath(__dirname, 'embarkjs.js')).toString();
code += "\nEmbarkJS.Names.registerProvider('ens', __embarkENS);";
let code = "";
code += "\n" + fs.readFileSync(utils.joinPath(__dirname, 'embarkjs.js')).toString();
code += "\nEmbarkJS.Names.registerProvider('ens', __embarkENS);";
this.embark.addCodeToEmbarkJS(code);
this.embark.addCodeToEmbarkJS(code);
}
addSetProvider() {
let config = JSON.stringify({
web3: this.nameConfig.web3,
});
let config = JSON.stringify({
server: this.storageConfig.host,
port: this.storageConfig.port
});
let code = "\nEmbarkJS.Names.setProvider('ens'," + config + ");";
let code = "\nEmbarkJS.Names.setProvider('ens'," + config + ");";
let shouldInit = (storageConfig) => {
return (namesConfig.provider === 'ens' && storageConfig.enabled === true);
};
let shouldInit = (storageConfig) => {
return (namesConfig.provider === 'ens' && storageConfig.enabled === true);
};
this.embark.addProviderInit('names', code, shouldInit);
}