Skip to content

Commit 7fec7c2

Browse files
committed
Ethscriptions Example Added
1 parent 80e0fcd commit 7fec7c2

17 files changed

+522
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: "CLI deploy"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
projectName:
7+
description: "Project name"
8+
required: true
9+
type: string
10+
jobs:
11+
deploy:
12+
name: CLI Deploy
13+
runs-on: ubuntu-latest
14+
environment:
15+
name: DEPLOYMENT
16+
env:
17+
SUBQL_ACCESS_TOKEN: ${{ secrets.SUBQL_ACCESS_TOKEN }}
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: Setup Node.js environment
21+
uses: actions/setup-node@v2
22+
with:
23+
node-version: 16
24+
- run: yarn
25+
- name: Codegen
26+
run: yarn codegen
27+
- name: Version
28+
run: npx subql --version
29+
- name: repo
30+
run: echo ${{github.repository}}
31+
- name: Publish and Deploy
32+
run: |
33+
sh .github/workflows/scripts/publish-deploy.sh -o ${{github.repository}} -p ${{github.event.inputs.projectName}}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: PR
2+
on:
3+
pull_request:
4+
paths-ignore:
5+
- ".github/workflows/**"
6+
jobs:
7+
pr:
8+
name: pr
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Setup Node.js environment
13+
uses: actions/setup-node@v2
14+
with:
15+
node-version: 16
16+
- run: yarn
17+
- name: Codegen
18+
run: yarn codegen
19+
- name: Build
20+
run: yarn build
21+
- name: Install subql-node-ethereum
22+
run: yarn global add @subql/node-ethereum
23+
- name: Run tests with Subquery Node
24+
run: subql-node-ethereum test -f ${{ github.workspace }}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
while getopts p:o: flag
4+
do
5+
case "${flag}" in
6+
p) PROJECTNAME=${OPTARG};;
7+
o) ORG=${OPTARG};;
8+
*) echo "Usage: $0 [-p projectname] [-o org]" && exit 1;;
9+
esac
10+
done
11+
12+
IPFSCID=$(npx subql publish -o -f .)
13+
14+
npx subql deployment:deploy -d --ipfsCID="$IPFSCID" --projectName="${PROJECTNAME}" --org="${ORG%/*}"

Ethereum/ethscriptions/.gitignore

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# These are some examples of commonly ignored file patterns.
2+
# You should customize this list as applicable to your project.
3+
# Learn more about .gitignore:
4+
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore
5+
6+
# Node artifact files
7+
node_modules/
8+
dist/
9+
10+
# lock files
11+
yarn.lock
12+
package-lock.json
13+
14+
# Compiled Java class files
15+
*.class
16+
17+
# Compiled Python bytecode
18+
*.py[cod]
19+
20+
# Log files
21+
*.log
22+
23+
# Package files
24+
*.jar
25+
26+
# Generated files
27+
target/
28+
dist/
29+
src/types
30+
project.yaml
31+
32+
# JetBrains IDE
33+
.idea/
34+
35+
# Unit test reports
36+
TEST*.xml
37+
38+
# Generated by MacOS
39+
.DS_Store
40+
41+
# Generated by Windows
42+
Thumbs.db
43+
44+
# Applications
45+
*.app
46+
*.exe
47+
*.war
48+
49+
# Large media files
50+
*.mp4
51+
*.tiff
52+
*.avi
53+
*.flv
54+
*.mov
55+
*.wmv
56+
57+
.data
58+
.yarn
59+
60+
.DS_Store

