mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-23 12:11:16 +00:00
fix indentations for linting purposes
Signed-off-by: VoR0220 <catalanor0220@gmail.com>
This commit is contained in:
parent
73720b6978
commit
8748084a6b
@ -1,5 +1,5 @@
|
|||||||
const namehash = require('eth-ens-namehash');
|
const namehash = require('eth-ens-namehash');
|
||||||
|
const Web3 = require('web3');
|
||||||
/*global web3*/
|
/*global web3*/
|
||||||
let __embarkENS = {};
|
let __embarkENS = {};
|
||||||
|
|
||||||
@ -248,8 +248,8 @@ var registryAddresses = {
|
|||||||
// Ropsten
|
// Ropsten
|
||||||
"3": "0x112234455c3a32fd11230c42e7bccd4a84e02010",
|
"3": "0x112234455c3a32fd11230c42e7bccd4a84e02010",
|
||||||
// Rinkeby
|
// Rinkeby
|
||||||
"4": "0xe7410170f87102DF0055eB195163A03B7F2Bff4A",
|
"4": "0xe7410170f87102DF0055eB195163A03B7F2Bff4A"
|
||||||
}
|
};
|
||||||
|
|
||||||
__embarkENS.setProvider = function (options) {
|
__embarkENS.setProvider = function (options) {
|
||||||
const self = this;
|
const self = this;
|
||||||
@ -264,24 +264,24 @@ __embarkENS.setProvider = function (options) {
|
|||||||
self.web3 = web3;
|
self.web3 = web3;
|
||||||
// get network id and then assign ENS contract based on that
|
// get network id and then assign ENS contract based on that
|
||||||
self.ens = web3.eth.net.getId().then(id => {
|
self.ens = web3.eth.net.getId().then(id => {
|
||||||
if (registryAddresses[id] !== undefined) {
|
if (registryAddresses[id] !== undefined) {
|
||||||
return new web3.eth.Contract(registryInterface, registryAddresses[id]);
|
return new web3.eth.Contract(registryInterface, registryAddresses[id]);
|
||||||
}
|
}
|
||||||
// todo: deploy at this point
|
// todo: deploy at this point
|
||||||
return undefined;
|
return undefined;
|
||||||
})
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
__embarkENS.resolve = function(name) {
|
__embarkENS.resolve = function(name) {
|
||||||
const self = this;
|
const self = this;
|
||||||
const web3 = this.web3;
|
const web3 = this.web3;
|
||||||
if (this.ens === undefined)
|
if (this.ens === undefined)
|
||||||
return undefined;
|
return undefined;
|
||||||
let node = namehash(name)
|
let node = namehash(name)
|
||||||
this.ens.methods.resolver(node).call().then((resolverAddress) => {
|
this.ens.methods.resolver(node).call().then((resolverAddress) => {
|
||||||
let resolverContract = new web3.eth.Contract(resolverInterface, resolverAddress);
|
let resolverContract = new web3.eth.Contract(resolverInterface, resolverAddress);
|
||||||
return resolverContract.methods.addr(node).call()
|
return resolverContract.methods.addr(node).call()
|
||||||
}).then((addr) => {
|
}).then((addr) => {
|
||||||
return addr
|
return addr
|
||||||
}).catch(err => err);
|
}).catch(err => err);
|
||||||
}
|
};
|
||||||
|
@ -2,53 +2,54 @@ const fs = require('../../core/fs.js');
|
|||||||
const utils = require('../../utils/utils.js');
|
const utils = require('../../utils/utils.js');
|
||||||
|
|
||||||
class ENS {
|
class ENS {
|
||||||
constructor(embark, options) {
|
constructor(embark, options) {
|
||||||
this.logger = embark.logger;
|
this.logger = embark.logger;
|
||||||
this.events = embark.events;
|
this.events = embark.events;
|
||||||
this.web3 = options.web3;
|
this.web3 = options.web3;
|
||||||
this.embark = embark;
|
this.embark = embark;
|
||||||
|
|
||||||
this.addENSToEmbarkJS();
|
this.addENSToEmbarkJS();
|
||||||
this.addSetProvider();
|
this.addSetProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
addENSToEmbarkJS() {
|
addENSToEmbarkJS() {
|
||||||
const self = this;
|
const self = this;
|
||||||
// TODO: make this a shouldAdd condition
|
// TODO: make this a shouldAdd condition
|
||||||
if (this.namesConfig === {}) {
|
if (this.namesConfig === {}) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((this.namesConfig.available_providers.indexOf('ens') < 0) && (this.namesConfig.provider !== 'ens' || this.namesConfig.enabled !== true)) {
|
if ((this.namesConfig.available_providers.indexOf('ens') < 0) && (this.namesConfig.provider !== 'ens' || this.namesConfig.enabled !== true)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.events.request("version:get:eth-ens-namehash", function(namehashVersion) {
|
self.events.request("version:get:eth-ens-namehash", function(namehashVersion) {
|
||||||
let currentEnsNamehashVersion = require('../../../package.json').dependencies["eth-ens-namehash"];
|
let currentEnsNamehashVersion = require('../../../package.json').dependencies["eth-ens-namehash"];
|
||||||
if (EnsNamehashVersion !== currentEnsNamehashVersion) {
|
if (EnsNamehashVersion !== currentEnsNamehashVersion) {
|
||||||
self.events.request("version:getPackageLocation", "eth-ens-namehash", EnsNamehashVersion, function(err, location) {
|
self.events.request("version:getPackageLocation", "eth-ens-namehash", EnsNamehashVersion, function(err, location) {
|
||||||
self.embark.registerImportFile("eth-ens-namehash", fs.dappPath(location));
|
self.embark.registerImportFile("eth-ens-namehash", fs.dappPath(location));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let code = "";
|
let code = "";
|
||||||
code += "\n" + fs.readFileSync(utils.joinPath(__dirname, 'embarkjs.js')).toString();
|
code += "\n" + fs.readFileSync(utils.joinPath(__dirname, 'embarkjs.js')).toString();
|
||||||
code += "\nEmbarkJS.Names.registerProvider('ens', __embarkENS);";
|
code += "\nEmbarkJS.Names.registerProvider('ens', __embarkENS);";
|
||||||
|
|
||||||
this.embark.addCodeToEmbarkJS(code);
|
this.embark.addCodeToEmbarkJS(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
addSetProvider() {
|
addSetProvider() {
|
||||||
let config = JSON.stringify({
|
let config = JSON.stringify({
|
||||||
web3: this.nameConfig.web3,
|
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) => {
|
let shouldInit = (storageConfig) => {
|
||||||
return (namesConfig.provider === 'ens' && storageConfig.enabled === true);
|
return (namesConfig.provider === 'ens' && storageConfig.enabled === true);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.embark.addProviderInit('names', code, shouldInit);
|
this.embark.addProviderInit('names', code, shouldInit);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user