graphprotocol / graphprotocol/graph-node
[Feature] Allow getting and setting of indexed arguments / topic filters within handlers
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.2k
- Forks
- 1.1k
- Avg merge
- 4d 1h
- Merged PRs (30d)
- 1
Description
Description
The new indexed arguments filter is a big step forward in reducing indexing times when sifting through a large amount of events. This feature could be even more powerful as a dynamic datasource, similar to how templates operate. Ideally we could set the topic filter for a specific datasource at handler runtime. Alternatively, if we could specify templates with arguments, we could also create a new datasource and specify the topic.
Without understanding how the implementation actually works, being able to update an existing datasource seems like a more elegant solution (and a better solution for my use case). Three things would need to be exposed by graph-ts: Get Datasource, Read Topic Values, Set Topic Values. The API could look something like this:
// Since datasource names should be unique, these can be auto generated
import { DatasourceName } from '../generated'
import { Event } from '../generated/Contract/Contract'
export function handleEvent(event: Contract) {
const eventHandlers = DatasourceName.getEventHandlers();
const transferHandler = eventHandlers.filter(event => event.abi === 'Transfer(indexed address,indexed
address,uint256)');
const topics = transferHandler.topics;
transferHandler.topics = topics.concat([event.address.toHexString()]);
transferHandler.save();
}
Are you aware of any blockers that must be resolved before implementing this feature? If so, which? Link to any relevant GitHub issues.
No response
Some information to help us out
- Tick this box if you plan on implementing this feature yourself.
- I have searched the issue tracker to make sure this issue is not a duplicate.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the graph-ts handler and generated datasource APIs referenced in the issue, then determine how indexed topic filters are represented at handler runtime. Done means handlers can get a datasource's event handlers, read topic values, and update and save those values, with behavior covered by the relevant tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- blockchain
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100