Skip to content

Commit 80e0fcd

Browse files
committed
Add Oasis Sapphire
1 parent 10c423b commit 80e0fcd

17 files changed

+768
-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%/*}"
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

Oasis/oasis-sapphire-starter/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.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# SubQuery - Example Project for Oasis Sapphire Devnet
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 all transfers and approval events for the [OCEAN Token](https://explorer.sapphire.oasis.io/token/0x39d22B78A7651A76Ffbde2aaAB5FD92666Aca520/token-transfers) on Oasis Sapphire**
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+
transfers(first: 5, orderBy: VALUE_DESC) {
45+
totalCount
46+
nodes {
47+
id
48+
blockHeight
49+
from
50+
to
51+
value
52+
contractAddress
53+
}
54+
}
55+
}
56+
approvals(first: 5, orderBy: BLOCK_HEIGHT_DESC) {
57+
nodes {
58+
id
59+
blockHeight
60+
owner
61+
spender
62+
value
63+
contractAddress
64+
}
65+
}
66+
}
67+
```
68+
69+
You can explore the different possible queries and entities to help you with GraphQL using the documentation draw on the right.
70+
71+
## Publish your project
72+
73+
SubQuery is open-source, meaning you have the freedom to run it in the following three ways:
74+
75+
- 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)
76+
- 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)
77+
- [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
78+
79+
## What Next?
80+
81+
Take a look at some of our advanced features to take your project to the next level!
82+
83+
- [**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.
84+
- [**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.
85+
- [**Project Optimisation Advice**](https://academy.subquery.network/build/optimisation.html) - Some common tips on how to tweak your project to maximise performance.
86+
- [**GraphQL Subscriptions**](https://academy.subquery.network/run_publish/subscription.html) - Build more reactive front end applications that subscribe to changes in your SubQuery project.
87+
88+
## Need Help?
89+
90+
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.

0 commit comments

Comments
 (0)