-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Arb-subgraph refactoring #585
base: main
Are you sure you want to change the base?
Changes from all commits
3054e72
fa7d8a6
feac5c6
ec01887
c20cbc4
83902d1
2b9b02c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
generated | ||
proto |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"parser": "@typescript-eslint/parser", | ||
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"], | ||
"plugins": ["@typescript-eslint", "prettier"], | ||
"env": { | ||
"node": true, | ||
"es6": true | ||
}, | ||
"rules": { | ||
"prettier/prettier": "error", | ||
"curly": "error", | ||
"semi": "off" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,6 @@ forta.config.json | |
*.log | ||
version.json | ||
.DS_Store | ||
|
||
# Env | ||
.env |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
generated | ||
proto |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"semi": false, | ||
"trailingComma": "all", | ||
"singleQuote": true, | ||
"printWidth": 120, | ||
"tabWidth": 2 | ||
} |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
# Build stage: compile Typescript to Javascript | ||
FROM node:16.17.1-alpine3.16 AS base | ||
FROM node:20.9.0-alpine3.18 AS base | ||
|
||
FROM base as builder | ||
WORKDIR /app | ||
|
||
COPY package*.json .yarnrc.yml yarn.lock ./ | ||
COPY .yarn/releases ./.yarn/releases/ | ||
RUN yarn install --immutable | ||
WORKDIR /app | ||
|
||
COPY . . | ||
RUN yarn install --immutable && yarn run build | ||
# Build app | ||
RUN yarn run build | ||
|
||
# Final stage: copy compiled Javascript from previous stage and install production dependencies | ||
|
@@ -17,13 +16,9 @@ LABEL "network.forta.settings.agent-logs.enable"="true" | |
ENV NODE_ENV=production | ||
WORKDIR /app | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have to provide the default values in DockerFile. |
||
RUN apk add --no-cache tini=0.19.0-r0 | ||
|
||
COPY package*.json .yarnrc.yml yarn.lock ./ | ||
COPY .yarn/releases ./.yarn/releases/ | ||
COPY package*.json yarn.lock ./ | ||
COPY --from=builder /app/node_modules ./node_modules | ||
COPY --from=builder /app/dist ./src | ||
COPY version.json ./ | ||
|
||
ENTRYPOINT ["/sbin/tini", "--"] | ||
CMD ["yarn", "run", "start:prod"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure that it would work. Check pls.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ill check it |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Makefile | ||
|
||
.PHONY: gen_proto_prod | ||
gen_proto_prod: | ||
# generate js codes via grpc-tools | ||
yarn grpc_tools_node_protoc \ | ||
--js_out=import_style=commonjs,binary:./dist/generated/proto \ | ||
--grpc_out=grpc_js:./dist/generated/proto \ | ||
--plugin=protoc-gen-grpc=./node_modules/.bin/grpc_tools_node_protoc_plugin \ | ||
-I ./src/brief/proto \ | ||
./src/brief/proto/*.proto | ||
|
||
.PHONY: gen_js | ||
gen_js: | ||
# generate js codes via grpc-tools | ||
yarn grpc_tools_node_protoc \ | ||
--js_out=import_style=commonjs,binary:./src/generated/proto \ | ||
--grpc_out=grpc_js:./src/generated/proto \ | ||
--plugin=protoc-gen-grpc=./node_modules/.bin/grpc_tools_node_protoc_plugin \ | ||
--proto_path=./src/brief/proto \ | ||
./src/brief/proto/*.proto | ||
|
||
.PHONY: gen_ts | ||
gen_ts: | ||
# generate d.ts codes | ||
yarn grpc_tools_node_protoc \ | ||
--plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts \ | ||
--ts_out=grpc_js:./src/generated/proto \ | ||
--proto_path=./src/brief/proto \ | ||
./src/brief/proto/*.proto | ||
|
||
tools: | ||
cd tools && go mod tidy && go mod vendor && go mod verify && go generate -tags tools | ||
.PHONY: tools | ||
|
||
.PHONY: check_alerts_syntax | ||
check_alerts_syntax: | ||
./bin/promtool check rules ./alerts.yml | ||
|
||
.PHONY: test_alerts | ||
test_alerts: | ||
bin/promtool test rules ./alerts_tests.yml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
/** @type {import("ts-jest").JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: "ts-jest", | ||
testEnvironment: "node", | ||
testRegex: ".*\\.spec\\.ts$", | ||
}; | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
testPathIgnorePatterns: ['dist'], | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
{ | ||
"name": "lido-arbitrum-bot", | ||
"name": "arb-subgraph", | ||
"version": "0.0.1", | ||
"description": "Forta Bot for Lido Apps on Arbitrum network", | ||
"description": "Forta Bot for Lido The Graph billing account", | ||
"license": "MIT", | ||
"chainIds": [ | ||
42161 | ||
], | ||
|
@@ -11,34 +12,62 @@ | |
"target": 5 | ||
} | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "yarn run lint" | ||
} | ||
}, | ||
"scripts": { | ||
"update-version": "node scripts/write-version.js", | ||
"build": "tsc --resolveJsonModule", | ||
"start": "yarn run start:dev", | ||
"start:dev": "nodemon --watch src --watch forta.config.json -e js,ts,json --exec \"yarn run build && forta-agent run\"", | ||
"start:prod": "forta-agent run --prod", | ||
"tx": "yarn run build && forta-agent run --tx", | ||
"block": "yarn run build && forta-agent run --block", | ||
"range": "yarn run build && forta-agent run --range", | ||
"file": "yarn run build && forta-agent run --file", | ||
"publish": "yarn run update-version && forta-agent publish", | ||
"update-version": "node ../utils/write-version.js", | ||
"build": "tsc && yarn run copy-version && mkdir dist/generated/proto && make gen_proto_prod", | ||
"copy-version": "cp version.json dist", | ||
"start": "ts-node src/main.ts", | ||
"start:dev": "nodemon --watch src --watch forta.config.json -e js,ts,json --exec \"yarn run build && yarn run copy-version && forta-agent run\"", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Useless command. This commit removes forta-agent dependency |
||
"start:prod": "node dist/main.js", | ||
"push": "yarn run update-version && forta-agent push", | ||
"disable": "forta-agent disable", | ||
"enable": "forta-agent enable", | ||
"keyfile": "forta-agent keyfile", | ||
"test": "jest --passWithNoTests" | ||
"test": "jest", | ||
"generate-types": "typechain --target=ethers-v5 --out-dir=./src/generated/typechain ./src/brief/abi/*", | ||
"generate-proto": "make gen_ts && make gen_js", | ||
"eslint:lint": "eslint ./src", | ||
"eslint:format": "eslint ./src --fix", | ||
"prettier:check": "prettier --check ./src", | ||
"prettier:format": "prettier --write ./src", | ||
"lint": "yarn run prettier:check && yarn run eslint:lint", | ||
"format": "yarn run eslint:format && yarn run prettier:format", | ||
"postinstall": "yarn generate-types && yarn generate-proto" | ||
}, | ||
"dependencies": { | ||
"bignumber.js": "^9.0.1", | ||
"forta-agent": "^0.1.48" | ||
"@fastify/env": "^4.4.0", | ||
"bignumber.js": "^9.1.2", | ||
"fastify": "^4.28.1", | ||
"fastify-plugin": "^4.5.1", | ||
"forta-agent": "^0.1.48", | ||
"prom-client": "^15.1.3", | ||
"winston": "^3.13.1" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^29.1.2", | ||
"@ethersproject/abi": "^5.0.0", | ||
"@ethersproject/providers": "^5.0.0", | ||
"@tsconfig/node20": "^20.1.2", | ||
"@typechain/ethers-v5": "^11.1.2", | ||
"@types/jest": "^29.5.12", | ||
"@types/nodemon": "^1.19.0", | ||
"jest": "^29.2.0", | ||
"nodemon": "^2.0.8", | ||
"@typescript-eslint/eslint-plugin": "^6.12.0", | ||
"@typescript-eslint/parser": "^6.12.0", | ||
"eslint": "^8.54.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint-plugin-jest": "^27.6.0", | ||
"eslint-plugin-prettier": "^5.0.1", | ||
"ethers": "^5.1.3", | ||
"grpc-tools": "^1.12.4", | ||
"grpc_tools_node_protoc_ts": "^5.3.3", | ||
"husky": "^8.0.3", | ||
"jest": "^29.7.0", | ||
"nodemon": "^3.0.1", | ||
"prettier": "^3.1.0", | ||
"ts-jest": "^29.0.3", | ||
"typescript": "^4.3.4" | ||
"typechain": "^8.3.2", | ||
"typescript": "^5.3.2" | ||
}, | ||
"packageManager": "yarn@3.3.0" | ||
"packageManager": "yarn@1.22.21" | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest upgrading all deps in package.json |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
# The URL of the Arbitrum RPC endpoint | ||
ARBITRUM_RPC_URL=https://arbitrum.drpc.com | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Found that https://arbitrum-one.publicnode.com works better. Especially for reading some data in the past. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a sample for envs. I doubt that these URLs will be used in any work of the bot |
||
|
||
# Port for the HTTP server | ||
HTTP_PORT=3000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest using the latest node.
FROM node:20.15.1-alpine3.20 AS base
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was left as is. The refactoring only affected the code of the bot itself. Thanks - I'll fix it!