├── packages ├── cli │ ├── tests │ │ ├── cli │ │ │ ├── init │ │ │ │ ├── near │ │ │ │ │ └── .gitkeep │ │ │ │ ├── subgraph │ │ │ │ │ └── .gitkeep │ │ │ │ ├── substreams │ │ │ │ │ └── substreams.spkg │ │ │ │ └── ethereum │ │ │ │ │ └── abis │ │ │ │ │ └── Airdropped.json │ │ │ ├── validation │ │ │ │ ├── abi-not-found │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── schema.graphql │ │ │ │ │ ├── Abi.json │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── indexer-hints │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── schema.graphql │ │ │ │ │ ├── Abi.json │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── invalid-abis │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── InvalidAbi.json │ │ │ │ │ ├── schema.graphql │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── near-is-valid │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── schema.graphql │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── 2d-array-is-valid │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── schema.graphql │ │ │ │ │ ├── Abi.json │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── 3d-array-is-valid │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── Abi.json │ │ │ │ │ ├── schema.graphql │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── entity-field-args │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── schema.graphql │ │ │ │ │ ├── Abi.json │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── event-not-found │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── schema.graphql │ │ │ │ │ ├── Abi.json │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── missing-entity-id │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── schema.graphql │ │ │ │ │ ├── Abi.json │ │ │ │ │ ├── types │ │ │ │ │ │ ├── schema.ts │ │ │ │ │ │ └── ExampleSubgraph │ │ │ │ │ │ │ └── ExampleContract.ts │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── no-network-names │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── schema.graphql │ │ │ │ │ ├── Abi.json │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── topic0-is-valid │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── schema.graphql │ │ │ │ │ ├── Abi.json │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── big-decimal-is-valid │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── schema.graphql │ │ │ │ │ ├── Abi.json │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── block-handler-filters │ │ │ │ │ ├── Abi.json │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── schema.graphql │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── call-function-not-found │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── schema.graphql │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── call-handler-with-tuple │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── schema.graphql │ │ │ │ │ ├── Abi.json │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── duplicate-template-name │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── schema.graphql │ │ │ │ │ └── Abi.json │ │ │ │ ├── example-values-found │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── schema.graphql │ │ │ │ │ ├── Abi.json │ │ │ │ │ ├── subgraph.yaml │ │ │ │ │ └── generated │ │ │ │ │ │ └── ExampleSubgraph │ │ │ │ │ │ └── ExampleContract.ts │ │ │ │ ├── invalid-graphql-schema │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── Abi.json │ │ │ │ │ ├── schema.graphql │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── conflicting-network-names │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── schema.graphql │ │ │ │ │ ├── Abi.json │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── conflicting-protocol-names │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── schema.graphql │ │ │ │ │ ├── Abi.json │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── duplicate-data-source-name │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── schema.graphql │ │ │ │ │ ├── Abi.json │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── invalid-contract-addresses │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── schema.graphql │ │ │ │ │ └── Abi.json │ │ │ │ ├── invalid-data-source-template │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── schema.graphql │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── invalid-entity-field-types │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── Abi.json │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── invalid-fulltext-directive │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── Abi.json │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── nested-template-nice-error │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── schema.graphql │ │ │ │ │ ├── Abi.json │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── require-immutable-argument │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── Abi.json │ │ │ │ │ ├── schema.graphql │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── derived-from-target-type-missing │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── Abi.json │ │ │ │ │ ├── schema.graphql │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── source-without-address-is-valid │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── schema.graphql │ │ │ │ │ ├── Abi.json │ │ │ │ │ ├── subgraph.yaml │ │ │ │ │ └── generated │ │ │ │ │ │ └── ExampleSubgraph │ │ │ │ │ │ └── ExampleContract.ts │ │ │ │ ├── ethereum-contract-without-handlers │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── schema.graphql │ │ │ │ │ ├── Abi.json │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── missing-or-invalid-derived-from-fields.stdout │ │ │ │ ├── missing-or-invalid-derived-from-fields │ │ │ │ │ ├── mapping.ts │ │ │ │ │ ├── Abi.json │ │ │ │ │ ├── subgraph.yaml │ │ │ │ │ └── schema.graphql │ │ │ │ ├── missing-entity-id.stderr │ │ │ │ ├── derived-from-target-type-missing.stderr │ │ │ │ ├── entity-field-args.stderr │ │ │ │ ├── invalid-abis.stderr │ │ │ │ ├── duplicate-template-name.stderr │ │ │ │ ├── invalid-manifest-cannot-infer-protocol │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── duplicate-data-source-name.stderr │ │ │ │ ├── invalid-manifest │ │ │ │ │ └── subgraph.yaml │ │ │ │ ├── require-immutable-argument.stderr │ │ │ │ ├── ethereum-contract-without-handlers.stderr │ │ │ │ ├── invalid-manifest-cannot-infer-protocol.stderr │ │ │ │ ├── nested-template-nice-error.stderr │ │ │ │ ├── call-function-not-found.stderr │ │ │ │ ├── conflicting-network-names.stderr │ │ │ │ ├── conflicting-protocol-names.stderr │ │ │ │ ├── abi-not-found copy.stderr │ │ │ │ ├── event-not-found.stderr │ │ │ │ ├── derived-from-with-interface │ │ │ │ │ ├── schema.graphql │ │ │ │ │ ├── subgraph.yaml │ │ │ │ │ └── mapping.ts │ │ │ │ ├── missing-or-invalid-derived-from-fields.stderr │ │ │ │ ├── invalid-manifest.stderr │ │ │ │ ├── invalid-contract-addresses.stderr │ │ │ │ ├── invalid-data-source-template.stderr │ │ │ │ ├── call-handler-with-tuple.stderr │ │ │ │ ├── source-without-address-is-valid.stderr │ │ │ │ └── invalid-graphql-schema.stderr │ │ │ ├── add │ │ │ │ └── subgraph │ │ │ │ │ ├── networks.json │ │ │ │ │ ├── schema.graphql │ │ │ │ │ ├── src │ │ │ │ │ └── mapping.ts │ │ │ │ │ └── subgraph.yaml │ │ │ ├── globalSetup.ts │ │ │ ├── globalTeardown.ts │ │ │ └── spawn-command.d.ts │ │ └── .latest.json │ ├── bin │ │ ├── run.cmd │ │ └── run.js │ ├── src │ │ ├── index.ts │ │ ├── command-helpers │ │ │ ├── ipfs.ts │ │ │ ├── fs.ts │ │ │ ├── subgraph.ts │ │ │ ├── retry.ts │ │ │ ├── node.ts │ │ │ └── jsonrpc.ts │ │ ├── constants.ts │ │ ├── validation │ │ │ └── index.ts │ │ ├── protocols │ │ │ ├── contract.ts │ │ │ ├── cosmos │ │ │ │ ├── scaffold │ │ │ │ │ └── manifest.ts │ │ │ │ └── subgraph.ts │ │ │ ├── subgraph.ts │ │ │ ├── substreams │ │ │ │ ├── scaffold │ │ │ │ │ └── manifest.ts │ │ │ │ └── subgraph.ts │ │ │ ├── arweave │ │ │ │ ├── scaffold │ │ │ │ │ └── manifest.ts │ │ │ │ └── subgraph.ts │ │ │ ├── near │ │ │ │ ├── scaffold │ │ │ │ │ └── manifest.ts │ │ │ │ └── subgraph.ts │ │ │ ├── subgraph │ │ │ │ ├── scaffold │ │ │ │ │ ├── mapping.ts │ │ │ │ │ └── manifest.ts │ │ │ │ └── subgraph.ts │ │ │ ├── ethereum │ │ │ │ ├── contract.ts │ │ │ │ └── codegen │ │ │ │ │ └── template.ts │ │ │ └── file_template.ts │ │ ├── migrations │ │ │ ├── util │ │ │ │ ├── load-manifest.ts │ │ │ │ └── versions.ts │ │ │ ├── spec_version_0_0_2.ts │ │ │ └── spec_version_0_0_3.ts │ │ ├── fetch.ts │ │ ├── version.ts │ │ ├── debug.ts │ │ ├── scaffold │ │ │ ├── get-git-ignore.ts │ │ │ ├── cosmos.test.ts │ │ │ └── near.test.ts │ │ └── commands │ │ │ └── clean.ts │ ├── tsconfig.build.json │ ├── tsconfig.dev.json │ ├── vitest.config.ts │ └── tsconfig.json └── ts │ ├── .gitignore │ ├── types │ └── tsconfig.base.json │ ├── tsconfig.json │ ├── common │ ├── conversion.ts │ └── json.ts │ ├── test │ ├── entity.ts │ └── bytes.ts │ ├── package.json │ └── chain │ └── starknet.ts ├── website ├── src │ ├── vite-env.d.ts │ ├── lib │ │ ├── constants.ts │ │ ├── graphql.ts │ │ ├── utils.ts │ │ └── ipfs.ts │ ├── routes │ │ ├── __root.tsx │ │ ├── publish.tsx │ │ └── index.lazy.tsx │ ├── components │ │ ├── editor.tsx │ │ ├── ui │ │ │ ├── label.tsx │ │ │ ├── textarea.tsx │ │ │ ├── toaster.tsx │ │ │ └── input.tsx │ │ └── wallet-provider.tsx │ └── main.tsx ├── .env.example ├── postcss.config.js ├── public │ └── the-graph-logomark-light.png ├── tsconfig.node.json ├── .gitignore ├── components.json ├── vite.config.ts ├── .eslintrc.cjs ├── index.html └── tsconfig.json ├── examples ├── near-blocks │ ├── .gitattributes │ ├── tsconfig.json │ ├── schema.graphql │ ├── README.md │ ├── src │ │ └── mapping.ts │ ├── subgraph.yaml │ ├── package.json │ ├── docker-compose.yml │ └── .gitignore ├── ethereum-gravatar │ ├── .gitattributes │ ├── schema.graphql │ ├── README.md │ ├── artifacts │ │ └── contracts │ │ │ ├── Migrations.sol │ │ │ └── Migrations.dbg.json │ │ │ └── Gravity.sol │ │ │ └── GravatarRegistry.dbg.json │ ├── hardhat.config.ts │ ├── migrations │ │ ├── 1_initial_migration.js │ │ ├── 2_deploy_contract.js │ │ └── 3_create_gravatars.js │ ├── contracts │ │ └── Migrations.sol │ ├── src │ │ └── mapping.ts │ ├── subgraph.yaml │ ├── package.json │ └── docker-compose.yml ├── near-receipts │ ├── .gitattributes │ ├── schema.graphql │ ├── README.md │ ├── subgraph.yaml │ ├── package.json │ ├── docker-compose.yml │ └── .gitignore ├── substreams-powered-subgraph │ ├── .gitignore │ ├── rust-toolchain.toml │ ├── schema.graphql │ ├── proto │ │ └── example.proto │ ├── Cargo.toml │ ├── subgraph.yaml │ ├── README.md │ ├── substreams.yaml │ └── package.json ├── cosmos-block-filtering │ ├── config │ │ ├── osmosis.json │ │ └── cosmoshub.json │ ├── schema.graphql │ ├── tsconfig.json │ ├── src │ │ └── mapping.ts │ ├── subgraph.yaml │ ├── subgraph.template.yaml │ ├── docker-compose.yml │ ├── .gitignore │ └── README.md ├── cosmos-validator-delegations │ ├── config │ │ ├── osmosis.json │ │ └── cosmoshub.json │ ├── tsconfig.json │ ├── schema.graphql │ ├── subgraph.yaml │ ├── subgraph.template.yaml │ ├── docker-compose.yml │ ├── .gitignore │ └── src │ │ └── mapping.ts ├── cosmos-validator-rewards │ ├── config │ │ ├── osmosis.json │ │ └── cosmoshub.json │ ├── tsconfig.json │ ├── schema.graphql │ ├── src │ │ └── mapping.ts │ ├── subgraph.yaml │ ├── subgraph.template.yaml │ ├── docker-compose.yml │ └── .gitignore ├── ethereum-basic-event-handlers │ ├── hardhat │ │ ├── hardhat.config.js │ │ ├── package.json │ │ ├── entrypoint.sh │ │ └── Dockerfile │ ├── README.md │ ├── .gitignore │ ├── tsconfig.json │ ├── schema.graphql │ ├── build │ │ ├── schema.graphql │ │ └── subgraph.yaml │ ├── hardhat.config.ts │ ├── scripts │ │ └── deploy.ts │ ├── src │ │ └── mapping.ts │ ├── template-subgraph.yaml │ └── subgraph.yaml ├── cosmos-osmosis-token-swaps │ ├── tsconfig.json │ ├── schema.graphql │ ├── subgraph.yaml │ ├── package.json │ ├── docker-compose.yml │ ├── README.md │ └── .gitignore ├── matic-lens-protocol-posts-subgraph │ ├── tsconfig.json │ ├── networks.json │ ├── schema.graphql │ └── package.json ├── example-subgraph │ ├── dist │ │ ├── ExampleSubgraph │ │ │ └── ExampleSubgraph.wasm │ │ ├── subgraph.yaml │ │ └── schema.graphql │ ├── package.json │ ├── subgraph.yaml │ └── schema.graphql ├── aggregations │ ├── README.md │ ├── package.json │ └── subgraph.yaml └── arweave-blocks-transactions │ ├── README.md │ ├── package.json │ ├── schema.graphql │ └── .gitignore ├── pnpm-workspace.yaml ├── .vscode ├── extensions.json ├── tasks.json ├── settings.json └── launch.json ├── .changeset ├── metal-lights-train.md ├── @graphprotocol_graph-cli-2068-dependencies.md ├── README.md └── config.json ├── .prettierignore ├── .gitmodules ├── .prettierrc.js ├── .github └── ISSUE_TEMPLATE │ └── config.yml ├── resources └── test │ └── docker-compose-standalone-node.yml ├── renovate.json └── LICENSE-MIT /packages/cli/tests/cli/init/near/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/init/subgraph/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/ts/.gitignore: -------------------------------------------------------------------------------- 1 | # build files 2 | *.wasm 3 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/abi-not-found/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/indexer-hints/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-abis/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/near-is-valid/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/2d-array-is-valid/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/3d-array-is-valid/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/entity-field-args/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/event-not-found/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/missing-entity-id/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/no-network-names/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/topic0-is-valid/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/bin/run.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | node "%~dp0\run" %* 4 | -------------------------------------------------------------------------------- /packages/cli/src/index.ts: -------------------------------------------------------------------------------- 1 | export { run } from '@oclif/core'; 2 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/big-decimal-is-valid/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/block-handler-filters/Abi.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/block-handler-filters/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/call-function-not-found/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/call-handler-with-tuple/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/duplicate-template-name/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/example-values-found/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-graphql-schema/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /website/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /examples/near-blocks/.gitattributes: -------------------------------------------------------------------------------- 1 | *.sol linguist-language=Solidity 2 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/conflicting-network-names/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/conflicting-protocol-names/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/duplicate-data-source-name/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-contract-addresses/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-data-source-template/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-entity-field-types/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-fulltext-directive/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/nested-template-nice-error/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/require-immutable-argument/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/ethereum-gravatar/.gitattributes: -------------------------------------------------------------------------------- 1 | *.sol linguist-language=Solidity 2 | -------------------------------------------------------------------------------- /examples/near-receipts/.gitattributes: -------------------------------------------------------------------------------- 1 | *.sol linguist-language=Solidity 2 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/derived-from-target-type-missing/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-abis/InvalidAbi.json: -------------------------------------------------------------------------------- 1 | "Hello" 2 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/source-without-address-is-valid/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/ethereum-contract-without-handlers/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/missing-or-invalid-derived-from-fields.stdout: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/missing-or-invalid-derived-from-fields/mapping.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /website/.env.example: -------------------------------------------------------------------------------- 1 | VITE_WALLETCONNECT_PROJECT_ID= 2 | -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - packages/* 3 | - examples/* 4 | - website 5 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/init/substreams/substreams.spkg: -------------------------------------------------------------------------------- 1 | test file, nothing to see here 2 | -------------------------------------------------------------------------------- /packages/ts/types/tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "assemblyscript/std/assembly" 3 | } 4 | -------------------------------------------------------------------------------- /packages/cli/tests/.latest.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.6.0", 3 | "timestamp": 1732733567707 4 | } 5 | -------------------------------------------------------------------------------- /website/src/lib/constants.ts: -------------------------------------------------------------------------------- 1 | export const CHAINS = ['arbitrum-one', 'arbitrum-sepolia'] as const; 2 | -------------------------------------------------------------------------------- /packages/cli/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": ["./src"] 4 | } 5 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"] 3 | } 4 | -------------------------------------------------------------------------------- /examples/substreams-powered-subgraph/.gitignore: -------------------------------------------------------------------------------- 1 | *.spkg 2 | target/ 3 | .idea 4 | src/pb/ 5 | node_modules/ 6 | -------------------------------------------------------------------------------- /examples/cosmos-block-filtering/config/osmosis.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Osmosis", 3 | "network": "osmosis-1" 4 | } 5 | -------------------------------------------------------------------------------- /website/postcss.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | plugins: { 3 | '@tailwindcss/postcss': {}, 4 | }, 5 | }; 6 | -------------------------------------------------------------------------------- /examples/cosmos-block-filtering/config/cosmoshub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "CosmosHub", 3 | "network": "cosmoshub-4" 4 | } 5 | -------------------------------------------------------------------------------- /examples/cosmos-validator-delegations/config/osmosis.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Osmosis", 3 | "network": "osmosis-1" 4 | } 5 | -------------------------------------------------------------------------------- /examples/cosmos-validator-rewards/config/osmosis.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Osmosis", 3 | "network": "osmosis-1" 4 | } 5 | -------------------------------------------------------------------------------- /examples/ethereum-basic-event-handlers/hardhat/hardhat.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | solidity: '0.8.9', 3 | }; 4 | -------------------------------------------------------------------------------- /examples/cosmos-validator-rewards/config/cosmoshub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "CosmosHub", 3 | "network": "cosmoshub-4" 4 | } 5 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/abi-not-found/schema.graphql: -------------------------------------------------------------------------------- 1 | type MyEntity @entity(immutable: true) { 2 | id: ID! 3 | } 4 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/block-handler-filters/schema.graphql: -------------------------------------------------------------------------------- 1 | type A @entity(immutable: true) { 2 | id: ID! 3 | } 4 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-abis/schema.graphql: -------------------------------------------------------------------------------- 1 | type MyEntity @entity(immutable: true) { 2 | id: ID! 3 | } 4 | -------------------------------------------------------------------------------- /examples/cosmos-validator-delegations/config/cosmoshub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "CosmosHub", 3 | "network": "cosmoshub-4" 4 | } 5 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/event-not-found/schema.graphql: -------------------------------------------------------------------------------- 1 | type MyEntity @entity(immutable: true) { 2 | id: ID! 3 | } 4 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/no-network-names/schema.graphql: -------------------------------------------------------------------------------- 1 | type MyEntity @entity(immutable: true) { 2 | id: ID! 3 | } 4 | -------------------------------------------------------------------------------- /.changeset/metal-lights-train.md: -------------------------------------------------------------------------------- 1 | --- 2 | '@graphprotocol/graph-cli': patch 3 | --- 4 | 5 | Fixed entity id format in generated tests 6 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/call-function-not-found/schema.graphql: -------------------------------------------------------------------------------- 1 | type MyEntity @entity(immutable: true) { 2 | id: ID! 3 | } 4 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/call-handler-with-tuple/schema.graphql: -------------------------------------------------------------------------------- 1 | type MyEntity @entity(immutable: true) { 2 | id: ID! 3 | } 4 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/example-values-found/schema.graphql: -------------------------------------------------------------------------------- 1 | type MyEntity @entity(immutable: true) { 2 | id: ID! 3 | } 4 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/missing-entity-id/schema.graphql: -------------------------------------------------------------------------------- 1 | type MyEntity @entity(immutable: true) { 2 | name: String! 3 | } 4 | -------------------------------------------------------------------------------- /examples/near-blocks/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@graphprotocol/graph-ts/types/tsconfig.base.json", 3 | "include": ["src"] 4 | } 5 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/conflicting-network-names/schema.graphql: -------------------------------------------------------------------------------- 1 | type MyEntity @entity(immutable: true) { 2 | id: ID! 3 | } 4 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/conflicting-protocol-names/schema.graphql: -------------------------------------------------------------------------------- 1 | type MyEntity @entity(immutable: true) { 2 | id: ID! 3 | } 4 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-contract-addresses/schema.graphql: -------------------------------------------------------------------------------- 1 | type MyEntity @entity(immutable: true) { 2 | id: ID! 3 | } 4 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-data-source-template/schema.graphql: -------------------------------------------------------------------------------- 1 | type MyEntity @entity(immutable: true) { 2 | id: ID! 3 | } 4 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/nested-template-nice-error/schema.graphql: -------------------------------------------------------------------------------- 1 | type MyEntity @entity(immutable: true) { 2 | id: ID! 3 | } 4 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/ethereum-contract-without-handlers/schema.graphql: -------------------------------------------------------------------------------- 1 | type MyEntity @entity(immutable: true) { 2 | id: ID! 3 | } 4 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/indexer-hints/schema.graphql: -------------------------------------------------------------------------------- 1 | type MyEntity @entity(immutable: true) { 2 | id: ID! 3 | x: BigDecimal! 4 | } 5 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/source-without-address-is-valid/schema.graphql: -------------------------------------------------------------------------------- 1 | type MyEntity @entity(immutable: true) { 2 | id: ID! 3 | } 4 | -------------------------------------------------------------------------------- /examples/cosmos-block-filtering/schema.graphql: -------------------------------------------------------------------------------- 1 | type Block @entity(immutable: true) { 2 | id: ID! 3 | number: BigInt 4 | timestamp: BigInt 5 | } 6 | -------------------------------------------------------------------------------- /examples/cosmos-block-filtering/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@graphprotocol/graph-ts/types/tsconfig.base.json", 3 | "include": ["src"] 4 | } 5 | -------------------------------------------------------------------------------- /examples/cosmos-validator-rewards/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@graphprotocol/graph-ts/types/tsconfig.base.json", 3 | "include": ["src"] 4 | } 5 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/topic0-is-valid/schema.graphql: -------------------------------------------------------------------------------- 1 | type MyEntity @entity(immutable: true) { 2 | id: ID! 3 | x: BigDecimal! 4 | } 5 | -------------------------------------------------------------------------------- /website/public/the-graph-logomark-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-tooling/HEAD/website/public/the-graph-logomark-light.png -------------------------------------------------------------------------------- /examples/cosmos-osmosis-token-swaps/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@graphprotocol/graph-ts/types/tsconfig.base.json", 3 | "include": ["src"] 4 | } 5 | -------------------------------------------------------------------------------- /examples/cosmos-validator-delegations/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@graphprotocol/graph-ts/types/tsconfig.base.json", 3 | "include": ["src"] 4 | } 5 | -------------------------------------------------------------------------------- /examples/cosmos-validator-rewards/schema.graphql: -------------------------------------------------------------------------------- 1 | type Reward @entity(immutable: true) { 2 | id: ID! 3 | amount: String 4 | validator: String 5 | } 6 | -------------------------------------------------------------------------------- /packages/cli/src/command-helpers/ipfs.ts: -------------------------------------------------------------------------------- 1 | const DEFAULT_IPFS_URL = 'https://api.thegraph.com/ipfs/api/v0' as const; 2 | 3 | export { DEFAULT_IPFS_URL }; 4 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/big-decimal-is-valid/schema.graphql: -------------------------------------------------------------------------------- 1 | type MyEntity @entity(immutable: true) { 2 | id: ID! 3 | x: BigDecimal! 4 | } 5 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/duplicate-template-name/schema.graphql: -------------------------------------------------------------------------------- 1 | type MyEntity @entity(immutable: true) { 2 | id: ID! 3 | x: BigDecimal! 4 | } 5 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/entity-field-args/schema.graphql: -------------------------------------------------------------------------------- 1 | type MyEntity @entity(immutable: true) { 2 | id: ID! 3 | foo(bar: Int!): Int! 4 | } 5 | -------------------------------------------------------------------------------- /examples/substreams-powered-subgraph/rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "1.72" 3 | components = ["rustfmt"] 4 | targets = ["wasm32-unknown-unknown"] 5 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/derived-from-target-type-missing/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent" 5 | } 6 | ] 7 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/duplicate-data-source-name/schema.graphql: -------------------------------------------------------------------------------- 1 | type MyEntity @entity(immutable: true) { 2 | id: ID! 3 | x: BigDecimal! 4 | } 5 | -------------------------------------------------------------------------------- /packages/ts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "assemblyscript/std/assembly", 3 | "include": ["index.ts", "helper-functions.ts", "global/global.ts", "test"] 4 | } 5 | -------------------------------------------------------------------------------- /examples/matic-lens-protocol-posts-subgraph/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@graphprotocol/graph-ts/types/tsconfig.base.json", 3 | "include": ["src", "tests"] 4 | } 5 | -------------------------------------------------------------------------------- /examples/ethereum-gravatar/schema.graphql: -------------------------------------------------------------------------------- 1 | type Gravatar @entity(immutable: false) { 2 | id: ID! 3 | owner: Bytes! 4 | displayName: String! 5 | imageUrl: String! 6 | } 7 | -------------------------------------------------------------------------------- /packages/cli/src/command-helpers/fs.ts: -------------------------------------------------------------------------------- 1 | import path from 'node:path'; 2 | 3 | const displayPath = (p: string) => path.relative(process.cwd(), p); 4 | 5 | export { displayPath }; 6 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/add/subgraph/networks.json: -------------------------------------------------------------------------------- 1 | { 2 | "test": { 3 | "Gravity": { 4 | "address": "0xCfEB869F69431e42cdB54A4F4f105C19C080A601" 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/2d-array-is-valid/schema.graphql: -------------------------------------------------------------------------------- 1 | type MyEntity @entity(immutable: true) { 2 | id: ID! 3 | childTokenURIs: [[String!]!]! # string[][] 4 | } 5 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/abi-not-found/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent", 5 | "inputs": [{ "type": "string" }] 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/indexer-hints/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent", 5 | "inputs": [{ "type": "string" }] 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/2d-array-is-valid/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent", 5 | "inputs": [{ "type": "string" }] 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/3d-array-is-valid/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent", 5 | "inputs": [{ "type": "string" }] 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/3d-array-is-valid/schema.graphql: -------------------------------------------------------------------------------- 1 | type MyEntity @entity(immutable: true) { 2 | id: ID! 3 | childTokenURIs: [[[String!]!]!]! # string[][][] 4 | } 5 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/entity-field-args/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent", 5 | "inputs": [{ "type": "string" }] 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/event-not-found/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent", 5 | "inputs": [{ "type": "string" }] 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/missing-entity-id/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent", 5 | "inputs": [{ "type": "string" }] 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/no-network-names/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent", 5 | "inputs": [{ "type": "string" }] 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/topic0-is-valid/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent", 5 | "inputs": [{ "type": "string" }] 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/big-decimal-is-valid/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent", 5 | "inputs": [{ "type": "string" }] 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/derived-from-target-type-missing/schema.graphql: -------------------------------------------------------------------------------- 1 | type Foo @entity(immutable: true) { 2 | id: ID! 3 | bars: [Bars!]! @derivedFrom(field: "foo") 4 | } 5 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/duplicate-template-name/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent", 5 | "inputs": [{ "type": "string" }] 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/example-values-found/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent", 5 | "inputs": [{ "type": "string" }] 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-graphql-schema/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent", 5 | "inputs": [{ "type": "string" }] 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /website/src/routes/__root.tsx: -------------------------------------------------------------------------------- 1 | import { createRootRoute, Outlet } from '@tanstack/react-router'; 2 | 3 | export const Route = createRootRoute({ 4 | component: () => , 5 | }); 6 | -------------------------------------------------------------------------------- /examples/ethereum-gravatar/README.md: -------------------------------------------------------------------------------- 1 | # Example Ethereum Subgraph 2 | 3 | An example to help you get started with The Graph. For more information see the docs on 4 | https://thegraph.com/docs/. 5 | -------------------------------------------------------------------------------- /examples/example-subgraph/dist/ExampleSubgraph/ExampleSubgraph.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphprotocol/graph-tooling/HEAD/examples/example-subgraph/dist/ExampleSubgraph/ExampleSubgraph.wasm -------------------------------------------------------------------------------- /examples/near-blocks/schema.graphql: -------------------------------------------------------------------------------- 1 | type BlockEvent @entity(immutable: true) { 2 | id: ID! 3 | number: BigInt 4 | hash: Bytes 5 | timestampNanosec: BigInt 6 | gasPrice: BigInt 7 | } 8 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/conflicting-network-names/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent", 5 | "inputs": [{ "type": "string" }] 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/conflicting-protocol-names/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent", 5 | "inputs": [{ "type": "string" }] 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/duplicate-data-source-name/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent", 5 | "inputs": [{ "type": "string" }] 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-contract-addresses/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent", 5 | "inputs": [{ "type": "string" }] 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-entity-field-types/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent", 5 | "inputs": [{ "type": "string" }] 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-fulltext-directive/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent", 5 | "inputs": [{ "type": "string" }] 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/nested-template-nice-error/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent", 5 | "inputs": [{ "type": "string" }] 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/require-immutable-argument/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent", 5 | "inputs": [{ "type": "string" }] 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /packages/cli/tsconfig.dev.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "sourceMap": true, 5 | "inlineSources": true 6 | }, 7 | "include": ["./src"] 8 | } 9 | -------------------------------------------------------------------------------- /examples/ethereum-basic-event-handlers/README.md: -------------------------------------------------------------------------------- 1 | # Example Subgraph 2 | 3 | An example to help you get started with The Graph. For more information see the docs on 4 | https://thegraph.com/docs/. 5 | -------------------------------------------------------------------------------- /examples/ethereum-gravatar/artifacts/contracts/Migrations.sol/Migrations.dbg.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-dbg-1", 3 | "buildInfo": "../../build-info/02f396becc82f8cfeb8abea132c96e29.json" 4 | } 5 | -------------------------------------------------------------------------------- /packages/cli/src/constants.ts: -------------------------------------------------------------------------------- 1 | import { version } from './version.js'; 2 | 3 | export const GRAPH_CLI_SHARED_HEADERS = { 4 | 'User-Agent': `@graphprotocol/graph-cli@${version}` as const, 5 | }; 6 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/ethereum-contract-without-handlers/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent", 5 | "inputs": [{ "type": "string" }] 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/source-without-address-is-valid/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent", 5 | "inputs": [{ "type": "string" }] 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /examples/ethereum-gravatar/artifacts/contracts/Gravity.sol/GravatarRegistry.dbg.json: -------------------------------------------------------------------------------- 1 | { 2 | "_format": "hh-sol-dbg-1", 3 | "buildInfo": "../../build-info/02f396becc82f8cfeb8abea132c96e29.json" 4 | } 5 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/missing-or-invalid-derived-from-fields/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "event", 4 | "name": "ExampleEvent", 5 | "inputs": [{ "type": "string" }] 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /packages/cli/src/validation/index.ts: -------------------------------------------------------------------------------- 1 | export { validateContract, validateContractValues } from './contract.js'; 2 | export { validateManifest } from './manifest.js'; 3 | export { validateSchema } from './schema.js'; 4 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/globalSetup.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | 3 | import { linkCli } from './link'; 4 | 5 | export default async () => { 6 | process.env.GRAPH_CLI_TESTS = '1'; 7 | await linkCli(); 8 | }; 9 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/near-is-valid/schema.graphql: -------------------------------------------------------------------------------- 1 | type MyEntity @entity(immutable: true) { 2 | id: ID! 3 | x: Account! 4 | } 5 | 6 | type Account @entity(immutable: true) { 7 | id: ID! 8 | } 9 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/globalTeardown.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | 3 | import { unlinkCli } from './util'; 4 | 5 | export default async () => { 6 | delete process.env.GRAPH_CLI_TESTS; 7 | await unlinkCli(); 8 | }; 9 | -------------------------------------------------------------------------------- /examples/matic-lens-protocol-posts-subgraph/networks.json: -------------------------------------------------------------------------------- 1 | { 2 | "matic": { 3 | "Contract": { 4 | "address": "0xDb46d1Dc155634FbC732f92E853b10B288AD5a1d", 5 | "startBlock": 28384641 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/missing-entity-id.stderr: -------------------------------------------------------------------------------- 1 | - Load subgraph from subgraph.yaml 2 | ✖ Failed to load subgraph from subgraph.yaml: Error in schema.graphql: 3 | 4 | MyEntity: 5 | - Missing field: id: ID! 6 | -------------------------------------------------------------------------------- /examples/ethereum-basic-event-handlers/.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | coverage 3 | coverage.json 4 | typechain 5 | typechain-types 6 | 7 | # Hardhat files 8 | cache 9 | artifacts/build-info 10 | artifacts/contracts/**/*.dbg.json 11 | -------------------------------------------------------------------------------- /examples/near-blocks/README.md: -------------------------------------------------------------------------------- 1 | # Example NEAR Blocks Subgraph 2 | 3 | An example to help you get started with NEAR indexing with The Graph. For more information see the 4 | docs on https://thegraph.com/docs/supported-networks/near. 5 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-graphql-schema/schema.graphql: -------------------------------------------------------------------------------- 1 | type Something @entity(immutable: true) { 2 | id: ID! 3 | } 4 | 5 | type MyEntity @entity(immutable: true) { 6 | id: ID! 7 | invalidField: [Something]! 8 | } 9 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/derived-from-target-type-missing.stderr: -------------------------------------------------------------------------------- 1 | - Load subgraph from subgraph.yaml 2 | ✖ Failed to load subgraph from subgraph.yaml: Error in schema.graphql: 3 | 4 | Foo: 5 | - Field 'bars': Unknown type 'Bars'. 6 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/entity-field-args.stderr: -------------------------------------------------------------------------------- 1 | - Load subgraph from subgraph.yaml 2 | ✖ Failed to load subgraph from subgraph.yaml: Error in schema.graphql: 3 | 4 | MyEntity: 5 | - Field 'foo': Field arguments are not supported. 6 | -------------------------------------------------------------------------------- /examples/ethereum-basic-event-handlers/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "outDir": "dist", 7 | "esModuleInterop": true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /examples/ethereum-gravatar/hardhat.config.ts: -------------------------------------------------------------------------------- 1 | import { HardhatUserConfig } from 'hardhat/config'; 2 | import '@nomicfoundation/hardhat-toolbox'; 3 | 4 | const config: HardhatUserConfig = { 5 | solidity: '0.4.25', 6 | }; 7 | 8 | export default config; 9 | -------------------------------------------------------------------------------- /examples/ethereum-gravatar/migrations/1_initial_migration.js: -------------------------------------------------------------------------------- 1 | var Migrations = artifacts.require('./Migrations.sol'); 2 | 3 | module.exports = async function () { 4 | const migrations = await Migrations.new(); 5 | Migrations.setAsDeployed(migrations); 6 | }; 7 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-abis.stderr: -------------------------------------------------------------------------------- 1 | - Load subgraph from subgraph.yaml 2 | ✖ Failed to load subgraph from subgraph.yaml: Error in subgraph.yaml: 3 | 4 | Path: dataSources > 0 > mapping > abis > 0 > file 5 | No valid ABI in file: InvalidAbi.json 6 | -------------------------------------------------------------------------------- /.changeset/@graphprotocol_graph-cli-2068-dependencies.md: -------------------------------------------------------------------------------- 1 | --- 2 | "@graphprotocol/graph-cli": patch 3 | --- 4 | dependencies updates: 5 | - Updated dependency [`kubo-rpc-client@^6.0.0` ↗︎](https://www.npmjs.com/package/kubo-rpc-client/v/6.0.0) (from `^5.0.2`, in `dependencies`) 6 | -------------------------------------------------------------------------------- /examples/substreams-powered-subgraph/schema.graphql: -------------------------------------------------------------------------------- 1 | type Contract @entity(immutable: true) { 2 | id: ID! 3 | 4 | "The timestamp when the contract was deployed" 5 | timestamp: String! 6 | 7 | "The block number of the contract deployment" 8 | blockNumber: BigInt! 9 | } 10 | -------------------------------------------------------------------------------- /examples/ethereum-gravatar/migrations/2_deploy_contract.js: -------------------------------------------------------------------------------- 1 | const GravatarRegistry = artifacts.require('./GravatarRegistry.sol'); 2 | 3 | module.exports = async function () { 4 | const gravatarRegistry = await GravatarRegistry.new(); 5 | GravatarRegistry.setAsDeployed(gravatarRegistry); 6 | }; 7 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/duplicate-template-name.stderr: -------------------------------------------------------------------------------- 1 | - Load subgraph from subgraph.yaml 2 | ✖ Failed to load subgraph from subgraph.yaml: Error in subgraph.yaml: 3 | 4 | Path: templates > 1 > name 5 | More than one template named 'ExampleSubgraph', template names must be unique. 6 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-manifest-cannot-infer-protocol/subgraph.yaml: -------------------------------------------------------------------------------- 1 | schema: 2 | file: ./non-existent.grapqhl 3 | dataSources: 4 | - name: 5 5 | abis: 6 | name: Foo 7 | mapping: 8 | - 12 9 | - 13 10 | - 14 11 | templates: 12 | field: foo 13 | -------------------------------------------------------------------------------- /examples/near-receipts/schema.graphql: -------------------------------------------------------------------------------- 1 | type Greeter @entity(immutable: true) { 2 | id: ID! 3 | name: String! 4 | greetings: [Greeting!] @derivedFrom(field: "greeter") 5 | } 6 | 7 | type Greeting @entity(immutable: true) { 8 | id: ID! 9 | greeter: Greeter! 10 | timestamp: BigInt! 11 | } 12 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/duplicate-data-source-name.stderr: -------------------------------------------------------------------------------- 1 | - Load subgraph from subgraph.yaml 2 | ✖ Failed to load subgraph from subgraph.yaml: Error in subgraph.yaml: 3 | 4 | Path: dataSources > 1 > name 5 | More than one data source named 'ExampleSubgraph', data source names must be unique. 6 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-manifest/subgraph.yaml: -------------------------------------------------------------------------------- 1 | schema: 2 | file: ./non-existent.grapqhl 3 | dataSources: 4 | - kind: ethereum/contract 5 | name: 5 6 | abis: 7 | name: Foo 8 | mapping: 9 | - 12 10 | - 13 11 | - 14 12 | templates: 13 | field: foo 14 | -------------------------------------------------------------------------------- /website/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "skipLibCheck": true, 5 | "module": "ESNext", 6 | "moduleResolution": "bundler", 7 | "allowSyntheticDefaultImports": true, 8 | "strict": true 9 | }, 10 | "include": ["vite.config.ts"] 11 | } 12 | -------------------------------------------------------------------------------- /examples/cosmos-osmosis-token-swaps/schema.graphql: -------------------------------------------------------------------------------- 1 | type Token @entity(immutable: true) { 2 | id: ID! 3 | amount: String 4 | denom: String 5 | } 6 | 7 | type TokenSwap @entity(immutable: true) { 8 | id: ID! 9 | sender: String 10 | poolId: String 11 | tokenIn: Token 12 | tokenOut: Token 13 | } 14 | -------------------------------------------------------------------------------- /examples/cosmos-validator-delegations/schema.graphql: -------------------------------------------------------------------------------- 1 | type Delegation @entity(immutable: true) { 2 | id: ID! 3 | delegatorAddress: String 4 | validatorAddress: String 5 | amount: Coin 6 | } 7 | 8 | type Coin @entity(immutable: true) { 9 | id: ID! 10 | denom: String 11 | amount: String 12 | } 13 | -------------------------------------------------------------------------------- /packages/cli/src/protocols/contract.ts: -------------------------------------------------------------------------------- 1 | // TODO: make sure the classes implement this type 2 | export interface ContractCtor { 3 | new (account: string): Contract; 4 | identifierName(): string; 5 | } 6 | 7 | export interface Contract { 8 | validate(): { valid: boolean; error: string | null }; 9 | } 10 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | .changeset 2 | dist 3 | build 4 | generated 5 | packages/cli/tests/cli/init 6 | packages/cli/tests/cli/validation 7 | packages/cli/tests/cli/add 8 | packages/cli/config/TheGraphNetworksRegistry.json 9 | packages/cli/CHANGELOG.md 10 | pnpm-lock.yaml 11 | website/src/graphql-env.d.ts 12 | renovate.json 13 | -------------------------------------------------------------------------------- /examples/matic-lens-protocol-posts-subgraph/schema.graphql: -------------------------------------------------------------------------------- 1 | type PostCreated @entity(immutable: true) { 2 | id: Bytes! 3 | ownerId: BigInt! 4 | contentURI: String! 5 | timestamp: BigInt! 6 | } 7 | 8 | type PostContent @entity(immutable: true) { 9 | id: Bytes! 10 | hash: String! 11 | content: String! 12 | } 13 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/require-immutable-argument.stderr: -------------------------------------------------------------------------------- 1 | - Load subgraph from subgraph.yaml 2 | ✖ Failed to load subgraph from subgraph.yaml: Error in schema.graphql: 3 | 4 | EntityA: 5 | - @entity directive requires `immutable` argument 6 | Hint: Try updating the entity definition with: @entity(immutable: true) 7 | -------------------------------------------------------------------------------- /examples/substreams-powered-subgraph/proto/example.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package example; 4 | 5 | message Contracts { 6 | repeated Contract contracts = 1; 7 | } 8 | 9 | message Contract { 10 | string address = 1; 11 | uint64 blockNumber = 2; 12 | string timestamp = 3; 13 | uint64 ordinal = 4; 14 | } -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/ethereum-contract-without-handlers.stderr: -------------------------------------------------------------------------------- 1 | - Load subgraph from subgraph.yaml 2 | ✖ Failed to load subgraph from subgraph.yaml: Error in subgraph.yaml: 3 | 4 | Path: dataSources > 0 > mapping 5 | Mapping has no blockHandlers, callHandlers or eventHandlers. 6 | At least one such handler must be defined. 7 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/add/subgraph/schema.graphql: -------------------------------------------------------------------------------- 1 | type NewGravatar @entity(immutable: true) { 2 | id: ID! 3 | owner: Bytes! 4 | displayName: String! 5 | imageUrl: String! 6 | } 7 | 8 | type UpdatedGravatar @entity(immutable: true) { 9 | id: ID! 10 | owner: Bytes! 11 | displayName: String! 12 | imageUrl: String! 13 | } 14 | -------------------------------------------------------------------------------- /examples/ethereum-basic-event-handlers/schema.graphql: -------------------------------------------------------------------------------- 1 | type NewGravatar @entity(immutable: false) { 2 | id: ID! 3 | owner: Bytes! 4 | displayName: String! 5 | imageUrl: String! 6 | } 7 | 8 | type UpdatedGravatar @entity(immutable: false) { 9 | id: ID! 10 | owner: Bytes! 11 | displayName: String! 12 | imageUrl: String! 13 | } 14 | -------------------------------------------------------------------------------- /examples/ethereum-basic-event-handlers/build/schema.graphql: -------------------------------------------------------------------------------- 1 | type NewGravatar @entity(immutable: false) { 2 | id: ID! 3 | owner: Bytes! 4 | displayName: String! 5 | imageUrl: String! 6 | } 7 | 8 | type UpdatedGravatar @entity(immutable: false) { 9 | id: ID! 10 | owner: Bytes! 11 | displayName: String! 12 | imageUrl: String! 13 | } 14 | -------------------------------------------------------------------------------- /examples/near-receipts/README.md: -------------------------------------------------------------------------------- 1 | # Example NEAR Receipts Subgraph: Good Morning NEAR 2 | 3 | This subgraph indexes `app.good-morning.near`, which you can interact with at 4 | https://gm-near.surge.sh/ 5 | 6 | An example to help you get started with NEAR indexing with The Graph. For more information see the 7 | docs on https://thegraph.com/docs/supported-networks/near. 8 | -------------------------------------------------------------------------------- /packages/cli/src/protocols/cosmos/scaffold/manifest.ts: -------------------------------------------------------------------------------- 1 | export const source = () => ` 2 | startBlock: 0`; 3 | 4 | export const mapping = () => ` 5 | apiVersion: 0.0.5 6 | language: wasm/assemblyscript 7 | entities: 8 | - ExampleEntity 9 | blockHandlers: 10 | - handler: handleBlock 11 | file: ./src/contract.ts`; 12 | -------------------------------------------------------------------------------- /examples/ethereum-basic-event-handlers/hardhat/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "contracts-docker", 3 | "version": "1.0.0", 4 | "description": "", 5 | "author": "", 6 | "license": "ISC", 7 | "keywords": [], 8 | "scripts": { 9 | "localnode": "hardhat node --hostname 0.0.0.0" 10 | }, 11 | "dependencies": { 12 | "hardhat": "^2.22.1" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-manifest-cannot-infer-protocol.stderr: -------------------------------------------------------------------------------- 1 | - Load subgraph from subgraph.yaml 2 | ✖ Failed to load subgraph from subgraph.yaml: Error in subgraph.yaml: 3 | 4 | Path: / 5 | Unable to determine for which protocol manifest file is built for. Ensure you have at least one 'dataSources' and/or 'templates' elements defined in your subgraph. 6 | -------------------------------------------------------------------------------- /packages/cli/src/protocols/subgraph.ts: -------------------------------------------------------------------------------- 1 | import immutable from 'immutable'; 2 | 3 | export interface SubgraphOptions { 4 | manifest?: any; 5 | resolveFile: (path: string) => string; 6 | protocol?: any; 7 | } 8 | 9 | export interface Subgraph extends SubgraphOptions { 10 | validateManifest(): immutable.List; 11 | handlerTypes(): immutable.List; 12 | } 13 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/spawn-command.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'spawn-command' { 2 | import { spawn, SpawnOptions, ChildProcessByStdio } from 'node:child_process'; 3 | 4 | type SpawnResult = ChildProcessByStdio; 5 | export { SpawnOptions, SpawnResult }; 6 | export default function spawn(command: string, options: SpawnOptions): SpawnResult; 7 | } 8 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "examples/subgraph-composition-example"] 2 | path = examples/subgraph-composition-example 3 | url = https://github.com/isum/subgraph-composition-example.git 4 | [submodule "examples/subgraph-composition-sample-subgraph"] 5 | path = examples/subgraph-composition-sample-subgraph 6 | url = https://github.com/incrypto32/subgraph-composition-sample-subgraph.git 7 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/nested-template-nice-error.stderr: -------------------------------------------------------------------------------- 1 | - Load subgraph from subgraph.yaml 2 | ✖ Failed to load subgraph from subgraph.yaml: Error in subgraph.yaml: 3 | 4 | Path: dataSources > 0 > mapping 5 | The way to declare data source templates has changed, please move the templates from inside data sources to a `templates:` field at the top level of the manifest. 6 | -------------------------------------------------------------------------------- /packages/cli/src/protocols/substreams/scaffold/manifest.ts: -------------------------------------------------------------------------------- 1 | export const source = ({ spkgPath, spkgModule }: { spkgPath?: string; spkgModule?: string }) => ` 2 | package: 3 | moduleName: ${spkgModule || 'graph_out'} 4 | file: ${spkgPath || 'substreams.spkg'}`; 5 | 6 | export const mapping = () => ` 7 | apiVersion: 0.0.5 8 | kind: substreams/graph-entities`; 9 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | import prettierConfig from '@theguild/prettier-config'; 2 | 3 | export default { 4 | ...prettierConfig, 5 | overrides: [ 6 | ...(prettierConfig.overrides || []), 7 | { 8 | files: '*.md{,x}', 9 | options: { 10 | semi: false, 11 | trailingComma: 'none', 12 | proseWrap: 'preserve', 13 | }, 14 | }, 15 | ], 16 | }; 17 | -------------------------------------------------------------------------------- /packages/cli/src/migrations/util/load-manifest.ts: -------------------------------------------------------------------------------- 1 | import path from 'node:path'; 2 | import fs from 'fs-extra'; 3 | import yaml from 'js-yaml'; 4 | 5 | export async function loadManifest(manifestFile: string) { 6 | if (manifestFile.match(/.js$/)) { 7 | return await import(path.resolve(manifestFile)); 8 | } 9 | return yaml.load(await fs.readFile(manifestFile, 'utf-8')); 10 | } 11 | -------------------------------------------------------------------------------- /packages/cli/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config'; 2 | 3 | export default defineConfig({ 4 | test: { 5 | env: { 6 | // node v21 has warnings about the deprecation of punycode which can break test snapshots 7 | NODE_NO_WARNINGS: '1', 8 | }, 9 | hookTimeout: 20_000, 10 | globalSetup: './tests/cli/globalSetup.ts', 11 | }, 12 | }); 13 | -------------------------------------------------------------------------------- /examples/ethereum-basic-event-handlers/hardhat.config.ts: -------------------------------------------------------------------------------- 1 | import { HardhatUserConfig } from 'hardhat/config'; 2 | import '@nomicfoundation/hardhat-toolbox'; 3 | 4 | const config: HardhatUserConfig = { 5 | solidity: '0.4.25', 6 | defaultNetwork: 'test', 7 | networks: { 8 | test: { 9 | url: 'http://localhost:8545', 10 | }, 11 | }, 12 | }; 13 | 14 | export default config; 15 | -------------------------------------------------------------------------------- /examples/ethereum-basic-event-handlers/hardhat/entrypoint.sh: -------------------------------------------------------------------------------- 1 | # Adapted from https://github.com/codingwithmanny/hardhat-docker 2 | 3 | #!/bin/sh 4 | 5 | # Change to the correct directory 6 | cd /usr/src/app 7 | 8 | # Run hardhat 9 | pnpm localnode 10 | 11 | # Keep node alive 12 | set -e 13 | if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then 14 | set -- node "$@" 15 | fi 16 | exec "$@" 17 | -------------------------------------------------------------------------------- /website/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | 26 | /src/routeTree.gen.ts 27 | -------------------------------------------------------------------------------- /website/components.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://ui.shadcn.com/schema.json", 3 | "style": "new-york", 4 | "rsc": false, 5 | "tsx": true, 6 | "tailwind": { 7 | "config": "tailwind.config.js", 8 | "css": "src/global.css", 9 | "baseColor": "slate", 10 | "cssVariables": true, 11 | "prefix": "" 12 | }, 13 | "aliases": { 14 | "components": "@/components", 15 | "utils": "@/lib/utils" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /website/src/routes/publish.tsx: -------------------------------------------------------------------------------- 1 | import { z } from 'zod'; 2 | import { createFileRoute } from '@tanstack/react-router'; 3 | 4 | export const Route = createFileRoute('/publish')({ 5 | validateSearch: z.object({ 6 | subgraphId: z.string().optional(), 7 | // Transforming string to enum here doesn't actually work 8 | network: z.string().optional(), 9 | id: z.string().optional(), 10 | apiKey: z.string().optional(), 11 | }), 12 | }); 13 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/call-function-not-found.stderr: -------------------------------------------------------------------------------- 1 | - Load subgraph from subgraph.yaml 2 | ✖ Failed to load subgraph from subgraph.yaml: Error in subgraph.yaml: 3 | 4 | Path: dataSources > 0 > callHandlers > 0 5 | Call function with signature 'doSomething(uint256)' not present in ABI 'ExampleContract'. 6 | Available call functions: 7 | - () 8 | - owner() 9 | - transferOwnership(address) 10 | - upgrade(address,bytes) 11 | -------------------------------------------------------------------------------- /examples/ethereum-basic-event-handlers/hardhat/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:20-alpine 2 | 3 | COPY . /usr/src/app 4 | 5 | WORKDIR /usr/src/app 6 | 7 | RUN apk add git 8 | 9 | RUN apk add --update python3 make g++ && rm -rf /var/cache/apk/* 10 | 11 | RUN corepack enable 12 | 13 | RUN corepack prepare pnpm@9.10.0 --activate 14 | 15 | RUN pnpm install 16 | 17 | COPY $PWD/entrypoint.sh /usr/local/bin 18 | 19 | ENTRYPOINT ["/bin/sh", "/usr/local/bin/entrypoint.sh"] 20 | -------------------------------------------------------------------------------- /examples/substreams-powered-subgraph/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "substreams-ethereum-quickstart" 3 | version = "1.0.0" 4 | edition = "2021" 5 | 6 | [lib] 7 | name = "substreams" 8 | crate-type = ["cdylib"] 9 | 10 | [dependencies] 11 | substreams = "0.5" 12 | substreams-ethereum = "0.9" 13 | substreams-entity-change = "1.3" 14 | prost = "0.11" 15 | prost-types = "0.11" 16 | base64 = "0.13" 17 | 18 | [profile.release] 19 | lto = true 20 | opt-level = 's' 21 | strip = "debuginfo" 22 | -------------------------------------------------------------------------------- /packages/cli/src/protocols/arweave/scaffold/manifest.ts: -------------------------------------------------------------------------------- 1 | export const source = ({ contract }: { contract: string }) => ` 2 | owner: '${contract}'`; 3 | 4 | export const mapping = () => ` 5 | apiVersion: 0.0.5 6 | language: wasm/assemblyscript 7 | entities: 8 | - Block 9 | - Transaction 10 | blockHandlers: 11 | - handler: handleBlock 12 | transactionHandlers: 13 | - handler: handleTx 14 | file: ./src/mapping.ts`; 15 | -------------------------------------------------------------------------------- /packages/cli/bin/run.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import process from 'node:process'; 3 | import semver from 'semver'; 4 | import { execute } from '@oclif/core'; 5 | import { nodeVersion } from '../dist/version.js'; 6 | 7 | if (!semver.satisfies(process.version, nodeVersion)) { 8 | process.stderr.write( 9 | `Node.js version ${nodeVersion} is required. Current version: ${process.version}\n`, 10 | ); 11 | process.exit(1); 12 | } 13 | 14 | await execute({ dir: import.meta.url }); 15 | -------------------------------------------------------------------------------- /packages/cli/src/fetch.ts: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line no-restricted-imports 2 | import { fetch } from '@whatwg-node/fetch'; 3 | import { GRAPH_CLI_SHARED_HEADERS } from './constants.js'; 4 | 5 | export default function fetchWrapper( 6 | input: Parameters[0], 7 | init?: Parameters[1], 8 | ) { 9 | return fetch(input, { 10 | ...init, 11 | headers: { 12 | ...init?.headers, 13 | ...GRAPH_CLI_SHARED_HEADERS, 14 | }, 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /website/vite.config.ts: -------------------------------------------------------------------------------- 1 | import path from 'node:path'; 2 | import { defineConfig } from 'vite'; 3 | import { nodePolyfills } from 'vite-plugin-node-polyfills'; 4 | import { TanStackRouterVite } from '@tanstack/router-vite-plugin'; 5 | import react from '@vitejs/plugin-react'; 6 | 7 | export default defineConfig({ 8 | plugins: [react(), nodePolyfills(), TanStackRouterVite()], 9 | resolve: { 10 | alias: { 11 | '@': path.resolve(__dirname, './src'), 12 | }, 13 | }, 14 | }); 15 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build:dev", 6 | "type": "shell", 7 | "command": "pnpm", 8 | "args": ["--filter=@graphprotocol/graph-cli", "build:dev"], 9 | "group": { 10 | "kind": "build", 11 | "isDefault": true 12 | }, 13 | "presentation": { 14 | "reveal": "silent", 15 | "panel": "shared" 16 | }, 17 | "problemMatcher": "$tsc" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "yaml.schemas": { 3 | "https://json.schemastore.org/github-issue-config.json": ".github/ISSUE_TEMPLATE/config.yml", 4 | "https://json.schemastore.org/github-workflow.json": ".github/workflows/**/*.yml" 5 | }, 6 | "eslint.format.enable": true, 7 | "editor.formatOnSave": true, 8 | "editor.defaultFormatter": "esbenp.prettier-vscode", 9 | "typescript.tsdk": "website/node_modules/typescript/lib", 10 | "typescript.enablePromptUseWorkspaceTsdk": true 11 | } 12 | -------------------------------------------------------------------------------- /examples/aggregations/README.md: -------------------------------------------------------------------------------- 1 | This subgraph demonstrates aggregations by aggregating over some easily predictable values, namely 2 | the block numbers of the underlying chain. It's of little value beyond that. 3 | 4 | The [schema](./schema.graphql), the [subgraph manifest](./subgraph.yaml) and the 5 | [mappings](./src/mappings/blocks.ts) have comments that explain how to write your own aggregations. 6 | 7 | The script `check-data.sh` can be used to check that the aggregations were performed correctly. 8 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Feature Request 4 | url: https://github.com/graphprotocol/graph-tooling/discussions/new?category=ideas 5 | about: Have an idea for a new feature? Please share it with us here. 6 | - name: Have a question? 7 | url: https://discord.gg/vtvv7FP 8 | about: 9 | Not sure about something? need help from the community? have a question to our team? please 10 | ask and answer questions here. 11 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/conflicting-network-names.stderr: -------------------------------------------------------------------------------- 1 | - Load subgraph from subgraph.yaml 2 | ✖ Failed to load subgraph from subgraph.yaml: Error in subgraph.yaml: 3 | 4 | Path: / 5 | Conflicting networks used in data sources and templates: 6 | Data sources and templates using 'mainnet': 7 | - ExampleSubgraph 8 | Data sources and templates having no network set: 9 | - ExampleTemplate 10 | Recommendation: Make all data sources and templates use the same network name. 11 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/conflicting-protocol-names.stderr: -------------------------------------------------------------------------------- 1 | - Load subgraph from subgraph.yaml 2 | ✖ Failed to load subgraph from subgraph.yaml: Error in subgraph.yaml: 3 | 4 | Path: / 5 | Conflicting protocol kinds used in data sources and templates: 6 | Data sources and templates using 'ethereum': 7 | - ExampleSubgraph 8 | Data sources and templates using 'near': 9 | - ExampleTemplate 10 | Recommendation: Make all data sources and templates use the same protocol kind. 11 | -------------------------------------------------------------------------------- /examples/cosmos-block-filtering/src/mapping.ts: -------------------------------------------------------------------------------- 1 | import { BigInt, cosmos } from '@graphprotocol/graph-ts'; 2 | import { Block } from '../generated/schema'; 3 | 4 | export function handleBlock(bl: cosmos.Block): void { 5 | const hash = bl.header.hash.toHexString(); 6 | const height = BigInt.fromString(bl.header.height.toString()); 7 | 8 | const block = new Block(hash); 9 | 10 | block.number = height; 11 | block.timestamp = BigInt.fromString(bl.header.time.seconds.toString()); 12 | 13 | block.save(); 14 | } 15 | -------------------------------------------------------------------------------- /packages/cli/src/protocols/near/scaffold/manifest.ts: -------------------------------------------------------------------------------- 1 | import { strings } from 'gluegun'; 2 | 3 | export const source = ({ contract }: { contract: string }) => ` 4 | account: '${contract}'`; 5 | 6 | export const mapping = ({ contractName }: { contractName: string }) => ` 7 | apiVersion: 0.0.5 8 | language: wasm/assemblyscript 9 | entities: 10 | - ExampleEntity 11 | receiptHandlers: 12 | - handler: handleReceipt 13 | file: ./src/${strings.kebabCase(contractName)}.ts`; 14 | -------------------------------------------------------------------------------- /packages/ts/common/conversion.ts: -------------------------------------------------------------------------------- 1 | import './eager-offset'; 2 | import { Bytes } from './collections'; 3 | 4 | /** Host type conversion interface */ 5 | export declare namespace typeConversion { 6 | function bytesToString(bytes: Uint8Array): string; 7 | function bytesToHex(bytes: Uint8Array): string; 8 | function bigIntToString(bigInt: Uint8Array): string; 9 | function bigIntToHex(bigInt: Uint8Array): string; 10 | function stringToH160(s: string): Bytes; 11 | function bytesToBase58(n: Uint8Array): string; 12 | } 13 | -------------------------------------------------------------------------------- /packages/cli/src/command-helpers/subgraph.ts: -------------------------------------------------------------------------------- 1 | export const getSubgraphBasename = (name: string) => { 2 | const segments = name.split('/', 2); 3 | return segments[segments.length - 1]; 4 | }; 5 | 6 | export const formatSubgraphName = (slug: string) => { 7 | return slug 8 | .toLowerCase() 9 | .replace(/\s+/g, '-') 10 | .replace(/[^a-z0-9_-]/g, ''); 11 | }; 12 | 13 | export const formatContractName = (contractName: string) => { 14 | return contractName.replace(/[\s.]+/g, '_').replace(/[^a-zA-Z0-9_-]/g, ''); 15 | }; 16 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/abi-not-found copy.stderr: -------------------------------------------------------------------------------- 1 | - Load subgraph from subgraph.yaml 2 | ✖ Failed to load subgraph from subgraph.yaml: Error in subgraph.yaml: 3 | 4 | Path: dataSources > 0 > source > abi 5 | ABI name 'NonExistentAbi' not found in mapping > abis. 6 | Available ABIs: 7 | - FirstAbi 8 | - SecondAbi 9 | 10 | Path: templates > 0 > eventHandlers > 0 11 | Event with signature 'ExampleEvent(string,uint256)' not present in ABI 'ExampleContract'. 12 | Available events: 13 | - ExampleEvent(string) 14 | -------------------------------------------------------------------------------- /examples/near-blocks/src/mapping.ts: -------------------------------------------------------------------------------- 1 | import { BigInt, near } from '@graphprotocol/graph-ts'; 2 | import { BlockEvent } from '../generated/schema'; 3 | 4 | export function handleBlock(block: near.Block): void { 5 | const header = block.header; 6 | let event = new BlockEvent(header.hash.toHexString()); 7 | event.number = BigInt.fromI32(header.height as i32); 8 | event.hash = header.hash; 9 | event.timestampNanosec = BigInt.fromU64(header.timestampNanosec); 10 | event.gasPrice = header.gasPrice; 11 | 12 | event.save(); 13 | } 14 | -------------------------------------------------------------------------------- /.changeset/README.md: -------------------------------------------------------------------------------- 1 | # Changesets 2 | 3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works 4 | with multi-package repos, or single-package repos to help you version and publish your code. You can 5 | find the full documentation for it [in our repository](https://github.com/changesets/changesets) 6 | 7 | We have a quick list of common questions to get you started engaging with this project in 8 | [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) 9 | -------------------------------------------------------------------------------- /examples/substreams-powered-subgraph/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.4 2 | description: Ethereum Contract Tracking Subgraph (powered by Substreams) 3 | repository: https://github.com/graphprotocol/graph-tooling 4 | schema: 5 | file: schema.graphql 6 | dataSources: 7 | - kind: substreams 8 | name: substream_test 9 | network: mainnet 10 | source: 11 | package: 12 | moduleName: graph_out 13 | file: substreams-test-v1.0.1.spkg 14 | mapping: 15 | kind: substreams/graph-entities 16 | apiVersion: 0.0.5 17 | -------------------------------------------------------------------------------- /packages/cli/src/protocols/subgraph/scaffold/mapping.ts: -------------------------------------------------------------------------------- 1 | export const generatePlaceholderHandlers = ({ 2 | entities, 3 | contract, 4 | }: { 5 | entities: string[]; 6 | contract: string; 7 | }) => ` 8 | import { ExampleEntity } from '../generated/schema' 9 | import {${entities.join(', ')}} from '../generated/subgraph-${contract}' 10 | 11 | ${entities 12 | .map( 13 | entityName => ` 14 | export function handle${entityName}(entity: ${entityName}): void { 15 | // Empty handler for ${entityName} 16 | }`, 17 | ) 18 | .join('\n')} 19 | `; 20 | -------------------------------------------------------------------------------- /packages/cli/src/version.ts: -------------------------------------------------------------------------------- 1 | import fs from 'node:fs'; 2 | import path from 'node:path'; 3 | import { fileURLToPath } from 'node:url'; 4 | 5 | const packageJson = JSON.parse( 6 | fs 7 | .readFileSync( 8 | // works even when bundled/built because the path to package.json is the same 9 | path.join(fileURLToPath(import.meta.url), '..', '..', 'package.json'), 10 | ) 11 | .toString(), 12 | ); 13 | 14 | export const version = packageJson.version as string; 15 | export const nodeVersion = (packageJson.engines?.node ?? '') as string; 16 | -------------------------------------------------------------------------------- /packages/ts/test/entity.ts: -------------------------------------------------------------------------------- 1 | import { BigDecimal, BigInt, Bytes, Entity } from './temp_lib/index'; 2 | 3 | export function testEntity(): void { 4 | const entity = new Entity(); 5 | 6 | entity.setBytes('x', new Bytes(1)); 7 | assert(entity.getBytes('x') == new Bytes(1)); 8 | 9 | entity.setBoolean('x', true); 10 | assert(entity.getBoolean('x') == true); 11 | 12 | // entity.setBigDecimal('x', new BigDecimal(BigInt.fromI32(2))); 13 | // TS2322: `getBigDecimal` doesn't return a nullable 14 | // assert(entity.getBigDecimal('x') !== null); 15 | } 16 | -------------------------------------------------------------------------------- /examples/cosmos-block-filtering/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.5 2 | description: Block Filtering Example 3 | repository: https://github.com/graphprotocol/graph-toolings 4 | schema: 5 | file: ./schema.graphql 6 | dataSources: 7 | - kind: cosmos 8 | name: CosmosHub 9 | network: cosmoshub-4 10 | source: 11 | startBlock: 0 12 | mapping: 13 | apiVersion: 0.0.7 14 | language: wasm/assemblyscript 15 | entities: 16 | - Block 17 | blockHandlers: 18 | - handler: handleBlock 19 | file: ./src/mapping.ts 20 | -------------------------------------------------------------------------------- /examples/cosmos-validator-rewards/src/mapping.ts: -------------------------------------------------------------------------------- 1 | import { cosmos } from '@graphprotocol/graph-ts'; 2 | import { Reward } from '../generated/schema'; 3 | 4 | export function handleReward(data: cosmos.EventData): void { 5 | const height = data.block.header.height; 6 | 7 | const amount = data.event.getAttributeValue('amount'); 8 | const validator = data.event.getAttributeValue('validator'); 9 | 10 | let reward = new Reward(`${height}-${validator}`); 11 | 12 | reward.amount = amount; 13 | reward.validator = validator; 14 | 15 | reward.save(); 16 | } 17 | -------------------------------------------------------------------------------- /examples/ethereum-basic-event-handlers/scripts/deploy.ts: -------------------------------------------------------------------------------- 1 | import { ethers } from 'hardhat'; 2 | 3 | async function main() { 4 | const Gravity = await ethers.getContractFactory('GravatarRegistry'); 5 | const gravity = await Gravity.deploy(); 6 | 7 | await gravity.deployed(); 8 | 9 | console.log(`Gravity.sol deployed to ${gravity.address}`); 10 | } 11 | 12 | // We recommend this pattern to be able to use async/await everywhere 13 | // and properly handle errors. 14 | main().catch(error => { 15 | console.error(error); 16 | process.exitCode = 1; 17 | }); 18 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/event-not-found.stderr: -------------------------------------------------------------------------------- 1 | - Load subgraph from subgraph.yaml 2 | ✖ Failed to load subgraph from subgraph.yaml: Error in subgraph.yaml: 3 | 4 | Path: dataSources > 0 > eventHandlers > 0 5 | Event with signature 'ExampleEvent(string,uint256)' not present in ABI 'ExampleContract'. 6 | Available events: 7 | - ExampleEvent(string) 8 | 9 | Path: templates > 0 > eventHandlers > 0 10 | Event with signature 'ExampleEvent(string,uint256)' not present in ABI 'ExampleContract'. 11 | Available events: 12 | - ExampleEvent(string) 13 | -------------------------------------------------------------------------------- /resources/test/docker-compose-standalone-node.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | ethereum: 4 | image: trufflesuite/ganache-cli:latest 5 | ports: 6 | - '18545:8545' 7 | - '18546:8546' 8 | command: -d -l 100000000000 -g 1 --noVMErrorsOnRPCResponse 9 | ipfs: 10 | image: ipfs/go-ipfs:v0.4.23 11 | ports: 12 | - '15001:5001' 13 | postgres: 14 | image: postgres 15 | ports: 16 | - '15432:5432' 17 | environment: 18 | POSTGRES_USER: graph 19 | POSTGRES_PASSWORD: let-me-in 20 | POSTGRES_DB: graph 21 | -------------------------------------------------------------------------------- /examples/near-blocks/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.4 2 | description: NEAR Blocks 3 | repository: https://github.com/graphprotocol/graph-toolings/tree/main/near/blocks-example 4 | schema: 5 | file: ./schema.graphql 6 | dataSources: 7 | - kind: near 8 | name: blocks 9 | network: near-mainnet 10 | source: 11 | startBlock: 0 12 | mapping: 13 | apiVersion: 0.0.6 14 | language: wasm/assemblyscript 15 | file: ./src/mapping.ts 16 | entities: 17 | - BlockEvent 18 | blockHandlers: 19 | - handler: handleBlock 20 | -------------------------------------------------------------------------------- /.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@2.2.0/schema.json", 3 | "changelog": [ 4 | "@changesets/changelog-github", 5 | { "repo": "graphprotocol/graph-cli" } 6 | ], 7 | "commit": false, 8 | "fixed": [], 9 | "linked": [], 10 | "access": "public", 11 | "baseBranch": "main", 12 | "updateInternalDependencies": "patch", 13 | "ignore": [ 14 | "example-*", 15 | "website" 16 | ], 17 | "snapshot": { 18 | "useCalculatedVersion": true, 19 | "prereleaseTemplate": "{tag}-{datetime}-{commit}" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/cosmos-block-filtering/subgraph.template.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.5 2 | description: Block Filtering Example 3 | repository: https://github.com/graphprotocol/graph-toolings 4 | schema: 5 | file: ./schema.graphql 6 | dataSources: 7 | - kind: cosmos 8 | name: { { name } } 9 | network: { { network } } 10 | source: 11 | startBlock: 0 12 | mapping: 13 | apiVersion: 0.0.7 14 | language: wasm/assemblyscript 15 | entities: 16 | - Block 17 | blockHandlers: 18 | - handler: handleBlock 19 | file: ./src/mapping.ts 20 | -------------------------------------------------------------------------------- /examples/cosmos-validator-delegations/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.5 2 | description: Validator Delegations Example 3 | repository: https://github.com/graphprotocol/graph-toolings 4 | schema: 5 | file: ./schema.graphql 6 | dataSources: 7 | - kind: cosmos 8 | name: CosmosHub 9 | network: cosmoshub-4 10 | source: 11 | startBlock: 0 12 | mapping: 13 | apiVersion: 0.0.7 14 | language: wasm/assemblyscript 15 | entities: 16 | - Delegation 17 | - Coin 18 | transactionHandlers: 19 | - handler: handleTx 20 | file: ./src/mapping.ts 21 | -------------------------------------------------------------------------------- /examples/cosmos-validator-rewards/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.5 2 | description: Validator Rewards Example 3 | repository: https://github.com/graphprotocol/graph-toolings 4 | schema: 5 | file: ./schema.graphql 6 | dataSources: 7 | - kind: cosmos 8 | name: CosmosHub 9 | network: cosmoshub-4 10 | source: 11 | startBlock: 0 12 | mapping: 13 | apiVersion: 0.0.7 14 | language: wasm/assemblyscript 15 | entities: 16 | - Reward 17 | eventHandlers: 18 | - event: rewards 19 | handler: handleReward 20 | file: ./src/mapping.ts 21 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/call-handler-with-tuple/Abi.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "constant": false, 4 | "inputs": [ 5 | { "name": "", "type": "uint256" }, 6 | { 7 | "type": "tuple", 8 | "components": [ 9 | { "type": "bytes32" }, 10 | { "type": "bytes32" }, 11 | { "type": "uint256" } 12 | ] 13 | }, 14 | { 15 | "type": "bool" 16 | } 17 | ], 18 | "name": "doSomething", 19 | "outputs": [], 20 | "payable": false, 21 | "stateMutability": "nonpayable", 22 | "type": "function" 23 | } 24 | ] 25 | -------------------------------------------------------------------------------- /website/src/routes/index.lazy.tsx: -------------------------------------------------------------------------------- 1 | import { createLazyFileRoute } from '@tanstack/react-router'; 2 | 3 | export const Route = createLazyFileRoute('/')({ 4 | component: Page, 5 | }); 6 | 7 | export function Page() { 8 | return ( 9 |
10 | 11 | The Graph logo 16 | 17 |
18 | ); 19 | } 20 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/ethereum-contract-without-handlers/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.1 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: ethereum/contract 6 | name: ExampleSubgraph 7 | source: 8 | address: "22843e74c59580b3eaf6c233fa67d8b7c561a835" 9 | abi: ExampleContract 10 | mapping: 11 | kind: ethereum/events 12 | apiVersion: 0.0.5 13 | language: wasm/assemblyscript 14 | file: ./mapping.ts 15 | entities: 16 | - ExampleEntity 17 | abis: 18 | - name: ExampleContract 19 | file: ./Abi.json 20 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/require-immutable-argument/schema.graphql: -------------------------------------------------------------------------------- 1 | # Entity is not valid because it is missing the immutable argument; 2 | type EntityA @entity { 3 | id: ID! 4 | } 5 | 6 | # Entity is valid because it has the immutable argument; 7 | type EntityB @entity(immutable: true) { 8 | id: ID! 9 | } 10 | 11 | # Entity is valid because it has the immutable argument; 12 | type EntityC @entity(immutable: false) { 13 | id: ID! 14 | } 15 | 16 | # Entity is valid because the timeseries argument ensures immutability; 17 | type EntityD @entity(timeseries: true) { 18 | id: ID! 19 | } 20 | -------------------------------------------------------------------------------- /examples/cosmos-validator-rewards/subgraph.template.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.5 2 | description: Validator Rewards Example 3 | repository: https://github.com/graphprotocol/graph-toolings 4 | schema: 5 | file: ./schema.graphql 6 | dataSources: 7 | - kind: cosmos 8 | name: { { name } } 9 | network: { { network } } 10 | source: 11 | startBlock: 0 12 | mapping: 13 | apiVersion: 0.0.7 14 | language: wasm/assemblyscript 15 | entities: 16 | - Reward 17 | eventHandlers: 18 | - event: rewards 19 | handler: handleReward 20 | file: ./src/mapping.ts 21 | -------------------------------------------------------------------------------- /examples/ethereum-gravatar/migrations/3_create_gravatars.js: -------------------------------------------------------------------------------- 1 | const GravatarRegistry = artifacts.require('./GravatarRegistry.sol'); 2 | 3 | module.exports = async function () { 4 | const registry = await GravatarRegistry.deployed(); 5 | 6 | console.log('Account address:', registry.address); 7 | 8 | let accounts = await web3.eth.getAccounts(); 9 | await registry.createGravatar('Carl', 'https://thegraph.com/img/team/team_04.png', { 10 | from: accounts[0], 11 | }); 12 | await registry.createGravatar('Lucas', 'https://thegraph.com/img/team/bw_Lucas.jpg', { 13 | from: accounts[1], 14 | }); 15 | }; 16 | -------------------------------------------------------------------------------- /examples/cosmos-validator-delegations/subgraph.template.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.5 2 | description: Validator Delegations Example 3 | repository: https://github.com/graphprotocol/graph-toolings 4 | schema: 5 | file: ./schema.graphql 6 | dataSources: 7 | - kind: cosmos 8 | name: { { name } } 9 | network: { { network } } 10 | source: 11 | startBlock: 0 12 | mapping: 13 | apiVersion: 0.0.7 14 | language: wasm/assemblyscript 15 | entities: 16 | - Delegation 17 | - Coin 18 | transactionHandlers: 19 | - handler: handleTx 20 | file: ./src/mapping.ts 21 | -------------------------------------------------------------------------------- /packages/cli/src/debug.ts: -------------------------------------------------------------------------------- 1 | import debugFactory from 'debug'; 2 | 3 | debugFactory.formatters.L = immutableList => { 4 | return JSON.stringify(immutableList); 5 | }; 6 | 7 | debugFactory.formatters.M = immutableMap => { 8 | if (immutableMap?.toMap != null) { 9 | return JSON.stringify(immutableMap.toMap()); 10 | } 11 | 12 | if (typeof immutableMap?.toJS === 'function') { 13 | return JSON.stringify(immutableMap.toJS()); 14 | } 15 | 16 | if (typeof immutableMap === 'object') { 17 | return JSON.stringify(immutableMap); 18 | } 19 | return immutableMap; 20 | }; 21 | 22 | export default debugFactory; 23 | -------------------------------------------------------------------------------- /website/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { browser: true, es2020: true }, 4 | extends: [ 5 | 'eslint:recommended', 6 | 'plugin:@typescript-eslint/recommended', 7 | 'plugin:react-hooks/recommended', 8 | ], 9 | ignorePatterns: ['dist', '.eslintrc.cjs', 'tailwind.config.js'], 10 | parser: '@typescript-eslint/parser', 11 | plugins: ['react-refresh'], 12 | rules: { 13 | 'react-refresh/only-export-components': ['warn', { allowConstantExport: true }], 14 | '@typescript-eslint/no-empty-object-type': 'warn', 15 | '@typescript-eslint/no-unused-vars': 'warn', 16 | }, 17 | }; 18 | -------------------------------------------------------------------------------- /examples/cosmos-osmosis-token-swaps/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.5 2 | description: Osmosis Token Swaps Example 3 | repository: https://github.com/graphprotocol/graph-toolings 4 | schema: 5 | file: ./schema.graphql 6 | dataSources: 7 | - kind: cosmos 8 | name: Osmosis 9 | network: osmosis-1 10 | source: 11 | startBlock: 2522560 12 | mapping: 13 | apiVersion: 0.0.7 14 | language: wasm/assemblyscript 15 | entities: 16 | - TokenSwap 17 | - Token 18 | eventHandlers: 19 | - event: token_swapped 20 | handler: handleSwaps 21 | file: ./src/mapping.ts 22 | -------------------------------------------------------------------------------- /packages/cli/src/scaffold/get-git-ignore.ts: -------------------------------------------------------------------------------- 1 | export const getGitIgnore = () => { 2 | return `# Graph CLI generated artifacts 3 | build/ 4 | generated/ 5 | 6 | # Dependency directories 7 | node_modules/ 8 | jspm_packages/ 9 | 10 | # Logs 11 | logs 12 | *.log 13 | npm-debug.log* 14 | yarn-debug.log* 15 | yarn-error.log* 16 | 17 | # Optional npm cache directory 18 | .npm 19 | 20 | # Optional eslint cache 21 | .eslintcache 22 | 23 | # dotenv environment variables file 24 | .env 25 | 26 | # Testing 27 | coverage 28 | coverage.json 29 | 30 | # Typechain 31 | typechain 32 | typechain-types 33 | 34 | # Hardhat files 35 | cache 36 | `; 37 | }; 38 | -------------------------------------------------------------------------------- /examples/ethereum-gravatar/contracts/Migrations.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.0; 2 | 3 | contract Migrations { 4 | address public owner; 5 | uint public last_completed_migration; 6 | 7 | constructor() public { 8 | owner = msg.sender; 9 | } 10 | 11 | modifier restricted() { 12 | if (msg.sender == owner) _; 13 | } 14 | 15 | function setCompleted(uint completed) public restricted { 16 | last_completed_migration = completed; 17 | } 18 | 19 | function upgrade(address new_address) public restricted { 20 | Migrations upgraded = Migrations(new_address); 21 | upgraded.setCompleted(last_completed_migration); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/cli/src/command-helpers/retry.ts: -------------------------------------------------------------------------------- 1 | import { prompt } from 'gluegun'; 2 | 3 | export async function retryWithPrompt(func: () => Promise): Promise { 4 | for (;;) { 5 | try { 6 | return await func(); 7 | } catch (_) { 8 | try { 9 | const { retry } = await prompt.ask({ 10 | type: 'confirm', 11 | name: 'retry', 12 | message: 'Do you want to retry?', 13 | initial: true, 14 | }); 15 | 16 | if (!retry) { 17 | break; 18 | } 19 | } catch (_) { 20 | break; 21 | } 22 | } 23 | } 24 | return undefined; 25 | } 26 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/missing-entity-id/types/schema.ts: -------------------------------------------------------------------------------- 1 | import { 2 | TypedMap, 3 | Entity, 4 | Value, 5 | Address, 6 | Bytes, 7 | BigInt 8 | } from "@graphprotocol/graph-ts"; 9 | 10 | export class MyEntity extends Entity { 11 | get name(): string { 12 | let value = this.get("name"); 13 | if (value === null) { 14 | return null; 15 | } else { 16 | return value.toString() as string; 17 | } 18 | } 19 | 20 | set name(value: string) { 21 | if (value === null) { 22 | this.unset("name"); 23 | } else { 24 | this.set("name", Value.fromString(value as string)); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/cli/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./dist", 4 | "moduleResolution": "bundler", 5 | "module": "ESNext", 6 | "target": "ESNext", 7 | "strict": true, 8 | "noUnusedLocals": true, 9 | "noUnusedParameters": true, 10 | "esModuleInterop": true, 11 | "forceConsistentCasingInFileNames": true, 12 | "useUnknownInCatchVariables": false, 13 | "declaration": true, 14 | "skipLibCheck": true, 15 | "allowJs": true 16 | }, 17 | "ts-node": { 18 | "esm": true 19 | }, 20 | "include": ["./src", "./tests"], 21 | "exclude": ["./tests/cli/init", "./tests/cli/validation"] 22 | } 23 | -------------------------------------------------------------------------------- /examples/near-receipts/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.4 2 | description: Good Morning NEAR 3 | repository: https://github.com/graphprotocol/graph-toolings/tree/main/near/receipts-example 4 | schema: 5 | file: ./schema.graphql 6 | dataSources: 7 | - kind: near 8 | name: receipts 9 | network: near-mainnet 10 | source: 11 | account: 'app.good-morning.near' 12 | startBlock: 50736511 13 | mapping: 14 | apiVersion: 0.0.6 15 | language: wasm/assemblyscript 16 | file: ./src/mapping.ts 17 | entities: 18 | - Greeter 19 | - Greeting 20 | receiptHandlers: 21 | - handler: handleReceipt 22 | -------------------------------------------------------------------------------- /packages/cli/src/protocols/ethereum/contract.ts: -------------------------------------------------------------------------------- 1 | import { Contract } from '../contract.js'; 2 | 3 | export default class EthereumContract implements Contract { 4 | static identifierName() { 5 | return 'address'; 6 | } 7 | 8 | constructor(private address: string) { 9 | this.address = address; 10 | } 11 | 12 | validate() { 13 | const pattern = /^(0x)?[0-9a-fA-F]{40}$/; 14 | 15 | const errorMessage = "Must be 40 hexadecimal characters, with an optional '0x' prefix."; 16 | 17 | const valid = pattern.test(this.address); 18 | 19 | return { 20 | valid, 21 | error: valid ? null : errorMessage, 22 | }; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/derived-from-with-interface/schema.graphql: -------------------------------------------------------------------------------- 1 | type Gravatar @entity(immutable: false) { 2 | id: ID! 3 | # This field points at an interface; we allow that a derived field 4 | # in a type that implements the interface derives from this field 5 | # The test checks that this construct is accepted 6 | owner: Account! 7 | imageUrl: String! 8 | } 9 | 10 | interface Account { 11 | id: ID! 12 | gravatars: [Gravatar!]! @derivedFrom(field: "owner") 13 | } 14 | 15 | type UserAccount implements Account @entity(immutable: true) { 16 | id: ID! 17 | name: String! 18 | gravatars: [Gravatar!]! @derivedFrom(field: "owner") 19 | } 20 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/init/ethereum/abis/Airdropped.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "anonymous": false, 4 | "inputs": [ 5 | { 6 | "indexed": false, 7 | "internalType": "address[]", 8 | "name": "to", 9 | "type": "address[]" 10 | }, 11 | { 12 | "indexed": false, 13 | "internalType": "uint256", 14 | "name": "quantity", 15 | "type": "uint256" 16 | }, 17 | { 18 | "indexed": false, 19 | "internalType": "uint256", 20 | "name": "fromTokenId", 21 | "type": "uint256" 22 | } 23 | ], 24 | "name": "Airdropped", 25 | "type": "event" 26 | } 27 | ] 28 | -------------------------------------------------------------------------------- /website/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 10 | 11 | 12 | Tooling | The Graph 13 | 14 | 15 |
16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "type": "node", 6 | "request": "launch", 7 | "name": "Debug graph init", 8 | "skipFiles": ["/**"], 9 | "program": "${workspaceFolder}/packages/cli/bin/run", 10 | "args": ["init", "--skip-git"], 11 | "preLaunchTask": "build:dev", 12 | "outFiles": ["${workspaceFolder}/packages/cli/dist/**/*.js"], 13 | "sourceMaps": true, 14 | "resolveSourceMapLocations": ["${workspaceFolder}/**", "!**/node_modules/**"], 15 | "console": "integratedTerminal", 16 | "internalConsoleOptions": "neverOpen" 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/missing-or-invalid-derived-from-fields.stderr: -------------------------------------------------------------------------------- 1 | - Load subgraph from subgraph.yaml 2 | ✖ Failed to load subgraph from subgraph.yaml: Error in schema.graphql: 3 | 4 | A: 5 | - Field 'b': @derivedFrom field 'a' does not exist on type 'B' 6 | - Field 'c': @derivedFrom field 'a' does not exist on type 'C' 7 | - Field 'd': @derivedFrom directive must have a 'field' argument 8 | - Field 'e': @derivedFrom directive must have a 'field' argument 9 | - Field 'f': Value of the @derivedFrom 'field' argument must be a string 10 | - Field 'g': @derivedFrom field 'a' on type 'G' must have the type 'A', 'A!', '[A!]!', or one of the interface types that 'A' implements 11 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/entity-field-args/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.1 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: ethereum/contract 6 | name: ExampleSubgraph 7 | source: 8 | address: '22843e74c59580b3eaf6c233fa67d8b7c561a835' 9 | abi: ExampleContract 10 | mapping: 11 | kind: ethereum/events 12 | apiVersion: 0.0.5 13 | language: wasm/assemblyscript 14 | file: ./mapping.ts 15 | entities: 16 | - ExampleEntity 17 | abis: 18 | - name: ExampleContract 19 | file: ./Abi.json 20 | eventHandlers: 21 | - event: ExampleEvent(string) 22 | handler: handleExampleEvent 23 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-abis/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.1 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: ethereum/contract 6 | name: ExampleSubgraph 7 | source: 8 | address: '22843e74c59580b3eaf6c233fa67d8b7c561a835' 9 | abi: ExampleContract 10 | mapping: 11 | kind: ethereum/events 12 | apiVersion: 0.0.5 13 | language: wasm/assemblyscript 14 | file: ./mapping.ts 15 | entities: 16 | - ExampleEntity 17 | abis: 18 | - name: ExampleContract 19 | file: ./InvalidAbi.json 20 | eventHandlers: 21 | - event: ExampleEvent(string) 22 | handler: handleExampleEvent 23 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/missing-entity-id/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.1 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: ethereum/contract 6 | name: ExampleSubgraph 7 | source: 8 | address: '22843e74c59580b3eaf6c233fa67d8b7c561a835' 9 | abi: ExampleContract 10 | mapping: 11 | kind: ethereum/events 12 | apiVersion: 0.0.5 13 | language: wasm/assemblyscript 14 | file: ./mapping.ts 15 | entities: 16 | - ExampleEntity 17 | abis: 18 | - name: ExampleContract 19 | file: ./Abi.json 20 | eventHandlers: 21 | - event: ExampleEvent(string) 22 | handler: handleExampleEvent 23 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/call-function-not-found/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.1 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: ethereum/contract 6 | name: ExampleSubgraph 7 | source: 8 | address: "22843e74c59580b3eaf6c233fa67d8b7c561a835" 9 | abi: ExampleContract 10 | mapping: 11 | kind: ethereum/events 12 | apiVersion: 0.0.5 13 | language: wasm/assemblyscript 14 | file: ./mapping.ts 15 | entities: 16 | - ExampleEntity 17 | abis: 18 | - name: ExampleContract 19 | file: ./Abi.json 20 | callHandlers: 21 | - function: doSomething(uint256) 22 | handler: handleDoSomething 23 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-graphql-schema/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.1 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: ethereum/contract 6 | name: ExampleSubgraph 7 | source: 8 | address: '22843e74c59580b3eaf6c233fa67d8b7c561a835' 9 | abi: ExampleContract 10 | mapping: 11 | kind: ethereum/events 12 | apiVersion: 0.0.5 13 | language: wasm/assemblyscript 14 | file: ./mapping.ts 15 | entities: 16 | - ExampleEntity 17 | abis: 18 | - name: ExampleContract 19 | file: ./Abi.json 20 | eventHandlers: 21 | - event: ExampleEvent(string) 22 | handler: handleExampleEvent 23 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-manifest.stderr: -------------------------------------------------------------------------------- 1 | - Load subgraph from subgraph.yaml 2 | ✖ Failed to load subgraph from subgraph.yaml: Error in subgraph.yaml: 3 | 4 | Path: specVersion 5 | No value provided 6 | 7 | Path: schema > file 8 | File does not exist: non-existent.grapqhl 9 | 10 | Path: dataSources > 0 > name 11 | Expected string, found number: 12 | 5 13 | 14 | Path: dataSources > 0 > source 15 | No value provided 16 | 17 | Path: dataSources > 0 > mapping 18 | Expected map, found list: 19 | - 12 20 | - 13 21 | - 14 22 | 23 | Path: dataSources > 0 24 | Unexpected key in map: abis 25 | 26 | Path: templates 27 | Expected list, found map: 28 | field: foo 29 | -------------------------------------------------------------------------------- /packages/cli/src/command-helpers/node.ts: -------------------------------------------------------------------------------- 1 | import { URL } from 'node:url'; 2 | import { print } from 'gluegun'; 3 | 4 | export const SUBGRAPH_STUDIO_URL = 'https://api.studio.thegraph.com/deploy/'; 5 | 6 | export const validateNodeUrl = (node: string) => new URL(node); 7 | 8 | export const normalizeNodeUrl = (node: string) => new URL(node).toString(); 9 | 10 | export function chooseNodeUrl({ node }: { node?: string }) { 11 | if (node) { 12 | try { 13 | validateNodeUrl(node); 14 | return { node }; 15 | } catch (e) { 16 | print.error(`Graph node "${node}" is invalid: ${e.message}`); 17 | process.exit(1); 18 | } 19 | } 20 | 21 | return { node: SUBGRAPH_STUDIO_URL }; 22 | } 23 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-entity-field-types/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.1 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: ethereum/contract 6 | name: ExampleSubgraph 7 | source: 8 | address: '22843e74c59580b3eaf6c233fa67d8b7c561a835' 9 | abi: ExampleContract 10 | mapping: 11 | kind: ethereum/events 12 | apiVersion: 0.0.5 13 | language: wasm/assemblyscript 14 | file: ./mapping.ts 15 | entities: 16 | - ExampleEntity 17 | abis: 18 | - name: ExampleContract 19 | file: ./Abi.json 20 | eventHandlers: 21 | - event: ExampleEvent(string) 22 | handler: handleExampleEvent 23 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-fulltext-directive/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.1 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: ethereum/contract 6 | name: ExampleSubgraph 7 | source: 8 | address: '22843e74c59580b3eaf6c233fa67d8b7c561a835' 9 | abi: ExampleContract 10 | mapping: 11 | kind: ethereum/events 12 | apiVersion: 0.0.5 13 | language: wasm/assemblyscript 14 | file: ./mapping.ts 15 | entities: 16 | - ExampleEntity 17 | abis: 18 | - name: ExampleContract 19 | file: ./Abi.json 20 | eventHandlers: 21 | - event: ExampleEvent(string) 22 | handler: handleExampleEvent 23 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/derived-from-target-type-missing/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.1 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: ethereum/contract 6 | name: ExampleSubgraph 7 | source: 8 | address: '22843e74c59580b3eaf6c233fa67d8b7c561a835' 9 | abi: ExampleContract 10 | mapping: 11 | kind: ethereum/events 12 | apiVersion: 0.0.5 13 | language: wasm/assemblyscript 14 | file: ./mapping.ts 15 | entities: 16 | - ExampleEntity 17 | abis: 18 | - name: ExampleContract 19 | file: ./Abi.json 20 | eventHandlers: 21 | - event: ExampleEvent(string) 22 | handler: handleExampleEvent 23 | -------------------------------------------------------------------------------- /packages/cli/src/protocols/subgraph/subgraph.ts: -------------------------------------------------------------------------------- 1 | import immutable from 'immutable'; 2 | import { Subgraph, SubgraphOptions } from '../subgraph'; 3 | 4 | export default class SubgraphDataSource implements Subgraph { 5 | public manifest: SubgraphOptions['manifest']; 6 | public resolveFile: SubgraphOptions['resolveFile']; 7 | public protocol: SubgraphOptions['protocol']; 8 | 9 | constructor(options: SubgraphOptions) { 10 | this.manifest = options.manifest; 11 | this.resolveFile = options.resolveFile; 12 | this.protocol = options.protocol; 13 | } 14 | 15 | validateManifest() { 16 | return immutable.List(); 17 | } 18 | 19 | handlerTypes() { 20 | return immutable.List([]); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/missing-or-invalid-derived-from-fields/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.1 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: ethereum/contract 6 | name: DataSource 7 | source: 8 | address: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' 9 | abi: ExampleContract 10 | mapping: 11 | kind: ethereum/events 12 | apiVersion: 0.0.5 13 | language: wasm/assemblyscript 14 | file: ./mapping.ts 15 | entities: 16 | - ExampleEntity 17 | abis: 18 | - name: ExampleContract 19 | file: ./Abi.json 20 | eventHandlers: 21 | - event: ExampleEvent(string) 22 | handler: handleExampleEvent 23 | -------------------------------------------------------------------------------- /packages/cli/src/protocols/substreams/subgraph.ts: -------------------------------------------------------------------------------- 1 | import immutable from 'immutable'; 2 | import { Subgraph, SubgraphOptions } from '../subgraph.js'; 3 | 4 | export default class SubstreamsSubgraph implements Subgraph { 5 | public manifest: SubgraphOptions['manifest']; 6 | public resolveFile: SubgraphOptions['resolveFile']; 7 | public protocol: SubgraphOptions['protocol']; 8 | 9 | constructor(options: SubgraphOptions) { 10 | this.manifest = options.manifest; 11 | this.resolveFile = options.resolveFile; 12 | this.protocol = options.protocol; 13 | } 14 | 15 | validateManifest() { 16 | return immutable.List(); 17 | } 18 | 19 | handlerTypes() { 20 | return immutable.List([]); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /examples/example-subgraph/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example-event-handler", 3 | "repository": { 4 | "type": "git", 5 | "url": "https://github.com/graphprotocol/graph-tooling", 6 | "directory": "examples/example-subgraph" 7 | }, 8 | "private": true, 9 | "scripts": { 10 | "build": "../../packages/cli/bin/run.js build subgraph.yaml", 11 | "build-ipfs": "../../packages/cli/bin/run.js build --ipfs /ip4/127.0.0.1/tcp/5001 subgraph.yaml", 12 | "build-wast": "../../packages/cli/bin/run.js build -t wast subgraph.yaml", 13 | "codegen": "../../packages/cli/bin/run.js codegen --output-dir src/types/ subgraph.yaml" 14 | }, 15 | "devDependencies": { 16 | "@graphprotocol/graph-ts": "0.35.1" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/cli/src/protocols/arweave/subgraph.ts: -------------------------------------------------------------------------------- 1 | import immutable from 'immutable'; 2 | import { Subgraph, SubgraphOptions } from '../subgraph.js'; 3 | 4 | export default class ArweaveSubgraph implements Subgraph { 5 | manifest: SubgraphOptions['manifest']; 6 | resolveFile: SubgraphOptions['resolveFile']; 7 | protocol: SubgraphOptions['protocol']; 8 | 9 | constructor(options: SubgraphOptions) { 10 | this.manifest = options.manifest; 11 | this.resolveFile = options.resolveFile; 12 | this.protocol = options.protocol; 13 | } 14 | 15 | validateManifest() { 16 | return immutable.List(); 17 | } 18 | 19 | handlerTypes() { 20 | return immutable.List(['blockHandlers', 'transactionHandlers']); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/2d-array-is-valid/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.1 2 | repository: https://github.com/graphprotocol/test-subgraph 3 | description: Test subgraph 4 | schema: 5 | file: ./schema.graphql 6 | dataSources: 7 | - kind: ethereum/contract 8 | name: ExampleSubgraph 9 | source: 10 | abi: ExampleContract 11 | mapping: 12 | kind: ethereum/events 13 | apiVersion: 0.0.5 14 | language: wasm/assemblyscript 15 | file: ./mapping.ts 16 | entities: 17 | - ExampleEntity 18 | abis: 19 | - name: ExampleContract 20 | file: ./Abi.json 21 | eventHandlers: 22 | - event: ExampleEvent(string) 23 | handler: handleExampleEvent 24 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/3d-array-is-valid/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.1 2 | repository: https://github.com/graphprotocol/test-subgraph 3 | description: Test subgraph 4 | schema: 5 | file: ./schema.graphql 6 | dataSources: 7 | - kind: ethereum/contract 8 | name: ExampleSubgraph 9 | source: 10 | abi: ExampleContract 11 | mapping: 12 | kind: ethereum/events 13 | apiVersion: 0.0.5 14 | language: wasm/assemblyscript 15 | file: ./mapping.ts 16 | entities: 17 | - ExampleEntity 18 | abis: 19 | - name: ExampleContract 20 | file: ./Abi.json 21 | eventHandlers: 22 | - event: ExampleEvent(string) 23 | handler: handleExampleEvent 24 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/big-decimal-is-valid/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.1 2 | repository: https://github.com/graphprotocol/test-subgraph 3 | description: Test subgraph 4 | schema: 5 | file: ./schema.graphql 6 | dataSources: 7 | - kind: ethereum/contract 8 | name: ExampleSubgraph 9 | source: 10 | abi: ExampleContract 11 | mapping: 12 | kind: ethereum/events 13 | apiVersion: 0.0.5 14 | language: wasm/assemblyscript 15 | file: ./mapping.ts 16 | entities: 17 | - ExampleEntity 18 | abis: 19 | - name: ExampleContract 20 | file: ./Abi.json 21 | eventHandlers: 22 | - event: ExampleEvent(string) 23 | handler: handleExampleEvent 24 | -------------------------------------------------------------------------------- /website/src/components/editor.tsx: -------------------------------------------------------------------------------- 1 | import MonacoEditor from '@monaco-editor/react'; 2 | 3 | export function Editor({ value }: { value: string }) { 4 | return ( 5 | { 16 | monaco.editor.defineTheme('graph-cli', { 17 | base: 'hc-black', 18 | inherit: false, 19 | rules: [], 20 | colors: { 21 | 'editor.background': '#FFFFFF', 22 | }, 23 | }); 24 | }} 25 | /> 26 | ); 27 | } 28 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/call-handler-with-tuple/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.2 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: ethereum/contract 6 | name: ExampleSubgraph 7 | source: 8 | address: '22843e74c59580b3eaf6c233fa67d8b7c561a835' 9 | abi: ExampleContract 10 | mapping: 11 | kind: ethereum/events 12 | apiVersion: 0.0.5 13 | language: wasm/assemblyscript 14 | file: ./mapping.ts 15 | entities: 16 | - ExampleEntity 17 | abis: 18 | - name: ExampleContract 19 | file: ./Abi.json 20 | callHandlers: 21 | - function: doSomething(uint256,(bytes32,bytes32,uint256),bool) 22 | handler: handleDoSomething 23 | -------------------------------------------------------------------------------- /packages/cli/src/protocols/near/subgraph.ts: -------------------------------------------------------------------------------- 1 | import immutable from 'immutable'; 2 | import { Subgraph, SubgraphOptions } from '../subgraph.js'; 3 | 4 | export default class NearSubgraph implements Subgraph { 5 | public manifest: SubgraphOptions['manifest']; 6 | public resolveFile: SubgraphOptions['resolveFile']; 7 | public protocol: SubgraphOptions['protocol']; 8 | 9 | constructor(options: SubgraphOptions) { 10 | this.manifest = options.manifest; 11 | this.resolveFile = options.resolveFile; 12 | this.protocol = options.protocol; 13 | } 14 | 15 | validateManifest() { 16 | return immutable.List(); 17 | } 18 | 19 | handlerTypes() { 20 | return immutable.List(['blockHandlers', 'receiptHandlers']); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/source-without-address-is-valid/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.1 2 | repository: https://github.com/graphprotocol/test-subgraph 3 | description: Test subgraph 4 | schema: 5 | file: ./schema.graphql 6 | dataSources: 7 | - kind: ethereum/contract 8 | name: ExampleSubgraph 9 | source: 10 | abi: ExampleContract 11 | mapping: 12 | kind: ethereum/events 13 | apiVersion: 0.0.5 14 | language: wasm/assemblyscript 15 | file: ./mapping.ts 16 | entities: 17 | - ExampleEntity 18 | abis: 19 | - name: ExampleContract 20 | file: ./Abi.json 21 | eventHandlers: 22 | - event: ExampleEvent(string) 23 | handler: handleExampleEvent 24 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/require-immutable-argument/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.1 2 | schema: 3 | file: ./schema.graphql 4 | dataSources: 5 | - kind: ethereum/contract 6 | name: ExampleContract 7 | source: 8 | address: '22843e74c59580b3eaf6c233fa67d8b7c561a835' 9 | abi: ExampleEvent 10 | mapping: 11 | kind: ethereum/events 12 | apiVersion: 0.0.5 13 | language: wasm/assemblyscript 14 | file: ./mapping.ts 15 | entities: 16 | - EntityA 17 | - EntityB 18 | - EntityC 19 | - EntityD 20 | abis: 21 | - name: ExampleEvent 22 | file: ./Abi.json 23 | eventHandlers: 24 | - event: ExampleEvent(string) 25 | handler: handleExampleEvent 26 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/invalid-contract-addresses.stderr: -------------------------------------------------------------------------------- 1 | - Load subgraph from subgraph.yaml 2 | ✖ Failed to load subgraph from subgraph.yaml: Error in subgraph.yaml: 3 | 4 | Path: dataSources > 0 > source > address 5 | Contract address is invalid: 22843e74c59580b3eaf6c233fa67d8b7c561a835a 6 | Must be 40 hexadecimal characters, with an optional '0x' prefix. 7 | 8 | Path: dataSources > 1 > source > address 9 | Contract address is invalid: 22843e74c59580b3eaf6c233fa67d8b7c561axyz 10 | Must be 40 hexadecimal characters, with an optional '0x' prefix. 11 | 12 | Path: dataSources > 2 > source > address 13 | Contract address is invalid: 0x22843e74c59580b3eaf6c233fa67d8b7c561a835a 14 | Must be 40 hexadecimal characters, with an optional '0x' prefix. 15 | -------------------------------------------------------------------------------- /website/src/components/ui/label.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { cva, type VariantProps } from 'class-variance-authority'; 3 | import { cn } from '@/lib/utils'; 4 | import * as LabelPrimitive from '@radix-ui/react-label'; 5 | 6 | const labelVariants = cva( 7 | 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70', 8 | ); 9 | 10 | const Label = React.forwardRef< 11 | React.ElementRef, 12 | React.ComponentPropsWithoutRef & VariantProps 13 | >(({ className, ...props }, ref) => ( 14 | 15 | )); 16 | Label.displayName = LabelPrimitive.Root.displayName; 17 | 18 | export { Label }; 19 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/example-values-found/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.1 2 | repository: https://github.com/graphprotocol/graph-tooling 3 | description: Gravatar for Ethereum 4 | schema: 5 | file: ./schema.graphql 6 | dataSources: 7 | - kind: ethereum/contract 8 | name: ExampleSubgraph 9 | source: 10 | address: '22843e74c59580b3eaf6c233fa67d8b7c561a835' 11 | abi: ExampleContract 12 | mapping: 13 | kind: ethereum/events 14 | apiVersion: 0.0.5 15 | language: wasm/assemblyscript 16 | file: ./mapping.ts 17 | entities: 18 | - ExampleEntity 19 | abis: 20 | - name: ExampleContract 21 | file: ./Abi.json 22 | eventHandlers: 23 | - event: ExampleEvent(string) 24 | handler: handleExampleEvent 25 | -------------------------------------------------------------------------------- /packages/cli/tests/cli/validation/topic0-is-valid/subgraph.yaml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.1 2 | repository: https://github.com/graphprotocol/test-subgraph 3 | description: Test subgraph 4 | schema: 5 | file: ./schema.graphql 6 | dataSources: 7 | - kind: ethereum/contract 8 | name: ExampleSubgraph 9 | source: 10 | abi: ExampleContract 11 | mapping: 12 | kind: ethereum/events 13 | apiVersion: 0.0.5 14 | language: wasm/assemblyscript 15 | file: ./mapping.ts 16 | entities: 17 | - ExampleEntity 18 | abis: 19 | - name: ExampleContract 20 | file: ./Abi.json 21 | eventHandlers: 22 | - event: ExampleEvent(string) 23 | topic0: b74a38eb2ebca56512a2bb0283f335555a4a4dac46ab998d65fd76f9027dca70 24 | handler: handleExampleEvent 25 | -------------------------------------------------------------------------------- /packages/cli/src/protocols/cosmos/subgraph.ts: -------------------------------------------------------------------------------- 1 | import immutable from 'immutable'; 2 | import { Subgraph, SubgraphOptions } from '../subgraph.js'; 3 | 4 | export default class CosmosSubgraph implements Subgraph { 5 | manifest: SubgraphOptions['manifest']; 6 | resolveFile: SubgraphOptions['resolveFile']; 7 | protocol: SubgraphOptions['protocol']; 8 | 9 | constructor(options: SubgraphOptions) { 10 | this.manifest = options.manifest; 11 | this.resolveFile = options.resolveFile; 12 | this.protocol = options.protocol; 13 | } 14 | 15 | validateManifest() { 16 | return immutable.List(); 17 | } 18 | 19 | handlerTypes() { 20 | return immutable.List([ 21 | 'blockHandlers', 22 | 'eventHandlers', 23 | 'transactionHandlers', 24 | 'messageHandlers', 25 | ]); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/substreams-powered-subgraph/README.md: -------------------------------------------------------------------------------- 1 | # Substreams-powered subgraph: tracking contract creation 2 | 3 | A basic Substreams-powered subgraph, including the Substreams definition. This example detects new 4 | contract deployments on Ethereum, tracking the creation block and timestamp. There is a 5 | demonstration of the Graph Node integration, using `substreams_entity_change` types and helpers. 6 | 7 | ## Prerequisites 8 | 9 | This 10 | [requires the dependencies necessary for local Substreams development](https://substreams.streamingfast.io/developers-guide/installation-requirements). 11 | 12 | ## Quickstart 13 | 14 | ``` 15 | yarn install # install graph-cli 16 | yarn substreams:prepare # build and package the substreams module 17 | yarn subgraph:build # build the subgraph 18 | yarn deploy # deploy the subgraph 19 | ``` 20 | -------------------------------------------------------------------------------- /website/src/components/ui/textarea.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { cn } from '@/lib/utils'; 3 | 4 | type TextareaProps = React.TextareaHTMLAttributes; 5 | 6 | const Textarea = React.forwardRef( 7 | ({ className, ...props }, ref) => { 8 | return ( 9 |