Skip to content

Commit 40801a8

Browse files
authored
Initial commit
0 parents  commit 40801a8

18 files changed

Lines changed: 3066 additions & 0 deletions

.env.example

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Mnemonic phrase
2+
MNEMONIC=""
3+
4+
# Private key
5+
PRIVATE_KEY=""
6+
7+
# Mainnet RPC URLs
8+
MAINNET_RPC_URL=""
9+
ARBITRUM_RPC_URL=""
10+
OPTIMISM_RPC_URL=""
11+
12+
# Testnet RPC URLs
13+
SEPOLIA_RPC_URL=""
14+
ARBITRUM_SEPOLIA_RPC_URL=""
15+
OPTIMISM_SEPOLIA_RPC_URL=""
16+
17+
# Used for verifying contracts on Etherscan
18+
ETHERSCAN_API_KEY=""
19+
ARBITRUM_ETHERSCAN_API_KEY=""
20+
OPTIMISM_ETHERSCAN_API_KEY=""
21+
POLYGONSCAN_API_KEY=""
22+
23+
# Used to run Hardhat scripts in fork mode
24+
FORK_ENABLED=true
25+
26+
# Used to report gas usage when running Forge tests
27+
FORGE_GAS_REPORT=true

.github/workflows/coverage.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: coverage
2+
3+
on: ["push", "pull_request"]
4+
5+
env:
6+
FOUNDRY_PROFILE: ci
7+
8+
jobs:
9+
forge:
10+
environment: ci
11+
strategy:
12+
fail-fast: true
13+
permissions:
14+
pull-requests: write
15+
name: Foundry project
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v3
19+
with:
20+
submodules: recursive
21+
22+
- name: Install Foundry
23+
uses: foundry-rs/foundry-toolchain@v1
24+
with:
25+
version: nightly
26+
27+
- name: Run Forge build
28+
run: |
29+
forge --version
30+
forge build --sizes
31+
id: build
32+
33+
- name: Run Forge test with gas report
34+
env:
35+
MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }}
36+
run: |
37+
forge test --gas-report
38+
id: test
39+
40+
- name: Install lcov
41+
uses: hrishikesh-kadam/setup-lcov@v1.0.0
42+
43+
- name: Run Forge coverage
44+
env:
45+
MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }}
46+
run: |
47+
forge coverage --report lcov && lcov --extract lcov.info -o lcov.info 'src/*'
48+
id: coverage
49+
50+
- name: Report code coverage
51+
uses: zgosalvez/github-actions-report-lcov@v1.5.0
52+
with:
53+
coverage-files: lcov.info
54+
minimum-coverage: 100
55+
github-token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Compiler files
2+
cache/
3+
coverage/
4+
out/
5+
6+
# Ignores development broadcast logs
7+
!/broadcast
8+
/broadcast/*/31337/
9+
/broadcast/**/dry-run/
10+
11+
# Mac
12+
.DS_Store
13+
14+
# Secrets
15+
.env
16+
.envrc
17+
18+
# Coverage
19+
lcov.info
20+
21+
# VS Code
22+
.history
23+
24+
# Modules
25+
node_modules

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "lib/forge-std"]
2+
path = lib/forge-std
3+
url = https://github.com/foundry-rs/forge-std
4+
branch = v1.3.0

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npm run lint-staged && npm test

.lintstagedrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"*.{json,md,sol,yml}": [
3+
"npm run format"
4+
],
5+
"*.sol": [
6+
"npm run hint"
7+
]
8+
}

.prettierignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
artifacts
2+
broadcast
3+
cache
4+
cache_hardhat
5+
deployments
6+
lib
7+
out
8+
types
9+
10+
package.json

.prettierrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"plugins": ["prettier-plugin-solidity"],
3+
"overrides": [
4+
{
5+
"files": "*.sol",
6+
"options": {
7+
"compiler": "0.8.24",
8+
"bracketSpacing": true,
9+
"printWidth": 120,
10+
"tabWidth": 4
11+
}
12+
}
13+
]
14+
}

.solhint.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "solhint:recommended",
3+
"plugins": ["prettier"],
4+
"rules": {
5+
"avoid-low-level-calls": "off",
6+
"compiler-version": ["error", "0.8.24"],
7+
"func-visibility": "off",
8+
"no-empty-blocks": "off",
9+
"no-inline-assembly": "off"
10+
}
11+
}

README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Foundry template
2+
3+
Template to kickstart a Foundry project.
4+
5+
## Getting started
6+
7+
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.
8+
9+
If you prefer to go the CLI way:
10+
11+
```
12+
forge init my-project --template https://github.com/GenerationSoftware/foundry-template
13+
```
14+
15+
## Development
16+
17+
### Installation
18+
19+
You may have to install the following tools to use this repository:
20+
21+
- [Foundry](https://github.com/foundry-rs/foundry) to compile and test contracts
22+
- [direnv](https://direnv.net/) to handle environment variables
23+
- [lcov](https://github.com/linux-test-project/lcov) to generate the code coverage report
24+
25+
Install dependencies:
26+
27+
```
28+
npm i
29+
```
30+
31+
### Env
32+
33+
Copy `.envrc.example` and write down the env variables needed to run this project.
34+
35+
```
36+
cp .envrc.example .envrc
37+
```
38+
39+
Once your env variables are setup, load them with:
40+
41+
```
42+
direnv allow
43+
```
44+
45+
### Compile
46+
47+
Run the following command to compile the contracts:
48+
49+
```
50+
npm run compile
51+
```
52+
53+
### Coverage
54+
55+
Forge is used for coverage, run it with:
56+
57+
```
58+
npm run coverage
59+
```
60+
61+
You can then consult the report by opening `coverage/index.html`:
62+
63+
```
64+
open coverage/index.html
65+
```
66+
67+
### Code quality
68+
69+
[Husky](https://typicode.github.io/husky/#/) is used to run [lint-staged](https://github.com/okonet/lint-staged) and tests when committing.
70+
71+
[Prettier](https://prettier.io) is used to format TypeScript and Solidity code. Use it by running:
72+
73+
```
74+
npm run format
75+
```
76+
77+
[Solhint](https://protofire.github.io/solhint/) is used to lint Solidity files. Run it with:
78+
79+
```
80+
npm run hint
81+
```
82+
83+
### CI
84+
85+
A default Github Actions workflow is setup to execute on push and pull request.
86+
87+
It will build the contracts and run the test coverage.
88+
89+
You can modify it here: [.github/workflows/coverage.yml](.github/workflows/coverage.yml)
90+
91+
For the coverage to work, you will need to setup the `MAINNET_RPC_URL` repository secret in the settings of your Github repository.

0 commit comments

Comments
 (0)