generated from m0-foundation/foundry-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 939ca6e
Showing
24 changed files
with
2,788 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Localhost RPC URL | ||
export LOCALHOST_RPC_URL=http://127.0.0.1:8545 | ||
|
||
# Mainnet RPC URLs | ||
export MAINNET_RPC_URL= | ||
|
||
# Testnet RPC URLs | ||
export SEPOLIA_RPC_URL= | ||
|
||
# Used for verifying contracts on Etherscan | ||
export ETHERSCAN_API_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Forge Coverage | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
permissions: write-all | ||
|
||
jobs: | ||
check: | ||
name: Code Coverage | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
|
||
- name: Install lcov | ||
uses: hrishikesh-kadam/setup-lcov@v1 | ||
|
||
- name: Run coverage | ||
env: | ||
MNEMONIC: ${{ secrets.MNEMONIC_FOR_TESTS }} | ||
MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }} | ||
run: make coverage profile=ci | ||
id: coverage | ||
|
||
- name: Report code coverage | ||
uses: zgosalvez/github-actions-report-lcov@v3 | ||
with: | ||
coverage-files: lcov.info | ||
artifact-name: code-coverage-report | ||
minimum-coverage: 95 | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
update-comment: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# name: Forge Fuzz Tests | ||
# | ||
# on: | ||
# push: | ||
# branches: | ||
# - main | ||
# pull_request: | ||
# | ||
# permissions: write-all | ||
# | ||
# jobs: | ||
# check: | ||
# name: Fuzz Tests | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - uses: actions/checkout@v4 | ||
# with: | ||
# submodules: recursive | ||
# | ||
# - name: Install Foundry | ||
# uses: foundry-rs/foundry-toolchain@v1 | ||
# | ||
# - name: Run Forge build | ||
# run: | | ||
# forge --version | ||
# make sizes | ||
# id: build | ||
# | ||
# - name: Run Forge fuzz tests | ||
# run: make fuzz profile=ci | ||
# env: | ||
# # make fuzzing semi-deterministic to avoid noisy gas cost estimation | ||
# # due to non-deterministic fuzzing (but still use pseudo-random fuzzing seeds) | ||
# FOUNDRY_FUZZ_SEED: 0x${{ github.event.pull_request.base.sha || github.sha }} | ||
# MNEMONIC: ${{ secrets.MNEMONIC_FOR_TESTS }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Forge Tests Gas Report | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
permissions: write-all | ||
|
||
jobs: | ||
check: | ||
name: Gas report | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
|
||
- name: Run Forge build | ||
run: | | ||
forge --version | ||
make sizes | ||
id: build | ||
|
||
- name: Run Forge tests with gas report | ||
run: make gas-report profile=ci | ||
env: | ||
# make fuzzing semi-deterministic to avoid noisy gas cost estimation | ||
# due to non-deterministic fuzzing (but still use pseudo-random fuzzing seeds) | ||
FOUNDRY_FUZZ_SEED: 0x${{ github.event.pull_request.base.sha || github.sha }} | ||
MNEMONIC: ${{ secrets.MNEMONIC_FOR_TESTS }} | ||
MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }} | ||
|
||
- name: Compare gas reports | ||
uses: Rubilmax/foundry-gas-diff@v3.16 | ||
id: gas_diff | ||
|
||
- name: Add gas diff to sticky comment | ||
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target' | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
# delete the comment in case changes no longer impact gas costs | ||
delete: ${{ !steps.gas_diff.outputs.markdown }} | ||
message: ${{ steps.gas_diff.outputs.markdown }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# name: Forge Integration Tests | ||
# | ||
# on: | ||
# push: | ||
# branches: | ||
# - main | ||
# pull_request: | ||
# | ||
# permissions: write-all | ||
# | ||
# jobs: | ||
# check: | ||
# name: Integration Tests | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - uses: actions/checkout@v4 | ||
# with: | ||
# submodules: recursive | ||
# | ||
# - name: Install Foundry | ||
# uses: foundry-rs/foundry-toolchain@v1 | ||
# | ||
# - name: Run Forge build | ||
# run: | | ||
# forge --version | ||
# make sizes | ||
# id: build | ||
# | ||
# - name: Run Forge integration tests | ||
# run: make integration profile=ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# name: Forge Invariant Tests | ||
# | ||
# on: | ||
# push: | ||
# branches: | ||
# - main | ||
# pull_request: | ||
# | ||
# permissions: write-all | ||
# | ||
# jobs: | ||
# check: | ||
# name: Invariant Tests | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - uses: actions/checkout@v4 | ||
# with: | ||
# submodules: recursive | ||
# | ||
# - name: Install Foundry | ||
# uses: foundry-rs/foundry-toolchain@v1 | ||
# | ||
# - name: Run Forge build | ||
# run: | | ||
# forge --version | ||
# make sizes | ||
# id: build | ||
# | ||
# - name: Run Forge invariant tests | ||
# run: make invariant profile=ci | ||
# env: | ||
# # make fuzzing semi-deterministic to avoid noisy gas cost estimation | ||
# # due to non-deterministic fuzzing (but still use pseudo-random fuzzing seeds) | ||
# FOUNDRY_FUZZ_SEED: 0x${{ github.event.pull_request.base.sha || github.sha }} | ||
# MNEMONIC: ${{ secrets.MNEMONIC_FOR_TESTS }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Compiler files | ||
cache/ | ||
out/ | ||
|
||
# Ignores development broadcast logs | ||
!/broadcast | ||
/broadcast/*/31337/ | ||
/broadcast/**/dry-run/ | ||
|
||
# Coverage files | ||
coverage/ | ||
lcov.info | ||
|
||
# Docs | ||
docs/ | ||
|
||
# Dotenv file | ||
.env | ||
|
||
# Mac OS files | ||
.DS_Store | ||
|
||
# NPM modules | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[submodule "lib/forge-std"] | ||
path = lib/forge-std | ||
url = https://github.com/foundry-rs/forge-std | ||
branch = v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npm run lint-staged && npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"*.{json,md,sol,yml}": [ | ||
"npm run prettier" | ||
], | ||
"*.sol": [ | ||
"npm run solhint" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"plugins": ["prettier-plugin-solidity"], | ||
"overrides": [ | ||
{ | ||
"files": "*.sol", | ||
"options": { | ||
"bracketSpacing": true, | ||
"compiler": "0.8.25", | ||
"parser": "solidity-parse", | ||
"printWidth": 120, | ||
"tabWidth": 4, | ||
} | ||
} | ||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"extends": ["solhint:recommended"], | ||
"plugins": ["prettier"], | ||
"rules": { | ||
"prettier/prettier": "error", | ||
"code-complexity": ["warn", 10], | ||
"compiler-version": ["error", "0.8.25"], | ||
"comprehensive-interface": "off", | ||
"const-name-snakecase": "off", | ||
"func-name-mixedcase": "off", | ||
"func-visibility": [ | ||
"warn", | ||
{ | ||
"ignoreConstructors": true | ||
} | ||
], | ||
"function-max-lines": ["warn", 100], | ||
"immutable-vars-naming": "off", | ||
"imports-on-top": "error", | ||
"max-line-length": ["warn", 120], | ||
"no-empty-blocks": "off", | ||
"no-inline-assembly": "off", | ||
"not-rely-on-time": "off", | ||
"private-vars-leading-underscore": [ | ||
"warn", | ||
{ | ||
"strict": true | ||
} | ||
], | ||
"visibility-modifier-order": "error" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# include .env file and export its env vars | ||
# (-include to ignore error if it does not exist) | ||
-include .env | ||
|
||
# dapp deps | ||
update:; forge update | ||
|
||
# Deployment helpers | ||
deploy-local :; FOUNDRY_PROFILE=production forge script script/Deploy.s.sol --rpc-url localhost --broadcast -v | ||
deploy-sepolia :; FOUNDRY_PROFILE=production forge script script/Deploy.s.sol --rpc-url sepolia --broadcast -vvv | ||
|
||
# Run slither | ||
slither :; FOUNDRY_PROFILE=production forge build --build-info --skip '*/test/**' --skip '*/script/**' --force && slither --compile-force-framework foundry --ignore-compile --sarif results.sarif --config-file slither.config.json . | ||
|
||
# Common tasks | ||
profile ?=default | ||
|
||
build: | ||
@./build.sh -p production | ||
|
||
test: | ||
@./test.sh -p $(profile) | ||
|
||
fuzz: | ||
@./test.sh -t testFuzz -p $(profile) | ||
|
||
integration: | ||
@./test.sh -d test/integration -p $(profile) | ||
|
||
invariant: | ||
@./test.sh -d test/invariant -p $(profile) | ||
|
||
coverage: | ||
FOUNDRY_PROFILE=$(profile) forge coverage --no-match-path 'test/invariant/**/*.sol' --report lcov && lcov --extract lcov.info -o lcov.info 'src/*' && genhtml lcov.info -o coverage | ||
|
||
gas-report: | ||
FOUNDRY_PROFILE=$(profile) forge test --gas-report > gasreport.ansi | ||
|
||
sizes: | ||
@./build.sh -p production -s | ||
|
||
clean: | ||
forge clean && rm -rf ./abi && rm -rf ./bytecode && rm -rf ./types | ||
|
Oops, something went wrong.