diff --git a/packages/web3-core-subscriptions/src/subscription.js b/packages/web3-core-subscriptions/src/subscription.js index fb3f95d5b66..4cb6090b96c 100644 --- a/packages/web3-core-subscriptions/src/subscription.js +++ b/packages/web3-core-subscriptions/src/subscription.js @@ -254,11 +254,13 @@ Subscription.prototype.subscribe = function() { // call callback on notifications _this.options.requestManager.addSubscription(_this.id, payload.params[0] , _this.options.type, function(err, result) { - // TODO remove once its fixed in geth - if(_.isArray(result)) - result = result[0]; - - var output = _this._formatOutput(result); + // TODO remove the length check once this is fixed in geth + var output; + if(_.isArray(result) && result.length > 1) { + output = _.map(result, (function(r) { return _this._formatOutput(r); })); + } else { + output = _.isArray(result) ? _this._formatOutput(result[0]) : _this._formatOutput(result); + } if (!err) { diff --git a/packages/web3-eth-contract/src/index.js b/packages/web3-eth-contract/src/index.js index e63997982ee..83174ae382c 100644 --- a/packages/web3-eth-contract/src/index.js +++ b/packages/web3-eth-contract/src/index.js @@ -647,7 +647,14 @@ Contract.prototype._on = function(){ outputFormatter: this._decodeEventABI.bind(subOptions.event), // DUBLICATE, also in web3-eth subscriptionHandler: function (output) { - if(output.removed) { + var changed; + if (_.isArray(output)) { + changed = _.reduce(output, function (c, log) {return c || log.changed;}, false); + } else { + changed = output.removed; + } + + if(changed) { this.emit('changed', output); } else { this.emit('data', output); diff --git a/packages/web3-eth/src/index.js b/packages/web3-eth/src/index.js index 30b9cbb081c..069f0aa2e2c 100644 --- a/packages/web3-eth/src/index.js +++ b/packages/web3-eth/src/index.js @@ -373,7 +373,14 @@ var Eth = function Eth() { outputFormatter: formatter.outputLogFormatter, // DUBLICATE, also in web3-eth-contract subscriptionHandler: function (output) { - if(output.removed) { + var changed; + if (_.isArray(output)) { + changed = _.reduce(output, function (c, log) {return c || log.changed;}, false); + } else { + changed = output.removed; + } + + if(changed) { this.emit('changed', output); } else { this.emit('data', output);