diff --git a/lib/modules/whisper/embarkjs.js b/lib/modules/whisper/embarkjs.js index 42bd1a09..dc377a8d 100644 --- a/lib/modules/whisper/embarkjs.js +++ b/lib/modules/whisper/embarkjs.js @@ -1,3 +1,5 @@ +/*global EmbarkJS, Web3 */ + let __embarkWhisper = {}; __embarkWhisper.setProvider = function(options) { @@ -18,8 +20,8 @@ __embarkWhisper.setProvider = function(options) { console.log("whisper not available"); } else if (version >= 5) { if (self.web3CompatibleWithV5()) { - self.web3.shh.newSymKey().then((id) => {self.symKeyID = id;}); - self.web3.shh.newKeyPair().then((id) => {self.sig = id;}); + self.web3.shh.newSymKey().then((id) => { self.symKeyID = id; }); + self.web3.shh.newKeyPair().then((id) => { self.sig = id; }); } else { console.log("this version of whisper in this node"); } @@ -32,20 +34,21 @@ __embarkWhisper.setProvider = function(options) { __embarkWhisper.web3CompatibleWithV5 = function() { var _web3 = new Web3(); - if (typeof(_web3.version) === "string") { + if ((typeof _web3.version) === "string") { return true; } return parseInt(_web3.version.api.split('.')[1], 10) >= 20; }; __embarkWhisper.getWhisperVersion = function(cb) { + const self = this; if (EmbarkJS.isNewWeb3()) { this.web3.shh.getVersion(function(err, version) { cb(err, version); }); } else { - this.web3.version.getWhisper(function(err, res) { - cb(err, web3.version.whisper); + this.web3.version.getWhisper(function(err, _res) { + cb(err, self.web3.version.whisper); }); } }; @@ -88,7 +91,7 @@ __embarkWhisper.sendMessage = function(options) { data = options.data || options.payload; ttl = options.ttl || 100; priority = options.priority || 1000; - var identity = options.identity || this.identity || web3.shh.newIdentity(); + var identity = options.identity || this.identity || this.web3.shh.newIdentity(); var _topics; if (topics === undefined) {