-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add crab parachain * crab->crabparachain * update genesis hash * repair token * update subql url * some config * enable crab parachain * filter event * repair target hash Co-authored-by: sxlwar <[email protected]>
- Loading branch information
Showing
23 changed files
with
6,880 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
SUBSTRATE_SUBSTRATE_BACKING=https://api.subquery.network/sq/helix-bridge/darwinia | ||
SUBSTRATE_SUBSTRATE_ISSUING=https://crab-thegraph.darwinia.network/subgraphs/name/wormhole/Sub2SubMappingTokenFactory | ||
SUBSTRATE_DVM_ENDPOINT=https://api.subquery.network/sq/helix-bridge/crab | ||
CHAIN_TYPE=formal | ||
SUBSTRATE_TO_PARACHAIN_BACKING=https://api.subquery.network/sq/helix-bridge/crab | ||
SUBSTRATE_TO_PARACHAIN_ISSUING=https://api.subquery.network/sq/helix-bridge/cpchain | ||
CHAIN_TYPE=formal | ||
PARACHAIN_LOCK_FEE_TOKEN=Crab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT LICENSE | ||
|
||
Copyright 2020-2021 OnFinality Limited authors & contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# SubQuery - Starter Package | ||
|
||
|
||
The Starter Package is an example that you can use as a starting point for developing your SubQuery project. | ||
A SubQuery package defines which data The SubQuery will index from the Substrate blockchain, and how it will store it. | ||
|
||
## Preparation | ||
|
||
#### Environment | ||
|
||
- [Typescript](https://www.typescriptlang.org/) are required to compile project and define types. | ||
|
||
- Both SubQuery CLI and generated Project have dependencies and require [Node](https://nodejs.org/en/). | ||
|
||
|
||
#### Install the SubQuery CLI | ||
|
||
Install SubQuery CLI globally on your terminal by using NPM: | ||
|
||
``` | ||
npm install -g @subql/cli | ||
``` | ||
|
||
Run help to see available commands and usage provide by CLI | ||
``` | ||
subql help | ||
``` | ||
|
||
## Initialize the starter package | ||
|
||
Inside the directory in which you want to create the SubQuery project, simply replace `project-name` with your project name and run the command: | ||
``` | ||
subql init --starter project-name | ||
``` | ||
Then you should see a folder with your project name has been created inside the directory, you can use this as the start point of your project. And the files should be identical as in the [Directory Structure](https://doc.subquery.network/directory_structure.html). | ||
|
||
Last, under the project directory, run following command to install all the dependency. | ||
``` | ||
yarn install | ||
``` | ||
|
||
|
||
## Configure your project | ||
|
||
In the starter package, we have provided a simple example of project configuration. You will be mainly working on the following files: | ||
|
||
- The Manifest in `project.yaml` | ||
- The GraphQL Schema in `schema.graphql` | ||
- The Mapping functions in `src/mappings/` directory | ||
|
||
For more information on how to write the SubQuery, | ||
check out our doc section on [Define the SubQuery](https://doc.subquery.network/define_a_subquery.html) | ||
|
||
#### Code generation | ||
|
||
In order to index your SubQuery project, it is mandatory to build your project first. | ||
Run this command under the project directory. | ||
|
||
```` | ||
yarn codegen | ||
```` | ||
|
||
## Build the project | ||
|
||
In order to deploy your SubQuery project to our hosted service, it is mandatory to pack your configuration before upload. | ||
Run pack command from root directory of your project will automatically generate a `your-project-name.tgz` file. | ||
|
||
``` | ||
yarn build | ||
``` | ||
|
||
## Indexing and Query | ||
|
||
#### Run required systems in docker | ||
|
||
|
||
Under the project directory run following command: | ||
|
||
``` | ||
docker-compose pull && docker-compose up | ||
``` | ||
#### Query the project | ||
|
||
Open your browser and head to `http://localhost:3000`. | ||
|
||
Finally, you should see a GraphQL playground is showing in the explorer and the schemas that ready to query. | ||
|
||
For the `subql-starter` project, you can try to query with the following code to get a taste of how it works. | ||
|
||
````graphql | ||
{ | ||
query{ | ||
starterEntities(first:10){ | ||
nodes{ | ||
field1, | ||
field2, | ||
field3 | ||
} | ||
} | ||
} | ||
} | ||
```` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
version: '3' | ||
|
||
services: | ||
postgres: | ||
image: postgres:12-alpine | ||
ports: | ||
- 5432:5432 | ||
volumes: | ||
- .data/postgres:/var/lib/postgresql/data | ||
environment: | ||
POSTGRES_PASSWORD: postgres | ||
healthcheck: | ||
test: ['CMD-SHELL', 'pg_isready -U postgres'] | ||
interval: 5s | ||
timeout: 5s | ||
retries: 10 | ||
|
||
subquery-node: | ||
image: onfinality/subql-node:v0.27.2-0 | ||
depends_on: | ||
'postgres': | ||
condition: service_healthy | ||
restart: always | ||
environment: | ||
DB_USER: postgres | ||
DB_PASS: postgres | ||
DB_DATABASE: postgres | ||
DB_HOST: postgres | ||
DB_PORT: 5432 | ||
volumes: | ||
- ./:/app | ||
command: | ||
- -f=/app | ||
- --db-schema=app | ||
healthcheck: | ||
test: ['CMD', 'curl', '-f', 'http://subquery-node:3000/ready'] | ||
interval: 3s | ||
timeout: 5s | ||
retries: 10 | ||
|
||
graphql-engine: | ||
image: onfinality/subql-query:v0.10.1-0 | ||
ports: | ||
- 3000:3000 | ||
depends_on: | ||
'postgres': | ||
condition: service_healthy | ||
'subquery-node': | ||
condition: service_healthy | ||
restart: always | ||
environment: | ||
DB_USER: postgres | ||
DB_PASS: postgres | ||
DB_DATABASE: postgres | ||
DB_HOST: postgres | ||
DB_PORT: 5432 | ||
command: | ||
- --name=app | ||
- --playground | ||
- --indexer=http://subquery-node:3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "crab-parachain", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"build": "tsc -b", | ||
"prepack": "rm -rf dist && npm build", | ||
"test": "jest", | ||
"start": "docker-compose pull && docker-compose up --remove-orphans", | ||
"codegen": "./node_modules/.bin/subql codegen" | ||
}, | ||
"homepage": "https://github.com/subquery/subql-starter", | ||
"repository": "github:subquery/subql-starter", | ||
"resolutions": { | ||
"ipfs-unixfs": "6.0.6" | ||
}, | ||
"files": [ | ||
"dist", | ||
"schema.graphql", | ||
"project.yaml" | ||
], | ||
"author": "xiaoch05", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@polkadot/api": "^8", | ||
"@subql/types": "latest", | ||
"typescript": "^4.2.4", | ||
"@subql/cli": "latest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
specVersion: 0.2.0 | ||
name: helix-crab-parachain | ||
version: 1.0.0 | ||
description: '' | ||
repository: [email protected]:helix-bridge/indexer.git | ||
|
||
schema: | ||
file: ./schema.graphql | ||
|
||
network: | ||
genesisHash: '0xeac895d7768b17837a9c3a9f0280c01502c3ef40193df923490a0fa9c60ea076' | ||
endpoint: wss://crab-parachain-rpc.darwinia.network | ||
chaintypes: | ||
file: ./types.yaml | ||
|
||
dataSources: | ||
- kind: substrate/Runtime | ||
startBlock: 535900 | ||
mapping: | ||
file: ./dist/index.js | ||
handlers: | ||
- handler: handleEvent | ||
kind: substrate/EventHandler | ||
filter: | ||
module: bridgeCrabDispatch | ||
method: MessageVersionSpecMismatch | ||
|
||
- handler: handleEvent | ||
kind: substrate/EventHandler | ||
filter: | ||
module: bridgeCrabDispatch | ||
method: MessageWeightMismatch | ||
|
||
- handler: handleEvent | ||
kind: substrate/EventHandler | ||
filter: | ||
module: bridgeCrabDispatch | ||
method: MessageDispatched | ||
|
||
- handler: handleEvent | ||
kind: substrate/EventHandler | ||
filter: | ||
module: bridgeCrabDispatch | ||
method: MessageCallValidateFailed | ||
|
||
- handler: handleEvent | ||
kind: substrate/EventHandler | ||
filter: | ||
module: fromCrabIssuing | ||
method: TokenBurnAndRemoteUnlocked | ||
|
||
- handler: handleEvent | ||
kind: substrate/EventHandler | ||
filter: | ||
module: fromCrabIssuing | ||
method: TokenUnlockedConfirmed | ||
|
Oops, something went wrong.