From ba908409ed750f370b203637b697906bea2d62ab Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 31 Jan 2019 16:23:22 +0100 Subject: [PATCH] rea-add connectToProvider --- src/index.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/index.ts b/src/index.ts index 48a3eaf..992bb1e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -65,6 +65,20 @@ class StatusJS { ); } + public async connectToProvider(provider: any, privateKey: any) { + let web3: any = new Web3(); + web3.setProvider(provider); + + this.shh = web3.shh; + this.mailservers = new mailservers(web3); + + await web3.shh.setMinPoW(constants.post.POW_TARGET); + _sig.set( + this, + privateKey ? await this.generateWhisperKeyFromWallet(privateKey) : await web3.shh.newKeyPair() + ); + } + public isConnected() { return this.shh.isListening(); }