Add metadata to event callbacks
See original GitHub issueWhen listening to events I oftentimes want to filter out events which belong to a certain transaction which the current user initiated. As I can just subscribe to all events I’m also getting the events initiated by other users. As data only the actual event data is provided so I can’t link it to a certain transaction. This would be quite helpful though. Web3 for example passes all kinds of metadata into the event callback:
https://github.com/ethereum/wiki/wiki/JavaScript-API#callback-return
Ethers.js just provides what is the args
object in web3. I’m aware that this would break the API, yet the lack of this functionality makes ethers.js unusable for me when it comes to linking events with txs.
One option which would work in a lot of cases, still would be to pass in a meta
object as the last argument of the callback. Let me know what you think.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:9 (4 by maintainers)
Top GitHub Comments
This is a great idea, as it is something I have needed recently as well.
What would you think about events pushing an additional parameters? For example:
This maintains backwards compatibility and seems like a natural place to include it; much in the same way operations can accept 1 additional parameter for the overrides.
Btw. Is there a similar function for the contract (i.e. contract.getLogs) to get past logs like provider.getLogs?