gnd: Carry resolved DynSolType through scaffold generators - #6700
Draft
incrypto32 wants to merge 3 commits into
Draft
gnd: Carry resolved DynSolType through scaffold generators#6700incrypto32 wants to merge 3 commits into
incrypto32 wants to merge 3 commits into
Conversation
The scaffold generators carried Solidity types as raw strings and matched
them with `ends_with("[]")` / `starts_with("uint")`, while codegen carries
alloy `DynSolType` and matches on variants. Every scaffold bug found while
reviewing tuple support was a string-matching bug in this half.
Resolve each event input to `DynSolType` once at the ABI boundary and carry
the typed value through `InputLeaf`, the schema generator and the mapping
cast. `solidity_to_graphql`/`int_to_graphql` become `graphql_type`, an
exhaustive match on the type; `needs_bytes_array_cast` matches
`Array(Address)` instead of the `"address[]"` string.
Typing the schema side also fixes fixed-size arrays of scalar elements
(`uint256[3]`, `bool[2]`, `bytes32[4]`, ...), which `ends_with("[]")` could
not see and which scaffolded to a non-building scalar field. `address[3]`
still needs the cast and is handled in the next commit.
Scaffolding runs on hand-written ABIs alloy accepts but cannot fully resolve
(a component-less `tuple`), so a fallible resolver falls back to a `Bytes`
field with a warning instead of panicking like codegen's resolver does.
A non-indexed `address[N]` resolves to `FixedArray(Address, N)` and now maps to a `[Bytes!]` schema field, but the mapping left `entity.x = event.params.x` uncast, assigning `Array<Address>` to a `Bytes[]` field and failing the build. Match `FixedArray(Address, _)` alongside `Array(Address)` so the `changetype` covers both. Safe because an indexed address array is already reduced to a `bytes32` hash leaf before it reaches this cast.
Cover every schema-side type-mapping row in one event, and the mapping cast for a fixed-size address array end-to-end. The fixed-size array rows (`address[3]`, `uint256[3]`, `uint8[3]`, `bool[2]`, `string[2]`, `bytes32[4]`) regress-guard the string matcher that could not see `[N]` and scaffolded them to non-building fields.
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 #6693 (which is stacked on #6661) — both should land first.
The scaffold decided GraphQL types by string-matching Solidity type names, in parallel with codegen's already-typed path. This parses the type once at the ABI boundary and carries the resolved
DynSolTypethrough the manifest, schema, and mapping generators, so a schema/codegen disagreement is unrepresentable rather than a string the two sides match differently.DynSolTypeonInputLeaf; drop the re-parse insideint_to_graphql.uint256[3]->[BigInt!],bool[2]->[Boolean!]) instead of collapsing to a scalar orBytes. Nested lists still flatten to one dimension, matching graph-node's store.Bytes[]in the mapping, with the indexed guard so an indexed array (a 32-byte hash) is never cast.