diff --git a/docs/cloud/reference/manifest.mdx b/docs/cloud/reference/manifest.mdx index d8cb1b93..161bf58d 100644 --- a/docs/cloud/reference/manifest.mdx +++ b/docs/cloud/reference/manifest.mdx @@ -24,7 +24,7 @@ The manifest header defines the squid metadata ## `build:` Specifies the way the squid is built into a docker image. Only an empty `build:` section is supported, and the squid must adhere -to the default [folder structure](/sdk/reference/layout). +to the default [folder structure](/sdk/how-to-start/layout). In particular, the following files and folders **must** be present in the root folder of the squid: diff --git a/docs/cloud/resources/best-practices.md b/docs/cloud/resources/best-practices.md index 9328c04f..2eaaaeaf 100644 --- a/docs/cloud/resources/best-practices.md +++ b/docs/cloud/resources/best-practices.md @@ -10,9 +10,9 @@ Here is a list of items to check out before you deploy your squid for use in pro * If your squid [saves its data to a database](/sdk/resources/persisting-data/typeorm), make sure your [schema](/sdk/reference/schema-file) has [`@index` decorators](/sdk/reference/schema-file/indexes-and-constraints) for all entities that will be looked up frequently. -* If your squid serves a [GraphQL API](/sdk/reference/graphql-server), consider: - 1. configuring the built-in [DoS protection](/sdk/reference/graphql-server/dos-protection) against heavy queries; - 2. configuring [caching](/sdk/reference/graphql-server/caching). +* If your squid serves a [GraphQL API](/sdk/resources/graphql-server), consider: + 1. configuring the built-in [DoS protection](/sdk/resources/graphql-server/dos-protection) against heavy queries; + 2. configuring [caching](/sdk/resources/graphql-server/caching). * If you deploy your squid to Subsquid Cloud: 1. Deploy your squid to a [Professional organization](/cloud/resources/organizations/#professional-organizations). diff --git a/docs/cloud/resources/migration.md b/docs/cloud/resources/migration.md index 31c87e39..d27a4ca5 100644 --- a/docs/cloud/resources/migration.md +++ b/docs/cloud/resources/migration.md @@ -58,7 +58,7 @@ deploy: ## 3. (Optional) Revise `cmd` -You may want to add additional flags to `api.cmd`, e.g. to enable [caching](/sdk/reference/graphql-server/caching) or [enforce query limits](/sdk/reference/graphql-server/dos-protection). +You may want to add additional flags to `api.cmd`, e.g. to enable [caching](/sdk/resources/graphql-server/caching) or [enforce query limits](/sdk/resources/graphql-server/dos-protection). ## 4. (Optional) Add `scale:` options diff --git a/docs/cloud/troubleshooting.md b/docs/cloud/troubleshooting.md index aaf50157..3de66f6e 100644 --- a/docs/cloud/troubleshooting.md +++ b/docs/cloud/troubleshooting.md @@ -21,8 +21,8 @@ npm update -g @subsquid/cli ```bash npm run update ``` -- Check that the squid adheres to the expected [structure](/sdk/reference/layout) -- Make sure you can [build and run Docker images locally](/sdk/resources/self-hosting) +- Check that the squid adheres to the expected [structure](/sdk/how-to-start/layout) +- Make sure you can [build and run Docker images locally](/sdk/resources/basics/self-hosting) ### `Validation error` when releasing a squid diff --git a/docs/glossary.md b/docs/glossary.md index 2e27fc6a..ad4489ec 100644 --- a/docs/glossary.md +++ b/docs/glossary.md @@ -58,7 +58,7 @@ An SDK (software development kit) and a smart-contract language for developing W ### OpenReader -An open-source GraphQL server that automatically generates an expressive API from an input schema file. See the [repo](https://github.com/subsquid/squid/tree/master/openreader) and [details](/sdk/reference/graphql-server). +An open-source GraphQL server that automatically generates an expressive API from an input schema file. See the [repo](https://github.com/subsquid/squid/tree/master/openreader) and [details](/sdk/resources/graphql-server). ### Palette @@ -86,7 +86,7 @@ The ETL part of the squid. Extracts on-chain data from an Archive, transforms, o ### Squid API -The data presentation part of the squid. Typically, it's a GraphQL API auto-generated from the schema file. See details [here](/sdk/reference/graphql-server). +The data presentation part of the squid. Typically, it's a GraphQL API auto-generated from the schema file. See details [here](/sdk/resources/graphql-server). ### Substrate diff --git a/docs/overview.mdx b/docs/overview.mdx index 5d47dbcc..9af53b4e 100644 --- a/docs/overview.mdx +++ b/docs/overview.mdx @@ -49,10 +49,10 @@ For real-time use cases such as app-specific APIs use [Squid SDK](/sdk): it'll u [Squid SDK](/sdk) is a powerful Typescript toolkit for building indexers on top of Subsquid Network, featuring - [High-level libraries](/sdk/reference/processors) for extracting and filtering the Subsquid Network data in what can be though of as Extract-Transform-Load (ETL) pipelines -- [Ergonomic tools](/sdk/reference/typegen) for decoding and normalizing raw data and efficiently accessing [network state](/sdk/reference/typegen/state-queries) +- [Ergonomic tools](/sdk/resources/tools/typegen) for decoding and normalizing raw data and efficiently accessing [network state](/sdk/resources/tools/typegen/state-queries) - Pluggable [data sinks](/sdk/reference/store) to save data into Postgres, files (local or s3) or BigQuery -- Expressive [GraphQL server](/sdk/reference/graphql-server) with a schema-based [config](/sdk/reference/schema-file) -- Seamless handling of [unfinalized blocks and chain reorganizations](/sdk/resources/unfinalized-blocks) for real-time data ingestion +- Expressive [GraphQL server](/sdk/resources/graphql-server) with a schema-based [config](/sdk/reference/schema-file) +- Seamless handling of [unfinalized blocks and chain reorganizations](/sdk/resources/basics/unfinalized-blocks) for real-time data ingestion - rapid data extraction and decoding [for local analytics](/sdk/tutorials/file-csv) The SDK is a go-to choice for production solutions and prototypes of @@ -78,10 +78,10 @@ A Platform-as-a-Service for deploying Squid SDK indexers, featuring ``` -- Learn about [squid components](/sdk/overview), [combining them](/sdk/squid-from-scratch) or follow the [end-to-end development guide](/sdk/squid-development) +- Learn about [squid components](/sdk/overview), [combining them](/sdk/how-to-start/squid-from-scratch) or follow the [end-to-end development guide](/sdk/how-to-start/squid-development) - Explore [tutorials](/sdk/tutorials) or [examples](/sdk/examples) - Learn how to [migrate from The Graph](/sdk/resources/migrate/migrate-subgraph) -- Explore the [GraphQL server options](/sdk/reference/graphql-server) including custom extensions, caching and DoS protection in production +- Explore the [GraphQL server options](/sdk/resources/graphql-server) including custom extensions, caching and DoS protection in production ```mdx-code-block diff --git a/docs/sdk/examples.mdx b/docs/sdk/examples.mdx index 7679cf1a..bcfc5240 100644 --- a/docs/sdk/examples.mdx +++ b/docs/sdk/examples.mdx @@ -1,5 +1,5 @@ --- -sidebar_position: 31 +sidebar_position: 80 title: Examples description: Example squids --- @@ -17,7 +17,7 @@ Browse a dedicated repository with [EVM squid examples](https://github.com/subsq - A [squid indexing ERC20 transfers](https://github.com/subsquid-labs/evm-logs-example) by extracting `Transfer(address,address,uint256)` logs emitted by the USDC contract. - A [squid indexing DEX trades](https://github.com/subsquid-labs/evm-factory-example) while dynamically tracking Uniswap v3 pool contracts as they are deployed. Shows [factory contract](/sdk/resources/evm/factory-contracts) indexing in action. -- A [NFT indexing squid](https://github.com/subsquid-labs/evm-multicall-example) that additionally queries the NFT metadata from the contract state. Illustrates batching RPC calls using the [Multicall contract](/sdk/reference/typegen/generation/#batching-contract-state-calls-using-the-multicall-contract). +- A [NFT indexing squid](https://github.com/subsquid-labs/evm-multicall-example) that additionally queries the NFT metadata from the contract state. Illustrates batching RPC calls using the [Multicall contract](/sdk/resources/tools/typegen/generation/#batching-contract-state-calls-using-the-multicall-contract). - A [multichain squid](https://github.com/subsquid-labs/squid-multichain-template) tracking USDC `Transfer` events on both Ethereum and BSC. and a few others. @@ -62,7 +62,7 @@ processor.run(new TypeormDatabase(), async (ctx) => {
Index all USDC Transfer events on Ethereum with real time updates -Real time data is fetched from a chain node RPC; a Database object with hot blocks support is required to store it (see [this page](/sdk/resources/unfinalized-blocks) for more details). [Full squid here](https://github.com/subsquid-labs/showcase01-all-usdc-transfers). +Real time data is fetched from a chain node RPC; a Database object with hot blocks support is required to store it (see [this page](/sdk/resources/basics/unfinalized-blocks) for more details). [Full squid here](https://github.com/subsquid-labs/showcase01-all-usdc-transfers). ```ts export const USDC_CONTRACT_ADDRESS = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' diff --git a/docs/sdk/faq.md b/docs/sdk/faq.md index 6977b1b2..afa024d5 100644 --- a/docs/sdk/faq.md +++ b/docs/sdk/faq.md @@ -1,5 +1,5 @@ --- -sidebar_position: 35 +sidebar_position: 80 title: FAQ description: Frequently asked questions --- @@ -16,7 +16,7 @@ Here is an incomplete list: ### How does Squid SDK handle unfinalized blocks? -The Subsquid Network only serves finalized blocks and is typically ~1000 blocks behind the tip. The most recent blocks, as well as the unfinalized blocks are seemlesly handled by the SDK from a complementary RPC data source, set by the `chain` config. Potential chain reorgs are automatically handled under the hood. See [Indexing unfinalized blocks](/sdk/resources/unfinalized-blocks) for details. +The Subsquid Network only serves finalized blocks and is typically ~1000 blocks behind the tip. The most recent blocks, as well as the unfinalized blocks are seemlesly handled by the SDK from a complementary RPC data source, set by the `chain` config. Potential chain reorgs are automatically handled under the hood. See [Indexing unfinalized blocks](/sdk/resources/basics/unfinalized-blocks) for details. ### What is the latency for the data served by the squid? @@ -24,11 +24,11 @@ Since the ArrowSquid release, the Squid SDK has the option to ingest unfinalized ### How do I enable GraphQL subscriptions for local runs? -Add `--subscription` flag to the `serve` command defined in `commands.json`. See [Subscriptions](/sdk/reference/graphql-server/subscriptions) for details. +Add `--subscription` flag to the `serve` command defined in `commands.json`. See [Subscriptions](/sdk/resources/graphql-server/subscriptions) for details. ### How do squids keep track of their sync progress? -Depends on the data sink used. Squid processors that use [`TypeormDatabase`](/sdk/resources/persisting-data/typeorm) keep their state in a [schema](https://www.postgresql.org/docs/current/sql-createschema.html), not in a table. By default the schema is called `squid_processor` (name must be overridden in [multiprocessor squids](/sdk/resources/multichain)). You can view it with +Depends on the data sink used. Squid processors that use [`TypeormDatabase`](/sdk/resources/persisting-data/typeorm) keep their state in a [schema](https://www.postgresql.org/docs/current/sql-createschema.html), not in a table. By default the schema is called `squid_processor` (name must be overridden in [multiprocessor squids](/sdk/resources/basics/multichain)). You can view it with ```sql select * from squid_processor.status; ``` diff --git a/docs/sdk/how-to-start/_category_.json b/docs/sdk/how-to-start/_category_.json new file mode 100644 index 00000000..a76a4720 --- /dev/null +++ b/docs/sdk/how-to-start/_category_.json @@ -0,0 +1,12 @@ +{ + "position": 20, + "label": "Getting started", + "collapsible": true, + "collapsed": true, + "className": "red", + "link": { + "type": "generated-index", + "slug": "/sdk/how-to-start", + "title": "Getting started with Squid SDK" + } +} diff --git a/docs/sdk/how-to-start/cli-cheatsheet.mdx b/docs/sdk/how-to-start/cli-cheatsheet.mdx new file mode 100644 index 00000000..de398c54 --- /dev/null +++ b/docs/sdk/how-to-start/cli-cheatsheet.mdx @@ -0,0 +1,7 @@ +--- +sidebar_position: 50 +title: CLI cheatsheet +description: Commonly used CLI commands +--- + +# Squid CLI cheatsheet \ No newline at end of file diff --git a/docs/sdk/resources/development-environment-set-up.mdx b/docs/sdk/how-to-start/development-environment-set-up.mdx similarity index 99% rename from docs/sdk/resources/development-environment-set-up.mdx rename to docs/sdk/how-to-start/development-environment-set-up.mdx index 6c77f06e..357375a4 100644 --- a/docs/sdk/resources/development-environment-set-up.mdx +++ b/docs/sdk/how-to-start/development-environment-set-up.mdx @@ -1,5 +1,5 @@ --- -sidebar_position: 20 +sidebar_position: 10 description: >- Prepare for working with Squid SDK --- diff --git a/docs/sdk/reference/layout.md b/docs/sdk/how-to-start/layout.md similarity index 86% rename from docs/sdk/reference/layout.md rename to docs/sdk/how-to-start/layout.md index c90dd337..a1e35161 100644 --- a/docs/sdk/reference/layout.md +++ b/docs/sdk/how-to-start/layout.md @@ -1,7 +1,7 @@ --- sidebar_position: 40 -title: Layout convention -description: The folder layout of a squid +title: Project structure +description: The folder layout of a squid project --- # Squid structure @@ -15,7 +15,7 @@ A squid is expected to follow the folder structure conventions listed below. + `/src/processor.ts` -- Processor object ([EVM](/sdk) or [Substrate](/sdk)) definition and configuration. + `/src/model/generated` -- The folder for the TypeORM entities generated from `schema.graphql`. + `/src/model` -- The module exporting the entity classes. - + `/src/server-extension/resolvers` -- An (optional) folder for [user-defined GraphQL resolvers](/sdk/reference/graphql-server/custom-resolvers). + + `/src/server-extension/resolvers` -- An (optional) folder for [user-defined GraphQL resolvers](/sdk/resources/graphql-server/custom-resolvers). + `/src/types` -- An (optional) output folder for typescript definitions of the Substrate data generated with [`squid-substrate-typegen`[(/sdk/tutorials/batch-processor-in-action). + `/src/abi` -- An (optional) output folder for the [EVM typegen[(/sdk/reference/typegen/state-queries) and [WASM typegen](https://github.com/subsquid/squid-sdk/tree/master/substrate/ink-typegen) tools that generate type definitions and the decoding boilerplate. - `/assets` -- (optional) A designated folder for custom user-provided files (e.g. static data files to seed the squid processor with). @@ -25,10 +25,7 @@ A squid is expected to follow the folder structure conventions listed below. - `docker-compose.yml` -- A Docker compose file for local runs. Has a Postgres service definition by default. Ignored by Subsquid Cloud. - `.env` -- Defines environment variables used by `docker-compose.yml` and when the squid is run locally. Ignored by Subsquid Cloud. - `typegen.json` -- (optional) The config file for `squid-substrate-typegen`. Ignored by Subsquid Cloud. -- `Makefile` -- (optional) Script definitions for `Make`. Ignored by Subsquid Cloud. +- `commands.json` -- User-defined scripts picked up by [Squid CLI](/squid-cli). - `tsconfig.json`, `package-lock.json`, `package.json` -- **(Required)** The `npm` and `tsc` configs. - `/archive` -- An (optional) folder for running a local Archive. Ignored by Subsquid Cloud. -The templates also define the following auxiliary scripts (optional): -- `build` to build the squid. -- `update` to update the squid packages to the latest version. diff --git a/docs/sdk/squid-development.mdx b/docs/sdk/how-to-start/squid-development.mdx similarity index 91% rename from docs/sdk/squid-development.mdx rename to docs/sdk/how-to-start/squid-development.mdx index f4de5d46..5c750faa 100644 --- a/docs/sdk/squid-development.mdx +++ b/docs/sdk/how-to-start/squid-development.mdx @@ -7,7 +7,7 @@ description: A general approach to squid development import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -This page is a definitive end-to-end guide into practical squid development. It uses templates and `sqd` [scripts](https://github.com/subsquid/squid-sdk/tree/master/util/commands) to simplify the process. Check out [Squid from scratch](/sdk/squid-from-scratch) for a more educational barebones approach. +This page is a definitive end-to-end guide into practical squid development. It uses templates and `sqd` [scripts](https://github.com/subsquid/squid-sdk/tree/master/util/commands) to simplify the process. Check out [Squid from scratch](/sdk/how-to-start/squid-from-scratch) for a more educational barebones approach. ## Prepare the environment @@ -16,14 +16,14 @@ This page is a definitive end-to-end guide into practical squid development. It - [Squid CLI](/squid-cli/installation) - Docker (if your squid will store its data to PostgreSQL) -See also the [Environment set up](/sdk/resources/development-environment-set-up) page. +See also the [Environment set up](/sdk/how-to-start/development-environment-set-up) page. ## Understand your technical requirements Consider your business requirements and find out 1. How the data should be delivered. Options: - - [PostgreSQL](/sdk/resources/persisting-data/typeorm) with an optional [GraphQL API](/sdk/reference/graphql-server) - can be real-time + - [PostgreSQL](/sdk/resources/persisting-data/typeorm) with an optional [GraphQL API](/sdk/resources/graphql-server) - can be real-time - [file-based dataset](/sdk/resources/persisting-data/file) - local or on S3 - [Google BigQuery](/sdk/resources/persisting-data/bigquery/) 2. What data should be delivered @@ -31,9 +31,9 @@ Consider your business requirements and find out - Ethereum Virtual Machine (EVM) chains like [Ethereum](https://ethereum.org) - [supported networks](/subsquid-network/reference/evm-networks) - [Substrate](https://substrate.io)-powered chains like [Polkadot](https://polkadot.network) and [Kusama](https://kusama.network) - [supported networks](/subsquid-network/reference/substrate-networks) - Note that you can use Subsquid via [RPC ingestion](/sdk/resources/unfinalized-blocks) even if your network is not listed. + Note that you can use Subsquid via [RPC ingestion](/sdk/resources/basics/unfinalized-blocks) even if your network is not listed. 4. What exact data should be retrieved from blockchain(s) -5. Whether you need to mix in any [off-chain data](/sdk/resources/external-api) +5. Whether you need to mix in any [off-chain data](/sdk/resources/basics/external-api) #### Example requirements @@ -58,7 +58,7 @@ Suppose you want to make a website that shows the image and ownership history fo 1. For this application it makes sense to deliver a GraphQL API. 2. Output data might have `Token`, `Owner` and `Transfer` [entities](/sdk/reference/openreader/queries), with e.g. `Token` supplying all the fields necessary to show ownership history and the image. 3. Ethereum is an EVM chain. -4. Data on token mints and ownership history can be derived from `Transfer(address,address,uint256)` EVM event logs emitted by the contract. To render images, you will also need token metadata URLs that are only available by [querying the contract state](/sdk/reference/typegen/state-queries) with the `tokenURI(uint256)` function. +4. Data on token mints and ownership history can be derived from `Transfer(address,address,uint256)` EVM event logs emitted by the contract. To render images, you will also need token metadata URLs that are only available by [querying the contract state](/sdk/resources/tools/typegen/state-queries) with the `tokenURI(uint256)` function. 5. You'll need to retrieve the off-chain token metadata (usually from IPFS).
@@ -78,7 +78,7 @@ Suppose you want to create a BigQuery dataset with Kusama native tokens transfer ## Start from a template {#templates} -Although it is possible to [compose a squid from individual packages](/sdk/squid-from-scratch), in practice it is usually easier to start from a template. +Although it is possible to [compose a squid from individual packages](/sdk/how-to-start/squid-from-scratch), in practice it is usually easier to start from a template. ```mdx-code-block @@ -95,7 +95,7 @@ Although it is possible to [compose a squid from individual packages](/sdk/squid ```bash sqd init my-squid-name -t gravatar ``` -- A template showing how to [combine data from multiple chains](/sdk/resources/multichain). Indexes USDC transfers on Ethereum and Binance. +- A template showing how to [combine data from multiple chains](/sdk/resources/basics/multichain). Indexes USDC transfers on Ethereum and Binance. ```bash sqd init my-squid-name -t multichain ``` @@ -217,7 +217,7 @@ Create a dataset with your BigQuery account, then follow the [template README](h ``` :::info -To make local runs more convenient squid templates define additional `sqd` commands at `commands.json`. All of `sqd` commands used here are such extras. Take a look at the contents of this file to learn more about how your template works [under the hood](/sdk/squid-from-scratch). +To make local runs more convenient squid templates define additional `sqd` commands at `commands.json`. All of `sqd` commands used here are such extras. Take a look at the contents of this file to learn more about how your template works [under the hood](/sdk/how-to-start/squid-from-scratch). ::: ## The bottom-up development cycle {#bottom-up-development} @@ -242,7 +242,7 @@ npx squid-evm-typegen \ ``` The utility classes will become available at `src/abi`. -See also the [EVM typegen code generation](/sdk/reference/typegen/generation/?typegen=evm) reference page. +See also [EVM typegen code generation](/sdk/resources/tools/typegen/generation/?typegen=evm). ```mdx-code-block @@ -250,13 +250,13 @@ See also the [EVM typegen code generation](/sdk/reference/typegen/generation/?ty ``` Follow the respective reference configuration pages of each typegen tool: -* [Substrate typegen configuration](/sdk/reference/typegen/generation/?typegen=substrate) -* [ink! typegen configuration](/sdk/reference/typegen/generation/?typegen=ink) +* [Substrate typegen configuration](/sdk/resources/tools/typegen/generation/?typegen=substrate) +* [ink! typegen configuration](/sdk/resources/tools/typegen/generation/?typegen=ink)
A tip for `frontier-evm` squids -These squids use both Substrate typegen _and_ EVM typegen. To generate all the required utilities, [configure the Substrate part](/sdk/reference/typegen/generation/?typegen=substrate), then save all relevant JSON ABIs to `./abi`, then run +These squids use both Substrate typegen _and_ EVM typegen. To generate all the required utilities, [configure the Substrate part](sdk/resources/tools/typegen/generation/?typegen=substrate), then save all relevant JSON ABIs to `./abi`, then run ```bash sqd typegen ``` @@ -270,7 +270,7 @@ sqd typegen ### II. Configure the data requests {#processor-config} -Data requests are [customarily](/sdk/reference/layout) defined at `src/processor.ts`. The details depend on the network type: +Data requests are [customarily](/sdk/how-to-start/layout) defined at `src/processor.ts`. The details depend on the network type: ```mdx-code-block @@ -281,7 +281,7 @@ Edit the definition of `const processor` to 1. Use a [data source](/sdk/reference/processors/evm-batch/general/#set-data-source) appropriate for your chain and task. - It is possible to use RPC as the only data source, but adding a [Subsquid Network](/subsquid-network/reference/evm-networks) data source will make your squid sync much faster. - RPC is a hard requirement if you're building a real-time API. - - If you're using RPC as one of your data sources, make sure to [set the number of finality confirmations](/sdk/reference/processors/evm-batch/general/#set-finality-confirmation) so that [hot blocks ingestion](/sdk/resources/unfinalized-blocks) works properly. + - If you're using RPC as one of your data sources, make sure to [set the number of finality confirmations](/sdk/reference/processors/evm-batch/general/#set-finality-confirmation) so that [hot blocks ingestion](/sdk/resources/basics/unfinalized-blocks) works properly. 2. Request all [event logs](/sdk/reference/processors/evm-batch/logs/), [transactions](/sdk/reference/processors/evm-batch/transactions/), [execution traces](/sdk/reference/processors/evm-batch/traces) and [state diffs](/sdk/reference/processors/evm-batch/state-diffs/) that your task requires, with any necessary related data (e.g. parent transactions for event logs). 3. [Select all data fields](/sdk/reference/processors/evm-batch/field-selection) necessary for your task (e.g. `gasUsed` for transactions). @@ -357,7 +357,7 @@ processor.run(db, async ctx => { } }) ``` -See also the [EVM data decoding reference](/sdk/reference/typegen/decoding/?typegen=evm). +See also the [EVM data decoding](/sdk/resources/tools/typegen/decoding/?typegen=evm). ```mdx-code-block @@ -396,11 +396,11 @@ processor.run(db, async ctx => { ``` -See also the [Substrate data decoding reference](/sdk/reference/typegen/decoding/?typegen=substrate). +See also the [Substrate data decoding](/sdk/resources/tools/typegen/decoding/?typegen=substrate). You can also decode the data of certain pallet-specific events and transactions with specialized tools: - - use the utility classes made with `@substrate/squid-ink-typegen` to [decode events emitted by ink! contracts](/sdk/reference/typegen/decoding/?typegen=ink) - - use the [`@subsquid/frontier` utils](/sdk/reference/frontier) and the [EVM typegen](/sdk/reference/typegen/decoding/?typegen=evm) to decode event logs and transactions of EVM contracts + - use the utility classes made with `@substrate/squid-ink-typegen` to [decode events emitted by ink! contracts](/sdk/resources/tools/typegen/decoding/?typegen=ink) + - use the [`@subsquid/frontier` utils](/sdk/reference/frontier) and the [EVM typegen](/sdk/resources/tools/typegen/decoding/?typegen=evm) to decode event logs and transactions of EVM contracts ```mdx-code-block @@ -409,9 +409,9 @@ You can also decode the data of certain pallet-specific events and transactions ### (Optional) IV. Mix in external data and chain state calls output {#external-data} -If you need external (i.e. non-blockchain) data in your transformation, take a look at the [External APIs and IPFS](/sdk/resources/external-api) page. +If you need external (i.e. non-blockchain) data in your transformation, take a look at the [External APIs and IPFS](/sdk/resources/basics/external-api) page. -If any of the on-chain data you need is unavalable from the processor or incovenient to retrieve with it, you have an option to get it via [direct chain queries](/sdk/reference/typegen/state-queries). +If any of the on-chain data you need is unavalable from the processor or incovenient to retrieve with it, you have an option to get it via [direct chain queries](/sdk/resources/tools/typegen/state-queries). ### V. Prepare the store {#store} @@ -543,7 +543,7 @@ It will often make sense to keep the entity instances in maps rather than arrays If you perform any [database lookups](/sdk/reference/store/typeorm/#typeorm-methods), try to do so in batches and make sure that the entity fields that you're searching over are [indexed](/sdk/reference/schema-file/indexes-and-constraints). -See also the [patterns](/sdk/resources/batch-processing/#patterns) and [anti-pattens](/sdk/resources/batch-processing/#anti-patterns) sections of the Batch processing guide. +See also the [patterns](/sdk/resources/basics/batch-processing/#patterns) and [anti-pattens](/sdk/resources/basics/batch-processing/#anti-patterns) sections of the Batch processing guide. ```mdx-code-block @@ -588,5 +588,5 @@ If you're developing a large squid, you may want to take a look at the [Giant Sq ## Next steps -* Deploy your squid [on own infrastructure](/sdk/resources/self-hosting) or to [Subsquid Cloud](/cloud) +* Deploy your squid [on own infrastructure](/sdk/resources/basics/self-hosting) or to [Subsquid Cloud](/cloud) * If your squid serves a GraphQL API, consult the [Core GraphQL API reference](/sdk/reference/openreader) while writing your frontend diff --git a/docs/sdk/squid-from-scratch.mdx b/docs/sdk/how-to-start/squid-from-scratch.mdx similarity index 94% rename from docs/sdk/squid-from-scratch.mdx rename to docs/sdk/how-to-start/squid-from-scratch.mdx index be6c1c22..595d4b8f 100644 --- a/docs/sdk/squid-from-scratch.mdx +++ b/docs/sdk/how-to-start/squid-from-scratch.mdx @@ -9,7 +9,7 @@ import TabItem from '@theme/TabItem'; Here's an example of how SDK packages can be combined into a working indexer (called *squid*). -This page goes through all the technical details to make the squid architecture easier to understand. If you would like to get to a working indexer ASAP, [bootstrap from a template](/sdk/squid-development/#templates). +This page goes through all the technical details to make the squid architecture easier to understand. If you would like to get to a working indexer ASAP, [bootstrap from a template](/sdk/how-to-start/squid-development/#templates). ## USDT transfers API @@ -102,7 +102,7 @@ To make the indexer, follow these steps: npx squid-typeorm-migration apply ``` -6. [Generate utility classes](/sdk/reference/typegen/generation) for decoding [USDT contract](https://etherscan.io/address/0xdac17f958d2ee523a2206206994597c13d831ec7) data based on its ABI downloaded from Etherscan: +6. [Generate utility classes](/sdk/resources/tools/typegen/generation) for decoding [USDT contract](https://etherscan.io/address/0xdac17f958d2ee523a2206206994597c13d831ec7) data based on its ABI downloaded from Etherscan: ```bash npx \ squid-evm-typegen \ diff --git a/docs/sdk/overview.mdx b/docs/sdk/overview.mdx index d46b856d..f006a241 100644 --- a/docs/sdk/overview.mdx +++ b/docs/sdk/overview.mdx @@ -10,7 +10,7 @@ import TabItem from '@theme/TabItem'; # Overview A _squid_ is an indexing project built with [Squid SDK](https://github.com/subsquid/squid-sdk) to retrieve and process blockchain data from the [Subsquid Network](/subsquid-network/overview) -(either permissioned or decentralized instance). The Squid SDK is a set of open source Typescript libraries that retrieve, decode, transform and persist the data. It can also make the transformed data available via an API. All stages of the indexing pipeline, from the data extraction to transformation to persistence are performed on [batches of blocks](/sdk/resources/batch-processing) to maximize the indexing speed. Modular architecture of the SDK makes it possible to extend indexing projects (squids) with custom plugins and data targets. +(either permissioned or decentralized instance). The Squid SDK is a set of open source Typescript libraries that retrieve, decode, transform and persist the data. It can also make the transformed data available via an API. All stages of the indexing pipeline, from the data extraction to transformation to persistence are performed on [batches of blocks](/sdk/resources/basics/batch-processing) to maximize the indexing speed. Modular architecture of the SDK makes it possible to extend indexing projects (squids) with custom plugins and data targets. ## Required squid components @@ -51,7 +51,7 @@ A _typegen_ is a tool for generating utility code for technology-specific operat ``` -* [`squid-evm-typegen`](/sdk/reference/typegen/generation/?typegen=evm) via [`@subsquid/evm-typegen`](https://www.npmjs.com/package/@subsquid/evm-typegen): +* [`squid-evm-typegen`](/sdk/resources/tools/typegen/generation/?typegen=evm) via [`@subsquid/evm-typegen`](https://www.npmjs.com/package/@subsquid/evm-typegen): - decodes smart contract data - handles direct calls to contract methods - exposes useful constants such as event topics and function signature hashes @@ -60,10 +60,10 @@ A _typegen_ is a tool for generating utility code for technology-specific operat ``` -* [`squid-substrate-typegen`](/sdk/reference/typegen/generation/?typegen=substrate) via [`@subsquid/substrate-typegen`](https://www.npmjs.com/package/@subsquid/substrate-typegen): +* [`squid-substrate-typegen`](/sdk/resources/tools/typegen/generation/?typegen=substrate) via [`@subsquid/substrate-typegen`](https://www.npmjs.com/package/@subsquid/substrate-typegen): - general purpose pallet data decoding (aware of runtime versions) - handles direct storage queries -* [`squid-ink-typegen`](/sdk/reference/typegen/generation/?typegen=ink) via [`@subsquid/ink-typegen`](https://www.npmjs.com/package/@subsquid/ink-typegen) for decoding the data of [ink!](https://use.ink) contracts +* [`squid-ink-typegen`](/sdk/resources/tools/typegen/generation/?typegen=ink) via [`@subsquid/ink-typegen`](https://www.npmjs.com/package/@subsquid/ink-typegen) for decoding the data of [ink!](https://use.ink) contracts ```mdx-code-block @@ -76,7 +76,7 @@ Install these with `--save-dev`. Squids that store their data in PostgreSQL can subsequently make it available as a GraphQL API. To use this functionality, install [`@subsquid/graphql-server`](https://www.npmjs.com/package/@subsquid/graphql-server). -The [server](/sdk/reference/graphql-server) runs as a separate process. [Core API](/sdk/reference/openreader) is automatically derived from the database schema; it is possible to extend it with [custom queries](/sdk/reference/graphql-server/custom-resolvers) and [basic access control](/sdk/reference/graphql-server/authorization). +The [server](/sdk/resources/graphql-server) runs as a separate process. [Core API](/sdk/reference/openreader) is automatically derived from the database schema; it is possible to extend it with [custom queries](/sdk/resources/graphql-server/custom-resolvers) and [basic access control](/sdk/resources/graphql-server/authorization). ### Misc utilities @@ -94,7 +94,7 @@ The [server](/sdk/reference/graphql-server) runs as a separate process. [Core AP * [Squid CLI](/squid-cli/installation) is a utility for [retrieving squid templates](/squid-cli/init), managing [chains of commands](https://github.com/subsquid/squid-sdk/tree/master/util/commands) commonly used in development and running [all squid processes at once](/squid-cli/run). It can also be used for deploying to [Subsquid Cloud](/cloud). * [`@subsquid/archive-registry`](https://www.npmjs.com/package/@subsquid/archive-registry) simplifies keeping track of available Subsquid [archives](/subsquid-network/overview) * [`@subsquid/ss58`](https://www.npmjs.com/package/@subsquid/ss58) handles encoding and decoding of SS58 addresses -* [`@subsquid/frontier`](https://www.npmjs.com/package/@subsquid/frontier) decodes events and calls of the [Frontier EVM pallet](https://paritytech.github.io/frontier/frame/evm.html) to make them decodable with [`squid-evm-typegen`](/sdk/reference/typegen/generation) +* [`@subsquid/frontier`](https://www.npmjs.com/package/@subsquid/frontier) decodes events and calls of the [Frontier EVM pallet](https://paritytech.github.io/frontier/frame/evm.html) to make them decodable with [`squid-evm-typegen`](/sdk/resources/tools/typegen/generation) ```mdx-code-block diff --git a/docs/sdk/reference/_category_.json b/docs/sdk/reference/_category_.json index 7c6109e6..05bb6d21 100644 --- a/docs/sdk/reference/_category_.json +++ b/docs/sdk/reference/_category_.json @@ -1,5 +1,5 @@ { - "position": 200, + "position": 70, "label": "Reference", "collapsible": true, "collapsed": true, diff --git a/docs/sdk/reference/openreader/and-or-filters.md b/docs/sdk/reference/openreader/and-or-filters.md index 1b1d8f1b..25405b1b 100644 --- a/docs/sdk/reference/openreader/and-or-filters.md +++ b/docs/sdk/reference/openreader/and-or-filters.md @@ -13,7 +13,7 @@ Our GraphQL implementation offers a vast selection of tools to filter and sectio In our GraphQL server implementation, we included logical operators to be used in the `where` clause, allowing to group multiple parameters in the same `where` argument using the `AND` and `OR` operators to filter results based on more than one criteria. -Note that the [newer](/sdk/reference/graphql-server/overview/#supported-queries) and [more advanced](/sdk/reference/openreader/paginate-query-results) `{entityName}sConnection` queries support exactly the same format of the `where` argument as the older `{entityName}s` queries used in the examples provided here. +Note that the [newer](/sdk/resources/graphql-server/overview/#supported-queries) and [more advanced](/sdk/reference/openreader/paginate-query-results) `{entityName}sConnection` queries support exactly the same format of the `where` argument as the older `{entityName}s` queries used in the examples provided here. ### Example of an `OR` clause: diff --git a/docs/sdk/reference/openreader/intro.md b/docs/sdk/reference/openreader/intro.md index 81de1d9e..585ed764 100644 --- a/docs/sdk/reference/openreader/intro.md +++ b/docs/sdk/reference/openreader/intro.md @@ -6,14 +6,14 @@ description: >- --- :::info -At the moment, [Squid SDK GraphQL server](/sdk/reference/graphql-server) can only be used with squids that use Postgres as their target database. +At the moment, [Squid SDK GraphQL server](/sdk/resources/graphql-server) can only be used with squids that use Postgres as their target database. ::: GraphQL is an API query language, and a server-side runtime for executing queries using a custom type system. Head over to the [official documentation website](https://graphql.org/learn/) for more info. -A GraphQL API served by the [GraphQL server](/sdk/reference/graphql-server) has two components: +A GraphQL API served by the [GraphQL server](/sdk/resources/graphql-server) has two components: 1. Core API is defined by the [schema file](/sdk/reference/schema-file). -2. Extensions added via [custom resolvers](/sdk/reference/graphql-server/custom-resolvers). +2. Extensions added via [custom resolvers](/sdk/resources/graphql-server/custom-resolvers). In this section we cover the core GraphQL API, with short explanations on how to perform GraphQL queries, how to paginate and sort results. This functionality is supported via [OpenReader](https://github.com/subsquid/squid-sdk/tree/master/graphql/openreader), Subsquid's own implementation of [OpenCRUD](https://www.opencrud.org). diff --git a/docs/sdk/reference/openreader/nested-field-queries.md b/docs/sdk/reference/openreader/nested-field-queries.md index 53e1a43b..79ae0156 100644 --- a/docs/sdk/reference/openreader/nested-field-queries.md +++ b/docs/sdk/reference/openreader/nested-field-queries.md @@ -44,4 +44,4 @@ query { } ``` -Note that the [newer](/sdk/reference/graphql-server/overview/#supported-queries) and [more advanced](/sdk/reference/openreader/paginate-query-results) `{entityName}sConnection` queries support exactly the same format of the `where` argument as the older `{entityName}s` queries used in the examples provided here. +Note that the [newer](/sdk/resources/graphql-server/overview/#supported-queries) and [more advanced](/sdk/reference/openreader/paginate-query-results) `{entityName}sConnection` queries support exactly the same format of the `where` argument as the older `{entityName}s` queries used in the examples provided here. diff --git a/docs/sdk/reference/openreader/queries.md b/docs/sdk/reference/openreader/queries.md index c8b049fe..69cd321f 100644 --- a/docs/sdk/reference/openreader/queries.md +++ b/docs/sdk/reference/openreader/queries.md @@ -29,7 +29,7 @@ query { } } ``` -or, using a [newer](/sdk/reference/graphql-server/overview/#supported-queries) and [more advanced](/sdk/reference/openreader/paginate-query-results) `{entityName}sConnection` query +or, using a [newer](/sdk/resources/graphql-server/overview/#supported-queries) and [more advanced](/sdk/reference/openreader/paginate-query-results) `{entityName}sConnection` query ```graphql query { diff --git a/docs/sdk/reference/processors/architecture.mdx b/docs/sdk/reference/processors/architecture.mdx index f825b714..257740a8 100644 --- a/docs/sdk/reference/processors/architecture.mdx +++ b/docs/sdk/reference/processors/architecture.mdx @@ -7,7 +7,7 @@ description: Makeup of squid processors import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -The processor service is a Node.js process responsible for data ingestion, transformation and data persisting into the target database. By [convention](/sdk/reference/layout), the processor entry point is at `src/main.ts`. It is run as +The processor service is a Node.js process responsible for data ingestion, transformation and data persisting into the target database. By [convention](/sdk/how-to-start/layout), the processor entry point is at `src/main.ts`. It is run as ```bash node lib/main.js ``` @@ -16,7 +16,7 @@ For local runs, one normally additionally exports environment variables from `.e ```bash node -r dotenv/config lib/main.js ``` -This is what the `sqd process` shortcut does under the hood in [templates](/sdk/squid-development/#templates). +This is what the `sqd process` shortcut does under the hood in [templates](/sdk/how-to-start/squid-development/#templates). ## Processor choice diff --git a/docs/sdk/reference/processors/evm-batch/context-interfaces.md b/docs/sdk/reference/processors/evm-batch/context-interfaces.md index 35db84a4..741412df 100644 --- a/docs/sdk/reference/processors/evm-batch/context-interfaces.md +++ b/docs/sdk/reference/processors/evm-batch/context-interfaces.md @@ -34,7 +34,7 @@ The exact fields available in each data item type are inferred from the `setFiel ## Example -The handler below simply outputs all the log items emitted by the contract `0x2E645469f354BB4F5c8a05B3b30A929361cf77eC` in [real time](/sdk/resources/unfinalized-blocks): +The handler below simply outputs all the log items emitted by the contract `0x2E645469f354BB4F5c8a05B3b30A929361cf77eC` in [real time](/sdk/resources/basics/unfinalized-blocks): ```ts import { TypeormDatabase } from '@subsquid/typeorm-store' diff --git a/docs/sdk/reference/processors/evm-batch/general.md b/docs/sdk/reference/processors/evm-batch/general.md index 9d31fabb..e8c27c23 100644 --- a/docs/sdk/reference/processors/evm-batch/general.md +++ b/docs/sdk/reference/processors/evm-batch/general.md @@ -21,9 +21,9 @@ The following setters configure the global settings of `EvmBatchProcessor`. They - When the data source is an `ArchiveDataSource = {archive: string}`, the processor will obtain data _only_ from an [archive](/subsquid-network/overview). This allows retrieving vast amounts of data rapidly and eliminates the need for a node RPC endpoint, but introduces a network latency typically in thousands of blocks. - A processor with an `ArchiveDataSource` cannot use [contract state queries](/sdk/reference/typegen/state-queries). If you want to operate your squid in this regime but require state queries, use a `MixedDataSource` with the [`useArchiveOnly()`](#use-archive-only) setter. + A processor with an `ArchiveDataSource` cannot use [contract state queries](/sdk/resources/tools/typegen/state-queries). If you want to operate your squid in this regime but require state queries, use a `MixedDataSource` with the [`useArchiveOnly()`](#use-archive-only) setter. -- When the data source is a `ChainDataSource = {chain: ChainRpc}`, the processor will obtain data _only_ from a node RPC endpoint. This mode of operation is slow, but requires no archive and has almost [no chain latency](/sdk/resources/unfinalized-blocks). It can be used with EVM networks not listed on the [supported networks](/subsquid-network/reference/evm-networks) page and with [local development nodes](/sdk/tutorials/evm-local). +- When the data source is a `ChainDataSource = {chain: ChainRpc}`, the processor will obtain data _only_ from a node RPC endpoint. This mode of operation is slow, but requires no archive and has almost [no chain latency](/sdk/resources/basics/unfinalized-blocks). It can be used with EVM networks not listed on the [supported networks](/subsquid-network/reference/evm-networks) page and with [local development nodes](/sdk/tutorials/evm-local). An Archive endpoint is specified as a string URL. Up-to-date URLs of public EVM Archives can be looked up with the `lookupArchive` utility from `@subsquid/archive-registry` (see [Supported networks](/subsquid-network/reference/evm-networks)). @@ -55,7 +55,7 @@ Note that block ranges can also be specified separately for each data request. T #### `useArchiveOnly(yes?: boolean | undefined)` {#use-archive-only} -Explicitly disables data ingestion from an RPC endpoint. Use this if you are making an Archive-only squid that also needs to [query contract state](/sdk/reference/typegen/state-queries). +Explicitly disables data ingestion from an RPC endpoint. Use this if you are making an Archive-only squid that also needs to [query contract state](/sdk/resources/tools/typegen/state-queries). #### `setChainPollInterval(ms: number)` {#set-chain-poll-interval} diff --git a/docs/sdk/reference/processors/evm-batch/state-diffs.md b/docs/sdk/reference/processors/evm-batch/state-diffs.md index 15438dc3..c8afb11d 100644 --- a/docs/sdk/reference/processors/evm-batch/state-diffs.md +++ b/docs/sdk/reference/processors/evm-batch/state-diffs.md @@ -7,7 +7,7 @@ description: >- # Storage state diffs :::tip -State diffs for historical blocks are [currently available](/subsquid-network/reference/evm-networks) from Archives on the same basis as all other data stored there: for free. If you deploy a squid that indexes traces [in real-time](/sdk/resources/unfinalized-blocks) to Subsquid Cloud and use our [RPC proxy](/cloud/reference/rpc-proxy), the necessary `trace_` or `debug_` RPC calls made will be counted alongside all other calls and [the price](/cloud/pricing/#rpc-requests) will be computed for the total count. There are no surcharges for traces or state diffs. +State diffs for historical blocks are [currently available](/subsquid-network/reference/evm-networks) from Archives on the same basis as all other data stored there: for free. If you deploy a squid that indexes traces [in real-time](/sdk/resources/basics/unfinalized-blocks) to Subsquid Cloud and use our [RPC proxy](/cloud/reference/rpc-proxy), the necessary `trace_` or `debug_` RPC calls made will be counted alongside all other calls and [the price](/cloud/pricing/#rpc-requests) will be computed for the total count. There are no surcharges for traces or state diffs. ::: #### `addStateDiff(options)` {#add-state-diff} diff --git a/docs/sdk/reference/processors/evm-batch/traces.md b/docs/sdk/reference/processors/evm-batch/traces.md index 4e7c7e2e..f65f3755 100644 --- a/docs/sdk/reference/processors/evm-batch/traces.md +++ b/docs/sdk/reference/processors/evm-batch/traces.md @@ -7,7 +7,7 @@ description: >- # Traces :::tip -Traces for historical blocks are [currently available](/subsquid-network/reference/evm-networks) from Archives on the same basis as all other data stored there: for free. If you deploy a squid that indexes traces [in real-time](/sdk/resources/unfinalized-blocks) to Subsquid Cloud and use our [RPC proxy](/cloud/reference/rpc-proxy), the necessary `trace_` or `debug_` RPC calls made will be counted alongside all other calls and [the price](/cloud/pricing/#rpc-requests) will be computed for the total count. There are no surcharges for traces or state diffs. +Traces for historical blocks are [currently available](/subsquid-network/reference/evm-networks) from Archives on the same basis as all other data stored there: for free. If you deploy a squid that indexes traces [in real-time](/sdk/resources/basics/unfinalized-blocks) to Subsquid Cloud and use our [RPC proxy](/cloud/reference/rpc-proxy), the necessary `trace_` or `debug_` RPC calls made will be counted alongside all other calls and [the price](/cloud/pricing/#rpc-requests) will be computed for the total count. There are no surcharges for traces or state diffs. ::: #### `addTrace(options)` {#add-trace} diff --git a/docs/sdk/reference/processors/substrate-batch/context-interfaces.md b/docs/sdk/reference/processors/substrate-batch/context-interfaces.md index 8a1f4a56..c9a67d55 100644 --- a/docs/sdk/reference/processors/substrate-batch/context-interfaces.md +++ b/docs/sdk/reference/processors/substrate-batch/context-interfaces.md @@ -29,7 +29,7 @@ The exact fields available in each data item type are inferred from the `setFiel ## Example -The handler below simply outputs all the `Balances.transfer_all` calls on Kusama in [real time](/sdk/resources/unfinalized-blocks): +The handler below simply outputs all the `Balances.transfer_all` calls on Kusama in [real time](/sdk/resources/basics/unfinalized-blocks): ```ts import {SubstrateBatchProcessor} from '@subsquid/substrate-processor' diff --git a/docs/sdk/reference/processors/substrate-batch/field-selection.md b/docs/sdk/reference/processors/substrate-batch/field-selection.md index ffbfa5c5..83040b72 100644 --- a/docs/sdk/reference/processors/substrate-batch/field-selection.md +++ b/docs/sdk/reference/processors/substrate-batch/field-selection.md @@ -224,7 +224,7 @@ BlockHeader{ } } ``` -`Runtime` is an internal type that tools like [squid-substrate-typegen](/sdk/reference/typegen) use for dealing with Substrate runtime versions. The curious may take a look at the definition [here](https://github.com/subsquid/squid-sdk/blob/master/substrate/substrate-runtime/src/runtime/runtime.ts). +`Runtime` is an internal type that tools like [squid-substrate-typegen](/sdk/resources/tools/typegen) use for dealing with Substrate runtime versions. The curious may take a look at the definition [here](https://github.com/subsquid/squid-sdk/blob/master/substrate/substrate-runtime/src/runtime/runtime.ts). ## A complete example diff --git a/docs/sdk/reference/processors/substrate-batch/general.md b/docs/sdk/reference/processors/substrate-batch/general.md index 24f30fcd..100bb5a5 100644 --- a/docs/sdk/reference/processors/substrate-batch/general.md +++ b/docs/sdk/reference/processors/substrate-batch/general.md @@ -21,7 +21,7 @@ The following setters configure the global settings of `SubstrateBatchProcessor` Note that `SubstrateBatchProcessor` also uses the RPC to occasionally retrieve chain metadata. That makes it impossible to use the processor without an RPC. -- When the data source is a `ChainDataSource = {chain: ChainRpc}`, the processor will obtain data _only_ from a node RPC endpoint. This mode of operation is slow, but requires no archive and. Like `MixedDataSource`, it also has almost [no chain latency](/sdk/resources/unfinalized-blocks). It can be used with Substrate networks not listed on the [supported networks](/subsquid-network/reference/substrate-networks) page and with local development nodes. +- When the data source is a `ChainDataSource = {chain: ChainRpc}`, the processor will obtain data _only_ from a node RPC endpoint. This mode of operation is slow, but requires no archive and. Like `MixedDataSource`, it also has almost [no chain latency](/sdk/resources/basics/unfinalized-blocks). It can be used with Substrate networks not listed on the [supported networks](/subsquid-network/reference/substrate-networks) page and with local development nodes. The node RPC endpoint can be specified as a string URL or as an object: ```ts diff --git a/docs/sdk/reference/schema-file/entity-relations.md b/docs/sdk/reference/schema-file/entity-relations.md index 1084bd4c..2eb026fb 100644 --- a/docs/sdk/reference/schema-file/entity-relations.md +++ b/docs/sdk/reference/schema-file/entity-relations.md @@ -10,7 +10,7 @@ The term "entity relation" refers to the situation when an entity instance conta [One-to-one](https://github.com/typeorm/typeorm/blob/master/docs/one-to-one-relations.md) and [one-to-many](https://github.com/typeorm/typeorm/blob/master/docs/many-to-one-one-to-many-relations.md) relations are supported by Typeorm. The "many" side of the one-to-many relations is always the owning side. Many-to-many relations are modeled as [two one-to-many relations with an explicit join table](#many-to-many-relations). -An entity relation is always unidirectional, but it is possible to request the data on the owning entity from the non-owning one. To do so, define a field decorated `@derivedFrom` in the schema. Doing so will cause the Typeorm code generated by [`squid-typeorm-codegen`](/sdk/resources/persisting-data/typeorm) and the GraphQL API served by [`squid-graphql-server`](/sdk/reference/graphql-server/overview/) to show a virtual (that is, **not mapping to a database column**) field populated via inverse lookup queries. +An entity relation is always unidirectional, but it is possible to request the data on the owning entity from the non-owning one. To do so, define a field decorated `@derivedFrom` in the schema. Doing so will cause the Typeorm code generated by [`squid-typeorm-codegen`](/sdk/resources/persisting-data/typeorm) and the GraphQL API served by [`squid-graphql-server`](/sdk/resources/graphql-server/overview/) to show a virtual (that is, **not mapping to a database column**) field populated via inverse lookup queries. The following examples illustrate the concepts. diff --git a/docs/sdk/reference/schema-file/interfaces.md b/docs/sdk/reference/schema-file/interfaces.md index 627d5994..26aadd9f 100644 --- a/docs/sdk/reference/schema-file/interfaces.md +++ b/docs/sdk/reference/schema-file/interfaces.md @@ -6,7 +6,7 @@ description: Queriable interfaces # Interfaces -The schema file supports [GraphQL Interfaces](https://graphql.org/learn/schema/#interfaces) for modelling complex types sharing common traits. Interfaces are annotated with `@query` at the type level and do not affect the backing database schema, only enriching the [GraphQL API queries](/sdk/reference/graphql-server) with [inline fragments](https://graphql.org/learn/queries/#inline-fragments). +The schema file supports [GraphQL Interfaces](https://graphql.org/learn/schema/#interfaces) for modelling complex types sharing common traits. Interfaces are annotated with `@query` at the type level and do not affect the backing database schema, only enriching the [GraphQL API queries](/sdk/resources/graphql-server) with [inline fragments](https://graphql.org/learn/queries/#inline-fragments). ### Examples @@ -47,7 +47,7 @@ type Baz implements MyEntity @entity { } ``` -The `MyEntity` interface above enables `myEntities` and `myEntitiesConnection` [GraphQL API queries](/sdk/reference/graphql-server) with inline fragments and the `_type`, `__typename` [meta fields](https://graphql.org/learn/queries/#meta-fields): +The `MyEntity` interface above enables `myEntities` and `myEntitiesConnection` [GraphQL API queries](/sdk/resources/graphql-server) with inline fragments and the `_type`, `__typename` [meta fields](https://graphql.org/learn/queries/#meta-fields): ```graphql query { diff --git a/docs/sdk/reference/schema-file/intro.md b/docs/sdk/reference/schema-file/intro.md index 61f5e571..1f3c2d9e 100644 --- a/docs/sdk/reference/schema-file/intro.md +++ b/docs/sdk/reference/schema-file/intro.md @@ -10,7 +10,7 @@ description: >- The schema file `schema.graphql` uses a GraphQL dialect to model the target entities and entity relations. The tooling around the schema file is then used to: - Generate TypeORM entities (with `squid-typeorm-codegen(1)`, see below) - Generate the database schema from the TypeORM entities (see [db migrations](/sdk/resources/persisting-data/typeorm)) -- Present the target data with a rich API served by a built-in [GraphQL Server](/sdk/reference/graphql-server). A full API reference is covered in the [Query a Squid](/sdk/reference/openreader) section. +- Present the target data with a rich API served by a built-in [GraphQL Server](/sdk/resources/graphql-server). A full API reference is covered in the [Query a Squid](/sdk/reference/openreader) section. The schema file format is loosely compatible with the [subgraph schema](https://thegraph.com/docs/en/developing/creating-a-subgraph/) file, see [Migrate from subgraph](/sdk/resources/migrate/migrate-subgraph) section for details. diff --git a/docs/sdk/resources/_category_.json b/docs/sdk/resources/_category_.json index 35065308..86cc91a0 100644 --- a/docs/sdk/resources/_category_.json +++ b/docs/sdk/resources/_category_.json @@ -1,6 +1,6 @@ { - "position": 60, - "label": "Resources", + "position": 33, + "label": "Features & Guides", "collapsible": true, "collapsed": true, "className": "red", diff --git a/docs/sdk/resources/basics/_category_.json b/docs/sdk/resources/basics/_category_.json new file mode 100644 index 00000000..0fe18207 --- /dev/null +++ b/docs/sdk/resources/basics/_category_.json @@ -0,0 +1,12 @@ +{ + "position": 9, + "label": "Basics", + "collapsible": true, + "collapsed": true, + "className": "red", + "link": { + "type": "generated-index", + "slug": "/sdk/resources/basics", + "title": "Basics of Squid SDK" + } +} diff --git a/docs/sdk/resources/batch-processing.md b/docs/sdk/resources/basics/batch-processing.md similarity index 96% rename from docs/sdk/resources/batch-processing.md rename to docs/sdk/resources/basics/batch-processing.md index 67d2d333..4301dd75 100644 --- a/docs/sdk/resources/batch-processing.md +++ b/docs/sdk/resources/basics/batch-processing.md @@ -1,5 +1,5 @@ --- -sidebar_position: 10 +sidebar_position: 11 title: Batch processing description: Batch-based data transformation model --- @@ -12,8 +12,8 @@ Batch data processing model employed by Squid SDK relies on the following princi - Minimize the number of database hits by grouping multiple single-row transactions into multi-row batch transactions. - Transform the data in memory using vectorized operators. -- Use the [MakerDAO `Multicall` contract](/sdk/reference/typegen/state-queries/#batch-state-queries) to batch EVM state queries. -- Use [`XXX.getMany()`](/sdk/reference/typegen/state-queries) to batch Substrate state queries. +- Use the [MakerDAO `Multicall` contract](/sdk/resources/tools/typegen/state-queries/#batch-state-queries) to batch EVM state queries. +- Use [`XXX.getMany()`](/sdk/resources/tools/typegen/state-queries) to batch Substrate state queries. In practice, batching is a more flexible (compared to handler parallelization) way to speed up the inherently sequential indexing of on-chain transactions and logs. diff --git a/docs/sdk/resources/external-api.md b/docs/sdk/resources/basics/external-api.md similarity index 100% rename from docs/sdk/resources/external-api.md rename to docs/sdk/resources/basics/external-api.md diff --git a/docs/sdk/resources/multichain.md b/docs/sdk/resources/basics/multichain.md similarity index 95% rename from docs/sdk/resources/multichain.md rename to docs/sdk/resources/basics/multichain.md index 46591d81..e6862bad 100644 --- a/docs/sdk/resources/multichain.md +++ b/docs/sdk/resources/basics/multichain.md @@ -6,7 +6,7 @@ description: Combine data from multiple chains # Multichain indexing -Squids can extract data from multiple chains into a shared data sink. If the data is [stored to Postgres](/sdk/resources/persisting-data/typeorm) it can then be served as a unified multichain [GraphQL API](/sdk/reference/graphql-server). +Squids can extract data from multiple chains into a shared data sink. If the data is [stored to Postgres](/sdk/resources/persisting-data/typeorm) it can then be served as a unified multichain [GraphQL API](/sdk/resources/graphql-server). To do this, run one [processor](/sdk/overview) per source network: @@ -56,13 +56,13 @@ Also ensure that async (ctx) => { // ... ``` -2. [Schema](/sdk/reference/schema-file) and [GraphQL API](/sdk/reference/graphql-server) are shared among the processors. +2. [Schema](/sdk/reference/schema-file) and [GraphQL API](/sdk/resources/graphql-server) are shared among the processors. ### Handling concurrency - The [default isolation level](/sdk/reference/store/typeorm/#typeormdatabase-constructor-arguments) used by `TypeormDatabase` is `SERIALIZABLE`, the most secure and the most restrictive one. Another isolation level commonly used in multichain squids is `READ COMMITTED`, which guarantees that the execution is deterministic for as long as the sets of records that different processors read/write do not overlap. - To avoid overlaps, use per-chain records for volatile data. E.g. if you track account balances across multiple chains you can avoid overlaps by storing the balance for each chain in a different table row. - - When you need to combine the records (e.g. get a total of all balaces across chains) use [custom resolvers](/sdk/reference/graphql-server/custom-resolvers) to do it on the GraphQL server side. + - When you need to combine the records (e.g. get a total of all balaces across chains) use [custom resolvers](/sdk/resources/graphql-server/custom-resolvers) to do it on the GraphQL server side. - It is OK to use cross-chain [entities](/sdk/reference/schema-file/entities) to simplify aggregation. Just don't store any data in them: ```graphql type Account @entity { diff --git a/docs/sdk/resources/self-hosting.md b/docs/sdk/resources/basics/self-hosting.md similarity index 100% rename from docs/sdk/resources/self-hosting.md rename to docs/sdk/resources/basics/self-hosting.md diff --git a/docs/sdk/resources/unfinalized-blocks.mdx b/docs/sdk/resources/basics/unfinalized-blocks.mdx similarity index 99% rename from docs/sdk/resources/unfinalized-blocks.mdx rename to docs/sdk/resources/basics/unfinalized-blocks.mdx index 7c7f2206..52182fbc 100644 --- a/docs/sdk/resources/unfinalized-blocks.mdx +++ b/docs/sdk/resources/basics/unfinalized-blocks.mdx @@ -1,5 +1,5 @@ --- -sidebar_position: 80 +sidebar_position: 12 title: RPC ingestion and hot blocks description: Data from chain and network consensus --- diff --git a/docs/sdk/reference/graphql-server/_category_.json b/docs/sdk/resources/graphql-server/_category_.json similarity index 75% rename from docs/sdk/reference/graphql-server/_category_.json rename to docs/sdk/resources/graphql-server/_category_.json index f6dab5f2..282d8113 100644 --- a/docs/sdk/reference/graphql-server/_category_.json +++ b/docs/sdk/resources/graphql-server/_category_.json @@ -1,12 +1,12 @@ { - "position": 70, + "position": 11, "label": "GraphQL server", "collapsible": true, "collapsed": true, "className": "red", "link": { "type": "generated-index", - "slug": "/sdk/reference/graphql-server", + "slug": "/sdk/resources/graphql-server", "title": "GraphQL API server for squid data" } } diff --git a/docs/sdk/reference/graphql-server/authorization.md b/docs/sdk/resources/graphql-server/authorization.md similarity index 97% rename from docs/sdk/reference/graphql-server/authorization.md rename to docs/sdk/resources/graphql-server/authorization.md index cc6b7003..033dd8fd 100644 --- a/docs/sdk/reference/graphql-server/authorization.md +++ b/docs/sdk/resources/graphql-server/authorization.md @@ -48,7 +48,7 @@ Here, ## Sending user data to resolvers -Authentication data such as user name can be passed from `requestCheck()` to a [custom resolver](/sdk/reference/graphql-server/custom-resolvers/) through Openreader context: +Authentication data such as user name can be passed from `requestCheck()` to a [custom resolver](/sdk/resources/graphql-server/custom-resolvers/) through Openreader context: ```typescript export async function requestCheck(req: RequestCheckContext): Promise { ... @@ -100,7 +100,7 @@ export class UserCommentResolver { ``` See full code in [this branch](https://github.com/subsquid-labs/access-control-example/tree/interacting-with-resolver). -This approach does not work with [subscriptions](/sdk/reference/graphql-server/subscriptions/). +This approach does not work with [subscriptions](/sdk/resources/graphql-server/subscriptions/). ## Examples diff --git a/docs/sdk/reference/graphql-server/caching.md b/docs/sdk/resources/graphql-server/caching.md similarity index 100% rename from docs/sdk/reference/graphql-server/caching.md rename to docs/sdk/resources/graphql-server/caching.md diff --git a/docs/sdk/reference/graphql-server/custom-resolvers.md b/docs/sdk/resources/graphql-server/custom-resolvers.md similarity index 98% rename from docs/sdk/reference/graphql-server/custom-resolvers.md rename to docs/sdk/resources/graphql-server/custom-resolvers.md index 95491f39..b924f513 100644 --- a/docs/sdk/reference/graphql-server/custom-resolvers.md +++ b/docs/sdk/resources/graphql-server/custom-resolvers.md @@ -37,7 +37,7 @@ export class CountResolver { ``` This example is designed to work with the `evm` template: -1. grab a test squid as described [here](/sdk/squid-development/); +1. grab a test squid as described [here](/sdk/how-to-start/squid-development/); 2. install `type-graphql`; 3. save the example code to `src/server-extension/resolver.ts`; 4. re-export `CountResolver` at `src/server-extension/resolvers/index.ts`: diff --git a/docs/sdk/reference/graphql-server/dos-protection.md b/docs/sdk/resources/graphql-server/dos-protection.md similarity index 98% rename from docs/sdk/reference/graphql-server/dos-protection.md rename to docs/sdk/resources/graphql-server/dos-protection.md index bfa3c810..8eb706c4 100644 --- a/docs/sdk/reference/graphql-server/dos-protection.md +++ b/docs/sdk/resources/graphql-server/dos-protection.md @@ -63,7 +63,7 @@ In a nutshell, assuming that the schema file is properly decorated with `@cardin **`--subscription-max-response-size `** -Same as `--max-response-size` but for live query [subscriptions](/sdk/reference/graphql-server/subscriptions). +Same as `--max-response-size` but for live query [subscriptions](/sdk/resources/graphql-server/subscriptions). #### Example diff --git a/docs/sdk/reference/graphql-server/overview.md b/docs/sdk/resources/graphql-server/overview.md similarity index 97% rename from docs/sdk/reference/graphql-server/overview.md rename to docs/sdk/resources/graphql-server/overview.md index 40f43c2f..694f0984 100644 --- a/docs/sdk/reference/graphql-server/overview.md +++ b/docs/sdk/resources/graphql-server/overview.md @@ -29,7 +29,7 @@ The details of the supported OpenReader queries can be found in a separate secti - a "get one by ID" query with the name `{entityName}ById` for each [entity](/sdk/reference/schema-file/entities) defined in the schema file - a "get one" query for [`@unique` fields](/sdk/reference/schema-file/indexes-and-constraints), with the name `{entityName}ByUniqueInput` - Entity queries named `{entityName}sConnection`. Each query supports rich filtering support, including [field-level filters](/sdk/reference/openreader/queries), composite [`AND` and `OR` filters](/sdk/reference/openreader/and-or-filters), [nested queries](/sdk/reference/openreader/nested-field-queries), [cross-relation queries](/sdk/reference/openreader/cross-relation-field-queries) and [Relay-compatible](https://relay.dev/graphql/connections.htm) cursor-based [pagination](/sdk/reference/openreader/paginate-query-results). -- [Subsriptions](/sdk/reference/graphql-server/subscriptions) via live queries +- [Subsriptions](/sdk/resources/graphql-server/subscriptions) via live queries - (Deprecated in favor of Relay connections) Lookup queries with the name `{entityName}s`. [Union and typed JSON types](/sdk/reference/schema-file/unions-and-typed-json) are mapped into [GraphQL Union Types](https://graphql.org/learn/schema/#union-types) with a [proper type resolution](/sdk/reference/openreader/resolve-union-types-interfaces) with `__typename`. diff --git a/docs/sdk/reference/graphql-server/subscriptions.md b/docs/sdk/resources/graphql-server/subscriptions.md similarity index 98% rename from docs/sdk/reference/graphql-server/subscriptions.md rename to docs/sdk/resources/graphql-server/subscriptions.md index ba4c16de..499fd9f8 100644 --- a/docs/sdk/reference/graphql-server/subscriptions.md +++ b/docs/sdk/resources/graphql-server/subscriptions.md @@ -16,7 +16,7 @@ npx squid-graphql-server --help For each entity types, the following queries are supported for subscriptions: - `${EntityName}ById` -- query a single entity - `${EntityName}s` -- query multiple entities with a `where` filter -Note that despite being [deprecated](/sdk/reference/graphql-server/overview/#supported-queries) from the regular query set, `${EntityName}s` queries will continue to be available for subscriptions going forward. +Note that despite being [deprecated](/sdk/resources/graphql-server/overview/#supported-queries) from the regular query set, `${EntityName}s` queries will continue to be available for subscriptions going forward. ## Local runs diff --git a/docs/sdk/resources/migrate/migrate-subgraph.md b/docs/sdk/resources/migrate/migrate-subgraph.md index bed30352..cca4e5f6 100644 --- a/docs/sdk/resources/migrate/migrate-subgraph.md +++ b/docs/sdk/resources/migrate/migrate-subgraph.md @@ -14,7 +14,7 @@ git clone https://github.com/subsquid-labs/gravatar-squid.git `EvmBatchProcessor` provided by the Squid SDK defines a single handler that indexes EVM logs and transaction data in batches. It differs from the programming model of subgraph mappings that defines a separate data handler for each EVM log topic to be indexed. Due to significantly less frequent database hits (once per batch compared to once per log) the batch-based handling model shows up to a 10x increase in the indexing speed. -At the same time, concepts of the [schema file](/sdk/reference/schema-file), [code generation from the schema file](/sdk/reference/schema-file/intro/#typeorm-codegen) and [auto-generated GraphQL API](/sdk/reference/graphql-server) should be familiar to subgraph developers. In most cases the schema file of a subgraph can be imported into a squid as is. +At the same time, concepts of the [schema file](/sdk/reference/schema-file), [code generation from the schema file](/sdk/reference/schema-file/intro/#typeorm-codegen) and [auto-generated GraphQL API](/sdk/resources/graphql-server) should be familiar to subgraph developers. In most cases the schema file of a subgraph can be imported into a squid as is. There are some known limitations: - Many-to-Many entity relations should be [modeled explicitly](/sdk/reference/schema-file/entity-relations/#many-to-many-relations) as two many-to-one relations @@ -24,12 +24,12 @@ On top of the features provided by subgraphs, Squid SDK and Subsquid Cloud offer - Full control over the target database (Postgres), including custom migrations and ad-hoc queries in the handler - Custom target databases and data formats (e.g. CSV) - Arbitrary code execution in the data handler -- [Extension of the GraphQL API](/sdk/reference/graphql-server/custom-resolvers) with arbitrary SQL +- [Extension of the GraphQL API](/sdk/resources/graphql-server/custom-resolvers) with arbitrary SQL - [Secret environment variables](/cloud/resources/env-variables), allowing to seamlessly use private third-party JSON-RPC endpoints and integrate with external APIs - [API versioning and aliasing](/cloud/resources/production-alias) -- [API caching](/sdk/reference/graphql-server/caching) +- [API caching](/sdk/resources/graphql-server/caching) -For a full feature set comparison, see [Subsquid vs The Graph](/sdk/resources/subsquid-vs-thegraph). +For a full feature set comparison, see [Subsquid vs The Graph](/sdk/subsquid-vs-thegraph). ## Squid setup @@ -226,5 +226,5 @@ and inspect the auto-generated GraphQL API using an interactive playground at [h - Compare your API to that of subgraph using the [compareGraphQL](https://github.com/subsquid-labs/compareGraphQL) script - Have a closer look at [`EvmBatchProcessor`](/sdk) - Learn how to [deploy a squid to Subsquid Cloud](/cloud) for free -- Learn how to [index and query the contract state](/sdk/reference/typegen/state-queries) +- Learn how to [index and query the contract state](/sdk/resources/tools/typegen/state-queries) - Inspect a more complex [Uniswap V3 squid](https://github.com/dariaag/uniswap-squid-arrow) which tracks Uniswap V3 trading data. It was migrated from the [Uniswap V3 subgraph](https://github.com/Uniswap/v3-subgraph). It takes only a few hours to sync from scratch on a local machine. diff --git a/docs/sdk/resources/migrate/migrate-to-arrowsquid-on-substrate.md b/docs/sdk/resources/migrate/migrate-to-arrowsquid-on-substrate.md index c348e2b9..2b473e7c 100644 --- a/docs/sdk/resources/migrate/migrate-to-arrowsquid-on-substrate.md +++ b/docs/sdk/resources/migrate/migrate-to-arrowsquid-on-substrate.md @@ -260,7 +260,7 @@ Note the changes: 1. Archive URL as `"specVersions"` is replaced with an URL of our new metadata service (`"https://v2.archive.subsquid.io/metadata/kusama"`) 2. Requests for data wrappers are now made on a per-pallet basis. -Check out the updated [Substrate typegen documentation page[(/sdk/tutorials/batch-processor-in-action). If you used any storage calls, consult [this documentation page](/sdk/reference/typegen/state-queries) for guidance. +Check out the updated [Substrate typegen documentation page[(/sdk/tutorials/batch-processor-in-action). If you used any storage calls, consult [this documentation page](/sdk/resources/tools/typegen/state-queries) for guidance. Once you're done migrating `typegen.json`, regenerate the wrapper classes with ```bash diff --git a/docs/sdk/resources/persisting-data/_category_.json b/docs/sdk/resources/persisting-data/_category_.json index 3a7993a2..ce7b1389 100644 --- a/docs/sdk/resources/persisting-data/_category_.json +++ b/docs/sdk/resources/persisting-data/_category_.json @@ -1,5 +1,5 @@ { - "position": 70, + "position": 10, "label": "Persisting data", "collapsible": true, "collapsed": true, diff --git a/docs/sdk/resources/substrate/_category_.json b/docs/sdk/resources/substrate/_category_.json index cd56972e..bdd18e8a 100644 --- a/docs/sdk/resources/substrate/_category_.json +++ b/docs/sdk/resources/substrate/_category_.json @@ -1,5 +1,5 @@ { - "position": 120, + "position": 31, "label": "Substrate-specific", "collapsible": true, "collapsed": true, diff --git a/docs/sdk/resources/substrate/frontier-evm.md b/docs/sdk/resources/substrate/frontier-evm.md index f1670293..a3ee3a3e 100644 --- a/docs/sdk/resources/substrate/frontier-evm.md +++ b/docs/sdk/resources/substrate/frontier-evm.md @@ -16,9 +16,9 @@ Check out the [Caveats](#caveats) section of this page to avoid common issues. This section describes additional options available for Substrate chains with the Frontier EVM pallet like Astar. On ArrowSquid, use the [frontier-evm template](https://github.com/subsquid-labs/squid-frontier-evm-template) as the starting point. -The overall approach is to use the `SubstrateBatchProcessor` methods [`addEvmLog()`](/sdk/reference/processors/substrate-batch/data-requests/#addevmlog) and [`addEthereumTransaction()`](/sdk/reference/processors/substrate-batch/data-requests/#addethereumtransaction) to request the required EVM data. The data can then be converted into a standard EVM format using the utils from [the frontier package](/sdk/reference/frontier) and decoded with utility classes [generated by `squid-evm-typegen`](/sdk/reference/typegen/generation/?typegen=evm). +The overall approach is to use the `SubstrateBatchProcessor` methods [`addEvmLog()`](/sdk/reference/processors/substrate-batch/data-requests/#addevmlog) and [`addEthereumTransaction()`](/sdk/reference/processors/substrate-batch/data-requests/#addethereumtransaction) to request the required EVM data. The data can then be converted into a standard EVM format using the utils from [the frontier package](/sdk/reference/frontier) and decoded with utility classes [generated by `squid-evm-typegen`](/sdk/resources/tools/typegen/generation/?typegen=evm). -Contract state can also be accessed via wrapped RPC queries using the [classes provided by the `squid-evm-typegen` tool](/sdk/reference/typegen/state-queries/?typegen=evm). +Contract state can also be accessed via wrapped RPC queries using the [classes provided by the `squid-evm-typegen` tool](/sdk/resources/tools/typegen/state-queries/?typegen=evm). ## Examples diff --git a/docs/sdk/resources/substrate/ink.md b/docs/sdk/resources/substrate/ink.md index 58ad3e4e..d016031c 100644 --- a/docs/sdk/resources/substrate/ink.md +++ b/docs/sdk/resources/substrate/ink.md @@ -9,7 +9,7 @@ title: ink! contracts support This section describes additional options available for indexing [ink!-based WASM contracts](https://use.ink), supported by chains with a `Contracts` pallet. At the moment of writing, AlephZero, Shibuya (Astar testnet), Shiden (Kusama parachain) and Astar (Polkadot parachain) are the most popular chains for deploying ink! contracts. -[Generate an ink! indexing squid automatically](/sdk/resources/squid-gen), follow the [WASM squid tutorial](/sdk/tutorials/ink) for a step-by-step instruction or check out the [squid-wasm-template](https://github.com/subsquid-labs/squid-wasm-template) reference project. +[Generate an ink! indexing squid automatically](/sdk/resources/tools/squid-gen), follow the [WASM squid tutorial](/sdk/tutorials/ink) for a step-by-step instruction or check out the [squid-wasm-template](https://github.com/subsquid-labs/squid-wasm-template) reference project. ## Processor configuration @@ -37,4 +37,4 @@ const processor = new SubstrateBatchProcessor() }) ``` -Generate and use the facade classes for decoding ink! smart contract data as described in the [typegens reference](/sdk/reference/typegen). You can also make [direct contract state queries](/sdk/reference/typegen/state-queries/?typegen=ink) using the `Contract` class generated by `squid-ink-typegen`. +Generate and use the facade classes for decoding ink! smart contract data as described in the [typegens reference](/sdk/resources/tools/typegen). You can also make [direct contract state queries](/sdk/resources/tools/typegen/state-queries/?typegen=ink) using the `Contract` class generated by `squid-ink-typegen`. diff --git a/docs/sdk/resources/tools/_category_.json b/docs/sdk/resources/tools/_category_.json new file mode 100644 index 00000000..e0774d18 --- /dev/null +++ b/docs/sdk/resources/tools/_category_.json @@ -0,0 +1,12 @@ +{ + "position": 40, + "label": "Tools", + "collapsible": true, + "collapsed": true, + "className": "red", + "link": { + "type": "generated-index", + "slug": "/sdk/resources/tools", + "title": "Development tools for type-safe decoding the raw data, streamlined persistence with TypeORM, and code generation." + } +} diff --git a/docs/sdk/resources/tools/migrations-gen.md b/docs/sdk/resources/tools/migrations-gen.md new file mode 100644 index 00000000..94e0171b --- /dev/null +++ b/docs/sdk/resources/tools/migrations-gen.md @@ -0,0 +1,22 @@ +--- +sidebar_position: 50 +title: TypeORM migration generation +description: Generate TypeORM models from a schema file +--- + +# TypeORM migration generation + +The [`typeorm-migration`](https://github.com/subsquid/squid-sdk/tree/master/typeorm/typeorm-migration) tool is used +to generate, apply and revert database migrations. It follows the conventions: + +* The migrations are generated in the `db/migrations` folder. +* The database connection is inferred from the `DB_XXX` environment variables. +* All entities should be exported from `lib/model` commonjs module, i.e. the entity classes must be compiled from TypeScript. + +Normally, the tool is invoked using CLI aliases defined in `commands.json`: + +``` +sqd migration:apply apply pending migrations +sqd migration:generate generate the migration for the schema defined in schema.graphql +sqd migration:clean clean the db/migrations folder +``` \ No newline at end of file diff --git a/docs/sdk/resources/tools/model-gen.md b/docs/sdk/resources/tools/model-gen.md new file mode 100644 index 00000000..3f4c927b --- /dev/null +++ b/docs/sdk/resources/tools/model-gen.md @@ -0,0 +1,26 @@ +--- +sidebar_position: 50 +title: TypeORM model generation +description: Generate TypeORM models from a schema file +--- + +# TypeORM model generation + +TypeORM entities can be automatically generated from the [schema file](/sdk/reference/schema-file) defined in `schema.graphql`. +The tool is called [`squid-typeorm-codegen(1)`](https://github.com/subsquid/squid-sdk/tree/master/typeorm/typeorm-codegen) and has no additonal options. + +Install with +```sh +npm i @subsquid/typeorm-codegen --save-dev +``` + +If `codegen` CLI alias is defined in the `commands.json` file in the project root, run: + +```sh +sqd codegen +``` + +Alternatively, run: +```sh +npx squid-typeorm-codegen +``` diff --git a/docs/sdk/resources/squid-gen.md b/docs/sdk/resources/tools/squid-gen.md similarity index 100% rename from docs/sdk/resources/squid-gen.md rename to docs/sdk/resources/tools/squid-gen.md diff --git a/docs/sdk/reference/typegen/_category_.json b/docs/sdk/resources/tools/typegen/_category_.json similarity index 75% rename from docs/sdk/reference/typegen/_category_.json rename to docs/sdk/resources/tools/typegen/_category_.json index a79fe11d..bd3df457 100644 --- a/docs/sdk/reference/typegen/_category_.json +++ b/docs/sdk/resources/tools/typegen/_category_.json @@ -1,12 +1,12 @@ { "position": 50, - "label": "Typegens", + "label": "Type-safe decoding", "collapsible": true, "collapsed": true, "className": "red", "link": { "type": "generated-index", - "slug": "/sdk/reference/typegen", + "slug": "/sdk/resources/tools/typegen", "title": "Generators of code for tech-specific tasks such as decoding and querying chains directly" } } diff --git a/docs/sdk/reference/typegen/decoding.mdx b/docs/sdk/resources/tools/typegen/decoding.mdx similarity index 100% rename from docs/sdk/reference/typegen/decoding.mdx rename to docs/sdk/resources/tools/typegen/decoding.mdx diff --git a/docs/sdk/reference/typegen/generation.mdx b/docs/sdk/resources/tools/typegen/generation.mdx similarity index 89% rename from docs/sdk/reference/typegen/generation.mdx rename to docs/sdk/resources/tools/typegen/generation.mdx index 83af59fd..9225deb1 100644 --- a/docs/sdk/reference/typegen/generation.mdx +++ b/docs/sdk/resources/tools/typegen/generation.mdx @@ -63,7 +63,7 @@ squid-evm-typegen src/abi 0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413#my-contract | | | |---------------------------|----------------------------------------------------------| -| `--multicall` | generate a facade for the MakerDAO multicall contract. May significantly improve the performance of contract state calls by [batching RPC requests](/sdk/reference/typegen/state-queries/?typegen=evm#batch-state-queries) | +| `--multicall` | generate a facade for the MakerDAO multicall contract. May significantly improve the performance of contract state calls by [batching RPC requests](/sdk/resources/tools/typegen/state-queries/?typegen=evm#batch-state-queries) | | `--etherscan-api ` | etherscan API to fetch contract ABI by a known address. By default, `https://api.etherscan.io/` | | `--clean` | delete output directory before the run | | `-h, --help` | display help for command | @@ -92,9 +92,9 @@ The generated utility modules have three intended uses: ] }) ``` -2. [Decoding of EVM logs and transactions](/sdk/reference/typegen/decoding/?typegen=evm) +2. [Decoding of EVM logs and transactions](/sdk/resources/tools/typegen/decoding/?typegen=evm) -3. [Direct chain state queries](/sdk/reference/typegen/state-queries/?typegen=evm), including [queries to multicall](/sdk/reference/typegen/state-queries/?typegen=evm#batch-state-queries). +3. [Direct chain state queries](/sdk/resources/tools/typegen/state-queries/?typegen=evm), including [queries to multicall](/sdk/resources/tools/typegen/state-queries/?typegen=evm#batch-state-queries). ```mdx-code-block @@ -184,9 +184,9 @@ All identifiers (pallet name, call name etc) are lowerCamelCased. E.g. the const 1. Item name constants (e.g. `events.balances.transfer.name`). -2. Runtime versioning-aware [decoding](/sdk/reference/typegen/decoding/?typegen=substrate). +2. Runtime versioning-aware [decoding](/sdk/resources/tools/typegen/decoding/?typegen=substrate). -3. [Chain storage queries](/sdk/reference/typegen/state-queries/?typegen=substrate) +3. [Chain storage queries](/sdk/resources/tools/typegen/state-queries/?typegen=substrate) 4. Runtime constants: ```typescript @@ -215,7 +215,7 @@ Usage: npx squid-ink-typegen --abi abi/erc20.json --output src/abi/erc20.ts ``` -The generated source code exposes the [decoding methods](/sdk/reference/typegen/decoding/?typegen=ink), some useful types and a class for performing [wrapped RPC queries](/sdk/reference/typegen/state-queries/?typegen=ink), using `@subsquid/ink-abi` under the hood +The generated source code exposes the [decoding methods](/sdk/resources/tools/typegen/decoding/?typegen=ink), some useful types and a class for performing [wrapped RPC queries](/sdk/resources/tools/typegen/state-queries/?typegen=ink), using `@subsquid/ink-abi` under the hood ```mdx-code-block diff --git a/docs/sdk/reference/typegen/state-queries.mdx b/docs/sdk/resources/tools/typegen/state-queries.mdx similarity index 99% rename from docs/sdk/reference/typegen/state-queries.mdx rename to docs/sdk/resources/tools/typegen/state-queries.mdx index 99634bdf..d1f082ae 100644 --- a/docs/sdk/reference/typegen/state-queries.mdx +++ b/docs/sdk/resources/tools/typegen/state-queries.mdx @@ -1,6 +1,6 @@ --- sidebar_position: 40 -title: Direct chain queries +title: Direct RPC queries description: >- Get chain state via wrapped RPC calls --- diff --git a/docs/sdk/resources/subsquid-vs-thegraph.md b/docs/sdk/subsquid-vs-thegraph.md similarity index 99% rename from docs/sdk/resources/subsquid-vs-thegraph.md rename to docs/sdk/subsquid-vs-thegraph.md index 9e6db1ec..88694409 100644 --- a/docs/sdk/resources/subsquid-vs-thegraph.md +++ b/docs/sdk/subsquid-vs-thegraph.md @@ -1,5 +1,5 @@ --- -sidebar_position: 110 +sidebar_position: 90 title: Subsquid vs The Graph description: Comparison of Subsquid and The Graph --- diff --git a/docs/sdk/troubleshooting/_category_.json b/docs/sdk/troubleshooting/_category_.json index 1a11db0f..9f4a421d 100644 --- a/docs/sdk/troubleshooting/_category_.json +++ b/docs/sdk/troubleshooting/_category_.json @@ -1,5 +1,5 @@ { - "position": 100, + "position": 62, "label": "Troubleshooting", "collapsible": true, "collapsed": true, diff --git a/docs/sdk/troubleshooting/graphql.md b/docs/sdk/troubleshooting/graphql.md index f96e41f5..7369d0d9 100644 --- a/docs/sdk/troubleshooting/graphql.md +++ b/docs/sdk/troubleshooting/graphql.md @@ -7,8 +7,8 @@ sidebar_position: 30 ### API queries are too slow - Make sure all the necessary fields are [indexed](/sdk/reference/schema-file/indexes-and-constraints/) -- Annotate the schema and [set reasonable limits](/sdk/reference/graphql-server/dos-protection/) for the incoming queries to protect against DoS attacks +- Annotate the schema and [set reasonable limits](/sdk/resources/graphql-server/dos-protection/) for the incoming queries to protect against DoS attacks ### `response might exceed the size limit` -Make sure the input query has limits set or the entities are decorated with `@cardinality`. We recommend using `XXXConnection` queries for pagination. For configuring limits and max response sizes, see [DoS protection](/sdk/reference/graphql-server/dos-protection/). +Make sure the input query has limits set or the entities are decorated with `@cardinality`. We recommend using `XXXConnection` queries for pagination. For configuring limits and max response sizes, see [DoS protection](/sdk/resources/graphql-server/dos-protection/). diff --git a/docs/sdk/troubleshooting/processor.md b/docs/sdk/troubleshooting/processor.md index 66cb1e0b..ccecda39 100644 --- a/docs/sdk/troubleshooting/processor.md +++ b/docs/sdk/troubleshooting/processor.md @@ -28,7 +28,7 @@ Another common source of this error is faulty RPC endpoints. If your EVM process ### `BAD_DATA` when using a Multicall contract -This error can occur for a variety of reasons, but one common cause is choosing a Multicall deployment that is newer than the oldest blocks that have to be indexed. When [batch state queries](/sdk/reference/typegen/state-queries/#batch-state-queries) are performed on historical chain state older than the Multicall deployment, EVM detects that and refuses to run. +This error can occur for a variety of reasons, but one common cause is choosing a Multicall deployment that is newer than the oldest blocks that have to be indexed. When [batch state queries](/sdk/resources/tools/typegen/state-queries/#batch-state-queries) are performed on historical chain state older than the Multicall deployment, EVM detects that and refuses to run. Solutions: 1. Use an older Multicall deployment. diff --git a/docs/sdk/tutorials/_category_.json b/docs/sdk/tutorials/_category_.json index 1a9c3f04..717073ac 100644 --- a/docs/sdk/tutorials/_category_.json +++ b/docs/sdk/tutorials/_category_.json @@ -1,5 +1,5 @@ { - "position": 40, + "position": 60, "label": "Tutorials", "collapsible": true, "collapsed": true, diff --git a/docs/sdk/tutorials/batch-processor-in-action.mdx b/docs/sdk/tutorials/batch-processor-in-action.mdx index 3a258ab6..48188998 100644 --- a/docs/sdk/tutorials/batch-processor-in-action.mdx +++ b/docs/sdk/tutorials/batch-processor-in-action.mdx @@ -16,7 +16,7 @@ import TabItem from '@theme/TabItem'; An end-to-end idiomatic usage of `EvmBatchProcessor` can be inspected in the [gravatar template repository](https://github.com/subsquid/gravatar-squid) and also learned from more elaborate [examples](/sdk/examples). -In order to illustrate the concepts covered in the [development guide](/sdk/squid-development), here we highlight the key steps, put together a processor configuration and a data handling definition. +In order to illustrate the concepts covered in the [development guide](/sdk/how-to-start/squid-development), here we highlight the key steps, put together a processor configuration and a data handling definition. ## 1. Model the target schema and generate entity classes @@ -134,7 +134,7 @@ Inspect the GraphQL API at [`http://localhost:4350/graphql`](http://localhost:43 An end-to-end idiomatic usage of `SubstrateBatchProcessor` can be inspected in the [squid-substrate-template](https://github.com/subsquid-labs/squid-substrate-template) and also learned from more elaborate [examples](/sdk/examples). -Here we highlight the key steps and put together a configuration and a data handling definition to illustrate the concepts covered in the [squid development guide](/sdk/squid-development). +Here we highlight the key steps and put together a configuration and a data handling definition to illustrate the concepts covered in the [squid development guide](/sdk/how-to-start/squid-development). ## 1. Set up the processor @@ -180,7 +180,7 @@ export const processor = new SubstrateBatchProcessor() The following code snippet illustrates how the data is extracted and normalized into some user-specific facade interface `TransferData`. Note how the data items in each of the block data iterables (`events`, `calls`, `extrinsics`) are filtered in the batch handler to make sure they match the data requests. -Type-safe access and decoding of the call and event data is done with the help of the classes generated by a suitable [typegen tool](/glossary/#typegen), in this case [squid-substrate-typegen](/sdk/reference/typegen). +Type-safe access and decoding of the call and event data is done with the help of the classes generated by a suitable [typegen tool](/glossary/#typegen), in this case [squid-substrate-typegen](/sdk/resources/tools/typegen). ```ts title="src/main.ts" import {Store} from '@subsquid/typeorm-store' diff --git a/docs/sdk/tutorials/bayc/step-four-optimizations.md b/docs/sdk/tutorials/bayc/step-four-optimizations.md index bf917ebf..7a1d1f4b 100644 --- a/docs/sdk/tutorials/bayc/step-four-optimizations.md +++ b/docs/sdk/tutorials/bayc/step-four-optimizations.md @@ -15,7 +15,7 @@ Pre-requisites: Node.js, [Subsquid CLI](/squid-cli/installation), Docker, a proj ## Using Multicall for aggregating state queries -We begin by introducing [batch processing](/sdk/resources/batch-processing/) wherever possible, and our first step is to replace individual contract state queries with [batch calls](/sdk/reference/typegen/state-queries/#batch-state-queries) to a [MakerDAO multicall contract](https://github.com/mds1/multicall). Retrieve the multicall contract ABI by re-running `squid-evm-typegen` with `--multicall` option: +We begin by introducing [batch processing](/sdk/resources/basics/batch-processing/) wherever possible, and our first step is to replace individual contract state queries with [batch calls](/sdk/resources/tools/typegen/state-queries/#batch-state-queries) to a [MakerDAO multicall contract](https://github.com/mds1/multicall). Retrieve the multicall contract ABI by re-running `squid-evm-typegen` with `--multicall` option: ```bash npx squid-evm-typegen --multicall src/abi 0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d#bayc ``` diff --git a/docs/sdk/tutorials/bayc/step-one-indexing-transfers.md b/docs/sdk/tutorials/bayc/step-one-indexing-transfers.md index 8d60fa74..d1e3cb97 100644 --- a/docs/sdk/tutorials/bayc/step-one-indexing-transfers.md +++ b/docs/sdk/tutorials/bayc/step-one-indexing-transfers.md @@ -195,7 +195,7 @@ Note a few things here: * A unique event log ID is available at `log.id` - no need to generate your own! * `tokenId` returned from the decoder is an `ethers.BigNumber`, so it has to be explicitly converted to `number`. The conversion is valid only because we know that BAYC NFT IDs run from 0 to 9999; in most cases we would use `BigInt` for the entity field type and convert with `tokenId.toBigInt()`. * `block.header` contains block metadata that we use to fill the extra fields. -* Accumulating the `Transfer` entity instances before using `ctx.store.insert()` on the whole array of them in the end allows us to get away with just one database transaction per batch. This is [crucial for achieving a good syncing performance](/sdk/resources/batch-processing/). +* Accumulating the `Transfer` entity instances before using `ctx.store.insert()` on the whole array of them in the end allows us to get away with just one database transaction per batch. This is [crucial for achieving a good syncing performance](/sdk/resources/basics/batch-processing/). At this point we have a squid that indexes the data on BAYC token transfers and is capable of serving it over a GraphQL API. Full code is available at [this commit](https://github.com/subsquid-labs/bayc-squid-1/tree/aeb6268168385cc605ce04fe09d0159f708efe47). Test it by running ```bash diff --git a/docs/sdk/tutorials/bayc/step-three-adding-external-data.md b/docs/sdk/tutorials/bayc/step-three-adding-external-data.md index 3c817128..e95d0fbd 100644 --- a/docs/sdk/tutorials/bayc/step-three-adding-external-data.md +++ b/docs/sdk/tutorials/bayc/step-three-adding-external-data.md @@ -17,7 +17,7 @@ Prerequisites: Node.js, [Subsquid CLI](/squid-cli/installation), Docker, a proje Now that we have a record for each BAYC NFT, let's explore how we can retrieve more data for each token. -[EIP-721](https://eips.ethereum.org/EIPS/eip-721) suggests that token metadata contracts may make token data available in a JSON referred to by the output of the `tokenURI()` contract function. Upon examining `src/abi/bayc.ts`, we find that the BAYC token contract implements this function. Also, the public ABI has no obvious contract methods that may set token URI or events that may be emitted on its change. In other words, it appears that the only way to retrieve this data is by [querying the contract state](/sdk/reference/typegen/state-queries/). +[EIP-721](https://eips.ethereum.org/EIPS/eip-721) suggests that token metadata contracts may make token data available in a JSON referred to by the output of the `tokenURI()` contract function. Upon examining `src/abi/bayc.ts`, we find that the BAYC token contract implements this function. Also, the public ABI has no obvious contract methods that may set token URI or events that may be emitted on its change. In other words, it appears that the only way to retrieve this data is by [querying the contract state](/sdk/resources/tools/typegen/state-queries/). This requires a RPC endpoint of an archive Ethereum node, but we do not need to add one here: processor will reuse the endpoint we [supplied in part one](../step-one-indexing-transfers/#configuring-the-data-filters) of the tutorial for use in [RPC ingestion](/sdk/overview/#rpc-ingestion). @@ -151,7 +151,7 @@ interface PartialToken { } ``` -Here, `PartialToken` stores the incomplete `Token` information obtained purely from blockchain events and function calls, before any [state queries](/sdk/reference/typegen/state-queries/) or enrichment with [external data](/sdk/resources/external-api/). +Here, `PartialToken` stores the incomplete `Token` information obtained purely from blockchain events and function calls, before any [state queries](/sdk/resources/tools/typegen/state-queries/) or enrichment with [external data](/sdk/resources/basics/external-api/). The function `completeTokens()` is responsible for filling `Token` fields that are missing in `PartialToken`s. This involves IO operations, so both the function and its caller `createTokens()` have to be asynchronous. The functions also require a batch context for state queries and logging. We modify the `createTokens()` call in the batch handler to accommodate these changes: ```diff processor.run(new TypeormDatabase(), async (ctx) => { diff --git a/docs/sdk/tutorials/bayc/step-two-deriving-owners-and-tokens.md b/docs/sdk/tutorials/bayc/step-two-deriving-owners-and-tokens.md index c5402069..d90b8a6d 100644 --- a/docs/sdk/tutorials/bayc/step-two-deriving-owners-and-tokens.md +++ b/docs/sdk/tutorials/bayc/step-two-deriving-owners-and-tokens.md @@ -99,7 +99,7 @@ Note how the entities we define form an acyclic dependency graph: As a consequence, the creation of entity instances must proceed in a [particular order](https://en.wikipedia.org/wiki/Topological_sorting). Squids usually use small graphs like this one, and in these the order can be easily found manually (e.g. `Owner`s then `Token`s then `Transfer`s in this case). We will assume that it can be hardcoded by the programmer. -Further, at each step we will [process the data for the whole batch](/sdk/resources/batch-processing/) instead of handling the items individually. This is crucial for achieving a good syncing performance. +Further, at each step we will [process the data for the whole batch](/sdk/resources/basics/batch-processing/) instead of handling the items individually. This is crucial for achieving a good syncing performance. With all that in mind, let's create a batch processor that generates and persists all of our entities: diff --git a/docs/sdk/tutorials/file-csv.md b/docs/sdk/tutorials/file-csv.md index 309782a4..93c4a373 100644 --- a/docs/sdk/tutorials/file-csv.md +++ b/docs/sdk/tutorials/file-csv.md @@ -181,7 +181,7 @@ processor.run(db, async (ctx) => { ``` :::info -The file in the GitHub repository is slightly different, as there's some added logic to obtain the number of decimals for the token. For that, the processor [interacts with the smart contract deployed on chain](/sdk/reference/typegen/state-queries). +The file in the GitHub repository is slightly different, as there's some added logic to obtain the number of decimals for the token. For that, the processor [interacts with the smart contract deployed on chain](/sdk/resources/tools/typegen/state-queries). ::: [//]: # (!!!! Consider dropping the contract state query use here) diff --git a/docs/sdk/tutorials/frontier-evm.md b/docs/sdk/tutorials/frontier-evm.md index 98b62508..3c33d7c3 100644 --- a/docs/sdk/tutorials/frontier-evm.md +++ b/docs/sdk/tutorials/frontier-evm.md @@ -16,7 +16,7 @@ A somewhat outdated version of the final result can be browsed [here](https://gi ## Pre-requisites - Familiarity with Git -- A properly set up [development environment](/sdk/resources/development-environment-set-up) consisting of Node.js, Git and Docker +- A properly set up [development environment](/sdk/how-to-start/development-environment-set-up) consisting of Node.js, Git and Docker - [Squid CLI](/squid-cli/installation) :::info @@ -105,7 +105,7 @@ The results will be stored at `src/abi`. One module will be generated for each A Subsquid SDK provides users with the [`SubstrateBatchProcessor` class](/sdk). Its instances connect to chain-specific [Subsquid archives](/subsquid-network/overview) to get chain data and apply custom transformations. The indexing begins at the starting block and keeps up with new blocks after reaching the tip. -`SubstrateBatchProcessor`s [expose methods](/sdk/reference/processors/substrate-batch) that "subscribe" them to specific data such as Substrate events and calls. There are also [specialized methods](/sdk/resources/substrate/frontier-evm) for subscribing to EVM logs and transactions by address. The actual data processing is then started by calling the `.run()` function. This will start generating requests to the Archive for [*batches*](/sdk/resources/batch-processing) of data specified in the configuration, and will trigger the callback function, or *batch handler* (passed to `.run()` as second argument) every time a batch is returned by the Archive. +`SubstrateBatchProcessor`s [expose methods](/sdk/reference/processors/substrate-batch) that "subscribe" them to specific data such as Substrate events and calls. There are also [specialized methods](/sdk/resources/substrate/frontier-evm) for subscribing to EVM logs and transactions by address. The actual data processing is then started by calling the `.run()` function. This will start generating requests to the Archive for [*batches*](/sdk/resources/basics/batch-processing) of data specified in the configuration, and will trigger the callback function, or *batch handler* (passed to `.run()` as second argument) every time a batch is returned by the Archive. It is in this callback function that all the mapping logic is expressed. This is where chain data decoding should be implemented, and where the code to save processed data on the database should be defined. diff --git a/docs/sdk/tutorials/ink.md b/docs/sdk/tutorials/ink.md index d42e9cc8..ad963a10 100644 --- a/docs/sdk/tutorials/ink.md +++ b/docs/sdk/tutorials/ink.md @@ -32,7 +32,7 @@ This tutorial uses custom scripts defined in `commands.json`. The scripts are au ## Pre-requisites - Familiarity with Git -- A properly set up [development environment](/sdk/resources/development-environment-set-up) consisting of Node.js, Git and Docker +- A properly set up [development environment](/sdk/how-to-start/development-environment-set-up) consisting of Node.js, Git and Docker - [Squid CLI](/squid-cli/installation) ## Run the template @@ -191,7 +191,7 @@ export type ProcessorContext = DataHandlerContext ## Define the batch handler -Once requested, the events can be processed by calling the `.run()` function that starts generating requests to the Archive for [*batches*](/sdk/resources/batch-processing) of data. +Once requested, the events can be processed by calling the `.run()` function that starts generating requests to the Archive for [*batches*](/sdk/resources/basics/batch-processing) of data. Every time a batch is returned by the Archive, it will trigger the callback function, or *batch handler* (passed to `.run()` as second argument). It is in this callback function that all the mapping logic is expressed. This is where chain data decoding should be implemented, and where the code to save processed data on the database should be defined. diff --git a/docs/sdk/tutorials/substrate.md b/docs/sdk/tutorials/substrate.md index 48087ced..db11207a 100644 --- a/docs/sdk/tutorials/substrate.md +++ b/docs/sdk/tutorials/substrate.md @@ -19,7 +19,7 @@ We expect that experienced software developers should be able to complete this t ## Pre-requisites - Familiarity with Git -- A properly set up [development environment](/sdk/resources/development-environment-set-up) consisting of Node.js, Git and Docker +- A properly set up [development environment](/sdk/how-to-start/development-environment-set-up) consisting of Node.js, Git and Docker - [Squid CLI](/squid-cli/installation) :::info @@ -37,7 +37,7 @@ cd substrate-crust-tutorial ### Run the project -Now you can follow the [quickstart](/sdk/squid-development) guide to get the project up and running. Here is a summary: +Now you can follow the [quickstart](/sdk/how-to-start/squid-development) guide to get the project up and running. Here is a summary: ```bash npm ci @@ -203,7 +203,7 @@ We also export the `ProcessorContext` type to be able to pass the sole argument ## Define the batch handler -Squids [batch process](/sdk/resources/batch-processing) chain data from multiple blocks. Compared to the [handlers](/sdk/resources/batch-processing/#migrate-from-handlers) approach this results in a much lower database load. Batch processing is fully defined by processor's [batch handler](/sdk/overview/#processorrun), the callback supplied to the `processor.run()` call at the entry point of each processor (`src/main.ts` by convention). +Squids [batch process](/sdk/resources/basics/batch-processing) chain data from multiple blocks. Compared to the [handlers](/sdk/resources/basics/batch-processing/#migrate-from-handlers) approach this results in a much lower database load. Batch processing is fully defined by processor's [batch handler](/sdk/overview/#processorrun), the callback supplied to the `processor.run()` call at the entry point of each processor (`src/main.ts` by convention). We begin defining our batch handler by importing the entity model classes and Crust event types that we generated in previous sections. We also import the processor and its types: diff --git a/docs/squid-cli/run.md b/docs/squid-cli/run.md index 90d79c23..b4eed98b 100644 --- a/docs/squid-cli/run.md +++ b/docs/squid-cli/run.md @@ -6,7 +6,7 @@ Run a squid locally according to the [deployment manifest](/cloud/reference/mani * [sqd run PATH](#sqd-run-path) Notes: - - The command is especially useful for running [multichain squids](/sdk/resources/multichain), as it runs all services in the same terminal and handles failures gracefully. + - The command is especially useful for running [multichain squids](/sdk/resources/basics/multichain), as it runs all services in the same terminal and handles failures gracefully. - Environment variables are read from the deployment manifest; `.env` file is ignored. - Unlike the common `commands.json` script `sqd process`, `sqd run` will neither build nor apply migrations automatically. ```bash diff --git a/docs/subsquid-network/public.md b/docs/subsquid-network/public.md index 5378a1b4..34eb96f7 100644 --- a/docs/subsquid-network/public.md +++ b/docs/subsquid-network/public.md @@ -47,7 +47,7 @@ A single account can register multiple workers. ### How do I deploy a simple squid indexer? -Start your first squid indexer in 5 minutes! Learn more [here](/sdk/squid-development). +Start your first squid indexer in 5 minutes! Learn more [here](/sdk/how-to-start/squid-development/#templates). ### What is a Subsquid Archive? diff --git a/redirectRules.js b/redirectRules.js index 0915b5f0..9c6ef4fb 100644 --- a/redirectRules.js +++ b/redirectRules.js @@ -25,15 +25,15 @@ const urlList = [ }, { "from": "/develop-a-squid/graphql-api", - "to": "/sdk/reference/graphql-server" + "to": "/sdk/resources/graphql-server" }, { "from": "/develop-a-squid/typegen/squid-substrate-typegen", - "to": "/sdk/reference/typegen" + "to": "/sdk/resources/tools/typegen" }, { "from": "/develop-a-squid/typegen/squid-evm-typegen", - "to": "/sdk/reference/typegen" + "to": "/sdk/resources/tools/typegen" }, { "from": "/develop-a-squid/evm-processor/configuration", @@ -97,11 +97,11 @@ const urlList = [ }, { "from": "/run-squid/run-in-docker", - "to": "/sdk/resources/self-hosting" + "to": "/sdk/resources/basics/self-hosting" }, { "from": "/run-squid/run-in-production", - "to": "/sdk/resources/self-hosting" + "to": "/sdk/resources/basics/self-hosting" }, { "from": "/basics/store/typeorm-store", @@ -221,15 +221,15 @@ const urlList = [ }, { "from": "/basics/batch-processing", - "to": "/sdk/resources/batch-processing" + "to": "/sdk/resources/basics/batch-processing" }, { "from": "/basics/external-api", - "to": "/sdk/resources/external-api" + "to": "/sdk/resources/basics/external-api" }, { "from": "/basics/multichain", - "to": "/sdk/resources/multichain" + "to": "/sdk/resources/basics/multichain" }, { "from": "/basics/logging", @@ -237,11 +237,11 @@ const urlList = [ }, { "from": "/basics/squid-development", - "to": "/sdk/squid-development" + "to": "/sdk/how-to-start/squid-development" }, { "from": "/basics/squid-gen", - "to": "/sdk/resources/squid-gen" + "to": "/sdk/resources/tools/squid-gen" }, { "from": "/basics/squid-processor", @@ -249,11 +249,11 @@ const urlList = [ }, { "from": "/basics/squid-structure", - "to": "/sdk/reference/layout" + "to": "/sdk/how-to-start/layout" }, { "from": "/basics/unfinalized-blocks", - "to": "/sdk/resources/unfinalized-blocks" + "to": "/sdk/resources/basics/unfinalized-blocks" }, { "from": "/deploy-squid/best-practices", @@ -309,7 +309,7 @@ const urlList = [ }, { "from": "/deploy-squid/self-hosting", - "to": "/sdk/resources/self-hosting" + "to": "/sdk/resources/basics/self-hosting" }, { "from": "/deploy-squid/troubleshooting", @@ -361,11 +361,11 @@ const urlList = [ }, { "from": "/evm-indexing/query-state", - "to": "/sdk/reference/typegen/state-queries" + "to": "/sdk/resources/tools/typegen/state-queries" }, { "from": "/evm-indexing/squid-evm-typegen", - "to": "/sdk/reference/typegen" + "to": "/sdk/resources/tools/typegen" }, { "from": "/evm-indexing/batch-processor-in-action", @@ -409,35 +409,35 @@ const urlList = [ }, { "from": "/graphql-api/authorization", - "to": "/sdk/reference/graphql-server/authorization" + "to": "/sdk/resources/graphql-server/authorization" }, { "from": "/graphql-api/caching", - "to": "/sdk/reference/graphql-server/caching" + "to": "/sdk/resources/graphql-server/caching" }, { "from": "/graphql-api/custom-resolvers", - "to": "/sdk/reference/graphql-server/custom-resolvers" + "to": "/sdk/resources/graphql-server/custom-resolvers" }, { "from": "/graphql-api/dos-protection", - "to": "/sdk/reference/graphql-server/dos-protection" + "to": "/sdk/resources/graphql-server/dos-protection" }, { "from": "/graphql-api/overview", - "to": "/sdk/reference/graphql-server/overview" + "to": "/sdk/resources/graphql-server/overview" }, { "from": "/graphql-api/subscriptions", - "to": "/sdk/reference/graphql-server/subscriptions" + "to": "/sdk/resources/graphql-server/subscriptions" }, { "from": "/graphql-api", - "to": "/sdk/reference/graphql-server" + "to": "/sdk/resources/graphql-server" }, { "from": "/migrate/subsquid-vs-thegraph", - "to": "/sdk/resources/subsquid-vs-thegraph" + "to": "/sdk/subsquid-vs-thegraph" }, { "from": "/migrate/migrate-to-arrowsquid-on-substrate", @@ -497,19 +497,19 @@ const urlList = [ }, { "from": "/quickstart/quickstart-substrate", - "to": "/sdk/squid-development" + "to": "/sdk/how-to-start/squid-development" }, { "from": "/quickstart/quickstart-ethereum", - "to": "/sdk/squid-development" + "to": "/sdk/how-to-start/squid-development" }, { "from": "/quickstart/quickstart-abi", - "to": "/sdk/resources/squid-gen" + "to": "/sdk/resources/tools/squid-gen" }, { "from": "/quickstart", - "to": "/sdk/squid-development" + "to": "/sdk/how-to-start/squid-development" }, { "from": "/store/postgres/schema-file/entities", @@ -617,11 +617,11 @@ const urlList = [ }, { "from": "/substrate-indexing/squid-substrate-typegen", - "to": "/sdk/reference/typegen" + "to": "/sdk/resources/tools/typegen" }, { "from": "/substrate-indexing/storage-state-calls", - "to": "/sdk/reference/typegen/state-queries" + "to": "/sdk/resources/tools/typegen/state-queries" }, { "from": "/substrate-indexing/context-interfaces", @@ -653,7 +653,7 @@ const urlList = [ }, { "from": "/tutorials/development-environment-set-up", - "to": "/sdk/resources/development-environment-set-up" + "to": "/sdk/how-to-start/development-environment-set-up" }, { "from": "/tutorials/case-studies",