generated from Uniswap/foundry-template
-
Notifications
You must be signed in to change notification settings - Fork 9
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 49d13d1
Showing
40 changed files
with
1,069 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,3 @@ | ||
PRIVATE_KEY= | ||
INFURA_KEY= | ||
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 @@ | ||
26304 |
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 @@ | ||
26394 |
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,31 @@ | ||
name: Bug report | ||
description: File a bug report to help us improve the code | ||
title: "[Bug]: " | ||
labels: ["bug"] | ||
|
||
body: | ||
- type: markdown | ||
attributes: | ||
value: | | ||
Please check that the bug is not already being tracked. | ||
- type: textarea | ||
attributes: | ||
label: Describe the bug | ||
description: Provide a clear and concise description of what the bug is and which contracts it affects. | ||
validations: | ||
required: true | ||
- type: textarea | ||
attributes: | ||
label: Expected Behavior | ||
description: Provide a clear and concise description of the desired fix. | ||
validations: | ||
required: true | ||
- type: textarea | ||
attributes: | ||
label: To Reproduce | ||
description: If you have written tests to showcase the bug, what can we run to reproduce the issue? | ||
placeholder: "git checkout <branchname> / forge test --isolate --mt <testName>" | ||
- type: textarea | ||
attributes: | ||
label: Additional context | ||
description: If there is any additional context needed like a dependency or integrating contract that is affected please describe it below. |
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,37 @@ | ||
name: Feature Improvement | ||
description: Suggest an improvement. | ||
labels: ["triage"] | ||
|
||
body: | ||
- type: markdown | ||
attributes: | ||
value: | | ||
Please ensure that the feature has not already been requested. | ||
- type: dropdown | ||
attributes: | ||
label: Component | ||
description: Which area of code does your idea improve? | ||
multiple: true | ||
options: | ||
- Gas Optimization | ||
- General design optimization (improving efficiency, cleanliness, or developer experience) | ||
- Testing | ||
- Documentation | ||
- type: textarea | ||
attributes: | ||
label: Describe the suggested feature and problem it solves. | ||
description: Provide a clear and concise description of what feature you would like to see, and what problems it solves. | ||
validations: | ||
required: true | ||
- type: textarea | ||
attributes: | ||
label: Describe the desired implementation. | ||
description: If possible, provide a suggested architecture change or implementation. | ||
- type: textarea | ||
attributes: | ||
label: Describe alternatives. | ||
description: If possible, describe the alternatives you've considered, or describe the current functionality and how it may be sub-optimal. | ||
- type: textarea | ||
attributes: | ||
label: Additional context. | ||
description: Please list any additional dependencies or integrating contacts that are affected. |
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 @@ | ||
# Pull Request | ||
|
||
## Description | ||
|
||
Please include a summary of the change and which feature was implemented or which issue was fixed. Also, include relevant motivation and context. List any dependencies that are required for this change. | ||
|
||
Fixes # (issue) | ||
|
||
### How Has This Been Tested? | ||
|
||
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration. | ||
|
||
# Checklist: | ||
|
||
Before deployment | ||
|
||
- [ ] 100% test and branch coverage | ||
- [ ] check slither for severe issues | ||
- [ ] fuzz and invariant tests (when applicable) | ||
- [ ] formal verification (when applicable) | ||
- [ ] deployment or upgrade scripts ready | ||
|
||
After deployment | ||
|
||
- [ ] transfer ownership after deployments (when applicable) | ||
- [ ] complete upgrade (when applicable) | ||
- [ ] generate deployment/upgrade log files | ||
|
||
--- | ||
|
||
### Considerations | ||
|
||
- I have followed the [contributing guidelines](../CONTRIBUTING.md). | ||
- My code follows the style guidelines of this project and I have run `forge fmt` and prettier to ensure the code style is valid | ||
- I have performed a self-review of my own code | ||
- I have commented my code, particularly in hard-to-understand areas | ||
- I have made corresponding changes to the documentation | ||
- My changes generate no new warnings | ||
- I have added tests that prove my fix is effective or that my feature works | ||
- New and existing unit tests pass locally with my changes | ||
|
||
### Additional context | ||
|
||
Add any other context about the pull request here. |
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,89 @@ | ||
name: code coverage | ||
|
||
on: | ||
pull_request: | ||
branches: [main, master, staging, dev] | ||
|
||
jobs: | ||
comment-forge-coverage: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
# with: | ||
# token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- 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 coverage | ||
id: coverage | ||
run: | | ||
{ | ||
echo 'COVERAGE<<EOF' | ||
forge coverage | grep '^|' | grep -v 'test/' | ||
echo EOF | ||
} >> "$GITHUB_OUTPUT" | ||
echo $GITHUB_OUTPUT | ||
env: | ||
FOUNDRY_RPC_URL: "${{ secrets.RPC_URL }}" | ||
|
||
- name: Check coverage is updated | ||
uses: actions/github-script@v5 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const fs = require('fs'); | ||
const file = "coverage.txt" | ||
if(!fs.existsSync(file)) { | ||
console.log("Nothing to check"); | ||
return | ||
} | ||
const currentCoverage = fs.readFileSync(file, "utf8").trim(); | ||
const newCoverage = (`${{ steps.coverage.outputs.COVERAGE }}`).trim(); | ||
if (newCoverage != currentCoverage) { | ||
core.setFailed(`Code coverage not updated. Run : forge coverage --no-match-coverage "(test)" | grep '^|' > coverage.txt`); | ||
} | ||
- name: Comment on PR | ||
id: comment | ||
uses: actions/github-script@v5 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const {data: comments} = await github.rest.issues.listComments({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.issue.number, | ||
}) | ||
const botComment = comments.find(comment => comment.user.id === 41898282) | ||
const output = `${{ steps.coverage.outputs.COVERAGE }}`; | ||
const commentBody = `Forge code coverage:\n${output}\n`; | ||
if (botComment) { | ||
github.rest.issues.updateComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
comment_id: botComment.id, | ||
body: commentBody | ||
}) | ||
} else { | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: commentBody | ||
}); | ||
} |
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 @@ | ||
name: Source branch check | ||
on: | ||
pull_request: | ||
branches: [main] | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
- edited | ||
jobs: | ||
check-main: | ||
if: github.base_ref == 'main' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Log | ||
run: | | ||
echo "Base ref: ${{ github.base_ref }}" | ||
echo "Head ref: ${{ github.head_ref }}" | ||
- name: Check branches | ||
run: | | ||
if [ ${{ github.head_ref }} != "staging" ]; then | ||
echo "Merge requests to main branch are only allowed from staging branch." | ||
exit 1 | ||
fi |
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,21 @@ | ||
# checks that pre-commit hooks pass before allowing to merge a PR | ||
|
||
name: pre-commit | ||
on: | ||
pull_request: | ||
branches: [main, master, staging, dev, feat/**, fix/**] | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v2 | ||
with: | ||
submodules: recursive | ||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
- name: Install pre-commit | ||
run: pip install pre-commit | ||
- name: Run pre-commit | ||
run: pre-commit run --all-files |
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: test | ||
|
||
on: | ||
pull_request: | ||
branches: [main, master, staging, dev, feat/**, fix/**] | ||
push: | ||
branches: [main, master, staging, dev] | ||
|
||
env: | ||
FOUNDRY_PROFILE: ${{ github.event_name == 'push' && 'ci' || 'pr' }} | ||
|
||
jobs: | ||
forge-test: | ||
strategy: | ||
fail-fast: true | ||
|
||
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: | | ||
echo Foundry profile: $FOUNDRY_PROFILE | ||
forge --version | ||
forge build --sizes | ||
id: build | ||
|
||
- name: Run Forge tests | ||
run: forge test --isolate -vvv | ||
id: test | ||
env: | ||
FORGE_SNAPSHOT_CHECK: 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,13 @@ | ||
/target | ||
/out | ||
/cache | ||
/coverage | ||
/report | ||
lcov.info | ||
.DS_Store | ||
.env | ||
.vscode | ||
.password | ||
|
||
broadcast/*/31337 | ||
deployments/**/31337.* |
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,9 @@ | ||
[submodule "lib/forge-std"] | ||
path = lib/forge-std | ||
url = https://github.com/foundry-rs/forge-std | ||
[submodule "lib/forge-chronicles"] | ||
path = lib/forge-chronicles | ||
url = https://github.com/0xPolygon/forge-chronicles | ||
[submodule "lib/forge-gas-snapshot"] | ||
path = lib/forge-gas-snapshot | ||
url = https://github.com/marktoda/forge-gas-snapshot |
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 @@ | ||
18 |
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 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: mixed-line-ending | ||
args: ["--fix=lf"] | ||
description: Forces to replace line ending by the UNIX 'lf' character. | ||
exclude: "^docs/autogen" | ||
- repo: local | ||
hooks: | ||
- id: format | ||
name: Format solidity code | ||
description: Format solidity code with `forge fmt` | ||
language: system | ||
entry: forge fmt | ||
exclude: "^lib/" | ||
pass_filenames: true | ||
- id: doc | ||
name: Generate documentation | ||
description: Generate docs with `forge doc` | ||
language: system | ||
# generates docs and unstages files if only the commit hash changed within the file, this way only when the documentation is updated, the documentation needs to be regenerated and only the changed files are pushed | ||
entry: "script/util/doc_gen.sh" | ||
pass_filenames: false | ||
- repo: https://github.com/pre-commit/mirrors-prettier | ||
rev: "v3.0.3" | ||
hooks: | ||
- id: prettier | ||
name: Format non solidity files with prettier | ||
exclude: "^docs/autogen" |
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,7 @@ | ||
foundry.toml | ||
out | ||
lib/ | ||
cache/ | ||
docs/autogenerated | ||
*.sol | ||
deployments/ |
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,26 @@ | ||
{ | ||
"printWidth": 120, | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"singleQuote": false, | ||
"bracketSpacing": true, | ||
"trailingComma": "all", | ||
"overrides": [ | ||
{ | ||
"files": "*.sol", | ||
"options": { | ||
"printWidth": 120, | ||
"tabWidth": 4, | ||
"useTabs": false, | ||
"singleQuote": false, | ||
"bracketSpacing": false | ||
} | ||
}, | ||
{ | ||
"files": "*.json", | ||
"options": { | ||
"tabWidth": 4 | ||
} | ||
} | ||
] | ||
} |
Oops, something went wrong.