disable preregister in privatenet and fix conditions

This commit is contained in:
Jonathan Rainville 2018-08-14 15:38:55 -04:00 committed by Iuri Matias
parent 70d71b190c
commit 5f3dd25e06
1 changed files with 14 additions and 5 deletions

View File

@ -8,6 +8,7 @@ const reverseAddrSuffix = '.addr.reverse';
class ENS {
constructor(embark, _options) {
this.env = embark.env;
this.isDev = embark.config.blockchainConfig.isDev;
this.logger = embark.logger;
this.events = embark.events;
this.namesConfig = embark.config.namesystemConfig;
@ -21,6 +22,12 @@ class ENS {
}
this.doSetENSProvider = this.namesConfig.provider === 'ens';
if (this.env === 'privatenet') {
this.logger.warn(__('ENS is disabled in privatenet'));
this.logger.info(__('To use ENS, use development, one of the testnets or mainnet'));
return;
}
this.addENSToEmbarkJS();
this.configureContracts();
this.registerEvents();
@ -67,7 +74,7 @@ class ENS {
self.addSetProvider(config);
}
if (!self.env === 'development' || !self.registration || !self.registration.subdomains || !Object.keys(self.registration.subdomains).length) {
if (!self.isDev || !self.registration || !self.registration.subdomains || !Object.keys(self.registration.subdomains).length) {
return cb();
}
self.registerConfigDomains(config, cb);
@ -279,6 +286,7 @@ class ENS {
}
}
};
config.testnet = config.ropsten;
if (this.registration && this.registration.rootDomain) {
// Register root domain if it is defined
@ -298,13 +306,14 @@ class ENS {
]
};
}
this.embark.registerContractConfiguration(config);
if (this.isDev) {
this.embark.events.request("config:contractsFiles:add", this.embark.pathToFile('./contracts/ENSRegistry.sol'));
this.embark.events.request("config:contractsFiles:add", this.embark.pathToFile('./contracts/FIFSRegistrar.sol'));
this.embark.events.request("config:contractsFiles:add", this.embark.pathToFile('./contracts/Resolver.sol'));
}
}
addSetProvider(config) {