Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

submit snapshot migration quest #9

Closed
wants to merge 5 commits into from
Closed
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
5 changes: 5 additions & 0 deletions snapshot-squid-0xNomind/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DB_NAME=squid
DB_PORT=23798
GQL_PORT=4350
# JSON-RPC node endpoint, both wss and https endpoints are accepted
RPC_ENDPOINT=
2 changes: 2 additions & 0 deletions snapshot-squid-0xNomind/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.env
21 changes: 21 additions & 0 deletions snapshot-squid-0xNomind/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Subsquid 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.
86 changes: 86 additions & 0 deletions snapshot-squid-0xNomind/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<p align="center">
<picture>
<source srcset="https://uploads-ssl.webflow.com/63b5a9958fccedcf67d716ac/64662df3a5a568fd99e3600c_Squid_Pose_1_White-transparent-slim%201.png" media="(prefers-color-scheme: dark)">
<img src="https://uploads-ssl.webflow.com/63b5a9958fccedcf67d716ac/64662df3a5a568fd99e3600c_Squid_Pose_1_White-transparent-slim%201.png" alt="Subsquid Logo">
</picture>
</p>

# Snapshot Squid
The implementation [Snapshot Subgraph](https://thegraph.com/hosted-service/subgraph/snapshot-labs/snapshot) with [Squid SDK](https://docs.subsquid.io/).
Dependencies: Node.js, Docker.

## Quickstart

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

# 1. Clone repository
git clone https://github.com/0xNomind/snapshot-subgraph-migration.git

# 2. Go to folder
cd snapshot-squid-0xNomind

# 3. Rename .env.example to .env

# 4. Install dependencies
npm ci

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

# 6. Migrate database
sqd migration:generate

# 7. Build and start the processor
sqd process

# 8. The command above will block the terminal
# being busy with fetching the chain data,
# transforming and storing it in the target database.
#
# To start the graphql server open the separate terminal
# and run
sqd serve
```
A GraphiQL playground will be available at [localhost:4350/graphql](http://localhost:4350/graphql).

## Query Examples
### Squid Query
```
query MyQuery {
delegations(limit: 5) {
id
delegator
space
delegate
}
blocks(limit: 5) {
id
number
timestamp
}
}
```
#### Output
![Screenshot from 2023-10-02 00-41-39](https://github.com/0xNomind/snapshot-squid/assets/140236074/b02b0a50-00c7-442b-8e64-8ecea8fa8ad5)

## Graph Query
```
{
delegations(first: 5) {
id
delegator
space
delegate
}
blocks(first: 5) {
id
number
timestamp
}
}
```
#### Output
![Screenshot from 2023-10-02 00-46-42](https://github.com/0xNomind/snapshot-squid/assets/140236074/5c3a4505-de51-4041-b504-56743b792dcf)

4,036 changes: 4,036 additions & 0 deletions snapshot-squid-0xNomind/abi/DelegateRegistry.json

Large diffs are not rendered by default.

Loading