gnd: Support tuple/struct event params in subgraph scaffolding#6661
Draft
incrypto32 wants to merge 5 commits into
Draft
gnd: Support tuple/struct event params in subgraph scaffolding#6661incrypto32 wants to merge 5 commits into
incrypto32 wants to merge 5 commits into
Conversation
incrypto32
force-pushed
the
incrypto32/gnd-tuples
branch
from
July 15, 2026 10:02
5c8dbc1 to
83e0f94
Compare
Replace the scaffold module's hand-rolled ABI parsing with alloy's typed
Event/EventParam, mirroring the codegen side (which already uses them). Events
are parsed in file order via serde; a malformed event is skipped with a warning
instead of silently dropping individual params.
The shared preprocessing (artifact-format unwrapping, anonymous/param{index}
defaults) moves from commands/codegen.rs to the abi module so scaffold and
codegen share it. As a result unnamed event params now yield param{index} entity
fields (matching graph-cli) rather than a bare value field, and scaffolding
accepts Foundry/Hardhat/Truffle artifact ABIs.
Build the manifest event signature from each param's canonical type (selector_type) instead of the raw ABI type, so a tuple expands to its components, e.g. Filled((address,uint256),uint256). Previously a tuple param produced Filled(tuple,uint256), whose topic0 hash did not match the on-chain event, so the handler never fired.
A tuple parameter now expands to one field per component (data -> data_account, data_amount) in both the schema and the mapping, with nested accessors (event.params.data.account), via a shared flatten_event_inputs 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).
incrypto32
force-pushed
the
incrypto32/gnd-tuples
branch
from
July 16, 2026 08:05
83e0f94 to
390be45
Compare
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.