Skip to content
This repository has been archived by the owner on Feb 15, 2021. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesLefrere committed Sep 11, 2020
0 parents commit e1b3851
Show file tree
Hide file tree
Showing 24 changed files with 6,360 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
generated/
11 changes: 11 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"rules": {
"prefer-const": "off" // Not possible for AssemblyScript
}
}
66 changes: 66 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next

build/
generated/
subgraph.yaml
abis/
4 changes: 4 additions & 0 deletions .graphqlconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"includes": ["*.graphql"],
"excludes": ["build/**/*.graphql"]
}
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.yaml
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": false,
"trailingComma": "all",
"printWidth": 80,
"singleQuote": true
}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Changelog

## Next
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 The Graph

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.
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# mStable Governance Subgraph

TODO write me

---

## Setup

### Prerequisites

First, ensure these are installed:

- [Ganache](https://www.trufflesuite.com/ganache)
- [Truffle](https://www.trufflesuite.com/truffle)
- [Docker](https://docs.docker.com/install)

Next, ensure the Docker daemon is running.

After that, clone [the Graph Node project](https://github.com/graphprotocol/graph-node) locally,
and navigate to the `docker` directory in that project (e.g. `cd graph-node/docker`).

If you're on Linux, run `./setup.sh` in that directory to set the host IP address in the docker config.

At this point, it should be possible to run the node: `docker-compose up`. Check that its services are running in the logs (GraphQL, Postgres, and IPFS).

Finally, run Ganache on `http://0.0.0.0:7545` such that it is available to running Docker images (`ganache-cli -p 7545 -h 0.0.0.0`)

### Installation

1. `yarn`
2. `yarn prepare:<config>` (i.e `ropsten`, `local`, `staging`, `mainnet`)
3. `yarn codegen`

### Development

Firstly, the subgraph can be created by running: `yarn create:local`; this should lead to a number of logs on the graph node.

Once the subgraph has been created, it can be deployed at any time with: `yarn deploy:local`.

This will cause the graph to start processing blocks and mapping events. Eventually, the
subgraph will have been (re)created.

If changes are made to the contracts, `subgraph.yaml`, or the GraphQL schema, run `yarn codegen`;
this re-create the `generated` folder.

**NB:** Type-checking is performed at build time; `yarn tsc` won't work.

---

## Deployment

1. `yarn`
2. Ensure correct config in `/config/<config>.json`
3. `yarn prepare:<config>`
4. `yarn codegen`
5. `yarn deploy:<config> <access token>`
3 changes: 3 additions & 0 deletions config/development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"network": "development"
}
3 changes: 3 additions & 0 deletions config/kovan.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"network": "kovan"
}
3 changes: 3 additions & 0 deletions config/mainnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"network": "mainnet"
}
3 changes: 3 additions & 0 deletions config/ropsten.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"network": "ropsten"
}
3 changes: 3 additions & 0 deletions config/staging.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"network": "mainnet"
}
46 changes: 46 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "mstable-governance-subgraph",
"version": "0.10",
"scripts": {
"codegen": "yarn graph codegen",
"build": "yarn graph build",
"prepare:local": "mustache config/development.json subgraph.template.yaml > subgraph.yaml",
"prepare:ropsten": "mustache config/ropsten.json subgraph.template.yaml > subgraph.yaml",
"prepare:kovan": "mustache config/kovan.json subgraph.template.yaml > subgraph.yaml",
"prepare:staging": "mustache config/staging.json subgraph.template.yaml > subgraph.yaml",
"prepare:mainnet": "mustache config/mainnet.json subgraph.template.yaml > subgraph.yaml",
"create:local": "yarn graph create mStable/mStable-governance --node http://127.0.0.1:8020",
"deploy:local": "yarn graph deploy mStable/mStable-governance --ipfs http://localhost:5001 --node http://127.0.0.1:8020",
"deploy:ropsten": "yarn graph deploy mStable/mStable-governance-ropsten --debug --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ --access-token ",
"deploy:kovan": "yarn graph deploy mStable/mStable-governance-kovan --debug --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ --access-token ",
"deploy:staging": "yarn graph deploy mStable/mStable-governance-staging --debug --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ --access-token ",
"deploy:mainnet": "yarn graph deploy mStable/mStable-governance --debug --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ --access-token ",
"lint": "yarn run eslint './src/**/*.{ts,tsx}' --fix"
},
"devDependencies": {
"@graphprotocol/graph-cli": "^0.18.0",
"@graphprotocol/graph-ts": "^0.18.1",
"@typescript-eslint/eslint-plugin": "^3.5.0",
"@typescript-eslint/parser": "^3.5.0",
"chalk": "^4.1.0",
"eslint": "^7.3.1",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.4",
"husky": "^4.2.1",
"lint-staged": "^10.0.7",
"mustache": "^4.0.1",
"prettier": "^2.0.5",
"typescript": "^4.0.2"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{ts,js,json,graphql}": [
"yarn run lint",
"git add"
]
}
}
1 change: 1 addition & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TODO
1 change: 1 addition & 0 deletions src/enums.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// TODO
Empty file added src/mappings/.gitkeep
Empty file.
Empty file added src/models/.gitkeep
Empty file.
Empty file added src/utils/.gitkeep
Empty file.
7 changes: 7 additions & 0 deletions subgraph.template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
specVersion: 0.0.2
description: mStable Governance
repository: https://github.com/mstable/mStable-governance-subgraph
schema:
file: ./schema.graphql

# TODO
13 changes: 13 additions & 0 deletions thegraph.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# These stubs are defined here for the benefit of IDEs; it isn't
# included in the build.

scalar BigInt
scalar BigDecimal
scalar Boolean
scalar Bytes
scalar ID
scalar String

directive @entity on OBJECT

directive @derivedFrom(field: String!) on FIELD_DEFINITION
6 changes: 6 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./node_modules/@graphprotocol/graph-ts/tsconfig.json",
"compilerOptions": {
"types": ["./node_modules/@graphprotocol/graph-ts"]
}
}
Loading

0 comments on commit e1b3851

Please sign in to comment.