Skip to content

gnd: Carry resolved DynSolType through scaffold generators - #6700

Draft
incrypto32 wants to merge 3 commits into
incrypto32/gnd-scaffold-followupsfrom
incrypto32/gnd-scaffold-dynsoltype
Draft

gnd: Carry resolved DynSolType through scaffold generators#6700
incrypto32 wants to merge 3 commits into
incrypto32/gnd-scaffold-followupsfrom
incrypto32/gnd-scaffold-dynsoltype

Conversation

@incrypto32

Copy link
Copy Markdown
Member

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 DynSolType through the manifest, schema, and mapping generators, so a schema/codegen disagreement is unrepresentable rather than a string the two sides match differently.

  • Resolve event param types with alloy once and carry DynSolType on InputLeaf; drop the re-parse inside int_to_graphql.
  • Fixed-size arrays now map to lists (uint256[3] -> [BigInt!], bool[2] -> [Boolean!]) instead of collapsing to a scalar or Bytes. Nested lists still flatten to one dimension, matching graph-node's store.
  • Cast fixed-size address arrays to Bytes[] in the mapping, with the indexed guard so an indexed array (a 32-byte hash) is never cast.
  • Add a type-mapping test matrix over scalars and arrays.

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.
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