generated from GenerationSoftware/foundry-template
-
Notifications
You must be signed in to change notification settings - Fork 0
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 619942b
Showing
18 changed files
with
3,066 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,27 @@ | ||
# Mnemonic phrase | ||
MNEMONIC="" | ||
|
||
# Private key | ||
PRIVATE_KEY="" | ||
|
||
# Mainnet RPC URLs | ||
MAINNET_RPC_URL="" | ||
ARBITRUM_RPC_URL="" | ||
OPTIMISM_RPC_URL="" | ||
|
||
# Testnet RPC URLs | ||
SEPOLIA_RPC_URL="" | ||
ARBITRUM_SEPOLIA_RPC_URL="" | ||
OPTIMISM_SEPOLIA_RPC_URL="" | ||
|
||
# Used for verifying contracts on Etherscan | ||
ETHERSCAN_API_KEY="" | ||
ARBITRUM_ETHERSCAN_API_KEY="" | ||
OPTIMISM_ETHERSCAN_API_KEY="" | ||
POLYGONSCAN_API_KEY="" | ||
|
||
# Used to run Hardhat scripts in fork mode | ||
FORK_ENABLED=true | ||
|
||
# Used to report gas usage when running Forge tests | ||
FORGE_GAS_REPORT=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,55 @@ | ||
name: coverage | ||
|
||
on: ["push", "pull_request"] | ||
|
||
env: | ||
FOUNDRY_PROFILE: ci | ||
|
||
jobs: | ||
forge: | ||
environment: ci | ||
strategy: | ||
fail-fast: true | ||
permissions: | ||
pull-requests: write | ||
name: Foundry project | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
|
||
- name: Run Forge build | ||
run: | | ||
forge --version | ||
forge build --sizes | ||
id: build | ||
|
||
- name: Run Forge test with gas report | ||
env: | ||
MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }} | ||
run: | | ||
forge test --gas-report | ||
id: test | ||
|
||
- name: Install lcov | ||
uses: hrishikesh-kadam/[email protected] | ||
|
||
- name: Run Forge coverage | ||
env: | ||
MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }} | ||
run: | | ||
forge coverage --report lcov && lcov --extract lcov.info -o lcov.info 'src/*' | ||
id: coverage | ||
|
||
- name: Report code coverage | ||
uses: zgosalvez/[email protected] | ||
with: | ||
coverage-files: lcov.info | ||
minimum-coverage: 100 | ||
github-token: ${{ secrets.GITHUB_TOKEN }} |
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,25 @@ | ||
# Compiler files | ||
cache/ | ||
coverage/ | ||
out/ | ||
|
||
# Ignores development broadcast logs | ||
!/broadcast | ||
/broadcast/*/31337/ | ||
/broadcast/**/dry-run/ | ||
|
||
# Mac | ||
.DS_Store | ||
|
||
# Secrets | ||
.env | ||
.envrc | ||
|
||
# Coverage | ||
lcov.info | ||
|
||
# VS Code | ||
.history | ||
|
||
# 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.3.0 |
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 format" | ||
], | ||
"*.sol": [ | ||
"npm run hint" | ||
] | ||
} |
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,10 @@ | ||
artifacts | ||
broadcast | ||
cache | ||
cache_hardhat | ||
deployments | ||
lib | ||
out | ||
types | ||
|
||
package.json |
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,14 @@ | ||
{ | ||
"plugins": ["prettier-plugin-solidity"], | ||
"overrides": [ | ||
{ | ||
"files": "*.sol", | ||
"options": { | ||
"compiler": "0.8.24", | ||
"bracketSpacing": true, | ||
"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,11 @@ | ||
{ | ||
"extends": "solhint:recommended", | ||
"plugins": ["prettier"], | ||
"rules": { | ||
"avoid-low-level-calls": "off", | ||
"compiler-version": ["error", "0.8.24"], | ||
"func-visibility": "off", | ||
"no-empty-blocks": "off", | ||
"no-inline-assembly": "off" | ||
} | ||
} |
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,91 @@ | ||
# Foundry template | ||
|
||
Template to kickstart a Foundry project. | ||
|
||
## Getting started | ||
|
||
The easiest way to get started is by clicking the [Use this template](https://github.com/GenerationSoftware/foundry-template/generate) button at the top right of this page. | ||
|
||
If you prefer to go the CLI way: | ||
|
||
``` | ||
forge init my-project --template https://github.com/GenerationSoftware/foundry-template | ||
``` | ||
|
||
## Development | ||
|
||
### Installation | ||
|
||
You may have to install the following tools to use this repository: | ||
|
||
- [Foundry](https://github.com/foundry-rs/foundry) to compile and test contracts | ||
- [direnv](https://direnv.net/) to handle environment variables | ||
- [lcov](https://github.com/linux-test-project/lcov) to generate the code coverage report | ||
|
||
Install dependencies: | ||
|
||
``` | ||
npm i | ||
``` | ||
|
||
### Env | ||
|
||
Copy `.envrc.example` and write down the env variables needed to run this project. | ||
|
||
``` | ||
cp .envrc.example .envrc | ||
``` | ||
|
||
Once your env variables are setup, load them with: | ||
|
||
``` | ||
direnv allow | ||
``` | ||
|
||
### Compile | ||
|
||
Run the following command to compile the contracts: | ||
|
||
``` | ||
npm run compile | ||
``` | ||
|
||
### Coverage | ||
|
||
Forge is used for coverage, run it with: | ||
|
||
``` | ||
npm run coverage | ||
``` | ||
|
||
You can then consult the report by opening `coverage/index.html`: | ||
|
||
``` | ||
open coverage/index.html | ||
``` | ||
|
||
### Code quality | ||
|
||
[Husky](https://typicode.github.io/husky/#/) is used to run [lint-staged](https://github.com/okonet/lint-staged) and tests when committing. | ||
|
||
[Prettier](https://prettier.io) is used to format TypeScript and Solidity code. Use it by running: | ||
|
||
``` | ||
npm run format | ||
``` | ||
|
||
[Solhint](https://protofire.github.io/solhint/) is used to lint Solidity files. Run it with: | ||
|
||
``` | ||
npm run hint | ||
``` | ||
|
||
### CI | ||
|
||
A default Github Actions workflow is setup to execute on push and pull request. | ||
|
||
It will build the contracts and run the test coverage. | ||
|
||
You can modify it here: [.github/workflows/coverage.yml](.github/workflows/coverage.yml) | ||
|
||
For the coverage to work, you will need to setup the `MAINNET_RPC_URL` repository secret in the settings of your Github repository. |
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,28 @@ | ||
[profile.default] | ||
src = 'src' | ||
out = 'out' | ||
test = 'test' | ||
libs = ['lib'] | ||
solc = "0.8.24" | ||
fs_permissions = [{ access = "read", path = "./broadcast" }] | ||
gas_reports = ["Foo"] | ||
|
||
[rpc_endpoints] | ||
mainnet = "${MAINNET_RPC_URL}" | ||
arbitrum = "${ARBITRUM_RPC_URL}" | ||
optimism = "${OPTIMISM_RPC_URL}" | ||
|
||
sepolia = "${SEPOLIA_RPC_URL}" | ||
arbitrum-sepolia = "${ARBITRUM_SEPOLIA_RPC_URL}" | ||
optimism-sepolia = "${OPTIMISM_SEPOLIA_RPC_URL}" | ||
|
||
[etherscan] | ||
mainnet = { key = "${ETHERSCAN_API_KEY}", url = "https://api.etherscan.io/api" } | ||
arbitrum = { key = "${ARBITRUM_ETHERSCAN_API_KEY}", url = "https://api.arbiscan.io/api" } | ||
optimism = { key = "${OPTIMISM_ETHERSCAN_API_KEY}", url = "https://api-optimistic.etherscan.io/api" } | ||
|
||
sepolia = { key = "${ETHERSCAN_API_KEY}", url = "https://api-sepolia.etherscan.io/api" } | ||
arbitrum-sepolia = { key = "${ARBITRUM_ETHERSCAN_API_KEY}", url = "https://api-sepolia.arbiscan.io/api" } | ||
optimism-sepolia = { key = "${OPTIMISM_ETHERSCAN_API_KEY}", url = "https://api-sepolia-optimistic.etherscan.io/api" } | ||
|
||
# See more config options https://github.com/foundry-rs/foundry/tree/master/config |
Oops, something went wrong.