mirror of https://github.com/embarklabs/embark.git
add function to register the domains from config
This commit is contained in:
parent
fe00535bd9
commit
9125fe82d9
|
@ -225,6 +225,33 @@ class ENS {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
registerConfigDomains(config, cb) {
|
||||||
|
const self = this;
|
||||||
|
self.events.request("blockchain:defaultAccount:get", (defaultAccount) => {
|
||||||
|
self.events.request("blockchain:contract:create",
|
||||||
|
{abi: config.registrarAbi, address: config.registrarAddress},
|
||||||
|
(registrar) => {
|
||||||
|
async.each(Object.keys(self.registration.domains), (subDomainName, eachCb) => {
|
||||||
|
const toSend = registrar.methods.register(utils.sha3(subDomainName),
|
||||||
|
defaultAccount, self.registration.domains[subDomainName]);
|
||||||
|
|
||||||
|
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));
|
||||||
|
});
|
||||||
|
}, cb);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
addENSToEmbarkJS() {
|
addENSToEmbarkJS() {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue