Skip to content

Commit

Permalink
Workflow with solhint (#101)
Browse files Browse the repository at this point in the history
* solhint cli

* update solhint checkpoints

* Update contracts/protocol/VoteWeigher.sol

Co-authored-by: cool-developer <[email protected]>

---------

Co-authored-by: cool-developer <[email protected]>
  • Loading branch information
ChainDev931105 and cool-develope authored May 14, 2024
1 parent fbd5f0f commit 94aadf3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/solhint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Solhint

on:
push:
branches:
- master
- develop
pull_request:

jobs:
solhint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install node dependencies
run: npm install solhint

- name: Validate PR commits with solhint
run: npx solhint "contracts/protocol/*.sol" --max-warnings 0
5 changes: 4 additions & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"contract-name-camelcase": "off",
"func-name-mixedcase": "off",
"var-name-mixedcase": "off",
"compiler-version": "off"
"compiler-version": "off",
"custom-errors": "off",
"no-global-import": "off",
"immutable-vars-naming": "off"
}
}
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ format:
npx prettier --write {test,util}/**/*.js
forge fmt

solhint:
npx solhint "contracts/protocol/*.sol"

.PHONY: format

# Register one random operator
Expand Down
2 changes: 1 addition & 1 deletion contracts/protocol/LagrangeCommittee.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ contract LagrangeCommittee is Initializable, OwnableUpgradeable, ILagrangeCommit
// ChainID => Operator address[]
mapping(uint32 => address[]) public committeeAddrs;
// Tree Depth => Node Value
mapping(uint8 => bytes32) zeroHashes;
mapping(uint8 => bytes32) private zeroHashes;

mapping(address => OperatorStatus) public operatorsStatus;

Expand Down
4 changes: 2 additions & 2 deletions contracts/protocol/VoteWeigher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ contract VoteWeigher is Initializable, OwnableUpgradeable, IVoteWeigher {

IStakeManager public immutable stakeManager;

uint8[] quorumNumbers; // list of all quorum numbers
uint8[] public quorumNumbers; // list of all quorum numbers

event QuorumAdded(uint8 indexed quorumNumber, TokenMultiplier[] multipliers);
event QuorumRemoved(uint8 indexed quorumNumber);
Expand Down Expand Up @@ -67,7 +67,7 @@ contract VoteWeigher is Initializable, OwnableUpgradeable, IVoteWeigher {
quorumMultipliers[quorumNumber].push(multiplier);
} else {
uint256 _length = quorumMultipliers[quorumNumber].length;
for (uint i; i < _length; i++) {
for (uint256 i; i < _length; i++) {
if (i != index) {
require(quorumMultipliers[quorumNumber][i].token != multiplier.token, "Multiplier already exists");
}
Expand Down

0 comments on commit 94aadf3

Please sign in to comment.