From 0eb54646f4b29a53d5789a2beba233763b11e2b0 Mon Sep 17 00:00:00 2001 From: simov Date: Wed, 16 Dec 2015 17:22:48 +0200 Subject: [PATCH] Call self.watch only if the callback is a function - For some reason when the callback is added through the watch method for allEvents, the Filter ctor receives the options object in place of the callback. Fixes #354 --- lib/web3/filter.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/web3/filter.js b/lib/web3/filter.js index e5a5f3267e4..ca7ba38e253 100644 --- a/lib/web3/filter.js +++ b/lib/web3/filter.js @@ -53,7 +53,7 @@ var getOptions = function (options) { if (utils.isString(options)) { return options; - } + } options = options || {}; @@ -69,8 +69,8 @@ var getOptions = function (options) { to: options.to, address: options.address, fromBlock: formatters.inputBlockNumberFormatter(options.fromBlock), - toBlock: formatters.inputBlockNumberFormatter(options.toBlock) - }; + toBlock: formatters.inputBlockNumberFormatter(options.toBlock) + }; }; /** @@ -78,7 +78,7 @@ Adds the callback and sets up the methods, to iterate over the results. @method getLogsAtStart @param {Object} self -@param {funciton} +@param {funciton} */ var getLogsAtStart = function(self, callback){ // call getFilterLogs for the first watch callback start @@ -168,7 +168,7 @@ var Filter = function (requestManager, options, methods, formatter, callback) { pollFilter(self); // start to watch immediately - if(callback) { + if(typeof callback === 'function') { return self.watch(callback); } }