comply with linter

This commit is contained in:
Iuri Matias 2017-12-28 13:13:30 -05:00
parent 310712567f
commit fc24b04bf6
1 changed files with 9 additions and 6 deletions

View File

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