use an event to get web3 instead of global

This commit is contained in:
Jonathan Rainville 2018-10-05 13:15:01 -04:00 committed by Pascal Precht
parent a0ef234fea
commit 5f8ad923c7
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
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

@ -302,13 +302,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(() => {