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 embarkJsUtils = require('embarkjs').Utils;
|
||||||
const reverseAddrSuffix = '.addr.reverse';
|
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 MAINNET_ID = '1';
|
||||||
const ROPSTEN_ID = '3';
|
const ROPSTEN_ID = '3';
|
||||||
const RINKEBY_ID = '4';
|
const RINKEBY_ID = '4';
|
||||||
|
|
||||||
const ENS_CONTRACTS_CONFIG = {
|
const ENS_CONTRACTS_CONFIG = {
|
||||||
[MAINNET_ID]: {
|
[MAINNET_ID]: {
|
||||||
"contracts": {
|
|
||||||
"ENSRegistry": {
|
"ENSRegistry": {
|
||||||
"address": "0x314159265dd8dbb310642f98f50c066173c1259b",
|
"address": "0x314159265dd8dbb310642f98f50c066173c1259b",
|
||||||
"silent": true
|
"silent": true
|
||||||
|
@ -46,10 +21,8 @@ const ENS_CONTRACTS_CONFIG = {
|
||||||
"FIFSRegistrar": {
|
"FIFSRegistrar": {
|
||||||
"deploy": false
|
"deploy": false
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
[ROPSTEN_ID]: {
|
[ROPSTEN_ID]: {
|
||||||
"contracts": {
|
|
||||||
"ENSRegistry": {
|
"ENSRegistry": {
|
||||||
"address": "0x112234455c3a32fd11230c42e7bccd4a84e02010",
|
"address": "0x112234455c3a32fd11230c42e7bccd4a84e02010",
|
||||||
"silent": true
|
"silent": true
|
||||||
|
@ -60,10 +33,8 @@ const ENS_CONTRACTS_CONFIG = {
|
||||||
"FIFSRegistrar": {
|
"FIFSRegistrar": {
|
||||||
"deploy": false
|
"deploy": false
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
[RINKEBY_ID]: {
|
[RINKEBY_ID]: {
|
||||||
"contracts": {
|
|
||||||
"ENSRegistry": {
|
"ENSRegistry": {
|
||||||
"address": "0xe7410170f87102DF0055eB195163A03B7F2Bff4A",
|
"address": "0xe7410170f87102DF0055eB195163A03B7F2Bff4A",
|
||||||
"silent": true
|
"silent": true
|
||||||
|
@ -75,7 +46,6 @@ const ENS_CONTRACTS_CONFIG = {
|
||||||
"deploy": false
|
"deploy": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ENS {
|
class ENS {
|
||||||
|
@ -130,7 +100,6 @@ class ENS {
|
||||||
|
|
||||||
registerEvents() {
|
registerEvents() {
|
||||||
this.embark.registerActionForEvent("deploy:beforeAll", this.configureContractsAndRegister.bind(this));
|
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));
|
this.events.setCommandHandler("storage:ens:associate", this.associateStorageToEns.bind(this));
|
||||||
}
|
}
|
||||||
|
@ -153,14 +122,14 @@ class ENS {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.events.request('blockchain:networkId', (networkId) => {
|
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;
|
const shouldRegisterSubdomain = self.registration && self.registration.subdomains && Object.keys(self.registration.subdomains).length;
|
||||||
if (isKnownNetwork || !shouldRegisterSubdomain) {
|
if (isKnownNetwork || !shouldRegisterSubdomain) {
|
||||||
return cb();
|
return cb();
|
||||||
}
|
}
|
||||||
|
process.exit();
|
||||||
self.registerConfigDomains(config, cb);
|
self.registerConfigDomains(config, cb);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
associateStorageToEns(options, cb) {
|
associateStorageToEns(options, cb) {
|
||||||
|
@ -298,56 +267,15 @@ class ENS {
|
||||||
}
|
}
|
||||||
|
|
||||||
configureContractsAndRegister(cb) {
|
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;
|
const self = this;
|
||||||
if (self.configured) {
|
if (self.configured) {
|
||||||
return cb();
|
return cb();
|
||||||
}
|
}
|
||||||
|
self.events.request('blockchain:networkId', (networkId) => {
|
||||||
const knownConfigs = {
|
if (ENS_CONTRACTS_CONFIG[networkId]) {
|
||||||
"ropsten": {
|
self.ensConfig = utils.recursiveMerge(self.ensConfig, ENS_CONTRACTS_CONFIG[networkId]);
|
||||||
"ENSRegistry": {
|
} else {
|
||||||
"address": "0x112234455c3a32fd11230c42e7bccd4a84e02010",
|
process.exit();
|
||||||
"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]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
|
@ -393,6 +321,7 @@ class ENS {
|
||||||
}
|
}
|
||||||
self.setProviderAndRegisterDomains(cb);
|
self.setProviderAndRegisterDomains(cb);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
addSetProvider(config) {
|
addSetProvider(config) {
|
||||||
|
|
Loading…
Reference in New Issue