diff options
author | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-28 21:55:39 +0800 |
---|---|---|
committer | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-28 21:55:39 +0800 |
commit | 61e8ae2f7be3ced902007a4aa09ce9130c31b33e (patch) | |
tree | eabcffc2733c3f03257f159bf79c5a53027ec742 /lib | |
parent | 2544d2c952dc003d62bdb99a554b3fa576b202c5 (diff) | |
download | go-tangerine-61e8ae2f7be3ced902007a4aa09ce9130c31b33e.tar go-tangerine-61e8ae2f7be3ced902007a4aa09ce9130c31b33e.tar.gz go-tangerine-61e8ae2f7be3ced902007a4aa09ce9130c31b33e.tar.bz2 go-tangerine-61e8ae2f7be3ced902007a4aa09ce9130c31b33e.tar.lz go-tangerine-61e8ae2f7be3ced902007a4aa09ce9130c31b33e.tar.xz go-tangerine-61e8ae2f7be3ced902007a4aa09ce9130c31b33e.tar.zst go-tangerine-61e8ae2f7be3ced902007a4aa09ce9130c31b33e.zip |
events init
Diffstat (limited to 'lib')
-rw-r--r-- | lib/contract.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/contract.js b/lib/contract.js index 65a061502..a3e76cfea 100644 --- a/lib/contract.js +++ b/lib/contract.js @@ -85,6 +85,7 @@ var contract = function (address, desc) { }); + // create contract functions abi.filterFunctions(desc).forEach(function (method) { var displayName = abi.methodDisplayName(method.name); @@ -139,6 +140,31 @@ var contract = function (address, desc) { }); + + // create contract events + abi.filterEvents(desc).forEach(function (event) { + + // TODO: rename these methods, cause they are used not only for methods + var displayName = abi.methodDisplayName(event.name); + var typeName = abi.methodTypeName(event.name); + + var impl = function (options) { + var o = options || {}; + o.address = o.address || address; + o.topics = o.topics || []; + o.topics.push(abi.methodSignature(event.name)); + + return web3.eth.watch(o); + }; + + if (result[displayName] === undefined) { + result[displayName] = impl; + } + + result[displayName][typeName] = impl; + + }); + return result; }; |