graphprotocol / graphprotocol/graph-node
[Feature] Allow getting and setting of indexed arguments / topic filters within handlers
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Rust
- Sterne
- 3.2k
- Forks
- 1.1k
- Ø Merge
- 4 T. 1 Std.
- Gemergte PRs (30 T.)
- 1
Beschreibung
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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, den graph-ts-Handler und die im Issue referenzierten generierten Datasource-APIs nachzuverfolgen, und ermittle anschließend, wie indizierte Topic-Filter zur Laufzeit des Handlers dargestellt werden. Als erledigt gilt die Aufgabe, wenn Handler die Event-Handler einer Datasource abrufen, Topic-Werte lesen sowie diese Werte aktualisieren und speichern können und das Verhalten durch die relevanten Tests abgedeckt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- blockchain
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 30/100