fix rebase problems and now works
This commit is contained in:
parent
c0d32e3581
commit
eae7784a87
|
@ -5,37 +5,12 @@ const async = require('async');
|
|||
const embarkJsUtils = require('embarkjs').Utils;
|
||||
const reverseAddrSuffix = '.addr.reverse';
|
||||
|
||||
const DEFAULT_ENS_CONTRACTS_CONFIG = {
|
||||
"default": {
|
||||
"contracts": {
|
||||
"ENS": {
|
||||
"deploy": false,
|
||||
"silent": true
|
||||
},
|
||||
"ENSRegistry": {
|
||||
"deploy": true,
|
||||
"silent": true,
|
||||
"args": []
|
||||
},
|
||||
"Resolver": {
|
||||
"deploy": true,
|
||||
"silent": true,
|
||||
"args": ["$ENSRegistry"]
|
||||
},
|
||||
"FIFSRegistrar": {
|
||||
"deploy": false
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const MAINNET_ID = '1';
|
||||
const ROPSTEN_ID = '3';
|
||||
const RINKEBY_ID = '4';
|
||||
|
||||
const ENS_CONTRACTS_CONFIG = {
|
||||
[MAINNET_ID]: {
|
||||
"contracts": {
|
||||
"ENSRegistry": {
|
||||
"address": "0x314159265dd8dbb310642f98f50c066173c1259b",
|
||||
"silent": true
|
||||
|
@ -46,10 +21,8 @@ const ENS_CONTRACTS_CONFIG = {
|
|||
"FIFSRegistrar": {
|
||||
"deploy": false
|
||||
}
|
||||
}
|
||||
},
|
||||
[ROPSTEN_ID]: {
|
||||
"contracts": {
|
||||
"ENSRegistry": {
|
||||
"address": "0x112234455c3a32fd11230c42e7bccd4a84e02010",
|
||||
"silent": true
|
||||
|
@ -60,10 +33,8 @@ const ENS_CONTRACTS_CONFIG = {
|
|||
"FIFSRegistrar": {
|
||||
"deploy": false
|
||||
}
|
||||
}
|
||||
},
|
||||
[RINKEBY_ID]: {
|
||||
"contracts": {
|
||||
"ENSRegistry": {
|
||||
"address": "0xe7410170f87102DF0055eB195163A03B7F2Bff4A",
|
||||
"silent": true
|
||||
|
@ -75,7 +46,6 @@ const ENS_CONTRACTS_CONFIG = {
|
|||
"deploy": false
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class ENS {
|
||||
|
@ -130,7 +100,6 @@ class ENS {
|
|||
|
||||
registerEvents() {
|
||||
this.embark.registerActionForEvent("deploy:beforeAll", this.configureContractsAndRegister.bind(this));
|
||||
this.events.once("web3Ready", this.configureContracts.bind(this));
|
||||
|
||||
this.events.setCommandHandler("storage:ens:associate", this.associateStorageToEns.bind(this));
|
||||
}
|
||||
|
@ -153,14 +122,14 @@ class ENS {
|
|||
}
|
||||
|
||||
self.events.request('blockchain:networkId', (networkId) => {
|
||||
const isKnownNetwork = Object.keys(ENS_CONTRACTS_CONFIG).includes(networkId);
|
||||
const isKnownNetwork = Boolean(ENS_CONTRACTS_CONFIG[networkId]);
|
||||
const shouldRegisterSubdomain = self.registration && self.registration.subdomains && Object.keys(self.registration.subdomains).length;
|
||||
if (isKnownNetwork || !shouldRegisterSubdomain) {
|
||||
return cb();
|
||||
}
|
||||
process.exit();
|
||||
self.registerConfigDomains(config, cb);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
associateStorageToEns(options, cb) {
|
||||
|
@ -298,56 +267,15 @@ class ENS {
|
|||
}
|
||||
|
||||
configureContractsAndRegister(cb) {
|
||||
this.events.request('blockchain:networkId', (networkId) => {
|
||||
const config = Object.assign({}, DEFAULT_ENS_CONTRACTS_CONFIG, {[this.env]: ENS_CONTRACTS_CONFIG[networkId]});
|
||||
const self = this;
|
||||
if (self.configured) {
|
||||
return cb();
|
||||
}
|
||||
|
||||
const knownConfigs = {
|
||||
"ropsten": {
|
||||
"ENSRegistry": {
|
||||
"address": "0x112234455c3a32fd11230c42e7bccd4a84e02010",
|
||||
"silent": true
|
||||
},
|
||||
"Resolver": {
|
||||
"deploy": false
|
||||
},
|
||||
"FIFSRegistrar": {
|
||||
"deploy": false
|
||||
}
|
||||
},
|
||||
"rinkeby": {
|
||||
"ENSRegistry": {
|
||||
"address": "0xe7410170f87102DF0055eB195163A03B7F2Bff4A",
|
||||
"silent": true
|
||||
},
|
||||
"Resolver": {
|
||||
"deploy": false
|
||||
},
|
||||
"FIFSRegistrar": {
|
||||
"deploy": false
|
||||
}
|
||||
},
|
||||
"livenet": {
|
||||
"ENSRegistry": {
|
||||
"address": "0x314159265dd8dbb310642f98f50c066173c1259b",
|
||||
"silent": true
|
||||
},
|
||||
"Resolver": {
|
||||
"deploy": false
|
||||
},
|
||||
"FIFSRegistrar": {
|
||||
"deploy": false
|
||||
}
|
||||
}
|
||||
};
|
||||
knownConfigs.testnet = knownConfigs.ropsten; // Synonyms
|
||||
knownConfigs.mainnet = knownConfigs.livenet; // Synonyms
|
||||
|
||||
if (knownConfigs[this.env]) {
|
||||
self.ensConfig = utils.recursiveMerge(self.ensConfig, knownConfigs[this.env]);
|
||||
self.events.request('blockchain:networkId', (networkId) => {
|
||||
if (ENS_CONTRACTS_CONFIG[networkId]) {
|
||||
self.ensConfig = utils.recursiveMerge(self.ensConfig, ENS_CONTRACTS_CONFIG[networkId]);
|
||||
} else {
|
||||
process.exit();
|
||||
}
|
||||
|
||||
async.waterfall([
|
||||
|
@ -393,6 +321,7 @@ class ENS {
|
|||
}
|
||||
self.setProviderAndRegisterDomains(cb);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
addSetProvider(config) {
|
||||
|
|
Loading…
Reference in New Issue