Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
traceurl committed Sep 5, 2022
0 parents commit 014c517
Show file tree
Hide file tree
Showing 50 changed files with 18,271 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ETHERSCAN_API_KEY=
PRIVATE_KEY=
RINKEBY_RPC=
24 changes: 24 additions & 0 deletions .github/workflows/analyze.yml
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/'
20 changes: 20 additions & 0 deletions .github/workflows/coverage-foundry.yml
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
14 changes: 14 additions & 0 deletions .github/workflows/coverage-hardhat.yml
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
14 changes: 14 additions & 0 deletions .github/workflows/integration.yml
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
14 changes: 14 additions & 0 deletions .github/workflows/lint.yml
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
18 changes: 18 additions & 0 deletions .github/workflows/summary.yml
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'
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
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
15 changes: 15 additions & 0 deletions .gitignore
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
3 changes: 3 additions & 0 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
skipFiles: ['lib', 'intf', 'external']
}
12 changes: 12 additions & 0 deletions .solhint.json
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"
}
}
1 change: 1 addition & 0 deletions .solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test/
8 changes: 8 additions & 0 deletions Makefile
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
133 changes: 133 additions & 0 deletions README.md
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";`
Loading

0 comments on commit 014c517

Please sign in to comment.