-
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 4d102a4
Showing
11 changed files
with
3,719 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 @@ | ||
DATABASE_URL=postgres://postgres:password@localhost:5432/delegate-registry-api |
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,20 @@ | ||
name: Lint and build | ||
on: [push] | ||
jobs: | ||
lint-build: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18' | ||
cache: 'yarn' | ||
- name: Set up MySQL | ||
run: | | ||
sudo /etc/init.d/mysql start | ||
mysql -e 'CREATE DATABASE checkpoint;' -uroot -proot | ||
- run: yarn install | ||
- run: yarn lint | ||
- run: yarn build | ||
env: | ||
DATABASE_URL: 'mysql://root:[email protected]:3306/checkpoint' |
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,14 @@ | ||
.DS_Store | ||
node_modules | ||
dist | ||
build | ||
.env | ||
coverage | ||
|
||
# Remove some common IDE working directories | ||
.idea | ||
.vscode | ||
*.log | ||
|
||
# Checkpoint | ||
.checkpoint |
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) Snapshot 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,34 @@ | ||
{ | ||
"name": "@snapshot-labs/checkpoint-template", | ||
"version": "0.1.0", | ||
"license": "MIT", | ||
"description": "Checkpoint starter template", | ||
"scripts": { | ||
"codegen": "checkpoint generate", | ||
"lint": "eslint src/ --ext .ts --fix", | ||
"prebuild": "yarn codegen", | ||
"build": "tsc", | ||
"dev": "nodemon src/index.ts", | ||
"start": "node dist/src/index.js" | ||
}, | ||
"eslintConfig": { | ||
"extends": "@snapshot-labs" | ||
}, | ||
"prettier": "@snapshot-labs/prettier-config", | ||
"dependencies": { | ||
"@snapshot-labs/checkpoint": "^0.1.0-beta.39", | ||
"@types/node": "^18.11.6", | ||
"cors": "^2.8.5", | ||
"dotenv": "^16.0.1", | ||
"express": "^4.18.1", | ||
"nodemon": "^2.0.19", | ||
"ts-node": "^10.8.1", | ||
"typescript": "^5.2.2" | ||
}, | ||
"devDependencies": { | ||
"@snapshot-labs/eslint-config": "^0.1.0-beta.18", | ||
"@snapshot-labs/prettier-config": "^0.1.0-beta.18", | ||
"eslint": "^8.53.0", | ||
"prettier": "^3.1.0" | ||
} | ||
} |
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,15 @@ | ||
{ | ||
"network_node_url": "https://subgrapher.snapshot.org/delegation", | ||
"decimal_types": { | ||
"BigIntVP": { | ||
"p": 80, | ||
"d": 0 | ||
}, | ||
"BigDecimalVP": { | ||
"p": 80, | ||
"d": 20 | ||
} | ||
}, | ||
"optimistic_indexing": false, | ||
"sources": [] | ||
} |
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,34 @@ | ||
import 'dotenv/config'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import Checkpoint, { LogLevel } from '@snapshot-labs/checkpoint'; | ||
import cors from 'cors'; | ||
import express from 'express'; | ||
import config from './config.json'; | ||
import { NoopIndexer } from './noopindexer'; | ||
|
||
const dir = __dirname.endsWith('dist/src') ? '../' : ''; | ||
const schemaFile = path.join(__dirname, `${dir}../src/schema.gql`); | ||
const schema = fs.readFileSync(schemaFile, 'utf8'); | ||
|
||
const indexer = new NoopIndexer(); | ||
const checkpoint = new Checkpoint(config, indexer, schema, { | ||
logLevel: LogLevel.Info, | ||
prettifyLogs: true | ||
}); | ||
|
||
async function run() { | ||
await checkpoint.reset(); | ||
await checkpoint.resetMetadata(); | ||
} | ||
|
||
run(); | ||
|
||
const app = express(); | ||
app.use(express.json({ limit: '4mb' })); | ||
app.use(express.urlencoded({ limit: '4mb', extended: false })); | ||
app.use(cors({ maxAge: 86400 })); | ||
app.use('/', checkpoint.graphql); | ||
|
||
const PORT = process.env.PORT || 3000; | ||
app.listen(PORT, () => console.log(`Listening at http://localhost:${PORT}`)); |
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,26 @@ | ||
import { BaseIndexer, BaseProvider, Instance } from '@snapshot-labs/checkpoint'; | ||
import { Logger } from '@snapshot-labs/checkpoint/dist/src/utils/logger'; | ||
|
||
export class NoopProvider extends BaseProvider {} | ||
|
||
export class NoopIndexer extends BaseIndexer { | ||
init({ | ||
instance, | ||
log, | ||
abis | ||
}: { | ||
instance: Instance; | ||
log: Logger; | ||
abis?: Record<string, any>; | ||
}) { | ||
this.provider = new NoopProvider({ | ||
instance, | ||
log, | ||
abis | ||
}); | ||
} | ||
|
||
public getHandlers(): string[] { | ||
return []; | ||
} | ||
} |
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 @@ | ||
scalar Id | ||
scalar Text | ||
scalar BigIntVP | ||
scalar BigDecimalVP | ||
|
||
type Governance { | ||
id: String! | ||
currentDelegates: Int! | ||
totalDelegates: Int! | ||
delegatedVotesRaw: BigIntVP! | ||
delegatedVotes: BigDecimalVP! | ||
} | ||
|
||
type Delegate { | ||
id: String! | ||
governance: Governance | ||
user: String! | ||
delegatedVotesRaw: BigIntVP! | ||
delegatedVotes: BigDecimalVP! | ||
tokenHoldersRepresentedAmount: Int! | ||
} |
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,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "esnext", | ||
"module": "commonjs", | ||
"rootDir": "./", | ||
"outDir": "./dist", | ||
"esModuleInterop": true, | ||
"strict": true, | ||
"noImplicitAny": false, | ||
"resolveJsonModule": true, | ||
"moduleResolution": "Node" | ||
} | ||
} |
Oops, something went wrong.