mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-02-13 07:36:21 +00:00
if no register config, dont register anything
This commit is contained in:
parent
5799dcfceb
commit
32f89e45c8
@ -229,12 +229,19 @@ __embarkENS.lookup = function (address, callback) {
|
||||
__embarkENS.registerSubDomain = function (name, address, callback) {
|
||||
callback = callback || function () {};
|
||||
|
||||
<<<<<<< HEAD
|
||||
if (this.env !== 'development' && this.env !== 'privatenet') {
|
||||
return callback('Sub-domain registration is only available in development or privatenet mode');
|
||||
}
|
||||
if (!this.registration || !this.registration.rootDomain) {
|
||||
return callback('No rootDomain is declared in config/namesystem.js (register.rootDomain). Unable to register a subdomain until then.');
|
||||
}
|
||||
=======
|
||||
if (!this.registration || !this.registration.rootDomain) {
|
||||
return callback('No rootDomain is declared in config/namesystem.js (register.rootDomain). Unable to register a subdomain until then.');
|
||||
}
|
||||
|
||||
>>>>>>> if no register config, dont register anything
|
||||
if (!address || !web3.utils.isAddress(address)) {
|
||||
return callback('You need to specify a valid address for the subdomain');
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ class ENS {
|
||||
this.registration = this.namesConfig.register || {};
|
||||
this.embark = embark;
|
||||
|
||||
<<<<<<< HEAD
|
||||
if (this.namesConfig === {} ||
|
||||
this.namesConfig.enabled !== true ||
|
||||
this.namesConfig.available_providers.indexOf('ens') < 0) {
|
||||
@ -22,6 +23,8 @@ class ENS {
|
||||
}
|
||||
this.doSetENSProvider = this.namesConfig.provider === 'ens';
|
||||
|
||||
=======
|
||||
>>>>>>> if no register config, dont register anything
|
||||
this.addENSToEmbarkJS();
|
||||
this.configureContracts();
|
||||
this.registerEvents();
|
||||
@ -68,10 +71,18 @@ class ENS {
|
||||
self.addSetProvider(config);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
if ((!self.isDev && self.env !== 'privatenet') || !self.registration || !self.registration.subdomains || !Object.keys(self.registration.subdomains).length) {
|
||||
return cb();
|
||||
}
|
||||
self.registerConfigDomains(config, cb);
|
||||
=======
|
||||
if (!self.registration || !self.registration.subdomains || !Object.keys(self.registration.subdomains).length) {
|
||||
return cb();
|
||||
}
|
||||
self.registerConfigDomains(config, cb);
|
||||
});
|
||||
>>>>>>> if no register config, dont register anything
|
||||
});
|
||||
}
|
||||
|
||||
@ -150,12 +161,32 @@ class ENS {
|
||||
const register = require('./register');
|
||||
const secureSend = embarkJsUtils.secureSend;
|
||||
self.events.request("blockchain:defaultAccount:get", (defaultAccount) => {
|
||||
<<<<<<< HEAD
|
||||
async.parallel([
|
||||
function createRegistryContract(paraCb) {
|
||||
self.events.request("blockchain:contract:create",
|
||||
{abi: config.registryAbi, address: config.registryAddress},
|
||||
(registry) => {
|
||||
paraCb(null, registry);
|
||||
=======
|
||||
self.events.request("blockchain:contract:create",
|
||||
{abi: config.registrarAbi, address: config.registrarAddress},
|
||||
(registrar) => {
|
||||
async.each(Object.keys(self.registration.subdomains), (subDomainName, eachCb) => {
|
||||
const toSend = registrar.methods.register(utils.soliditySha3(subDomainName), defaultAccount);
|
||||
|
||||
toSend.estimateGas().then(gasEstimated => {
|
||||
return toSend.send({gas: gasEstimated + 1000, from: defaultAccount}).then(transaction => {
|
||||
if (transaction.status !== "0x1" && transaction.status !== "0x01" && transaction.status !== true) {
|
||||
return eachCb('Failed to register. Check gas cost.');
|
||||
}
|
||||
eachCb(null, transaction);
|
||||
}).catch(err => {
|
||||
eachCb('Failed to register with error: ' + (err.message || err));
|
||||
});
|
||||
}).catch(err => {
|
||||
eachCb("Register would error. Is it already registered? Do you have token balance? Is Allowance set? " + (err.message || err));
|
||||
>>>>>>> if no register config, dont register anything
|
||||
});
|
||||
},
|
||||
function createRegistrarContract(paraCb) {
|
||||
@ -212,7 +243,9 @@ class ENS {
|
||||
configureContracts() {
|
||||
const config = {
|
||||
"default": {
|
||||
"gas": "auto",
|
||||
"gas": "auto"
|
||||
},
|
||||
"development": {
|
||||
"contracts": {
|
||||
"ENS": {
|
||||
"deploy": false,
|
||||
@ -246,6 +279,9 @@ class ENS {
|
||||
"Resolver": {
|
||||
"deploy": false
|
||||
},
|
||||
"Resolver": {
|
||||
"deploy": false
|
||||
},
|
||||
"FIFSRegistrar": {
|
||||
"deploy": false
|
||||
}
|
||||
@ -260,6 +296,9 @@ class ENS {
|
||||
"Resolver": {
|
||||
"deploy": false
|
||||
},
|
||||
"Resolver": {
|
||||
"deploy": false
|
||||
},
|
||||
"FIFSRegistrar": {
|
||||
"deploy": false
|
||||
}
|
||||
@ -274,13 +313,39 @@ class ENS {
|
||||
"Resolver": {
|
||||
"deploy": false
|
||||
},
|
||||
"Resolver": {
|
||||
"deploy": false
|
||||
},
|
||||
"FIFSRegistrar": {
|
||||
"deploy": false
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
<<<<<<< HEAD
|
||||
config.testnet = config.ropsten;
|
||||
=======
|
||||
|
||||
if (this.registration && this.registration.rootDomain) {
|
||||
// Register root domain if it is defined
|
||||
const rootNode = namehash.hash(this.registration.rootDomain);
|
||||
config.development.contracts['FIFSRegistrar'] = {
|
||||
"deploy": true,
|
||||
"args": ["$ENSRegistry", rootNode],
|
||||
"onDeploy": [
|
||||
`ENSRegistry.methods.setOwner('${rootNode}', web3.eth.defaultAccount).send().then(() => {
|
||||
ENSRegistry.methods.setResolver('${rootNode}', "$Resolver").send();
|
||||
var reverseNode = web3.utils.soliditySha3(web3.eth.defaultAccount.toLowerCase().substr(2) + '.addr.reverse');
|
||||
ENSRegistry.methods.setResolver(reverseNode, "$Resolver").send();
|
||||
Resolver.methods.setAddr('${rootNode}', web3.eth.defaultAccount).send();
|
||||
Resolver.methods.setName(reverseNode, '${this.registration.rootDomain}').send();
|
||||
})`
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
this.embark.registerContractConfiguration(config);
|
||||
>>>>>>> if no register config, dont register anything
|
||||
|
||||
if (this.registration && this.registration.rootDomain) {
|
||||
// Register root domain if it is defined
|
||||
|
@ -1,7 +1,11 @@
|
||||
/*global web3*/
|
||||
const namehash = require('eth-ens-namehash');
|
||||
|
||||
<<<<<<< HEAD
|
||||
function registerSubDomain(ens, registrar, resolver, defaultAccount, subdomain, rootDomain, reverseNode, address, logger, secureSend, callback) {
|
||||
=======
|
||||
function registerSubDomain(ens, registrar, resolver, defaultAccount, subdomain, rootDomain, reverseNode, address, callback) {
|
||||
>>>>>>> if no register config, dont register anything
|
||||
const subnode = namehash.hash(subdomain);
|
||||
const rootNode = namehash.hash(rootDomain);
|
||||
const node = namehash.hash(`${subdomain}.${rootDomain}`);
|
||||
|
Loading…
x
Reference in New Issue
Block a user