https://github.com/kodadot/rubick
Implementation SubSquid indexer for Kusama NFTs
https://github.com/kodadot/rubick
graphql hacktoberfest indexing kusama nft polkadot polkadot-js rmrk subsquid
Last synced: 6 months ago
JSON representation
Implementation SubSquid indexer for Kusama NFTs
- Host: GitHub
- URL: https://github.com/kodadot/rubick
- Owner: kodadot
- Created: 2021-11-01T13:26:28.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-07-04T10:27:05.000Z (over 1 year ago)
- Last Synced: 2025-04-04T18:51:51.248Z (7 months ago)
- Topics: graphql, hacktoberfest, indexing, kusama, nft, polkadot, polkadot-js, rmrk, subsquid
- Language: TypeScript
- Homepage: https://github.com/kodadot/rubick
- Size: 2.07 MB
- Stars: 9
- Watchers: 3
- Forks: 15
- Open Issues: 76
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rubick

## Prerequisites
* node 16.x
* docker## Quickly running the sample
Example commands below use [make(1)](https://www.gnu.org/software/make/).
Please, have a look at commands in [Makefile](Makefile) if your platform doesn't support it.
On Windows we recommend to use [WSL](https://docs.microsoft.com/en-us/windows/wsl/).```bash
# 1. Install dependencies
npm ci# 2. Compile typescript files
make build# 3. Start target Postgres database and detach
make up# 4. Apply database migrations from db/migrations
make migrate# 5. Start the processor
make process# 6. The command above will block the terminal
# being busy with fetching the chain data,
# transforming and storing it in the target database.
#
# To start the graphql server open the separate terminal
# and run
make serve# 7. Now you can see the resuls by visiting the localhost:4350/graphql
```## Project structure
Hydra tools expect a certain directory layout:
* `src/generated` - model/server definitions created by `codegen`. Do not alter the contents of this directory manually.
* `src/server-extension` - module with custom `type-graphql` based resolvers
* `src/types` - data type definitions for chain events and extrinsics created by `typegen`.
* `src/mappings` - mapping module.
* `lib` - compiled js files. The structure of this directory must reflect `src`.
* `.env` - hydra tools are heavily driven by environment variables defined here or supplied by a shell.If you do not plan to extend GraphQl server you can delete `server-extension` module and then remove
`type-graphql` and `class-validator` dependencies.## Dev flow
### 1. Define database schema
Start development by defining the schema of the target database via `schema.graphql`.
Schema definition consists of regular graphql type declarations annotated with custom directives.
Full description of `schema.graphql` dialect is available [here](https://docs.subsquid.io/schema-file/).### 2. Generate TypeORM classes
Mapping developers use [TypeORM](https://typeorm.io) entities
to interact with the target database during data processing. All necessary entity classes are
generated by the squid framework from `schema.graphql`. This is done by running `npx squid-typeorm-codegen`
command.### 3. Generate database migration
All database changes are applied through migration files located at `db/migrations`.
`squid-typeorm-migration(1)` tool provides several commands to drive the process.
It is all [TypeORM](https://typeorm.io/#/migrations) under the hood.```bash
# Connect to database, analyze its state and generate migration to match the target schema.
# The target schema is derived from entity classes generated earlier.
# Don't forget to compile your entity classes beforehand!
npx squid-typeorm-migration generate# Create template file for custom database changes
npx squid-typeorm-migration create# Apply database migrations from `db/migrations`
npx squid-typeorm-migration apply# Revert the last performed migration
npx squid-typeorm-migration revert
```## Setting up the project for resolvers
In case you just want to extend resolvers you don't index the whole project and just import the postgres database (last data 29.03.2023):
1. [Contact @vikiival on Discord](https://discord.gg/yfeumhRCuw)
2. `docker-compose up db`
3. `docker exec -it rubick-db-1 psql -U postgres -d postgres -c "CREATE DATABASE squid;"`
4. `docker exec -i rubick-db-1 psql -U postgres -d squid < rubick.sql`⚠️ In case the command does not work, check if the container is called `rubick-db-1`.
## Misc
For more details, please check out https://docs.subsquid.io.