simov / crypto-contract

Ethereum Contract Tool
MIT License
0 stars 0 forks source link

allEvents event filter breaks the tool #1

Closed f00bar closed 8 years ago

f00bar commented 8 years ago

allEvents catches all events emitted by a contract: https://github.com/ethereum/wiki/wiki/JavaScript-API#contract-allevents

To reproduce execute: allEvents({}, {fromBlock: 0, toBlock: 'latest'}).watch and make you contract execute two or more events.

contract$ epcis: allEvents({}, {fromBlock: 7939, toBlock: 'latest'}).watch
[14:07] Event 
blockNumber:      7951
transactionIndex: 0
logIndex:         0
blockHash:        0x4ee617648afea2e3065b8f60fe5d6c27c7a9feb451f49c05f5bb843b51938798
address:          0x1c3799f0aca0adf008b870e9033777f063d18059
args: 
  sender:      0x7e5a21fed3e38bf11855634ea7cc50180de8d6f3
  epc:         urn:epc:id:sgtin:0614141.112345.12346
  disposition: urn:epcglobal:hls:disp:active
transactionHash:  0xfdd3373740ecb55e8f40da2dab3f8a5e659326365c201b6c06164be32dd108d3
event:            commissioningAddEvent
contract$ epcis: 
/root/.nvm/versions/node/v5.1.0/lib/node_modules/@crypto/contract/node_modules/web3/lib/web3/filter.js:117
            messages.forEach(function (message) {
                     ^
TypeError: callback is not a function
simov commented 8 years ago

I'm looking at this example and we are doing exactly that. You can easily test it outside of this tool and you'll probably get the same error. Let me know what do you think.

f00bar commented 8 years ago

allEvents seems to be working when I'm going through web3:

> var events = epcisInstance.allEvents({fromBlock: 0, toBlock: 'latest'})
undefined
> events.watch(function(error, event){
......   if (!error)
......     console.log(event);
...... });
[object Object]
[object Object]
[object Object]
simov commented 8 years ago

Should be fixed in https://github.com/ethereum/web3.js/pull/355 when merged. For the time being I'm using my own web3 fork.