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

chore: add local slither script #34

Merged
merged 4 commits into from
Aug 7, 2024
Merged
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: 1 addition & 1 deletion .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"**/*.{js,ts,md,json,sol,yml,yaml}": "prettier --write"
"**/*.{js,ts,md,json,sol,yml,yaml}": "yarn prettier --write"
cedoor marked this conversation as resolved.
Show resolved Hide resolved
}
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,23 @@ or to automatically format the code:
yarn format:write
```

### Linting

```bash
yarn lint
```

Will lint all the packages with [`solhint`](https://github.com/protofire/solhint)

### Static Analysis

```bash
yarn slither
```

Will perform a static analysis of all the contracts with [`slither`](https://github.com/crytic/slither) to identify potential vulnerabilities.
You'll need to [install slither](https://github.com/crytic/slither?tab=readme-ov-file#how-to-install) beforehand.

### Conventional commits

ZK-Kit uses [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/). A [command line utility](https://github.com/commitizen/cz-cli) to commit using the correct syntax can be used by running:
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
"format": "prettier -c .",
"format:write": "prettier -w .",
"remove:stable-version-field": "ts-node scripts/remove-stable-version-field.ts ${0} && yarn format:write",
"postinstall": "husky && git config --local core.editor cat"
"lint": "yarn workspaces foreach -Ap run lint",
"postinstall": "husky && git config --local core.editor cat",
"slither": "./scripts/check-slither.sh && yarn workspaces foreach -Ap run slither"
},
"keywords": [
"solidity",
Expand Down
3 changes: 2 additions & 1 deletion packages/excubiae/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"test:report-gas": "REPORT_GAS=true hardhat test",
"test:coverage": "hardhat coverage",
"typechain": "hardhat typechain",
"lint": "solhint 'contracts/**/*.sol'"
"lint": "solhint 'contracts/**/*.sol'",
"slither": "slither . --include-paths contracts --exclude-dependencies --ignore-compile"
},
"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "^2.0.3",
Expand Down
3 changes: 2 additions & 1 deletion packages/imt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"test:report-gas": "REPORT_GAS=true hardhat test",
"test:coverage": "hardhat coverage",
"typechain": "hardhat typechain",
"lint": "solhint 'contracts/**/*.sol'"
"lint": "solhint 'contracts/**/*.sol'",
"slither": "slither . --include-paths contracts --exclude-dependencies --ignore-compile"
},
"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "^2.0.3",
Expand Down
3 changes: 2 additions & 1 deletion packages/lazy-imt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"test:report-gas": "REPORT_GAS=true hardhat test",
"test:coverage": "hardhat coverage",
"typechain": "hardhat typechain",
"lint": "solhint 'contracts/**/*.sol'"
"lint": "solhint 'contracts/**/*.sol'",
"slither": "slither . --include-paths contracts --exclude-dependencies --ignore-compile"
},
"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "^2.0.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/lazy-imt/test/LazyIMT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ describe("LazyIMT", () => {
const staticRoot = await lazyIMTTest.staticRoot(depth)

// If they match, proof is valid
await expect(calculatedRoot).to.be.equal(staticRoot)
expect(calculatedRoot).to.be.equal(staticRoot)
}

// Done with test, revert the tree state
Expand Down
3 changes: 2 additions & 1 deletion packages/lazytower/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"test:report-gas": "REPORT_GAS=true hardhat test",
"test:coverage": "hardhat coverage",
"typechain": "hardhat typechain",
"lint": "solhint 'contracts/**/*.sol'"
"lint": "solhint 'contracts/**/*.sol'",
"slither": "slither . --include-paths contracts --exclude-dependencies --ignore-compile"
},
"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "^2.0.3",
Expand Down
3 changes: 2 additions & 1 deletion packages/lean-imt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"test:report-gas": "REPORT_GAS=true hardhat test",
"test:coverage": "hardhat coverage",
"typechain": "hardhat typechain",
"lint": "solhint 'contracts/**/*.sol'"
"lint": "solhint 'contracts/**/*.sol'",
"slither": "slither . --include-paths contracts --exclude-dependencies --ignore-compile"
},
"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "^2.0.3",
Expand Down
19 changes: 19 additions & 0 deletions scripts/check-slither.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh
set -eu

CYAN="\033[36m"
RED="\033[31m"
RESET="\033[0m"

log() {
printf "%b\n" "$1"
}

main() {
if ! command -v slither >/dev/null; then
log "${RED}error: slither is required but is not installed${RESET}.\nFollow instructions at ${CYAN}https://github.com/crytic/slither?tab=readme-ov-file#how-to-install${RESET} and try again."
exit 1
fi
}

main