Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript manifest #421

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 81 additions & 2 deletions docs/build/manifest/polkadot.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,88 @@

The Manifest `project.yaml` file can be seen as an entry point of your project and it defines most of the details on how SubQuery will index and transform the chain data. It clearly indicates where we are indexing data from, and to what on chain events we are subscribing to.

The Manifest can be in either YAML or JSON format. In this document, we will use YAML in all the examples.
The Manifest can be in either TYPESCRIPT, YAML or JSON format.

### Typescript Manifest
The project manifest can be more complex when we add more features it gets very hard to know how to write. It's now possible to write your manifest in typescript.
This means that you get a fully typed project manifest with documentation and examples in your editor.

Below is a standard example of a basic `project.ts`.

```typescript
// This require @subql/types version 3.0.1 or later
import { SubstrateDatasourceKind, SubstrateHandlerKind, SubstrateProject } from "@subql/types";

const project: SubstrateProject = {
specVersion: "1.0.0",
version: '1.0.0',
description: "This project can be use as a starting point for developing your Polkadot based SubQuery project",
repository: "https://github.com/subquery/subql-starter",
name:"subquery-starter",
runner: {
node: {
name: '@subql/node',
version: "*",
},
query: {
name: '@subql/query',
version: "*"
},
},
schema: {
file: './schema.graphql'
},
network: {
chainId: '0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3',
bypassBlocks: [5, '1-10'],
endpoint: 'wss://polkadot.api.onfinality.io/public-ws'
},
dataSources: [
{
kind: SubstrateDatasourceKind.Runtime,
startBlock: 1,
mapping: {
file: './dist/index.js',
handlers: [
{
kind: SubstrateHandlerKind.Block,
handler: 'handleBlock',
filter: {
modulo: 5,
}
},
{
kind: SubstrateHandlerKind.Call,
handler: 'handleCall',
filter: {
module: 'balances',
method: 'Deposit',
success: true,
}
},
{
kind: SubstrateHandlerKind.Event,
handler: 'handleEvent',
filter: {
module: 'balances',
method: 'Deposit',
}
}
]
}
}
],
}

// Must set default to the project instance
export default project;
```

Unlike create a YAML-formatted manifest, after editing of a TypeScript-formatted manifest, we need to execute the subql CLI (4.0.0 or later) [build command]() to automatically generate a compiled project object, and this object will be written into a YAML file with the same name.
For example, if you provide "polkadot-project.ts," the generated file will be "polkadot-project.yaml."

Below is a standard example of a basic `project.yaml`.
### Yaml Manifest
Another example written in YAML format.

```yml
specVersion: 1.0.0
Expand Down
Loading