question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add metadata to event callbacks

See original GitHub issue

When 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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ricmoocommented, Dec 2, 2017

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:

// event Foobar(uint256 someData, address someAddress)
someContract.onfoobar = function(someData, someAddress, transactionData) {
   // ...
}

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.

0reactions
jochenonlinecommented, Feb 26, 2019

Btw. Is there a similar function for the contract (i.e. contract.getLogs) to get past logs like provider.getLogs?

Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript Events Handlers — Metadata and Ajax Events
The onloadedmetadata property of a media DOM element lets us set an event handler function that's run when the loademetadata event is fired....
Read more >
HTMLMediaElement: loadedmetadata event - Web APIs | MDN
The loadedmetadata event is fired when the metadata has been loaded. Syntax. Use the event name in methods like addEventListener() , or set...
Read more >
Custom Event Metadata - Bluedot documentation
Custom event metadata is a feature which is available in the Bluedot Point SDK for our customers to set additional event-specific metadata ......
Read more >
Where are attached event-handlers 'meta-data' stored? On the ...
I'm asking JavaScript & DOM and the 'meta-data' that connects these events, not the codes that jQuery uses to translate to attachEvent or...
Read more >
Monitoring API Developer Guide - Tag Manager
To identify this tag from an event callback, add metadata to the tag: In the tag definition, click Advanced Settings > Additional Tag...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found