Skip to content
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

[WIP] feat: refactor arb-subgraph forta alert, updated packages #580

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions arb-subgraph/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
generated
proto
14 changes: 14 additions & 0 deletions arb-subgraph/.eslintrc.json
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"
}
}
1 change: 1 addition & 0 deletions arb-subgraph/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ forta.config.json
*.log
version.json
.DS_Store
src/generated
2 changes: 2 additions & 0 deletions arb-subgraph/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
generated
proto
7 changes: 7 additions & 0 deletions arb-subgraph/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": false,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 120,
"tabWidth": 2
}
807 changes: 0 additions & 807 deletions arb-subgraph/.yarn/releases/yarn-3.3.0.cjs

This file was deleted.

3 changes: 0 additions & 3 deletions arb-subgraph/.yarnrc.yml

This file was deleted.

15 changes: 5 additions & 10 deletions arb-subgraph/Dockerfile
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
Expand All @@ -17,13 +16,9 @@ LABEL "network.forta.settings.agent-logs.enable"="true"
ENV NODE_ENV=production
WORKDIR /app

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"]
8 changes: 4 additions & 4 deletions arb-subgraph/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
testRegex: ".*\\.spec\\.ts$",
};
preset: 'ts-jest',
testEnvironment: 'node',
testRegex: '.*\\.spec\\.ts$',
}
58 changes: 46 additions & 12 deletions arb-subgraph/package.json
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
],
Expand All @@ -11,34 +12,67 @@
"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\"",
"update-version": "node ../utils/write-version.js",
"build": "tsc && yarn run copy-version",
"copy-version": "cp version.json dist",
"start": "yarn run update-version && yarn run start:dev",
"start:dev": "nodemon --watch src --watch forta.config.json -e js,ts,json --exec \"yarn run build && yarn run copy-version && 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",
"alert": "yarn run build && forta-agent run --alert",
"sequence": "yarn run build && forta-agent run --sequence",
"file": "yarn run build && forta-agent run --file",
"publish": "yarn run update-version && forta-agent publish",
"info": "forta-agent info",
"logs": "forta-agent logs",
"push": "yarn run update-version && forta-agent push",
"disable": "forta-agent disable",
"enable": "forta-agent enable",
"keyfile": "forta-agent keyfile",
"test": "jest --passWithNoTests"
"stake": "forta-agent stake",
"test": "jest",
"generate-types": "typechain --target=ethers-v5 --out-dir=./src/generated ./src/abi/*",
"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"
},
"dependencies": {
"bignumber.js": "^9.0.1",
"bignumber.js": "^9.1.2",
"forta-agent": "^0.1.48"
},
"devDependencies": {
"@typechain/ethers-v5": "^11.1.2",
"@tsconfig/node20": "^20.1.2",
"@types/jest": "^29.1.2",
"@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",
"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",
"@ethersproject/abi": "^5.0.0",
"@ethersproject/providers": "^5.0.0",
"ethers": "^5.1.3"
},
"packageManager": "yarn@3.3.0"
"packageManager": "yarn@1.22.21"
}
33 changes: 12 additions & 21 deletions arb-subgraph/scripts/write-version.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
const childProcess = require("child_process");
const fs = require("fs");
const childProcess = require('child_process')
const fs = require('fs')

const commitHash = childProcess
.execSync("git rev-parse HEAD")
.toString("utf-8")
.trim();
const commitMsg = childProcess
.execSync("git log -1 --pretty=%B")
.toString("utf-8")
.trim();
const gitStatusOutput = childProcess
.execSync("git status --porcelain")
.toString("utf-8")
.trim();
const commitHash = childProcess.execSync('git rev-parse HEAD').toString('utf-8').trim()
const commitMsg = childProcess.execSync('git log -1 --pretty=%B').toString('utf-8').trim()
const gitStatusOutput = childProcess.execSync('git status --porcelain').toString('utf-8').trim()

const commitHashShort = commitHash.substr(0, 7);
const commitMsgShort = commitMsg.split("\n")[0];
const isWdClean = gitStatusOutput === "";
const commitHashSuffux = isWdClean ? "" : " [dirty]";
const commitHashShort = commitHash.substr(0, 7)
const commitMsgShort = commitMsg.split('\n')[0]
const isWdClean = gitStatusOutput === ''
const commitHashSuffux = isWdClean ? '' : ' [dirty]'

const version = {
desc: `${commitHashShort}${commitHashSuffux} (${commitMsgShort})`,
Expand All @@ -26,8 +17,8 @@ const version = {
commitMsg,
commitMsgShort,
isWdClean,
};
}

console.log("Writing to version.json:", JSON.stringify(version, null, " "));
console.log('Writing to version.json:', JSON.stringify(version, null, ' '))

fs.writeFileSync("version.json", JSON.stringify(version));
fs.writeFileSync('version.json', JSON.stringify(version))
Loading
Loading