Support more than one address per source
The subgraph.yaml schema is very poorly documented. The only place I see is here: https://thegraph.academy/developers/defining-a-subgraph/ which is a tutorial. There needs to be a dedicated reference-style document describing the schema of this file.
In particular we are trying to figure out how to define several dataSources.source values for the same ABI/mapping. We have several contracts that have the same event ABI that we want to listen to. These are not "dynamically created" from a factory, but manually deployed by us as needed
# ...
dataSources:
- kind: ethereum/contract
name: Gravity
network: mainnet
source: # support several sources here
address: '0x2E645469f354BB4F5c8a05B3b30A929361cf77eC'
abi: Gravity
startBlock: 6175244
mapping:
# ...
Otherwise we have to duplicate a lot of code in subgraph.yaml just to listen to one more address.
Thanks @KholdStare - @leoyvens wondering if there is an implementation in detail in Graph Node that would make this difficult? Also wondering if this could be neatly handled by https://github.com/graphprotocol/graph-node/issues/3221 spawning the required templates
@azf20 Thanks. Either solution would work for us.
I think this could be solved exclusively on graph-cli by manifest templating. Perhaps networks.json could support providing an array of addresses, and would then generate one data source definition for each address.
@leoyvens I like that a lot, perhaps I prematurely transferred this issue 🤔
@evaporei I think this could indeed be happen - only at deploy time, or also in build?
@azf20 @leoyvens Should this issue be moved back into graph-tooling? I like this idea:
I think this could be solved exclusively on graph-cli by manifest templating. Perhaps networks.json could support providing an array of addresses, and would then generate one data source definition for each address.
That would simplify our config a lot.
@azf20 @saihaj Any thoughts/updates on this issue? Running into this again. I tried using the blockHandlers with filter: once to create some things from a template, but there isn't a way to do different things for different networks. If we have a bunch of addresses for each chain, I don't see how to distinguish chains from inside handlers.
Additionally blockHandlers do not make available the source.address in any way, so there's no way to somehow use networks.json to substitute an address and have that accessible in a block handler.
hey @KholdStare I think @saihaj tried the above approach but encountered some challenges, any update Saihaj?
But it sounds like you could could use dataSource.network() or dataSource.context() (docs) - context can be added to the manifest (docs)
dataSource.network() and dataSource.address() help a lot! I did not know about those, thank you!