mirror of
https://github.com/embarklabs/embark.git
synced 2025-03-01 13:50:43 +00:00
fix(@embark/whisper): ensure web3 is ready when whisper info is requested
In 1461e95c39
we've introduced a guard that ensures whisper isn't crashing
when Embark is used with the Simulator. This unfortunately also introduced
code that tries to connect to an existing websocket provider that isn't actually
ready at the time it tries to connect.
This commit ensures `web3.shh.getInfo()` is only called once `web3` is ready
and therefore the WS connection as well.
This commit is contained in:
parent
503a79ca7a
commit
fd311f9d24
@ -30,6 +30,7 @@ class Whisper {
|
|||||||
this.connectToProvider();
|
this.connectToProvider();
|
||||||
|
|
||||||
this.events.request('processes:register', 'whisper', (cb) => {
|
this.events.request('processes:register', 'whisper', (cb) => {
|
||||||
|
this.waitForWeb3Ready(() => {
|
||||||
this.web3.shh.getInfo((err) => {
|
this.web3.shh.getInfo((err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
const message = err.message || err;
|
const message = err.message || err;
|
||||||
@ -41,7 +42,6 @@ class Whisper {
|
|||||||
this.setServiceCheck();
|
this.setServiceCheck();
|
||||||
this.addWhisperToEmbarkJS();
|
this.addWhisperToEmbarkJS();
|
||||||
this.addSetProvider();
|
this.addSetProvider();
|
||||||
this.waitForWeb3Ready(() => {
|
|
||||||
this.registerAPICalls();
|
this.registerAPICalls();
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user