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,44 +108,22 @@ class ENS {
|
||||||
|
|
||||||
setProviderAndRegisterDomains(cb = (() => {})) {
|
setProviderAndRegisterDomains(cb = (() => {})) {
|
||||||
const self = this;
|
const self = this;
|
||||||
async.parallel([
|
let config = {
|
||||||
function getENSRegistry(paraCb) {
|
env: self.env,
|
||||||
self.events.request('contracts:contract', "ENSRegistry", (contract) => {
|
registration: self.registration,
|
||||||
paraCb(null, contract);
|
registryAbi: self.ensConfig.ENSRegistry.abiDefinition,
|
||||||
});
|
registryAddress: self.ensConfig.ENSRegistry.deployedAddress,
|
||||||
},
|
registrarAbi: self.ensConfig.FIFSRegistrar.abiDefinition,
|
||||||
function getRegistrar(paraCb) {
|
registrarAddress: self.ensConfig.FIFSRegistrar.deployedAddress,
|
||||||
self.events.request('contracts:contract', "FIFSRegistrar", (contract) => {
|
resolverAbi: self.ensConfig.Resolver.abiDefinition,
|
||||||
paraCb(null, contract);
|
resolverAddress: self.ensConfig.Resolver.deployedAddress
|
||||||
});
|
};
|
||||||
},
|
console.dir(config);
|
||||||
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
|
|
||||||
};
|
|
||||||
|
|
||||||
if (self.doSetENSProvider) {
|
if (self.doSetENSProvider) {
|
||||||
self.addSetProvider(config);
|
console.log('PLEAGRGFIUWIUF');
|
||||||
}
|
self.addSetProvider(config);
|
||||||
|
}
|
||||||
|
|
||||||
self.events.request('blockchain:networkId', (networkId) => {
|
self.events.request('blockchain:networkId', (networkId) => {
|
||||||
const isKnownNetwork = Object.keys(ENS_CONTRACTS_CONFIG).includes(networkId);
|
const isKnownNetwork = Object.keys(ENS_CONTRACTS_CONFIG).includes(networkId);
|
||||||
|
@ -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