Skip to content

btn-group/squid-safe-send

Repository files navigation

Squid Safe Send

This squid tracks the events of the Safe Send smart contract on the Aleph Zero Testnet and serves them via graphql API.

Getting Started

Prerequisites

  • Node.js
  • Docker
  • @subsquid/cli
npm i -g @subsquid/cli

Running locally

# 1. Install dependencies
npm ci

# 2. Start a Postgres database container and detach
sqd up

# 3. Start the processor
sqd process

# 4. Start the graphql server in a new tab
sqd serve

# 5. Access via http://localhost:4350/graphql

Deployment

Update squid.yaml and deploy as per this.

# add --hard-reset if you want to drop and re-create all the squid resources including the database.
sqd deploy --org btngroup ../squid-safe-send --hard-reset

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.

2. Generate TypeORM classes

Mapping developers use TypeORM EntityManager to interact with target database during data processing. All necessary entity classes are generated by the squid framework from schema.graphql. This is done by running sqd codegen command.

3. Generate database migrations

All database changes are applied through migration files located at db/migrations. squid-typeorm-migration(1) tool provides several commands to drive the process.

## drop create the database
sqd down
sqd up

## replace any old schemas with a new one made from the entities
sqd migration:generate

See docs on database migrations for more details.

4. Import ABI contract and generate interfaces to decode events

npx squid-ink-typegen --abi abi/safe_send.json --output src/abi/safe_send.ts

5. Checking code

npm run lint

References

  1. https://docs.subsquid.io/firesquid/tutorials/create-a-wasm-processing-squid/
  2. https://docs.subsquid.io/firesquid/substrate-indexing/
  3. Entity relations
  4. Project conventions
  5. [Graphql JSON body converter]https://datafetcher.com/graphql-json-body-converter
  6. Squid Ink template (Arrowsquid)

About

Subsquid for indexing Safe Send smart contract

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published