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

frontier -> multi-chain #115

Merged
merged 4 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
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
34 changes: 21 additions & 13 deletions Astar/astar-evm-starter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

[SubQuery](https://subquery.network) is a fast, flexible, and reliable open-source data indexer that provides you with custom APIs for your web3 project across all of our supported networks. To learn about how to get started with SubQuery, [visit our docs](https://academy.subquery.network).

**This SubQuery project indexes all transfers and approval events for all ERC20 tokens on Astar's EVM**
**This SubQuery project indexes all transfers and approval events for all ERC20 tokens on Astar's EVM as well as transfers related to Substrate.**

**In order to index both Substrate and EVM, we run this as a [multi-chain project](https://academy.subquery.network/build/multi-chain.html). You may decide to delete one manifest (`.yaml`) file in order to run this as a single chain project.**

## Start

Expand Down Expand Up @@ -41,26 +43,32 @@ For this project, you can try to query with the following GraphQL code to get a
```graphql
{
query {
transactions(first: 5, orderBy: VALUE_DESC) {
totalCount
eRC20TokenTransfers(first: 3) {
nodes {
id
transactionHash
blockHeight
from
to
value
contractAddress
}
}
}
approvals(first: 5) {
nodes {
id
owner
spender
value
contractAddress
eRC20Approvals(first: 3) {
nodes {
id
value
owner
spender
contractAddress
}
}
substrateTransfers(first: 3) {
nodes {
id
from
to
amount
date
}
}
}
}
Expand Down
56 changes: 43 additions & 13 deletions Astar/astar-evm-starter/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,38 @@ services:
timeout: 5s
retries: 5

subquery-node:
subquery-node-evm:
image: subquerynetwork/subql-node-ethereum:latest
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:
- --multi-chain
- --db-schema=multi-chain
- --disable-historical
- -f=app/evm.yaml
- --batch-size=30
- --workers=4
healthcheck:
test:
- CMD
- curl
- -f
- http://subquery-node-ethereum:3000/ready
interval: 3s
timeout: 5s
retries: 10

subquery-node-substrate:
image: subquerynetwork/subql-node-substrate:latest
depends_on:
"postgres":
Expand All @@ -32,14 +63,16 @@ services:
volumes:
- ./:/app
command:
- ${SUB_COMMAND:-} # set SUB_COMMAND env variable to "test" to run tests
- -f=/app
- --db-schema=app
- --workers=4
- --batch-size=30
- --unfinalized-blocks=true
- -f=app/substrate.yaml
- --multi-chain
- --db-schema=multi-chain
- --disable-historical
healthcheck:
test: ["CMD", "curl", "-f", "http://subquery-node:3000/ready"]
test:
- CMD
- curl
- -f
- http://subquery-node-project-kusama:3000/ready
interval: 3s
timeout: 5s
retries: 10
Expand All @@ -51,16 +84,13 @@ services:
depends_on:
"postgres":
condition: service_healthy
"subquery-node":
condition: service_healthy
restart: always
restart: unless-stopped
environment:
DB_USER: postgres
DB_PASS: postgres
DB_DATABASE: postgres
DB_HOST: postgres
DB_PORT: 5432
command:
- --name=app
- --name=multi-chain
- --playground
- --indexer=http://subquery-node:3000
41 changes: 41 additions & 0 deletions Astar/astar-evm-starter/evm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# // Auto-generated , DO NOT EDIT
specVersion: 1.0.0
version: 0.0.1
name: astar-evm-starter
description: >-
This project can be use as a starting point for developing your new Ethereum
SubQuery project
runner:
node:
name: "@subql/node-ethereum"
version: ">=3.0.0"
query:
name: "@subql/query"
version: "*"
schema:
file: ./schema.graphql
network:
chainId: "592"
endpoint:
- wss://astar.api.onfinality.io/public-ws
- wss://rpc.astar.network
dataSources:
- kind: ethereum/Runtime
startBlock: 970733
options:
abi: erc20
assets:
erc20:
file: ./abis/erc20.abi.json
mapping:
file: ./dist/index.js
handlers:
- handler: handleEVMLog
kind: ethereum/LogHandler
filter:
topics:
- Transfer(address indexed from,address indexed to,uint256 value)
- handler: handleEVMTransaction
kind: ethereum/TransactionHandler
filter:
function: approve(address to,uint256 value)
19 changes: 10 additions & 9 deletions Astar/astar-evm-starter/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "astar-evm-starter",
"version": "1.0.0",
"description": "A basic Frontier EVM example project with an event and call handler. Read more about this at https://university.subquery.network/create/frontier/. This project can be use as a starting point for developing your SubQuery project",
"description": "A basic EVM example project with an event and call handler. Read more about this at https://academy.subquery.network/build/substrate-evm.html. This project can be use as a starting point for developing your SubQuery project",
"main": "dist/index.js",
"scripts": {
"build": "subql build",
Expand All @@ -24,19 +24,20 @@
"ipfs-unixfs": "6.0.6"
},
"devDependencies": {
"@polkadot/api": "^10",
"@subql/cli": "latest",
"@subql/frontier-evm-processor": "latest",
"@subql/node": "latest",
"@subql/testing": "latest",
"@subql/types": "latest",
"@subql/types-ethereum": "latest",
"typescript": "^5.2.2"
"@subql/testing": "latest",
"@subql/node-ethereum": "latest",
"ethers": "^5.7.2",
"@polkadot/api": "^10",
"typescript": "^5.2.2",
"@subql/node": "latest"
},
"exports": {
"chaintypes": "src/chaintypes.ts"
},
"dependencies": {
"assert": "^2.0.0"
"assert": "^2.0.0",
"@subql/types-ethereum": "latest"
}
}
}
88 changes: 0 additions & 88 deletions Astar/astar-evm-starter/project.ts

This file was deleted.

31 changes: 21 additions & 10 deletions Astar/astar-evm-starter/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
type Transaction @entity {
id: ID! # Unique identifier
transactionHash: String!
value: BigInt
to: String
from: String
blockHeight: String
# To improve query performance, we strongly suggest adding indexes to any field that you plan to filter or sort by
# Add the `@index` or `@index(unique: true)` annotation after any non-key field
# https://academy.subquery.network/build/graphql.html#indexing-by-non-primary-key-field

type ERC20TokenTransfer @entity {
id: ID!
value: BigInt!
to: String!
from: String!
contractAddress: String!
}

type Approval @entity {
id: ID! # Unique identifier
value: BigInt
type ERC20Approval @entity {
id: ID!
value: BigInt!
owner: String!
spender: String!
contractAddress: String!
}

type SubstrateTransfer @entity {
id: ID!
amount: BigInt!
blockNumber: Int!
date: Date!
from: String!
to: String!
}
Loading
Loading