conflict in ens index
This commit is contained in:
parent
eb56657dd7
commit
302da3f263
File diff suppressed because one or more lines are too long
|
@ -86,6 +86,7 @@ class ENS {
|
|||
this.namesConfig = embark.config.namesystemConfig;
|
||||
this.registration = this.namesConfig.register || {};
|
||||
this.embark = embark;
|
||||
this.ensConfig = require('./ensContractConfigs');
|
||||
|
||||
if (this.namesConfig === {} ||
|
||||
this.namesConfig.enabled !== true ||
|
||||
|
@ -127,7 +128,7 @@ class ENS {
|
|||
}
|
||||
|
||||
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.setCommandHandler("storage:ens:associate", this.associateStorageToEns.bind(this));
|
||||
|
@ -135,44 +136,22 @@ class ENS {
|
|||
|
||||
setProviderAndRegisterDomains(cb = (() => {})) {
|
||||
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 = {
|
||||
env: self.env,
|
||||
registration: self.registration,
|
||||
registryAbi: results[0].abiDefinition,
|
||||
registryAddress: results[0].deployedAddress,
|
||||
registrarAbi: results[1].abiDefinition,
|
||||
registrarAddress: results[1].deployedAddress,
|
||||
resolverAbi: results[2].abiDefinition,
|
||||
resolverAddress: results[2].deployedAddress
|
||||
};
|
||||
let config = {
|
||||
env: self.env,
|
||||
registration: self.registration,
|
||||
registryAbi: self.ensConfig.ENSRegistry.abiDefinition,
|
||||
registryAddress: self.ensConfig.ENSRegistry.deployedAddress,
|
||||
registrarAbi: self.ensConfig.FIFSRegistrar.abiDefinition,
|
||||
registrarAddress: self.ensConfig.FIFSRegistrar.deployedAddress,
|
||||
resolverAbi: self.ensConfig.Resolver.abiDefinition,
|
||||
resolverAddress: self.ensConfig.Resolver.deployedAddress
|
||||
};
|
||||
console.dir(config);
|
||||
|
||||
if (self.doSetENSProvider) {
|
||||
self.addSetProvider(config);
|
||||
}
|
||||
if (self.doSetENSProvider) {
|
||||
console.log('PLEAGRGFIUWIUF');
|
||||
self.addSetProvider(config);
|
||||
}
|
||||
|
||||
self.events.request('blockchain:networkId', (networkId) => {
|
||||
const isKnownNetwork = Object.keys(ENS_CONTRACTS_CONFIG).includes(networkId);
|
||||
|
@ -319,9 +298,48 @@ class ENS {
|
|||
this.embark.addCodeToEmbarkJS(code);
|
||||
}
|
||||
|
||||
configureContracts() {
|
||||
configureContractsAndRegister() {
|
||||
this.events.request('blockchain:networkId', (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) {
|
||||
// Register root domain if it is defined
|
||||
|
|
Loading…
Reference in New Issue