Skip to content

Commit

Permalink
chore(contract): apply linter for deploy scripts and contracts
Browse files Browse the repository at this point in the history
- [x] Update hardhat, ethers and add @nomicfoundation/hardhat-toolbox
- [x] Linter fixes for deploy scripts
- [x] Prettier fixes for solidity contracts
- [x] Optimize e2e workflow
- [x] Fixes for cli and integrations tests due to contracts dependency update
- [x] Type fixes
  • Loading branch information
0xmad authored and ctrlc03 committed Dec 7, 2023
1 parent 7aa1f93 commit 9af9c04
Show file tree
Hide file tree
Showing 111 changed files with 17,387 additions and 7,076 deletions.
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
node_modules
dist
coverage
build
build
typechain-types
.eslintrc.js
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
command: ["prettier", "lint"]
command: ["prettier", "lint:ts"]

runs-on: ubuntu-22.04

Expand Down
17 changes: 7 additions & 10 deletions .github/workflows/reusable-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ on:

jobs:
e2e:
strategy:
fail-fast: false
matrix:
command: ["test:cli", "test:integration"]

runs-on: ubuntu-22.04

steps:
Expand Down Expand Up @@ -53,7 +58,6 @@ jobs:
- name: Compile Contracts
run: |
cd contracts
npm run compileSol
npm run hardhat &
sleep 5
Expand Down Expand Up @@ -84,15 +88,8 @@ jobs:
cd integrationTests
npm run download-zkeys
- name: Bespoke Test
run: |
cd cli
npm run test
- name: Integration Test
run: |
cd integrationTests
npm run test
- name: ${{ matrix.command }}
run: npm run ${{ matrix.command }}

- name: Stop Hardhat
run: kill $(lsof -t -i:8545)
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ contracts/artifacts
contracts/compiled
cli/cache
contracts/cache
typechain-types/

node_modules
blake2sdef.json
Expand Down
4 changes: 2 additions & 2 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"**/*.ts": ["prettier --ignore-unknown --write", "eslint --fix"],
"**/*.{sol, yaml, yml, md}": ["prettier --ignore-unknown --write"]
"**/*.{ts,js}": ["prettier --ignore-unknown --write", "eslint --fix"],
"**/*.{sol, yaml, yml, md, json}": ["prettier --ignore-unknown --write"]
}
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ package-lock.json
**/package-lock.json
CHANGELOG.md
.eslintignore
circuits/ts/verifier_groth16.sol
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"plugins": ["prettier-plugin-solidity"],
"arrowParens": "always",
"bracketSpacing": true,
"endOfLine": "lf",
Expand All @@ -13,6 +14,8 @@
"files": "*.sol",
"options": {
"printWidth": 120,
"useTabs": false,
"singleQuote": false,
"semi": true
}
}
Expand Down
11 changes: 11 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "solhint:recommended",
"rules": {
"avoid-suicide": "error",
"avoid-sha3": "warn",
"max-line-length": ["warn", 120],
"quotes": ["error", "single"],
"func-visibility": ["error", { "ignoreConstructors": true }],
"state-visibility": "error"
}
}
4 changes: 2 additions & 2 deletions circuits/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion circuits/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"devDependencies": {
"@types/chai": "^4.3.11",
"@types/mocha": "^10.0.4",
"@types/mocha": "^10.0.6",
"@types/node": "^18.11.9",
"chai": "^4.3.10",
"circom_tester": "^0.0.20",
Expand Down
23 changes: 0 additions & 23 deletions cli/hardhat.config.js

This file was deleted.

25 changes: 25 additions & 0 deletions cli/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";

import path from "path";

import { DEFAULT_ETH_SK, DEFAULT_ETH_PROVIDER } from "./ts/utils/defaults";

const parentDir = __dirname.includes("build") ? ".." : "";

const config: HardhatUserConfig = {
defaultNetwork: "localhost",
networks: {
localhost: {
url: process.env.ETH_PROVIDER || DEFAULT_ETH_PROVIDER,
accounts: [process.env.ETH_SK || DEFAULT_ETH_SK],
loggingEnabled: false,
},
},
paths: {
sources: path.resolve(__dirname, parentDir, "../contracts/contracts"),
artifacts: path.resolve(__dirname, parentDir, "../contracts/artifacts"),
},
};

export default config;
Loading

0 comments on commit 9af9c04

Please sign in to comment.