gnd: Support tuple/struct event params in subgraph scaffolding#6661
Draft
incrypto32 wants to merge 4 commits into
Draft
gnd: Support tuple/struct event params in subgraph scaffolding#6661incrypto32 wants to merge 4 commits into
incrypto32 wants to merge 4 commits into
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Bytesfield 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.componentsrecursivelyFoo((address,uint256),uint256), so topic0 matchesdata->data_a,data_b) in both the schema and the mapping, with nested accessors (event.params.data.a), via a sharedflatten_event_inputschangetype<Bytes[]>'d so the assignment type-checksTests: 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
tupleunrolls;tuple[]stays aBytes[]field + changetype.