Skip to content

Address various gnd issues#6663

Open
lutter wants to merge 6 commits into
masterfrom
lutter/gnd
Open

Address various gnd issues#6663
lutter wants to merge 6 commits into
masterfrom
lutter/gnd

Conversation

@lutter

@lutter lutter commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

This PR addresses the issues noted in graph-tooling

lutter added 6 commits June 30, 2026 09:56
Move preprocess_abi_json (and add_default_event_param_names) out of the
codegen command and into the shared abi module so that other components
can normalize ABIs the same way codegen does. No behavior change for
codegen; this is a prerequisite for making manifest validation parse
ABIs identically to codegen.
load_abi previously returned Option and silently dropped read/parse
errors, so an event handler referencing a malformed ABI would skip
signature validation entirely and codegen would still report success.

Return Result<Option<JsonAbi>, ManifestValidationError> instead:
- missing file -> Ok(None) (reported by file-existence validation)
- present but unparseable -> Err(InvalidFile), surfaced to the user
- otherwise Ok(Some(abi))

The ABI is now preprocessed via abi::preprocess_abi_json so validation
parses exactly what codegen parses, avoiding spurious mismatches.
'gnd add' wrote the ABI, mapping stub, manifest entry and networks.json
for the new data source but never updated schema.graphql, so the
generated subgraph referenced entity types that did not exist and failed
to compile.

Add add_schema_entities, which appends a GraphQL entity type per event
(reusing the new scaffold::generate_event_entities helper). Entity names
already present in the schema are skipped with a notice, so re-running
'add' or adding a contract that shares event names never produces
duplicate type definitions.
The contract-address validator hardcoded Ethereum's 0x + 40-hex format,
so 'gnd init --protocol near' rejected every valid NEAR named account
(e.g. wnear.flux-dev).

Add protocol-aware validate_contract_address: Ethereum keeps the hex
check, NEAR uses the account-id rules (length 2..=64 and NEAR's naming
regex), and other protocols are checked only for non-emptiness. Wire it
into both the non-interactive init_from_contract path and the
interactive contract-address prompt.
load_manifest parsed manifests with graph-node's Ethereum-typed
UnresolvedSubgraphManifest, whose deserializer rejects 'kind: near', so
'gnd codegen' failed outright on NEAR subgraphs.

NEAR (like cosmos/arweave/substreams) has no ABIs, and codegen only needs
the schema path plus data-source/template names and mapping files. Rather
than depend on each chain crate, detect these kinds and route to a
lightweight parse_manifest_loose that extracts just those fields from the
YAML. The Ethereum/subgraph typed path is unchanged. NEAR codegen now
emits schema types only, matching graph-cli.
graph-node no longer supports the cosmos, arweave, or substreams chains, so
gnd should not let users create or process subgraphs for them. Refuse them
both when creating a subgraph (`init --protocol`) and when loading an existing
manifest (codegen/build/validate/test/deploy), pointing users to an older
graph-cli version instead.

The `--protocol` flag still accepts these values (the variants are kept but
hidden from `--help` and completion) so we can emit a helpful message rather
than a generic clap error. NEAR stays supported, and the still-supported
`file/arweave` offchain data source is left untouched.
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