Skip to content

Commit c3dc859

Browse files
authored
Slither and Solhint enabled on all future PRs (#172)
This PR resolves all Slither and Solhint issues (but disables them for the recently added PaymentSplitter). It adds the checks to that they will apply for each PR. Documentation is added to provide more information on building new contracts.
1 parent 8167edd commit c3dc859

File tree

66 files changed

+792
-864
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+792
-864
lines changed

.github/workflows/test.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ jobs:
5252
- name: Install dependencies
5353
run: yarn install --frozen-lockfile --network-concurrency 1
5454
- name: Run eslint
55-
continue-on-error: true
5655
run: yarn run eslint
5756
solhint:
5857
name: Run solhint
@@ -68,8 +67,23 @@ jobs:
6867
- name: Install dependencies
6968
run: yarn install --frozen-lockfile --network-concurrency 1
7069
- name: Run solhint
71-
continue-on-error: true
7270
run: yarn run solhint contracts/**/*.sol
71+
slither:
72+
name: Run slither
73+
runs-on: ubuntu-latest
74+
steps:
75+
- name: Checkout Code
76+
uses: actions/checkout@v3
77+
- name: Install Slither
78+
run: sudo pip3 install slither-analyzer
79+
- name: Show Slither Version
80+
run: slither --version
81+
- name: Install Foundry
82+
uses: foundry-rs/foundry-toolchain@v1
83+
- name: Show Forge Version
84+
run: forge --version
85+
- name: Run slither
86+
run: slither --compile-force-framework forge --foundry-out-directory foundry-out .
7387
publish:
7488
name: Publish to NPM (dry run)
7589
runs-on: ubuntu-latest

BUILD.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Build and Test Information
2+
3+
## Install
4+
5+
Install dependencies:
6+
7+
```
8+
yarn install
9+
sudo pip3 install slither-analyzer
10+
```
11+
12+
## Build and Test
13+
14+
To build and test the contracts:
15+
16+
```
17+
forge test -vvv
18+
yarn test
19+
```
20+
21+
## Solidity Linter
22+
23+
To execute solhint:
24+
25+
```
26+
yarn run solhint contracts/**/*.sol
27+
```
28+
29+
To resolve formatting issues:
30+
31+
```
32+
npx prettier --write --plugin=prettier-plugin-solidity 'contracts/**/*.sol'
33+
```
34+
35+
36+
## Static Code Analysis
37+
38+
To run slither:
39+
40+
```
41+
slither --compile-force-framework forge --foundry-out-directory foundry-out .
42+
```
43+
44+
## Test Coverage
45+
46+
To check the test coverage based on Foundry tests use:
47+
48+
```
49+
forge coverage
50+
```

CONTRIBUTING.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,19 @@ git pull upstream main
5858
git checkout -b <your-branch-name>
5959
```
6060

61-
6. Be sure to run the tests and set up the relevant linters to ensure all GitHub checks pass (see GitHub issues: https://docs.github.com/en/issues/tracking-your-work-with-issues/about-issues for more information).
61+
6. Be sure to run the tests and set up the relevant linters to ensure all GitHub checks pass (see GitHub issues: https://docs.github.com/en/issues/tracking-your-work-with-issues/about-issues, and [build information](BUILD.md) for more information). New test code should use Foundry tests and not Hardhat.
6262

6363
```
64+
forge test -vvv
6465
yarn test
6566
```
6667

68+
Test coverage for all new code must be 100%. To check your test coverage:
69+
70+
```
71+
forge coverage
72+
```
73+
6774
7. Add and commit your changes, including a comprehensive commit message summarising your changes, then push changes to your fork. (e.g. Fixed formatting issue with ImmutableERC721MintByID.sol)
6875

6976
```

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Immutable Contracts is a library of smart contracts targeted at developers who w
1212

1313
- Smart Contract Wallets
1414

15+
- Random Number Generation
16+
1517
These contracts are feature-rich and are the recommended standard on Immutable zkEVM intended for all users and partners within the ecosystem.
1618

1719
## Setup
@@ -77,6 +79,10 @@ const mintTransaction = await client.populateMint(receiver, 1);
7779
const tx = await signer.sendTransaction(mintTransaction);
7880
```
7981

82+
## Build and Test
83+
84+
Information about how to build and test the contracts can be found in our [build information](BUILD.md).
85+
8086
## Contribution
8187

8288
We aim to build robust and feature-rich standards to help all developers onboard and build their projects on Immuable zkEVM, and we welcome any and all feedback and contributions to this repository! See our [contribution guideline](CONTRIBUTING.md) for more details on opening Github issues, pull requests requesting features, minor security vulnerabilities and providing general feedback.

clients/erc20.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class ERC20Client {
2929
public async balanceOf(
3030
provider: Provider,
3131
account: PromiseOrValue<string>,
32-
overrides: CallOverrides = {}
32+
overrides: CallOverrides = {},
3333
): Promise<BigNumber> {
3434
return this.contract.connect(provider).balanceOf(account, overrides);
3535
}
@@ -41,7 +41,7 @@ export class ERC20Client {
4141
provider: Provider,
4242
owner: PromiseOrValue<string>,
4343
spender: PromiseOrValue<string>,
44-
overrides: CallOverrides = {}
44+
overrides: CallOverrides = {},
4545
): Promise<BigNumber> {
4646
return this.contract.connect(provider).allowance(owner, spender, overrides);
4747
}
@@ -52,7 +52,7 @@ export class ERC20Client {
5252
public async populateTransfer(
5353
to: PromiseOrValue<string>,
5454
amount: PromiseOrValue<BigNumberish>,
55-
overrides: Overrides & { from?: PromiseOrValue<string> } = {}
55+
overrides: Overrides & { from?: PromiseOrValue<string> } = {},
5656
): Promise<PopulatedTransaction> {
5757
return this.contract.populateTransaction.transfer(to, amount, { ...defaultGasOverrides, ...overrides });
5858
}
@@ -63,7 +63,7 @@ export class ERC20Client {
6363
public async populateApprove(
6464
spender: PromiseOrValue<string>,
6565
amount: PromiseOrValue<BigNumberish>,
66-
overrides: Overrides & { from?: PromiseOrValue<string> } = {}
66+
overrides: Overrides & { from?: PromiseOrValue<string> } = {},
6767
): Promise<PopulatedTransaction> {
6868
return this.contract.populateTransaction.approve(spender, amount, { ...defaultGasOverrides, ...overrides });
6969
}
@@ -75,7 +75,7 @@ export class ERC20Client {
7575
from: PromiseOrValue<string>,
7676
to: PromiseOrValue<string>,
7777
amount: PromiseOrValue<BigNumberish>,
78-
overrides: Overrides & { from?: PromiseOrValue<string> } = {}
78+
overrides: Overrides & { from?: PromiseOrValue<string> } = {},
7979
): Promise<PopulatedTransaction> {
8080
return this.contract.populateTransaction.transferFrom(from, to, amount, { ...defaultGasOverrides, ...overrides });
8181
}

0 commit comments

Comments
 (0)