Coder Social home page Coder Social logo

subsquid-labs / squid-frontier-evm-template Goto Github PK

View Code? Open in Web Editor NEW
6.0 5.0 8.0 774 KB

A template squid for Frontier EVM chains: Moonriver, Moonbeam, Astar

License: GNU General Public License v3.0

Shell 0.70% Dockerfile 2.36% JavaScript 5.82% TypeScript 91.13%
moonriver moonsama

squid-frontier-evm-template's Introduction

Frontier EVM squid template

This is a template squid for indexing EVM contracts deployed to chains with Frontier EVM support (Moonbeam, Moonriver, Shiden, Astar). This template indexes token transfers on the Moonriver network and serves them via GraphQL API.

For more details, consult the Squid SDK docs

Dependencies: Node.js v16 or newer, Git, Docker.

Quickstart

# 0. Install @subsquid/cli a.k.a. the sqd command globally
npm i -g @subsquid/cli

# 1. Retrieve the template
sqd init my_squid_name -t frontier-evm
cd my_squid_name

# 2. Install dependencies
npm ci

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

# 4. Build the project
sqd build

# 5. Start both the squid processor and the GraphQL server
sqd run .

A GraphiQL playground will be available at localhost:4350/graphql.

You can also start squid services one by one:

sqd process
sqd serve

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

It is necessary to import the respective ABI definition to decode EVM logs. For Moonsama transfers we use the standard ERC721 interface, see abi/erc721.json.

To generate a type-safe facade class to decode EVM logs, use squid-evm-typegen(1):

sqd typegen

See more details on the squid-evm-typegen doc page

Project conventions

Squid tools assume a certain project layout:

  • All compiled js files must reside in lib and all TypeScript sources in src. The layout of lib must reflect src.
  • All TypeORM classes must be exported by src/model/index.ts (lib/model module).
  • Database schema must be defined in schema.graphql.
  • Database migrations must reside in db/migrations and must be plain js files.
  • sqd(1) and squid-*(1) executables consult .env file for environment variables.

squid-frontier-evm-template's People

Contributors

abernatskiy avatar belopash avatar dzhelezov avatar raekwoniii avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

squid-frontier-evm-template's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Location: renovate.json
Error type: Invalid JSON (parsing failed)
Message: Syntax error: expecting String near ], // "a

No ethers on dependency file package.json

It does not have the ethers library on package.json while the abi files that generated with typegen are using ethersjs.

the code that uses ethers

import * as ethers from 'ethers'
import {LogEvent, Func, ContractBase} from './abi.support'
import {ABI_JSON} from './erc721.abi'
export const abi = new ethers.Interface(ABI_JSON);

the package.json

"dependencies": {
"@subsquid/archive-registry": "^3.1.0",
"@subsquid/frontier": "^0.2.0",
"@subsquid/graphql-server": "^3.3.2",
"@subsquid/ss58": "^0.1.4",
"@subsquid/substrate-processor": "^2.4.1",
"@subsquid/typeorm-migration": "^0.1.6",
"@subsquid/typeorm-store": "^0.2.2",
"dotenv": "^16.0.0",
"pg": "8.9.0",
"typeorm": "^0.3.17"
},
"devDependencies": {
"@subsquid/evm-typegen": "^3.2.0",
"@subsquid/substrate-metadata-explorer": "^1.1.2",
"@subsquid/substrate-typegen": "^2.2.1",
"@subsquid/typeorm-codegen": "^0.3.3",
"@types/node": "^18.11.18",
"typescript": "^4.9.5"
}

please correct me if im wrong and this is intentional. Thanks!

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: File contents are invalid JSON but parse using JSON5. Support for this will be removed in a future release so please change to a support .json5 file name or ensure correct JSON syntax.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

docker-compose
docker-compose.yml
dockerfile
Dockerfile
npm
package.json
  • @subsquid/frontier ^4.0.3
  • @subsquid/graphql-server ^4.5.1
  • @subsquid/ss58 ^2.0.2
  • @subsquid/substrate-processor ^8.3.0
  • @subsquid/typeorm-migration ^1.3.0
  • @subsquid/typeorm-store ^1.4.0
  • @subsquid/evm-typegen ^3.3.0
  • @subsquid/substrate-metadata-explorer ^3.1.2
  • @subsquid/substrate-typegen ^8.1.0
  • @subsquid/typeorm-codegen ^2.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.