generated from dgma/sol-starter
-
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 d97b212
Showing
28 changed files
with
10,753 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,9 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/alpine | ||
{ | ||
"name": "Foundry", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
"build": { | ||
"dockerfile": "../Dockerfile" | ||
} | ||
} |
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 @@ | ||
root = true | ||
|
||
[*] | ||
soft_wrap = true | ||
end_of_line = lf | ||
[*.{sol}] | ||
tab_width = 4 | ||
[*.{js,ts}] | ||
tab_width = 2 |
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 @@ | ||
# Deploy Properties | ||
|
||
PRIVATE_KEY= | ||
|
||
## Arbitrum | ||
### key | ||
ABISCAN_API_KEY= | ||
### arbitrum-sepolia rpc | ||
ARBITRUM_SEPOLIA_RPC= | ||
|
||
## Localhost | ||
### rpc | ||
RPC_URL=http://localhost:8545 |
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: Setup | ||
description: Install and cache npm and node_modules to reuse them in workflows and jobs | ||
inputs: | ||
foundry: | ||
description: "Boolean to flag foundry installation" | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- uses: actions/setup-node@v4 | ||
with: | ||
cache: "npm" | ||
node-version: 20.x | ||
- uses: actions/cache@v4 | ||
id: cache | ||
with: | ||
path: '**/node_modules' | ||
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }} | ||
- run: make install-ci | ||
shell: bash | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
- name: Install Foundry | ||
if: ${{ inputs.foundry }} | ||
uses: foundry-rs/foundry-toolchain@v1 |
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,62 @@ | ||
name: Quality Gate | ||
on: | ||
push: | ||
|
||
concurrency: | ||
group: quality-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
permissions: | ||
contents: read | ||
packages: read | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/setup | ||
- run: make lint | ||
|
||
check-deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/setup | ||
with: | ||
foundry: true | ||
- run: make compile | ||
- run: make deploy | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/setup | ||
with: | ||
foundry: true | ||
- run: make test | ||
|
||
slither: | ||
permissions: | ||
# required for all workflows | ||
security-events: write | ||
packages: read | ||
# only required for workflows in private repositorie | ||
contents: read | ||
actions: read | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/setup | ||
- run: rm foundry.toml && touch .env | ||
- uses: crytic/[email protected] | ||
id: slither | ||
with: | ||
node-version: 20.11.0 | ||
sarif: results.sarif | ||
fail-on: none | ||
- name: Upload SARIF file | ||
uses: github/codeql-action/upload-sarif@v3 | ||
with: | ||
sarif_file: ${{ steps.slither.outputs.sarif }} |
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,17 @@ | ||
cache/ | ||
out/ | ||
cache_hardhat/ | ||
artifacts/ | ||
.gas-snapshot | ||
.vscode/ | ||
.env | ||
.encryptedKey | ||
broadcast/ | ||
abi/ | ||
|
||
node_modules | ||
.yarn | ||
|
||
.DS_Store | ||
src/.DS_Store | ||
local.deployment-lock.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,3 @@ | ||
[submodule "lib/forge-std"] | ||
path = lib/forge-std | ||
url = https://github.com/foundry-rs/forge-std |
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" | ||
|
||
npx lint-staged; |
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,5 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
make lint; | ||
make 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,6 @@ | ||
{ | ||
"src/**/*.sol": ["solhint --fix --noPrompt", "forge fmt"], | ||
"test/**/*.sol": ["solhint --fix --noPrompt", "forge fmt"], | ||
"integration/**/*.js": "prettier --write", | ||
"deployment-lock.json": "prettier --write" | ||
} |
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 @@ | ||
build | ||
coverage | ||
out | ||
lib | ||
assets | ||
node_modules | ||
.next | ||
artifacts | ||
cache_hardhat | ||
cache |
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,6 @@ | ||
{ | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"printWidth": 100, | ||
"singleQuote": false | ||
} |
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 @@ | ||
{ | ||
"extends": "solhint:recommended", | ||
"rules": { | ||
"avoid-throw": "off", | ||
"avoid-suicide": "error", | ||
"avoid-sha3": "warn", | ||
"compiler-version": ["error", ">=0.8.0 <0.9.0"], | ||
"func-name-mixedcase": "off", | ||
"var-name-mixedcase": "off", | ||
"code-complexity": ["error", 8], | ||
"constructor-syntax": "error", | ||
"func-visibility": [ | ||
"error", | ||
{ | ||
"ignoreConstructors": true | ||
} | ||
], | ||
"max-line-length": ["error", 100], | ||
"not-rely-on-time": "off", | ||
"reason-string": [ | ||
"warn", | ||
{ | ||
"maxLength": 64 | ||
} | ||
] | ||
} | ||
} |
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 @@ | ||
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,8 @@ | ||
FROM ghcr.io/foundry-rs/foundry:latest | ||
WORKDIR /usr/src/app | ||
COPY . . | ||
RUN apk update | ||
RUN apk add --no-cache make | ||
RUN apk add --no-cache nodejs npm | ||
RUN make | ||
ENTRYPOINT ["/bin/sh","-c","sleep infinity"] |
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 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Dzmitry Lahunouski, Dzianis Roi, Tikhon Scherbakov. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,35 @@ | ||
-include .env | ||
|
||
.PHONY: all test clean install compile snapshot | ||
|
||
all: clean install test | ||
|
||
# Clean the repo | ||
clean :; forge clean | ||
|
||
# Local installation | ||
install :; npm i && npx husky install | ||
|
||
# CI installation | ||
install-ci :; touch .env; npm ci | ||
|
||
# Update Dependencies | ||
forge-update:; forge update | ||
|
||
compile :; npx hardhat compile | ||
|
||
test :; forge test -vvv; npx hardhat test | ||
|
||
snapshot :; forge snapshot | ||
|
||
format :; forge fmt src/; forge fmt test/ | ||
|
||
lint :; npx solhint src/**/*.sol | ||
|
||
node :; npx hardhat node | ||
|
||
network?=hardhat | ||
|
||
deploy :; npx hardhat --network $(network) deploy-bundle | ||
|
||
-include ${FCT_PLUGIN_PATH}/makefile-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,62 @@ | ||
# Sol-starter | ||
|
||
Template to bootstrap solidity project | ||
|
||
## Features | ||
|
||
- Foundry for unit testing | ||
- Hardhat for integration tests & deployment | ||
- hardhat-sol-bundler for declarative and smart deployments | ||
- linters, code formatter, pre-commit and pre-push hooks | ||
- Makefile & Docker dev container for convenient and safe development | ||
- Custom github action and quality gate workflow for fast CI strategy implementation | ||
|
||
## Requirements | ||
|
||
- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) | ||
- You'll know you've done it right if you can run `git --version` | ||
- [Foundry / Foundryup](https://github.com/gakonst/foundry) | ||
- This will install `forge`, `cast`, and `anvil` | ||
- You can test you've installed them right by running `forge --version` and get an output like: `forge 0.2.0 (f016135 2022-07-04T00:15:02.930499Z)` | ||
- To get the latest of each, just run `foundryup` | ||
- [Node.js](https://nodejs.org/en) | ||
- Optional. [Docker](https://www.docker.com/) | ||
- You'll need to run docker if you want to use dev container and safely play with smartcontracts & scripts | ||
|
||
## Configuration | ||
|
||
- use forge as solidity formatter in your IDE settings | ||
For VS it's recommended to use [Juan Blanco Plugin](https://github.com/juanfranblanco/vscode-solidity) and have the next sittings.json | ||
|
||
```json | ||
{ | ||
"solidity.formatter": "forge", | ||
"solidity.packageDefaultDependenciesContractsDirectory": "src", | ||
"solidity.packageDefaultDependenciesDirectory": ["node_modules", "lib"], | ||
"solidity.remappings": [ | ||
"@std=lib/forge-std/src/", | ||
"forge-std/=lib/forge-std/src/", | ||
"@openzeppelin/=node_modules/@openzeppelin/", | ||
"src=src/" | ||
], | ||
"solidity.defaultCompiler": "localNodeModule", | ||
"[solidity]": { | ||
"editor.defaultFormatter": "JuanBlanco.solidity" | ||
} | ||
} | ||
``` | ||
|
||
## Contributing | ||
|
||
Contributions are always welcome! Open a PR or an issue! | ||
|
||
Please install the following: | ||
|
||
And you probably already have `make` installed... but if not [try looking here.](https://askubuntu.com/questions/161104/how-do-i-install-make) | ||
|
||
## Resources | ||
|
||
- [Foundry Documentation](https://book.getfoundry.sh/) | ||
- [Hardhat Documentation](https://hardhat.org/docs) | ||
- [hardhat-sol-bundler Documentation](https://github.com/dgma/hardhat-sol-bundler) | ||
``` |
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 @@ | ||
const { VerifyPlugin } = require("@dgma/hardhat-sol-bundler/plugins/Verify"); | ||
|
||
const config = { | ||
Template: {}, | ||
}; | ||
|
||
module.exports = { | ||
hardhat: { | ||
config: config, | ||
}, | ||
localhost: { lockFile: "./local.deployment-lock.json", config: config }, | ||
"arbitrum-sepolia": { | ||
lockFile: "./deployment-lock.json", | ||
verify: true, | ||
plugins: [VerifyPlugin], | ||
config: config, | ||
}, | ||
}; |
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 @@ | ||
[profile.default] | ||
gas_reports = ["*"] | ||
libs = ['lib'] | ||
out = 'out' | ||
solc-version = "0.8.20" | ||
src = 'src' | ||
test = 'test' | ||
|
||
remappings = [ | ||
'@std=lib/forge-std/src/', | ||
'forge-std/=lib/forge-std/src/', | ||
'@openzeppelin/=node_modules/@openzeppelin/', | ||
'src=src/' | ||
] | ||
|
||
[fmt] | ||
bracket_spacing = false | ||
line_length = 100 | ||
tab_width = 4 | ||
wrap_comments = true | ||
|
||
# Remappings in remappings.txt | ||
|
||
# See more config options https://github.com/gakonst/foundry/tree/master/config |
Oops, something went wrong.