Ethereum/ethscriptions/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT LICENSE
2+
3+
Copyright 2020-2021 SubQuery Pte Ltd authors & contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Ethereum/ethscriptions/README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# SubQuery - Example Project for Ethereum
2+
3+
[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).
4+
5+
**This SubQuery project indexes inscriptions on Ethereum Mainnet**
6+
7+
## Start
8+
9+
First, install SubQuery CLI globally on your terminal by using NPM `npm install -g @subql/cli`
10+
11+
You can either clone this GitHub repo, or use the `subql` CLI to bootstrap a clean project in the network of your choosing by running `subql init` and following the prompts.
12+
13+
Don't forget to install dependencies with `npm install` or `yarn install`!
14+
15+
## Editing your SubQuery project
16+
17+
Although this is a working example SubQuery project, you can edit the SubQuery project by changing the following files:
18+
19+
- The project manifest in `project.ts` defines the key project configuration and mapping handler filters
20+
- The GraphQL Schema (`schema.graphql`) defines the shape of the resulting data that you are using SubQuery to index
21+
- The Mapping functions in `src/mappings/` directory are typescript functions that handle transformation logic
22+
23+
SubQuery supports various layer-1 blockchain networks and provides [dedicated quick start guides](https://academy.subquery.network/quickstart/quickstart.html) as well as [detailed technical documentation](https://academy.subquery.network/build/introduction.html) for each of them.
24+
25+
## Run your project
26+
27+
_If you get stuck, find out how to get help below._
28+
29+
The simplest way to run your project is by running `yarn dev` or `npm run-script dev`. This does all of the following:
30+
31+
1. `yarn codegen` - Generates types from the GraphQL schema definition and contract ABIs and saves them in the `/src/types` directory. This must be done after each change to the `schema.graphql` file or the contract ABIs
32+
2. `yarn build` - Builds and packages the SubQuery project into the `/dist` directory
33+
3. `docker-compose pull && docker-compose up` - Runs a Docker container with an indexer, PostgeSQL DB, and a query service. This requires [Docker to be installed](https://docs.docker.com/engine/install) and running locally. The configuration for this container is set from your `docker-compose.yml`
34+
35+
You can observe the three services start, and once all are running (it may take a few minutes on your first start), please open your browser and head to [http://localhost:3000](http://localhost:3000) - you should see a GraphQL playground showing with the schemas ready to query. [Read the docs for more information](https://academy.subquery.network/run_publish/run.html) or [explore the possible service configuration for running SubQuery](https://academy.subquery.network/run_publish/references.html).
36+
37+
## Query your project
38+
39+
For this project, you can try to query with the following GraphQL code to get a taste of how it works.
40+
41+
```graphql
42+
{
43+
query {
44+
inscriptions {
45+
nodes {
46+
id
47+
block
48+
creator
49+
data
50+
}
51+
}
52+
}
53+
}
54+
```
55+
56+
You can explore the different possible queries and entities to help you with GraphQL using the documentation draw on the right.
57+
58+
## Publish your project
59+
60+
SubQuery is open-source, meaning you have the freedom to run it in the following three ways:
61+
62+
- Locally on your own computer (or a cloud provider of your choosing), [view the instructions on how to run SubQuery Locally](https://academy.subquery.network/run_publish/run.html)
63+
- By publishing it to our enterprise-level [Managed Service](https://managedservice.subquery.network), where we'll host your SubQuery project in production ready services for mission critical data with zero-downtime blue/green deployments. We even have a generous free tier. [Find out how](https://academy.subquery.network/run_publish/publish.html)
64+
- [Coming Soon] By publishing it to the decentralised [SubQuery Network](https://subquery.network/network), the most open, performant, reliable, and scalable data service for dApp developers. The SubQuery Network indexes and services data to the global community in an incentivised and verifiable way
65+
66+
## What Next?
67+
68+
Take a look at some of our advanced features to take your project to the next level!
69+
70+
- [**Multi-chain indexing support**](https://academy.subquery.network/build/multi-chain.html) - SubQuery allows you to index data from across different layer-1 networks into the same database, this allows you to query a single endpoint to get data for all supported networks.
71+
- [**Dynamic Data Sources**](https://academy.subquery.network/build/dynamicdatasources.html) - When you want to index factory contracts, for example on a DEX or generative NFT project.
72+
- [**Project Optimisation Advice**](https://academy.subquery.network/build/optimisation.html) - Some common tips on how to tweak your project to maximise performance.
73+
- [**GraphQL Subscriptions**](https://academy.subquery.network/run_publish/subscription.html) - Build more reactive front end applications that subscribe to changes in your SubQuery project.
74+
75+
## Need Help?
76+
77+
The fastest way to get support is by [searching our documentation](https://academy.subquery.network), or by [joining our discord](https://discord.com/invite/subquery) and messaging us in the `#technical-support` channel.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
version: "3"
2+
3+
services:
4+
postgres:
5+
build:
6+
context: .
7+
dockerfile: ./docker/pg-Dockerfile
8+
ports:
9+
- 5432:5432
10+
volumes:
11+
- .data/postgres:/var/lib/postgresql/data
12+
environment:
13+
POSTGRES_PASSWORD: postgres
14+
healthcheck:
15+
test: ["CMD-SHELL", "pg_isready -U postgres"]
16+
interval: 5s
17+
timeout: 5s
18+
retries: 5
19+
20+
subquery-node:
21+
image: subquerynetwork/subql-node-ethereum:latest
22+
depends_on:
23+
"postgres":
24+
condition: service_healthy
25+
restart: always
26+
environment:
27+
DB_USER: postgres
28+
DB_PASS: postgres
29+
DB_DATABASE: postgres
30+
DB_HOST: postgres
31+
DB_PORT: 5432
32+
volumes:
33+
- ./:/app
34+
command:
35+
- ${SUB_COMMAND:-} # set SUB_COMMAND env variable to "test" to run tests
36+
- -f=/app
37+
- --db-schema=app
38+
- --workers=4
39+
- --batch-size=30
40+
- --unfinalized-blocks=true
41+
42+
healthcheck:
43+
test: ["CMD", "curl", "-f", "http://subquery-node:3000/ready"]
44+
interval: 3s
45+
timeout: 5s
46+
retries: 10
47+
48+
graphql-engine:
49+
image: subquerynetwork/subql-query:latest
50+
ports:
51+
- 3000:3000
52+
depends_on:
53+
"postgres":
54+
condition: service_healthy
55+
"subquery-node":
56+
condition: service_healthy
57+
restart: always
58+
environment:
59+
DB_USER: postgres
60+
DB_PASS: postgres
61+
DB_DATABASE: postgres
62+
DB_HOST: postgres
63+
DB_PORT: 5432
64+
command:
65+
- --name=app
66+
- --playground
67+
- --indexer=http://subquery-node:3000
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
#!/bin/sh
3+
4+
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<EOF
5+
CREATE EXTENSION IF NOT EXISTS btree_gist;
6+
EOF
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM postgres:16-alpine
2+
3+
# Variables needed at runtime to configure postgres and run the initdb scripts
4+
ENV POSTGRES_DB 'postgres'
5+
ENV POSTGRES_USER 'postgres'
6+
ENV POSTGRES_PASSWORD 'postgres'
7+
8+
# Copy in the load-extensions script
9+
COPY docker/load-extensions.sh /docker-entrypoint-initdb.d/
10+
11+
# Convert line endings to LF
12+
RUN sed -i 's/\r$//' /docker-entrypoint-initdb.d/load-extensions.sh && chmod +x /docker-entrypoint-initdb.d/load-extensions.sh

Ethereum/ethscriptions/package.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "ethscriptions",
3+
"version": "0.0.1",
4+
"description": "This project can be use as a starting point for developing your new Ethereum SubQuery project",
5+
"main": "dist/index.js",
6+
"scripts": {
7+
"build": "subql build",
8+
"codegen": "subql codegen",
9+
"start:docker": "docker-compose pull && docker-compose up --remove-orphans",
10+
"dev": "subql codegen && subql build && docker-compose pull && docker-compose up --remove-orphans",
11+
"prepack": "rm -rf dist && npm run build",
12+
"test": "subql build && subql-node-ethereum test"
13+
},
14+
"homepage": "https://github.com/subquery/ethereum-subql-starter",
15+
"repository": "github:subquery/ethereum-subql-starter",
16+
"files": [
17+
"dist",
18+
"schema.graphql",
19+
"project.yaml"
20+
],
21+
"author": "SubQuery Team",
22+
"license": "MIT",
23+
"dependencies": {
24+
"@subql/common": "latest",
25+
"@subql/types-ethereum": "latest",
26+
"@subql/validator": "latest",
27+
"assert": "^2.0.0"
28+
},
29+
"devDependencies": {
30+
"@subql/cli": "latest",
31+
"@subql/types": "latest",
32+
"@subql/testing": "latest",
33+
"@subql/node-ethereum": "latest",
34+
"ethers": "^5.7.2",
35+
"typescript": "latest"
36+
}
37+
}

0 commit comments

Comments
 (0)