mirror of https://github.com/embarklabs/embark.git
conflict in ens index
This commit is contained in:
parent
7acf13d931
commit
7d193054f8
File diff suppressed because one or more lines are too long
|
@ -86,6 +86,7 @@ class ENS {
|
||||||
this.namesConfig = embark.config.namesystemConfig;
|
this.namesConfig = embark.config.namesystemConfig;
|
||||||
this.registration = this.namesConfig.register || {};
|
this.registration = this.namesConfig.register || {};
|
||||||
this.embark = embark;
|
this.embark = embark;
|
||||||
|
this.ensConfig = require('./ensContractConfigs');
|
||||||
|
|
||||||
if (this.namesConfig === {} ||
|
if (this.namesConfig === {} ||
|
||||||
this.namesConfig.enabled !== true ||
|
this.namesConfig.enabled !== true ||
|
||||||
|
@ -99,7 +100,7 @@ class ENS {
|
||||||
}
|
}
|
||||||
|
|
||||||
registerEvents() {
|
registerEvents() {
|
||||||
this.events.once("contracts:deploy:afterAll", this.setProviderAndRegisterDomains.bind(this));
|
this.events.once("contracts:deploy:afterAll", this.configureContractsAndRegister.bind(this));
|
||||||
this.events.once("web3Ready", this.configureContracts.bind(this));
|
this.events.once("web3Ready", this.configureContracts.bind(this));
|
||||||
|
|
||||||
this.events.setCommandHandler("storage:ens:associate", this.associateStorageToEns.bind(this));
|
this.events.setCommandHandler("storage:ens:associate", this.associateStorageToEns.bind(this));
|
||||||
|
@ -107,42 +108,20 @@ class ENS {
|
||||||
|
|
||||||
setProviderAndRegisterDomains(cb = (() => {})) {
|
setProviderAndRegisterDomains(cb = (() => {})) {
|
||||||
const self = this;
|
const self = this;
|
||||||
async.parallel([
|
|
||||||
function getENSRegistry(paraCb) {
|
|
||||||
self.events.request('contracts:contract', "ENSRegistry", (contract) => {
|
|
||||||
paraCb(null, contract);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
function getRegistrar(paraCb) {
|
|
||||||
self.events.request('contracts:contract', "FIFSRegistrar", (contract) => {
|
|
||||||
paraCb(null, contract);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
function getResolver(paraCb) {
|
|
||||||
self.events.request('contracts:contract', "Resolver", (contract) => {
|
|
||||||
paraCb(null, contract);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
], (err, results) => {
|
|
||||||
if (err) {
|
|
||||||
return cb(err);
|
|
||||||
}
|
|
||||||
if (!results[0] || !results[1] || !results[2]) {
|
|
||||||
return cb(__('Aborting ENS setup as some of the contracts did not deploy properly'));
|
|
||||||
}
|
|
||||||
// result[0] => ENSRegistry; result[1] => FIFSRegistrar; result[2] => FIFSRegistrar
|
|
||||||
let config = {
|
let config = {
|
||||||
env: self.env,
|
env: self.env,
|
||||||
registration: self.registration,
|
registration: self.registration,
|
||||||
registryAbi: results[0].abiDefinition,
|
registryAbi: self.ensConfig.ENSRegistry.abiDefinition,
|
||||||
registryAddress: results[0].deployedAddress,
|
registryAddress: self.ensConfig.ENSRegistry.deployedAddress,
|
||||||
registrarAbi: results[1].abiDefinition,
|
registrarAbi: self.ensConfig.FIFSRegistrar.abiDefinition,
|
||||||
registrarAddress: results[1].deployedAddress,
|
registrarAddress: self.ensConfig.FIFSRegistrar.deployedAddress,
|
||||||
resolverAbi: results[2].abiDefinition,
|
resolverAbi: self.ensConfig.Resolver.abiDefinition,
|
||||||
resolverAddress: results[2].deployedAddress
|
resolverAddress: self.ensConfig.Resolver.deployedAddress
|
||||||
};
|
};
|
||||||
|
console.dir(config);
|
||||||
|
|
||||||
if (self.doSetENSProvider) {
|
if (self.doSetENSProvider) {
|
||||||
|
console.log('PLEAGRGFIUWIUF');
|
||||||
self.addSetProvider(config);
|
self.addSetProvider(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,9 +270,48 @@ class ENS {
|
||||||
this.embark.addCodeToEmbarkJS(code);
|
this.embark.addCodeToEmbarkJS(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
configureContracts() {
|
configureContractsAndRegister() {
|
||||||
this.events.request('blockchain:networkId', (networkId) => {
|
this.events.request('blockchain:networkId', (networkId) => {
|
||||||
const config = Object.assign({}, DEFAULT_ENS_CONTRACTS_CONFIG, {[this.env]: ENS_CONTRACTS_CONFIG[networkId]});
|
const config = Object.assign({}, DEFAULT_ENS_CONTRACTS_CONFIG, {[this.env]: ENS_CONTRACTS_CONFIG[networkId]});
|
||||||
|
const self = this;
|
||||||
|
async.waterfall([
|
||||||
|
function registry(next) {
|
||||||
|
self.events.request('deploy:contract', self.ensConfig.ENSRegistry, next);
|
||||||
|
},
|
||||||
|
function resolver(next) {
|
||||||
|
self.ensConfig.Resolver.args = [self.ensConfig.ENSRegistry.deployedAddress];
|
||||||
|
self.events.request('deploy:contract', self.ensConfig.Resolver, next);
|
||||||
|
},
|
||||||
|
function registrar(next) {
|
||||||
|
if (!self.registration || !self.registration.rootDomain) {
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
const registryAddress = self.ensConfig.ENSRegistry.deployedAddress;
|
||||||
|
const resolverAddress = self.ensConfig.Resolver.deployedAddress;
|
||||||
|
const rootNode = namehash.hash(self.registration.rootDomain);
|
||||||
|
const contract = self.ensConfig.FIFSRegistrar;
|
||||||
|
contract.args = [registryAddress, rootNode];
|
||||||
|
contract.onDeploy = [
|
||||||
|
`ENSRegistry.methods.setOwner('${rootNode}', web3.eth.defaultAccount).send({from: web3.eth.defaultAccount}).then(() => {
|
||||||
|
ENSRegistry.methods.setResolver('${rootNode}', "${resolverAddress}").send({from: web3.eth.defaultAccount});
|
||||||
|
var reverseNode = web3.utils.soliditySha3(web3.eth.defaultAccount.toLowerCase().substr(2) + '${reverseAddrSuffix}');
|
||||||
|
ENSRegistry.methods.setResolver(reverseNode, "${resolverAddress}").send({from: web3.eth.defaultAccount});
|
||||||
|
Resolver.methods.setAddr('${rootNode}', web3.eth.defaultAccount).send({from: web3.eth.defaultAccount});
|
||||||
|
Resolver.methods.setName(reverseNode, '${self.registration.rootDomain}').send({from: web3.eth.defaultAccount});
|
||||||
|
})`
|
||||||
|
];
|
||||||
|
self.events.request('deploy:contract', contract, next);
|
||||||
|
}
|
||||||
|
], (err) => {
|
||||||
|
if (err) {
|
||||||
|
self.logger.error('Error while deploying ENS contracts');
|
||||||
|
self.logger.error(err.message || err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self.setProviderAndRegisterDomains();
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
if (this.registration && this.registration.rootDomain) {
|
if (this.registration && this.registration.rootDomain) {
|
||||||
// Register root domain if it is defined
|
// Register root domain if it is defined
|
||||||
|
|
Loading…
Reference in New Issue