Skip to content

TypeError thrown when event received. #15

@kybernetikos

Description

@kybernetikos

TypeError thrown when event received.

Running in nodejs, I watch for the following event:

    event Transfer(address indexed _from, address indexed _to, uint256 _value);

When the event occurs, an exception is thrown:

Error: [ethjs-filter] while decoding filter change event data from RPC '[{"logIndex":"0","transactionIndex":"0","transactionHash":"0x6b0d1c8f2b072615aab822459b6318bfad01dca4663c2c4d41c6cdd1d84b3033","blockHash":"0x1f603b873f6e016ce99a2f4a34b13e877cbdd94308e4fc4fbd42f1d8a132cb1a","blockNumber":"17","address":"0x345ca3e014aaf5dca488057592ee47305d9b3e10","data":"0x0000000000000000000000000000000000000000000000001bc16d674ec80000","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x000000000000000000000000627306090abab3a6e1400e9345bc60c78a8bef57","0x000000000000000000000000f17f52151ebef6c7334fad080c5704d77216b732"],"type":"mined"}]': TypeError: Cannot read property 'slice' of undefined
    at C:\Development\sandbox\ethereum\repl-alliance\node_modules\ethjs-filter\lib\index.js:29:31
    at C:\Development\sandbox\ethereum\repl-alliance\node_modules\ethjs-query\lib\index.js:101:16
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:160:7)

The problem appears to be caused in the decodeEvent function. My topics array contains only a single value - 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. This was set by eth-contract v0.1.9 and is the hash of the signature of the Transfer event. However, the code in decodeEvent looks for a value in topics[1].

The event has two indexed 'inputs' and is not anonymous, but there is only a single item in the topics array (the signature), so the .slice is called on undefined, and the exception is thrown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions