Protean-Labs / graphgen

A subgraph generator for The Graph Network
Apache License 2.0
11 stars 0 forks source link

Expand `NewEntity` action to allow for field setting from event (or call) attributes. #56

Open cvauclair opened 3 years ago

cvauclair commented 3 years ago

Add optional arguments to the NewEntity @gg:handler action to allow for field setting from event (or call) attributes. This would reduce the need to make contract calls just to set contract static parameters.

Potential idea example:

interface IUniswapV2Factory {
  /* @gg:handler 
    actions:
      - NewEntity Pair from pair with token0 = token0, token1 = token1
  */
  event PairCreated(address indexed token0, address indexed token1, address pair, uint);
  ...
}

This will require enhancing the parsing of @gg:handler actions so as to allow variations in the actions syntax (E.g.: NewEntity X from Y and NewEntity X from Y with field1 = attr1, field2 = attr2). A new small seperate lexer/parser could potentially be made just to handle the actions syntax.