From 68432b43fd9c65f04a66a03d21475947bca4122a Mon Sep 17 00:00:00 2001 From: Intizar Date: Thu, 9 May 2024 20:43:36 +0900 Subject: [PATCH 1/5] remappings.tsx for vscode intellisense --- contracts/v0.2/remappings.txt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 contracts/v0.2/remappings.txt diff --git a/contracts/v0.2/remappings.txt b/contracts/v0.2/remappings.txt new file mode 100644 index 000000000..a69e53176 --- /dev/null +++ b/contracts/v0.2/remappings.txt @@ -0,0 +1,6 @@ +@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/ +ds-test/=lib/forge-std/lib/ds-test/src/ +erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/ +forge-std/=lib/forge-std/src/ +openzeppelin-contracts/=lib/openzeppelin-contracts/ +solidity-stringutils/=lib/solidity-stringutils/ From 2c367b7aeeb7dbd0989b9e43edc493faa0626781 Mon Sep 17 00:00:00 2001 From: Intizar Date: Thu, 9 May 2024 20:44:01 +0900 Subject: [PATCH 2/5] onsave formatting with prettier and forge --- contracts/v0.2/.vscode/extensions.json | 3 +++ contracts/v0.2/.vscode/settings.json | 10 ++++++++++ 2 files changed, 13 insertions(+) create mode 100644 contracts/v0.2/.vscode/extensions.json create mode 100644 contracts/v0.2/.vscode/settings.json diff --git a/contracts/v0.2/.vscode/extensions.json b/contracts/v0.2/.vscode/extensions.json new file mode 100644 index 000000000..d171aee92 --- /dev/null +++ b/contracts/v0.2/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["JuanBlanco.solidity", "esbenp.prettier-vscode"] +} \ No newline at end of file diff --git a/contracts/v0.2/.vscode/settings.json b/contracts/v0.2/.vscode/settings.json new file mode 100644 index 000000000..46d20338b --- /dev/null +++ b/contracts/v0.2/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "solidity.packageDefaultDependenciesContractsDirectory": "src", + "solidity.packageDefaultDependenciesDirectory": "lib", + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "[solidity]": { + "editor.defaultFormatter": "JuanBlanco.solidity" + }, + "solidity.formatter": "forge" +} From 10e3a073f83f9436d9f57c00253e3a2557086fa4 Mon Sep 17 00:00:00 2001 From: Intizar Date: Mon, 13 May 2024 14:05:38 +0900 Subject: [PATCH 3/5] remove .vscode dir --- contracts/v0.2/.vscode/extensions.json | 3 --- contracts/v0.2/.vscode/settings.json | 10 ---------- 2 files changed, 13 deletions(-) delete mode 100644 contracts/v0.2/.vscode/extensions.json delete mode 100644 contracts/v0.2/.vscode/settings.json diff --git a/contracts/v0.2/.vscode/extensions.json b/contracts/v0.2/.vscode/extensions.json deleted file mode 100644 index d171aee92..000000000 --- a/contracts/v0.2/.vscode/extensions.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "recommendations": ["JuanBlanco.solidity", "esbenp.prettier-vscode"] -} \ No newline at end of file diff --git a/contracts/v0.2/.vscode/settings.json b/contracts/v0.2/.vscode/settings.json deleted file mode 100644 index 46d20338b..000000000 --- a/contracts/v0.2/.vscode/settings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "solidity.packageDefaultDependenciesContractsDirectory": "src", - "solidity.packageDefaultDependenciesDirectory": "lib", - "editor.formatOnSave": true, - "editor.defaultFormatter": "esbenp.prettier-vscode", - "[solidity]": { - "editor.defaultFormatter": "JuanBlanco.solidity" - }, - "solidity.formatter": "forge" -} From f8a5712b66b8bd2113585295b91b181660a6b0bb Mon Sep 17 00:00:00 2001 From: Intizar Date: Mon, 13 May 2024 15:05:07 +0900 Subject: [PATCH 4/5] implement husky and lint staged for sol files --- .husky/pre-commit | 4 ++++ lint-staged.config.js | 3 +++ package.json | 8 ++++++-- yarn.lock | 5 +++++ 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100755 .husky/pre-commit create mode 100644 lint-staged.config.js diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 000000000..0312b7602 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npx lint-staged \ No newline at end of file diff --git a/lint-staged.config.js b/lint-staged.config.js new file mode 100644 index 000000000..3c7c6b277 --- /dev/null +++ b/lint-staged.config.js @@ -0,0 +1,3 @@ +module.exports = { + "contracts/v0.2/**/*.sol": "yarn contracts-v02 lint", +}; diff --git a/package.json b/package.json index 770dfa484..67c51e9ba 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,10 @@ ] }, "dependencies": {}, - "devDependencies": {}, + "devDependencies": { + "husky": "^9.0.11", + "lint-staged": "^15.2.2" + }, "scripts": { "cli": "yarn workspace @bisonai/orakl-cli", "contracts": "yarn workspace @bisonai/orakl-contracts", @@ -35,6 +38,7 @@ "l2-api": "yarn workspace @bisonai/orakl-l2-api", "monitor": "yarn workspace @bisonai/orakl-monitor", "vrf": "yarn workspace @bisonai/orakl-vrf", - "util": "yarn workspace @bisonai/orakl-util" + "util": "yarn workspace @bisonai/orakl-util", + "prepare": "husky install && chmod +x .husky/pre-commit" } } diff --git a/yarn.lock b/yarn.lock index 083cd27e4..3a156440e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7329,6 +7329,11 @@ husky@^8.0.2: resolved "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz" integrity sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg== +husky@^9.0.11: + version "9.0.11" + resolved "https://registry.yarnpkg.com/husky/-/husky-9.0.11.tgz#fc91df4c756050de41b3e478b2158b87c1e79af9" + integrity sha512-AB6lFlbwwyIqMdHYhwPe+kjOC3Oc5P3nThEoW/AaO2BX3vJDjWPFxYLxokUZOo6RNX20He3AaT8sESs9NJcmEw== + iconv-lite@0.4.24, iconv-lite@^0.4.24: version "0.4.24" resolved "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz" From a5168aa4650c05ca6cd723e6197fcc6de91eee50 Mon Sep 17 00:00:00 2001 From: Intizar Date: Mon, 13 May 2024 15:49:06 +0900 Subject: [PATCH 5/5] move precommit logic from core/ to root --- .husky/pre-commit | 2 +- core/.eslintrc | 7 +++---- core/.husky/pre-commit | 4 ---- core/package.json | 6 ++---- lint-staged.config.js | 4 ++++ 5 files changed, 10 insertions(+), 13 deletions(-) delete mode 100755 core/.husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit index 0312b7602..ecd1ce930 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" -npx lint-staged \ No newline at end of file +npx lint-staged --allow-empty \ No newline at end of file diff --git a/core/.eslintrc b/core/.eslintrc index 349cce55f..62e89b8d3 100644 --- a/core/.eslintrc +++ b/core/.eslintrc @@ -5,7 +5,8 @@ "prettier", "eslint:recommended", "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended" + "plugin:@typescript-eslint/recommended", + "plugin:prettier/recommended" ], "plugins": [ "prettier", @@ -13,9 +14,7 @@ ], "rules": { "no-throw-literal": "error", - "prettier/prettier": [ - "error" - ], + "prettier/prettier": "error", "@typescript-eslint/ban-ts-comment": "off", "@typescript-eslint/no-unused-vars": [ "warn", diff --git a/core/.husky/pre-commit b/core/.husky/pre-commit deleted file mode 100755 index 01b89ff66..000000000 --- a/core/.husky/pre-commit +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -cd core && yarn lint && yarn test diff --git a/core/package.json b/core/package.json index 233ba76b0..7973838bb 100644 --- a/core/package.json +++ b/core/package.json @@ -27,7 +27,6 @@ "homepage": "https://github.com/Bisonai/orakl/tree/master/core#orakl-network-core", "license": "MIT", "scripts": { - "prepare": "cd .. && husky install core/.husky", "clean": "rm -rf dist", "prebuild": "yarn --cwd='../' vrf build && yarn --cwd='../' contracts-v01 build && yarn --cwd='../' util build", "build": "yarn clean && tsc", @@ -64,13 +63,13 @@ "aggregator-hash": "node --no-warnings --import=specifier-resolution-node/register --experimental-json-modules dist/cli/generate-aggregator-hash.js", "flush": "node --no-warnings --import=specifier-resolution-node/register --experimental-json-modules dist/tools/flush-queues.js", "test": "node --no-warnings --experimental-vm-modules node_modules/.bin/jest", - "lint": "DEBUG=eslint:cli-engine eslint 'src/**/*.ts' 'src/*.ts' 'test/*.ts'", + "lint": "DEBUG=eslint:cli-engine eslint --fix", "bull-dashboard": "docker-compose -f docker-compose.bull-monitor.yaml up" }, "dependencies": { "@bisonai/orakl-contracts": "*", - "@bisonai/orakl-vrf": "*", "@bisonai/orakl-util": "*", + "@bisonai/orakl-vrf": "*", "@ethersproject/experimental": "^5.7.0", "@slack/webhook": "^6.1.0", "axios": "^1.2.2", @@ -99,7 +98,6 @@ "eslint": "^8.30.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-prettier": "^4.2.1", - "husky": "^8.0.2", "jest": "^29.3.1", "prettier": "^2.8.1", "prettier-plugin-organize-imports": "^3.2.3", diff --git a/lint-staged.config.js b/lint-staged.config.js index 3c7c6b277..498193248 100644 --- a/lint-staged.config.js +++ b/lint-staged.config.js @@ -1,3 +1,7 @@ module.exports = { "contracts/v0.2/**/*.sol": "yarn contracts-v02 lint", + + "core/**/*": "yarn core test test", + "core/src/**/*.ts": "yarn core lint", + "core/test/**/*.ts": "yarn core lint", };