diff options
author | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-29 19:35:21 +0800 |
---|---|---|
committer | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-29 19:35:21 +0800 |
commit | 842b8cf323a3b39d9e29ddd831bc41ddb98279ad (patch) | |
tree | eb1684ed47913b02115e35cd894c7da45bcb591c /lib | |
parent | 61e8ae2f7be3ced902007a4aa09ce9130c31b33e (diff) | |
download | dexon-842b8cf323a3b39d9e29ddd831bc41ddb98279ad.tar dexon-842b8cf323a3b39d9e29ddd831bc41ddb98279ad.tar.gz dexon-842b8cf323a3b39d9e29ddd831bc41ddb98279ad.tar.bz2 dexon-842b8cf323a3b39d9e29ddd831bc41ddb98279ad.tar.lz dexon-842b8cf323a3b39d9e29ddd831bc41ddb98279ad.tar.xz dexon-842b8cf323a3b39d9e29ddd831bc41ddb98279ad.tar.zst dexon-842b8cf323a3b39d9e29ddd831bc41ddb98279ad.zip |
event.js
Diffstat (limited to 'lib')
-rw-r--r-- | lib/contract.js | 18 | ||||
-rw-r--r-- | lib/event.js | 16 |
2 files changed, 31 insertions, 3 deletions
diff --git a/lib/contract.js b/lib/contract.js index a3e76cfea..732aa9111 100644 --- a/lib/contract.js +++ b/lib/contract.js @@ -20,7 +20,7 @@ * @date 2014 */ -var web3 = require('./web3'); // jshint ignore:line +var web3 = require('./web3'); var abi = require('./abi'); /** @@ -62,7 +62,17 @@ var contract = function (address, desc) { var inputParser = abi.inputParser(desc); var outputParser = abi.outputParser(desc); - var result = {}; + var result = { + address: address, + }; + + Object.defineProperty(result, 'topics', { + get: function() { + return abi.filterEvents(desc).map(function (event) { + return abi.methodSignature(event.name); + }); + } + }); result.call = function (options) { result._isTransact = false; @@ -148,11 +158,13 @@ var contract = function (address, desc) { var displayName = abi.methodDisplayName(event.name); var typeName = abi.methodTypeName(event.name); + var impl = function (options) { + var signature = abi.methodSignature(event.name); var o = options || {}; o.address = o.address || address; o.topics = o.topics || []; - o.topics.push(abi.methodSignature(event.name)); + o.topics.push(signature); return web3.eth.watch(o); }; diff --git a/lib/event.js b/lib/event.js new file mode 100644 index 000000000..724acde81 --- /dev/null +++ b/lib/event.js @@ -0,0 +1,16 @@ + +var abi = require('./abi'); + +var implementationOfEvent = function (event, address, signature) { + + return function (options) { + var o = options || {}; + o.address = o.address || address; + o.topics = o.topics || []; + o.topics.push(signature); + return o; + }; +}; + +module.exports = implementationOfEvent; + |