use an event to get web3 instead of global

This commit is contained in:
Jonathan Rainville 2018-10-05 13:15:01 -04:00
parent ec1382e838
commit 467eeeec55
2 changed files with 15 additions and 5 deletions

View File

@ -168,6 +168,10 @@ class BlockchainConnector {
registerRequests() {
const self = this;
this.events.setCommandHandler("blockchain:get", function(cb) {
cb(self.web3);
});
this.events.setCommandHandler("blockchain:defaultAccount:get", function(cb) {
cb(self.defaultAccount());
});

View File

@ -274,13 +274,19 @@ class ENS {
(resolver) => {
paraCb(null, resolver);
});
},
function getWeb3(paraCb) {
self.events.request("blockchain:get",
(web3) => {
paraCb(null, web3);
});
}
], (err, contracts) => {
self.ensContract = contracts[0];
self.registrarContract = contracts[1];
self.resolverContract = contracts[2];
], (err, result) => {
self.ensContract = result[0];
self.registrarContract = result[1];
self.resolverContract = result[2];
const web3 = result[3];
/*global web3*/
const rootNode = namehash.hash(self.registration.rootDomain);
var reverseNode = web3.utils.soliditySha3(web3.eth.defaultAccount.toLowerCase().substr(2) + reverseAddrSuffix);
self.ensContract.methods.setOwner(rootNode, web3.eth.defaultAccount).send({from: web3.eth.defaultAccount, gas: 700000}).then(() => {