Address various gnd issues#6663
Open
lutter wants to merge 6 commits into
Open
Conversation
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.
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.
This PR addresses the issues noted in graph-tooling