diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/contract.js | 14 | ||||
-rw-r--r-- | lib/event.js | 21 | ||||
-rw-r--r-- | lib/filter.js | 13 |
3 files changed, 44 insertions, 4 deletions
diff --git a/lib/contract.js b/lib/contract.js index 58a67efe6..13c48ca10 100644 --- a/lib/contract.js +++ b/lib/contract.js @@ -22,7 +22,7 @@ var web3 = require('./web3'); var abi = require('./abi'); -var eventImplementation = require('./event'); +var eventImpl = require('./event'); var addFunctionRelatedPropertiesToContract = function (contract) { @@ -127,10 +127,18 @@ var addEventsToContract = function (contract, desc, address) { var impl = function () { var params = Array.prototype.slice.call(arguments); var signature = abi.methodSignature(e.name); - var eventImpl = eventImplementation(address, signature); - var o = eventImpl.apply(null, params); + var event = eventImpl(address, signature); + var o = event.apply(null, params); return web3.eth.watch(o); }; + + impl.address = address; + + Object.defineProperty(impl, 'topics', { + get: function() { + return [abi.methodSignature(e.name)]; + } + }); // TODO: rename these methods, cause they are used not only for methods var displayName = abi.methodDisplayName(e.name); diff --git a/lib/event.js b/lib/event.js index e8312ccdb..ae2195381 100644 --- a/lib/event.js +++ b/lib/event.js @@ -1,5 +1,24 @@ +/* + This file is part of ethereum.js. -var abi = require('./abi'); + ethereum.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + ethereum.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with ethereum.js. If not, see <http://www.gnu.org/licenses/>. +*/ +/** @file event.js + * @authors: + * Marek Kotewicz <marek@ethdev.com> + * @date 2014 + */ var implementationOfEvent = function (address, signature) { diff --git a/lib/filter.js b/lib/filter.js index d93064b58..677b0657c 100644 --- a/lib/filter.js +++ b/lib/filter.js @@ -31,6 +31,19 @@ var Filter = function(options, impl) { this.impl = impl; this.callbacks = []; + if (typeof options !== "string") { + // evaluate lazy properties + options = { + to: options.to, + topics: options.topics, + earliest: options.earliest, + latest: options.latest, + max: options.max, + skip: options.skip, + address: options.address + }; + } + this.id = impl.newFilter(options); web3.provider.startPolling({call: impl.changed, args: [this.id]}, this.id, this.trigger.bind(this)); }; |