-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError thrown when event received. #15
Comments
Ah, nice catch! This module will eventually be moved over to ethers.js module, but do you have a fix in the meantime?
…Sent from my iPhone
On Apr 8, 2018, at 11:34 PM, kybernetikos ***@***.***> wrote:
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. 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.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
That depends a little. I don't have enough background in the code to be confident with suggesting a fix at the moment. I look at If data doesn't include indexed values, and they're not in the topics array either, then I'm not sure where they can be read from. Or does data sometimes include indexed values and not other times? In which case, we could check to see if the values are in topics and use them from there, and if not, try to read them from data. |
I'll take a closer look today, can you provide what network you are on? (Eg rinkeby)
…Sent from my iPhone
On Apr 9, 2018, at 9:45 AM, kybernetikos ***@***.***> wrote:
do you have a fix in the meantime?
That depends a little. I don't have enough background in the code to be confident with suggesting a fix at the moment.
I look at decodeEvent, and I see that it separates indexed values from nonindexed values. I don't really understand why it needs to read some values from the topics (the indexed values) and some values from the data (the nonindexed values). Is it because data doesn't include indexed values?
If data doesn't include indexed values, and they're not in the topics array either, then I'm not sure where they can be read from. Or does data sometimes include indexed values and not other times? In which case, we could check to see if the values are in topics and use them from there, and if not, try to read them from data.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I've been running against ganache and ganache-cli. (which incidentally shows another problem - the first 16 watchers for the node don't seem to work properly - I think the watcher ids are being set without a leading 0 which ganache expects, or something like that) My smart contract is https://github.com/ConsenSys/Tokens/blob/master/contracts/eip20/EIP20.sol and my listen code is
|
Will review tomorrow.
…Sent from my iPhone
On Apr 9, 2018, at 2:51 PM, kybernetikos ***@***.***> wrote:
I've been running against ganache and ganache-cli.
(which incidentally shows another problem - the first 16 watchers for the node don't seem to work properly - I think the watcher ids are being set without a leading 0 which ganache expects, or something like that)
My smart contract is https://github.com/ConsenSys/Tokens/blob/master/contracts/eip20/EIP20.sol which and my listen code is
// e.g. event = EIP20.Transfer
const filter = event({ delay:10000 });
filter.new({
"fromBlock": "latest",
"toBlock": "latest"
}).then((filterId) => {
console.log('\nFilter id ' + filterId + ' created.');
filter.watch((err, result) => {
if (err) {
console.log('\nEvent error:', err);
} else {
console.log('\nEvent:', name + '.' + evtName, result);
}
});
});
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I'm faced to the same error. Trying to understand it, to make my project work. In ethjs-contract (https://github.com/ethjs/ethjs-contract/blob/master/dist/ethjs-contract.js)
So abi.decodeEvent is called with a filterTopcis with a single element. But in eth-abi (https://github.com/ethjs/ethjs-abi/blob/master/src/index.js), on line 147 : So the decodeEvent may look for topics[1] if the event is not anonymous, which leads to the error seen. I still wonder how this could be solved... (by the way, may be filterTopcis should be modified to filterTopics in ethjs-contract.js...) |
TypeError thrown when event received.
Running in nodejs, I watch for the following event:
When the event occurs, an exception is thrown:
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 intopics[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.
The text was updated successfully, but these errors were encountered: