Skip to content

Commit

Permalink
Copy over eden-watcher from watcher-ts repo (#1)
Browse files Browse the repository at this point in the history
* Copy over watcher from watcher-ts

* Add missing dependency

* Add license and pre-commit lint

* Add subgraph build
  • Loading branch information
nikugogoi authored Apr 13, 2023
1 parent 051cc8d commit e664f3a
Show file tree
Hide file tree
Showing 116 changed files with 18,063 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Don't lint build output.
dist
28 changes: 28 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"semistandard",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"indent": ["error", 2, { "SwitchCase": 1 }],
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/explicit-module-boundary-types": [
"warn",
{
"allowArgumentsExplicitlyTypedAsAny": true
}
]
}
}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
dist/
out/

.vscode
.idea
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@cerc-io:registry=https://git.vdb.to/api/packages/cerc-io/npm/
662 changes: 662 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
# eden-watcher-ts
# EdenNetwork Watcher

## Setup

First try the [stack orchestrator](https://github.com/cerc-io/stack-orchestrator) to quickly get started. Advanced users can see [here](/docs/README.md) for instructions on setting up a local environment by hand.


## Run

Setup with:

```bash
yarn && yarn build
```

then checkout the [CLI guide](/docs/cli.md) for examples of commands that can be run on this watcher.
43 changes: 43 additions & 0 deletions codegen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Config to generate eden-watcher using codegen.
# Contracts to watch (required).
contracts:
# Contract name.
- name: EdenNetwork
# Contract file path or an url.
path: ~/eden/governance/contracts/EdenNetwork.sol
# Contract kind (should match that in {subgraphPath}/subgraph.yaml if subgraphPath provided)
kind: EdenNetwork

# Contract name.
- name: MerkleDistributor
# Contract file path or an url.
path: ~/eden/governance/contracts/MerkleDistributor.sol
# Contract kind (should match that in {subgraphPath}/subgraph.yaml if subgraphPath provided)
kind: EdenNetworkDistribution

# Contract name.
- name: DistributorGovernance
# Contract file path or an url.
path: ~/eden/governance/contracts/DistributorGovernance.sol
# Contract kind (should match that in {subgraphPath}/subgraph.yaml if subgraphPath provided)
kind: EdenNetworkGovernance

# Output folder path (logs output using `stdout` if not provided).
outputFolder: ../demo-eden-watcher

# Code generation mode [eth_call | storage | all | none] (default: all).
mode: none

# Kind of watcher [lazy | active] (default: active).
kind: active

# Watcher server port (default: 3008).
port: 3012

# Flatten the input contract file(s) [true | false] (default: true).
flatten: true

# Path to the subgraph build (optional).
subgraphPath: ~/eden/eden-data/packages/subgraph/build

# NOTE: When passed an *URL* as contract path, it is assumed that it points to an already flattened contract file.
75 changes: 75 additions & 0 deletions environments/local.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
[server]
host = "127.0.0.1"
port = 3012
kind = "active"

# Checkpointing state.
checkpointing = true

# Checkpoint interval in number of blocks.
checkpointInterval = 2000

subgraphPath = "./subgraph"

# Enable state creation
# CAUTION: Disable only if state creation is not desired or can be filled subsequently
enableState = true

# Interval to restart wasm instance periodically
wasmRestartBlocksInterval = 20

# Boolean to filter logs by contract.
filterLogs = true

# Max block range for which to return events in eventsInRange GQL query.
# Use -1 for skipping check on block range.
maxEventsBlockRange = 1000

# Interval in number of blocks at which to clear entities cache.
clearEntitiesCacheInterval = 1000

# GQL cache settings
[server.gqlCache]
enabled = true

# Max in-memory cache size (in bytes) (default 8 MB)
# maxCacheSize

# GQL cache-control max-age settings (in seconds)
maxAge = 15
timeTravelMaxAge = 86400 # 1 day

[metrics]
host = "127.0.0.1"
port = 9000
[metrics.gql]
port = 9001

[database]
type = "postgres"
host = "localhost"
port = 5432
database = "eden-watcher"
username = "postgres"
password = "postgres"
synchronize = true
logging = false

[upstream]
[upstream.ethServer]
gqlApiEndpoint = "http://127.0.0.1:8083/graphql"
rpcProviderEndpoint = "http://127.0.0.1:8082"

[upstream.cache]
name = "requests"
enabled = false
deleteOnStart = false

[jobQueue]
dbConnectionString = "postgres://postgres:postgres@localhost/eden-watcher-job-queue"
maxCompletionLagInSecs = 300
jobDelayInMilliSecs = 100
eventsInBatch = 50
blockDelayInMilliSecs = 2000
prefetchBlocksInMem = true
prefetchBlockCount = 10
75 changes: 75 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"name": "@cerc-io/eden-watcher-ts",
"version": "0.2.34",
"description": "eden-watcher-ts",
"private": true,
"main": "dist/index.js",
"scripts": {
"lint": "eslint --max-warnings=0 .",
"build": "yarn clean && tsc && yarn copy-assets",
"clean": "rm -rf ./dist",
"copy-assets": "copyfiles -u 1 src/**/*.gql dist/",
"prepare": "husky install",
"server": "DEBUG=vulcanize:* YARN_CHILD_PROCESS=true node --enable-source-maps dist/server.js",
"server:dev": "DEBUG=vulcanize:* YARN_CHILD_PROCESS=true ts-node src/server.ts",
"job-runner": "DEBUG=vulcanize:* YARN_CHILD_PROCESS=true node --max-old-space-size=3072 --enable-source-maps dist/job-runner.js",
"job-runner:dev": "DEBUG=vulcanize:* YARN_CHILD_PROCESS=true ts-node src/job-runner.ts",
"watch:contract": "DEBUG=vulcanize:* ts-node src/cli/watch-contract.ts",
"fill": "DEBUG=vulcanize:* ts-node src/fill.ts",
"fill:state": "DEBUG=vulcanize:* ts-node src/fill.ts --state",
"reset": "DEBUG=vulcanize:* ts-node src/cli/reset.ts",
"checkpoint": "DEBUG=vulcanize:* node --enable-source-maps --max-old-space-size=3072 dist/cli/checkpoint.js",
"checkpoint:dev": "DEBUG=vulcanize:* ts-node src/cli/checkpoint.ts",
"export-state": "DEBUG=vulcanize:* node --enable-source-maps --max-old-space-size=3072 dist/cli/export-state.js",
"export-state:dev": "DEBUG=vulcanize:* ts-node src/cli/export-state.ts",
"import-state": "DEBUG=vulcanize:* node --enable-source-maps --max-old-space-size=3072 dist/cli/import-state.js",
"import-state:dev": "DEBUG=vulcanize:* ts-node src/cli/import-state.ts",
"inspect-cid": "DEBUG=vulcanize:* ts-node src/cli/inspect-cid.ts",
"index-block": "DEBUG=vulcanize:* ts-node src/cli/index-block.ts"
},
"repository": {
"type": "git",
"url": "git+https://github.com/cerc-io/eden-watcher-ts.git"
},
"author": "",
"license": "AGPL-3.0",
"bugs": {
"url": "https://github.com/cerc-io/eden-watcher-ts/issues"
},
"homepage": "https://github.com/cerc-io/eden-watcher-ts#readme",
"dependencies": {
"@apollo/client": "^3.3.19",
"@cerc-io/cli": "^0.2.34",
"@cerc-io/graph-node": "^0.2.34",
"@cerc-io/ipld-eth-client": "^0.2.34",
"@cerc-io/solidity-mapper": "^0.2.34",
"@cerc-io/util": "^0.2.34",
"@ethersproject/providers": "^5.4.4",
"apollo-type-bigint": "^0.1.3",
"debug": "^4.3.1",
"decimal.js": "^10.3.1",
"ethers": "^5.4.4",
"graphql": "^15.5.0",
"reflect-metadata": "^0.1.13",
"typeorm": "^0.2.32",
"yargs": "^17.0.1"
},
"devDependencies": {
"@ethersproject/abi": "^5.3.0",
"@types/yargs": "^17.0.0",
"@types/debug": "^4.1.5",
"@typescript-eslint/eslint-plugin": "^5.47.1",
"@typescript-eslint/parser": "^5.47.1",
"copyfiles": "^2.4.1",
"eslint": "^8.35.0",
"eslint-config-semistandard": "^15.0.1",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-standard": "^5.0.0",
"husky": "^7.0.2",
"ts-node": "^10.2.1",
"typescript": "^5.0.2"
}
}
Loading

0 comments on commit e664f3a

Please sign in to comment.