Skip to content

gnd: Support tuple/struct event params in subgraph scaffolding#6661

Draft
incrypto32 wants to merge 4 commits into
incrypto32/gnd-add-fixfrom
incrypto32/gnd-tuples
Draft

gnd: Support tuple/struct event params in subgraph scaffolding#6661
incrypto32 wants to merge 4 commits into
incrypto32/gnd-add-fixfrom
incrypto32/gnd-tuples

Conversation

@incrypto32

Copy link
Copy Markdown
Member

Stacked on #6660 (base is the PR A branch, incrypto32/gnd-add-fix) — review/merge that first.

A tuple/struct event parameter previously collapsed to a single Bytes field and was dropped from the event signature, producing a subgraph that fails to build and whose topic0 never matches the on-chain event. This adds proper tuple support to the scaffolder.

  • ABI parsing reads nested tuple components recursively
  • Event signatures expand tuples, Foo((address,uint256),uint256), so topic0 matches
  • A tuple unrolls into one field per component (data -> data_a, data_b) in both the schema and the mapping, with nested accessors (event.params.data.a), via a shared flatten_event_inputs
  • Arrays of address/tuple are changetype<Bytes[]>'d so the assignment type-checks

Tests: unit tests for tuple flatten + recursive signatures + changetype; an e2e that a tuple ABI scaffolds the unrolled schema/mapping; and a codegen regression e2e for reserved-word/unnamed params.

Mirrors graph-cli: only a single tuple unrolls; tuple[] stays a Bytes[] field + changetype.

EventInput now carries nested components for tuple / tuple[] inputs, parsed
recursively from the ABI. Event signatures expand tuples, e.g.
Foo((address,uint256),uint256), so the topic0 hash matches the on-chain
event. Previously a tuple parameter produced Foo(tuple,...) and the handler
would never fire.
A tuple parameter now expands to one field per component (data -> data_a,
data_b) in both the schema and the mapping, with nested accessors
(event.params.data.a), via a shared flatten_input helper. Arrays of
address/tuple are changetype'd to Bytes[] so the assignment type-checks.
Previously a tuple collapsed to a single Bytes field that did not match the
generated event params.
init from an ABI with a tuple event unrolls it into data_account /
data_amount schema fields and reads them via the nested accessor in the
generated mapping.
Regression guard for the LHS/RHS escaping mismatch: codegen a contract with
a reserved-word param (`new`) and an unnamed param, then assert the mapping's
event.params accessor matches the getter the bindings actually expose
(new_, param1).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant