mirror of https://github.com/embarklabs/embark.git
use an event to get web3 instead of global
This commit is contained in:
parent
a0ef234fea
commit
5f8ad923c7
|
@ -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());
|
||||
});
|
||||
|
|
|
@ -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(() => {
|
||||
|
|
Loading…
Reference in New Issue