Declared calls syntax from: Graph Node
/// calls:
/// - myCall1: Contract[address].function(arg1, arg2, ...)
/// - ..
/// ```
///
/// The `address` and `arg` fields can be either `event.address` or
/// `event.params.<name>`. Each entry under `calls` gets turned into a
/// `CallDcl`
In Graph Node
eventHandlers:
- event: Created(address)
handler: handleGet
calls:
fake1: Factory[event.address].get(event.params.address)
fake2: Factory[event.params.address].get(event.params.address)
fake3: Factory[0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF].get(event.address)
fake4: Factory[0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF].get(0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF)
Breaking down the syntax above:
calls:
is an object with key value pairs, the key is an arbitrary name (described below) and the value is the eth_call being made. Make sure to include these calls under the relevant source mapping that makes the eth_calls.
fake1:
is an arbitrary name you specify for the declared call, think of it as self documenting, so if your eth_call is getLiquidity
you could call this getLiquidity: ...
Factory
is the name of the ABI in the subgraph, and typically in the source mapping code, it will be used like so: Factory.bind(address)
. You can use the bind
pattern to search through your code to see where to apply declared eth calls.
[event.address]
, [event.params.address]
are the parameters passed to the Factory
ABI when binding. This can be any parameter that's normally accessible from the event object within the source mapping, or a constant, like a hex string address.
.get(...)
is the actual eth_call being made. It may be get
but could be any contract method eth_call that is in your ABI. Note that if your eth_call uses try_
syntax, like try_getSymbol
, you won't include the try_...
syntax, just the method name of the actual eth_call.
.get(event.params.address)
is the parameter or parameters passed to the contract method when making the eth_call, like when binding to the Factory, it can be any of the parameters to the event object, or a constant, but should match what you have in your source mapping.
Finally, as you can see, constants are embedded without quotes, so if you use any constants, make sure to stick to the above pattern.