pre-dploy using the same function as register

This commit is contained in:
Jonathan Rainville 2018-07-25 13:57:03 -04:00 committed by Iuri Matias
parent c89a554fd8
commit 1654ae63db
3 changed files with 49 additions and 0 deletions

View File

@ -252,7 +252,11 @@ __embarkENS.registerSubDomain = function (name, address, callback) {
// Register function generated by the index
registerSubDomain(this.ens, this.registrar, this.resolver, web3.eth.defaultAccount, name, this.registration.rootDomain,
<<<<<<< HEAD
web3.utils.soliditySha3(address.toLowerCase().substr(2) + reverseAddrSuffix), address, console, EmbarkJS.Utils.secureSend, callback);
=======
web3.utils.soliditySha3(address.toLowerCase().substr(2) + '.addr.reverse'), address, console, callback);
>>>>>>> pre-dploy using the same function as register
};
__embarkENS.isAvailable = function () {

View File

@ -165,15 +165,20 @@ class ENS {
registerConfigDomains(config, cb) {
const self = this;
const register = require('./register');
<<<<<<< HEAD
const secureSend = embarkJsUtils.secureSend;
self.events.request("blockchain:defaultAccount:get", (defaultAccount) => {
<<<<<<< HEAD
=======
self.events.request("blockchain:defaultAccount:get", (defaultAccount) => {
>>>>>>> pre-dploy using the same function as register
async.parallel([
function createRegistryContract(paraCb) {
self.events.request("blockchain:contract:create",
{abi: config.registryAbi, address: config.registryAddress},
(registry) => {
paraCb(null, registry);
<<<<<<< HEAD
=======
self.events.request("blockchain:contract:create",
{abi: config.registrarAbi, address: config.registrarAddress},
@ -193,6 +198,8 @@ class ENS {
}).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
=======
>>>>>>> pre-dploy using the same function as register
});
},
function createRegistrarContract(paraCb) {
@ -209,7 +216,11 @@ class ENS {
paraCb(null, resolver);
});
}
<<<<<<< HEAD
], function(err, contracts) {
=======
], function (err, contracts) {
>>>>>>> pre-dploy using the same function as register
if (err) {
return cb(err);
}
@ -217,9 +228,15 @@ class ENS {
async.each(Object.keys(self.registration.subdomains), (subDomainName, eachCb) => {
const address = self.registration.subdomains[subDomainName];
<<<<<<< HEAD
const reverseNode = utils.soliditySha3(address.toLowerCase().substr(2) + reverseAddrSuffix);
register(ens, registrar, resolver, defaultAccount, subDomainName, self.registration.rootDomain,
reverseNode, address, self.logger, secureSend, eachCb);
=======
const reverseNode = utils.soliditySha3(address.toLowerCase().substr(2) + '.addr.reverse');
register(ens, registrar, resolver, defaultAccount, subDomainName, self.registration.rootDomain,
reverseNode, address, self.logger, eachCb);
>>>>>>> pre-dploy using the same function as register
}, cb);
});

View File

@ -1,11 +1,15 @@
/*global web3*/
const namehash = require('eth-ens-namehash');
<<<<<<< HEAD
<<<<<<< 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
=======
function registerSubDomain(ens, registrar, resolver, defaultAccount, subdomain, rootDomain, reverseNode, address, logger, callback) {
>>>>>>> pre-dploy using the same function as register
const subnode = namehash.hash(subdomain);
const rootNode = namehash.hash(rootDomain);
const node = namehash.hash(`${subdomain}.${rootDomain}`);
@ -14,7 +18,15 @@ function registerSubDomain(ens, registrar, resolver, defaultAccount, subdomain,
const toSend = ens.methods.setSubnodeOwner(rootNode, subnode, defaultAccount);
let transaction;
<<<<<<< HEAD
secureSend(web3, toSend, {from: defaultAccount}, false)
=======
toSend.estimateGas()
// Register domain
.then(gasEstimated => {
return toSend.send({gas: gasEstimated + 1000, from: defaultAccount});
})
>>>>>>> pre-dploy using the same function as register
// Set resolver for the node
.then(transac => {
if (transac.status !== "0x1" && transac.status !== "0x01" && transac.status !== true) {
@ -22,6 +34,7 @@ function registerSubDomain(ens, registrar, resolver, defaultAccount, subdomain,
return callback('Failed to register. Check gas cost.');
}
transaction = transac;
<<<<<<< HEAD
return secureSend(web3, ens.methods.setResolver(node, resolver.options.address), {from: defaultAccount}, false);
})
// Set address for node
@ -35,6 +48,21 @@ function registerSubDomain(ens, registrar, resolver, defaultAccount, subdomain,
// Set name for reverse node
.then(_result => {
return secureSend(web3, resolver.methods.setName(reverseNode, `${subdomain}.${rootDomain}`), {from: defaultAccount}, false);
=======
return ens.methods.setResolver(node, resolver.options.address).send({from: defaultAccount});
})
// Set address for node
.then(_result => {
return resolver.methods.setAddr(node, address).send({from: defaultAccount});
})
// Set resolver for the reverse node
.then(_result => {
return ens.methods.setResolver(reverseNode, resolver.options.address).send({from: defaultAccount});
})
// Set name for reverse node
.then(_result => {
return resolver.methods.setName(reverseNode, subdomain + '.embark.eth').send({from: defaultAccount});
>>>>>>> pre-dploy using the same function as register
})
.then(_result => {
callback(null, transaction);