-
Notifications
You must be signed in to change notification settings - Fork 5
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 014c517
Showing
50 changed files
with
18,271 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 @@ | ||
ETHERSCAN_API_KEY= | ||
PRIVATE_KEY= | ||
RINKEBY_RPC= |
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: analyze | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
analyze: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
security-events: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Run Slither | ||
uses: crytic/[email protected] | ||
continue-on-error: true | ||
id: slither | ||
with: | ||
target: 'contracts/' |
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,20 @@ | ||
name: coverage | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
coverage-foundry: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out | ||
uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
- run: yarn | ||
|
||
- name: Install Foundry | ||
uses: onbjerg/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
|
||
- run: yarn coverage-forge |
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 @@ | ||
name: coverage | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
coverage-hardhat: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out | ||
uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
- run: yarn | ||
- run: yarn coverage |
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 @@ | ||
name: integration | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
integration: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out | ||
uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
- run: yarn | ||
- run: yarn integration |
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 @@ | ||
name: lint | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out | ||
uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
- run: yarn add solhint | ||
- run: yarn lint |
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 @@ | ||
name: summary | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
summary: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Run Slither | ||
uses: crytic/[email protected] | ||
continue-on-error: true | ||
id: slither | ||
with: | ||
target: 'src/' | ||
slither-config: 'slither.config.json' | ||
slither-args: '--filter-paths src/test --print contract-summary' |
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 @@ | ||
on: [push, pull_request] | ||
|
||
name: test | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: recursive | ||
|
||
- uses: actions/setup-node@v2 | ||
- run: yarn | ||
|
||
- uses: onbjerg/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
|
||
- run: forge 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,15 @@ | ||
.env | ||
|
||
artifacts/ | ||
cache-hardhat/ | ||
cache-foundry/ | ||
cache/ | ||
out/ | ||
|
||
node_modules | ||
|
||
coverage/ | ||
coverage.json | ||
lcov.info | ||
|
||
.vscode |
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 @@ | ||
module.exports = { | ||
skipFiles: ['lib', 'intf', 'external'] | ||
} |
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,12 @@ | ||
{ | ||
"extends": "solhint:recommended", | ||
"plugins": [], | ||
"rules": { | ||
"compiler-version": ["error","0.8.16"], | ||
"func-visibility": ["warn", { "ignoreConstructors": true }], | ||
"avoid-suicide": "error", | ||
"avoid-sha3": "warn", | ||
"var-name-mixedcase": "ignore", | ||
"not-rely-on-time": "ignore" | ||
} | ||
} |
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 @@ | ||
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 @@ | ||
install: | ||
forge install | ||
build: | ||
forge build | ||
lint: | ||
solhint ./contracts/**.sol | ||
test: | ||
forge test -vvvv |
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,133 @@ | ||
# Template | ||
|
||
Template using Foundry && HardHat architecture. | ||
|
||
## Motivation | ||
|
||
With this new architecture, we can get: | ||
|
||
- Unit tests written in solidity | ||
- Foundry's cast | ||
- Integration testing with Hardhat | ||
- Hardhat deploy & verify | ||
- Typescript | ||
|
||
### Foundry | ||
|
||
**Foundry is a blazing fast, portable and modular toolkit for Ethereum | ||
application development written in Rust.** | ||
|
||
Foundry consists of: | ||
|
||
- [**Forge**](./forge): Ethereum testing framework (like Truffle, Hardhat and | ||
Dapptools). | ||
- [**Cast**](./cast): Swiss army knife for interacting with EVM smart contracts, | ||
sending transactions and getting chain data. | ||
|
||
**Need help getting started with Foundry? Read the [📖 Foundry | ||
Book][foundry-book] (WIP)!** | ||
|
||
[foundry-book]: https://onbjerg.github.io/foundry-book/ | ||
|
||
### Hardhat | ||
|
||
Hardhat is an Ethereum development environment for professionals. It facilitates performing frequent tasks, such as running tests, automatically checking code for mistakes or interacting with a smart contract. | ||
|
||
On [Hardhat's website](https://hardhat.org) you will find: | ||
|
||
- [Guides to get started](https://hardhat.org/getting-started/) | ||
- [Hardhat Network](https://hardhat.org/hardhat-network/) | ||
- [Plugin list](https://hardhat.org/plugins/) | ||
|
||
## Directory Structure | ||
|
||
``` | ||
integration - "Hardhat integration tests" | ||
lib - forge-std: "Test dependency" | ||
scripts - "hardhat deploy scripts" | ||
contracts - "Solidity contract" | ||
test - "forge tests" | ||
.env.example - "Expamle dot env" | ||
.gitignore - "Ignore workfiles" | ||
.gitmodules - "Dependecy modules" | ||
.solcover.js - "Configure coverage" | ||
.solhint.json - "Configure solidity lint" | ||
foundry.toml - "Configure foundry" | ||
hardhat.config.ts - "Configure hardhat" | ||
package.json - "Node dependencies" | ||
README.md - "This file" | ||
remappings.txt - "Forge dependcy mappings" | ||
slither.config.json - "Configure slither" | ||
``` | ||
|
||
## Installation | ||
|
||
### Foundry | ||
|
||
First run the command below to get `foundryup`, the Foundry toolchain installer: | ||
|
||
```sh | ||
curl -L https://foundry.paradigm.xyz | bash | ||
``` | ||
|
||
If you do not want to use the redirect, feel free to manually download the | ||
foundryup installation script from | ||
[here](https://raw.githubusercontent.com/gakonst/foundry/master/foundryup/install). | ||
|
||
Then, in a new terminal session or after reloading your `PATH`, run it to get | ||
the latest `forge` and `cast` binaries: | ||
|
||
```sh | ||
foundryup | ||
``` | ||
|
||
Advanced ways to use `foundryup`, and other documentation, can be found in the | ||
[foundryup package](./foundryup/README.md). Happy forging! | ||
|
||
### Hardhat | ||
|
||
`npm install` or `yarn` | ||
|
||
## Commands | ||
|
||
```sh | ||
Scripts available via `npm run-script`: | ||
compile | ||
npx hardhat compile | ||
coverage | ||
npx hardhat coverage --solcoverjs .solcover.js | ||
deploy | ||
npx hardhat run scripts/deploy.ts | ||
integration | ||
npx hardhat test | ||
verify | ||
npx hardhat verify | ||
``` | ||
```sh | ||
Hardhat Commands | ||
integration tests | ||
yarn integration | ||
coverage | ||
yarn coverage | ||
``` | ||
```sh | ||
Foundry Commands | ||
unit tests | ||
forge test | ||
coverage | ||
forge coverage | ||
``` | ||
## Adding dependency | ||
|
||
Prefer `npm` packages when available and update the remappings. | ||
|
||
### Example | ||
|
||
install: | ||
`yarn add -D @openzeppelin/contracts` | ||
|
||
remapping: | ||
`@openzeppelin/contracts=node_modules/@openzeppelin/contracts` | ||
|
||
import: | ||
`import "@openzeppelin/contracts/token/ERC20/ERC20.sol";` |
Oops, something went wrong.