Skip to content
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

"Error: invalid event" when listening with WebSocketProvider #784

Closed
bbarton opened this issue Apr 15, 2020 · 4 comments
Closed

"Error: invalid event" when listening with WebSocketProvider #784

bbarton opened this issue Apr 15, 2020 · 4 comments
Labels
bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published.

Comments

@bbarton
Copy link

bbarton commented Apr 15, 2020

Hi @ricmoo ,

I'm having an issue using the new WebSocketProvider to listen to events.

The following code fires when an event is detected, but my contract.on callback returns an error. I've received the same error trying this on multiple contracts.

var wsProvider = new ethers.providers.WebSocketProvider("wss://rinkeby.infura.io/ws/v3/my_id_here");
let contract = new ethers.Contract(rinkebyAddress, CONTRACT_ABI, wsProvider);
let filter = "Minted";

contract.on(filter, (from, to, value, event) => {
  console.log("from: ", from);
});

The error I receive:

Error: invalid event - filter:0xff2e8205a69f2f4403a66de436894c2eaed1b3d6:0x30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe
    at getEventTag (/Users/bb/Desktop/aa/node_modules/@ethersproject/providers/lib/base-provider.js:125:11)
    at WebSocketProvider.BaseProvider.listenerCount (/Users/bb/Desktop/aa/node_modules/@ethersproject/providers/lib/base-provider.js:1270:24)
    at WebSocketProvider._stopEvent (/Users/bb/Desktop/aa/node_modules/@ethersproject/providers/lib/websocket-provider.js:274:23)
    at /Users/bb/Desktop/aa/node_modules/@ethersproject/providers/lib/base-provider.js:1303:50
    at Array.forEach (<anonymous>)
    at WebSocketProvider.BaseProvider.off (/Users/bb/Desktop/aa/node_modules/@ethersproject/providers/lib/base-provider.js:1303:17)
    at Contract._checkRunningEvents (/Users/bb/Desktop/aa/node_modules/@ethersproject/contracts/lib/index.js:561:27)
    at Contract.emit (/Users/bb/Desktop/aa/node_modules/@ethersproject/contracts/lib/index.js:647:14)
    at WebSocketProvider.wrappedEmit (/Users/bb/Desktop/aa/node_modules/@ethersproject/contracts/lib/index.js:601:28)
    at Timeout._onTimeout (/Users/bb/Desktop/aa/node_modules/@ethersproject/providers/lib/base-provider.js:1254:32)
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7)

Any guidance appreciated!

(I am on 5.0.0-beta.180)

@ricmoo ricmoo added investigate Under investigation and may be a bug. bug Verified to be an issue. on-deck This Enhancement or Bug is currently being worked on. and removed investigate Under investigation and may be a bug. labels Apr 15, 2020
@ricmoo
Copy link
Member

ricmoo commented Apr 15, 2020

I've been able to reproduce this and am tracking down the root cause...

@ricmoo
Copy link
Member

ricmoo commented Apr 15, 2020

I found the problem and it helped expose another bug.

I've fixed it locally and am running the test suite. Once I commit and the CI finishes I'll publish and update this issue. It should be up in about an hour.

Sorry for the inconvenience.

@ricmoo
Copy link
Member

ricmoo commented Apr 15, 2020

Published to 5.0.0-beta.181. Try it out and let me know if you have any issues. :)

@ricmoo ricmoo added fixed/complete This Bug is fixed or Enhancement is complete and published. and removed on-deck This Enhancement or Bug is currently being worked on. labels Apr 15, 2020
@bbarton
Copy link
Author

bbarton commented Apr 16, 2020

Thank you! It's now working for my contract events. Grateful for your fast response and your overall work on this project!

@bbarton bbarton closed this as completed Apr 16, 2020
michaeltout pushed a commit to michaeltout/ethers.js that referenced this issue Aug 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published.
Projects
None yet
Development

No branches or pull requests

2 participants