-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit fbfd743
Showing
28 changed files
with
7,011 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/.git | ||
/node_modules | ||
/lib | ||
/*Versions.json | ||
npm-debug.log | ||
|
||
# OS Files | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Database connection options | ||
# Squid supports PosgreSQL and compatible databases (e.g CockroachDB) | ||
# Specify the DB_URL or the rest of the variables | ||
DB_URL=postgres://postgres:postgres@localhost:23798/squid | ||
# ---------------------------OR--------------------------- | ||
DB_NAME=squid | ||
DB_PORT=23798 | ||
DB_USER=postgres | ||
DB_PASS=postgres | ||
DB_HOST=localhost | ||
|
||
# Database connection SSL options | ||
DB_SSL=false | ||
DB_SSL_CA= | ||
DB_SSL_CA_FILE= | ||
DB_SSL_CERT= | ||
DB_SSL_CERT_FILE= | ||
DB_SSL_KEY= | ||
DB_SSL_KEY_FILE= | ||
DB_SSL_REJECT_UNAUTHORIZED= | ||
|
||
# GraphQL server port | ||
GQL_PORT=4350 | ||
|
||
# Subsquid Gateway | ||
# Set either GATEWAY_NETWORK or GATEWAY_URL or leave both empty to disable the gateway | ||
# See https://docs.subsquid.io/subsquid-network/reference/evm-networks for more info | ||
SUBSQUID_GATEWAY_NETWORK=eth-mainnet | ||
SUBSQUID_GATEWAY_URL=https://v2.archive.subsquid.io/network/ethereum-mainnet | ||
# Gateway request timeout in ms (optional) | ||
SUBSQUID_GATEWAY_REQUEST_TIMEOUT= | ||
|
||
# JSON-RPC node endpoint (wss or https) | ||
RPC_ENDPOINT=https://rpc.ankr.com/eth | ||
# Optional settings for JSON-RPC endpoint | ||
# Maximum number of ongoing concurrent requests | ||
RPC_ENDPOINT_CAPACITY= | ||
# Maximum number of requests per second | ||
RPC_ENDPOINT_MAX_REQUESTS_PER_SECOND= | ||
# Request timeout in ms | ||
RPC_ENDPOINT_REQUEST_TIMEOUT= | ||
# Maximum number of requests in a single batch call | ||
RPC_ENDPOINT_MAX_BATCH_CALL_SIZE= | ||
|
||
# Blocks range to index | ||
BLOCKS_RANGE_FROM= | ||
BLOCKS_RANGE_TO= | ||
|
||
# Distance from the head block behind which all blocks are considered to be finalized | ||
BLOCKS_FINALITY_CONFIRMATIONS=75 | ||
|
||
# Uncommenting this line enables the debug mode | ||
# More info at https://docs.subsquid.io/basics/logging/ | ||
#SQD_DEBUG=* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
module.exports = { | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
project: 'tsconfig.json', | ||
tsconfigRootDir: __dirname, | ||
sourceType: 'module', | ||
}, | ||
plugins: ['@typescript-eslint/eslint-plugin', 'prettier', 'sort-imports-es6-autofix'], | ||
extends: ['plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'], | ||
root: true, | ||
env: { | ||
node: true, | ||
jest: true, | ||
}, | ||
ignorePatterns: ['.eslintrc.js', 'lib', 'db', 'src/model/generated'], | ||
rules: { | ||
'@typescript-eslint/interface-name-prefix': 'off', | ||
'@typescript-eslint/explicit-function-return-type': 'off', | ||
'@typescript-eslint/explicit-module-boundary-types': 'off', | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'sort-imports-es6-autofix/sort-imports-es6': ['error', {}], | ||
'padding-line-between-statements': [ | ||
'error', | ||
{ | ||
blankLine: 'always', | ||
prev: 'block', | ||
next: '*', | ||
}, | ||
{ blankLine: 'always', prev: 'block-like', next: '*' }, | ||
{ | ||
blankLine: 'always', | ||
prev: '*', | ||
next: 'block', | ||
}, | ||
{ blankLine: 'always', prev: '*', next: 'block-like' }, | ||
{ | ||
blankLine: 'always', | ||
prev: 'directive', | ||
next: '*', | ||
}, | ||
{ | ||
blankLine: 'always', | ||
prev: '*', | ||
next: 'export', | ||
}, | ||
{ | ||
blankLine: 'always', | ||
prev: 'multiline-const', | ||
next: '*', | ||
}, | ||
{ | ||
blankLine: 'always', | ||
prev: '*', | ||
next: 'multiline-const', | ||
}, | ||
{ | ||
blankLine: 'always', | ||
prev: 'multiline-expression', | ||
next: '*', | ||
}, | ||
{ | ||
blankLine: 'always', | ||
prev: '*', | ||
next: 'multiline-expression', | ||
}, | ||
{ | ||
blankLine: 'always', | ||
prev: 'multiline-let', | ||
next: '*', | ||
}, | ||
{ | ||
blankLine: 'always', | ||
prev: '*', | ||
next: 'multiline-let', | ||
}, | ||
{ blankLine: 'always', prev: '*', next: 'return' }, | ||
{ blankLine: 'always', prev: '*', next: 'throw' }, | ||
{ blankLine: 'always', prev: 'throw', next: '*' }, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Build project | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build project | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20.11.0' | ||
- run: npm ci | ||
- run: npm run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Publish Docker image | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
push_to_registry: | ||
name: Push Docker image to Docker Hub | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Extract metadata for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
rebaseorg/evm-blocks-squid | ||
tags: | | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/node_modules | ||
/lib | ||
/builds | ||
|
||
/**Versions.json | ||
|
||
# IDE files | ||
/.idea | ||
|
||
# Environment variables | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# This configuration file was automatically generated by Gitpod. | ||
# Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml) | ||
# and commit this file to your remote git repository to share the goodness with others. | ||
|
||
# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart | ||
github: | ||
prebuilds: | ||
# enable for the master/default branch (defaults to true) | ||
master: true | ||
# enable for all branches in this repo (defaults to false) | ||
branches: false | ||
# enable for pull requests coming from this repo (defaults to true) | ||
pullRequests: true | ||
# add a check to pull requests (defaults to true) | ||
addCheck: true | ||
# add a "Review in Gitpod" button as a comment to pull requests (defaults to false) | ||
addComment: false | ||
|
||
tasks: | ||
- init: | | ||
npm i | ||
npm i -g @subsquid/cli | ||
docker compose pull | ||
gp sync-done setup | ||
- name: DB | ||
command: | | ||
gp sync-await setup | ||
sqd up | ||
- name: GraphQL API | ||
command: | | ||
gp sync-await setup | ||
sqd serve | ||
- command: | | ||
gp ports await 4350 | ||
gp preview $(gp url 4350)/graphql | ||
- name: Squid procesor | ||
command: | | ||
gp open src/processor.ts | ||
gp sync-await setup | ||
sqd build | ||
gp ports await 23798 | ||
sqd process |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"printWidth": 100 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
FROM node:16-alpine AS node | ||
|
||
FROM node AS node-with-gyp | ||
RUN apk add g++ make python3 | ||
|
||
FROM node-with-gyp AS builder | ||
WORKDIR /squid | ||
ADD package.json . | ||
ADD package-lock.json . | ||
ADD db db | ||
ADD assets assets | ||
ADD schema.graphql . | ||
RUN npm ci | ||
ADD tsconfig.json . | ||
ADD src src | ||
RUN npm run build | ||
|
||
FROM node-with-gyp AS deps | ||
WORKDIR /squid | ||
ADD package.json . | ||
ADD package-lock.json . | ||
RUN npm ci --production | ||
|
||
FROM node AS squid | ||
WORKDIR /squid | ||
COPY --from=deps /squid/package.json . | ||
COPY --from=deps /squid/package-lock.json . | ||
COPY --from=deps /squid/node_modules node_modules | ||
COPY --from=builder /squid/lib lib | ||
COPY --from=builder /squid/db db | ||
COPY --from=builder /squid/assets assets | ||
COPY --from=builder /squid/schema.graphql schema.graphql | ||
ADD commands.json . | ||
RUN echo -e "loglevel=silent\\nupdate-notifier=false" > /squid/.npmrc | ||
RUN npm i -g @subsquid/commands && mv $(which squid-commands) /usr/local/bin/sqd | ||
ENV PROCESSOR_PROMETHEUS_PORT 3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Rebase Labs | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# EVM Blocks Squid | ||
|
||
🚀 Blazing fast* and simple real-time blocks indexer for EVM based chains with GraphQL API available out of the box which | ||
can be quickly configured with environment variables and deployed anywhere with Docker. Details about deployment and | ||
configuration will be described soon. | ||
|
||
* – the maximum indexing speed can be reached with Subsquid Gateways. The list of supported EVM chains can be found | ||
[here](https://docs.subsquid.io/subsquid-network/reference/evm-networks). | ||
|
||
More information about Squids and Subsquid protocol can be found in the [offical documentation](https://docs.subsquid.io). | ||
|
||
## Local running | ||
|
||
```bash | ||
# 1. Install dependencies | ||
npm ci | ||
|
||
# 2. Start a Postgres database container and detach | ||
sqd up | ||
|
||
# 3. Build the squid | ||
sqd build | ||
|
||
# 4. Start both the squid processor and the GraphQL server | ||
sqd run . | ||
``` | ||
|
||
A GraphiQL playground will be available at [localhost:4350/graphql](http://localhost:4350/graphql). | ||
|
||
You can also start squid services one by one: | ||
|
||
```bash | ||
sqd process | ||
sqd serve | ||
``` | ||
|
||
## Project conventions | ||
|
||
Squid tools assume a certain [project layout](https://docs.subsquid.io/basics/squid-structure): | ||
|
||
* 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# ABI folder | ||
|
||
This is a dedicated folder for ABI files. Place you contract ABI here and generate facade classes for type-safe decoding of the event, function data and contract state queries with | ||
|
||
```sh | ||
sqd typegen | ||
``` | ||
|
||
This `typegen` command is defined in `commands.json`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Assets | ||
|
||
`assets` is the designated folder for any additional files to be used by the squid, for example a static data file. The folder is added by default to `Dockerfile` and is kept when the squid is deployed to the Aquairum. |
Oops, something went wrong.