Skip to content

Commit

Permalink
✨ upgrade project to a newer version
Browse files Browse the repository at this point in the history
  • Loading branch information
andreivladbrg committed Jan 15, 2024
1 parent 5458fd1 commit 6ff84c4
Show file tree
Hide file tree
Showing 21 changed files with 248 additions and 602 deletions.
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.{sol}]
[*.sol]
indent_size = 4

[*.tree]
indent_size = 1
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export API_KEY_INFURA="YOUR_API_KEY_INFURA"
export MNEMONIC="YOUR_MNEMONIC"

107 changes: 83 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,97 @@
name: CI
name: "CI"

on:
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- main

env:
FOUNDRY_PROFILE: ci
- "main"

jobs:
run-ci:
runs-on: ubuntu-latest
lint:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v3"
with:
submodules: "recursive"
- name: "Check out the repo"
uses: "actions/checkout@v4"

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Install Bun"
uses: "oven-sh/setup-bun@v1"

- name: "Install the Node.js dependencies"
run: "bun install"

- name: Build the contracts
- name: "Lint the code"
run: "bun run lint"

- name: "Add lint summary"
run: |
forge --version
forge build --sizes
echo "## Lint result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
build:
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: "actions/checkout@v4"

- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Install Bun"
uses: "oven-sh/setup-bun@v1"

- name: "Install the Node.js dependencies"
run: "bun install"

- name: "Build the contracts and print their size"
run: "forge build --sizes"

- name: "Add build summary"
run: |
echo "## Build result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
- name: "Cache the build and the node modules so that they can be re-used by the other jobs"
uses: "actions/cache/save@v3"
with:
key: "build-and-modules-${{ github.sha }}"
path: |
cache
node_modules
out
out-optimized
test:
needs: ["lint", "build"]
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: "actions/checkout@v4"

- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Install Bun"
uses: "oven-sh/setup-bun@v1"

- name: "Restore the cached build and the node modules"
uses: "actions/cache/restore@v3"
with:
fail-on-cache-miss: true
key: "build-and-modules-${{ github.sha }}"
path: |
cache
node_modules
out
out-optimized
- name: Run tests
run: forge test
- name: "Run the tests"
run: "forge test"

- name: Add test summary
- name: "Add test summary"
run: |
echo ## Tests >> $GITHUB_STEP_SUMMARY
echo ✅ Passed >> $GITHUB_STEP_SUMMARY
echo "## Tests result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
27 changes: 18 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
# MacOS
.DS_Store

# Foundry
/cache
# directories
cache
coverage
node_modules
out

# Node
/node_modules
# files
*.env
*.log
.DS_Store
.pnp.*
lcov.info
package-lock.json
pnpm-lock.yaml
yarn.lock

# Dapptools
/out
# broadcasts
!broadcast
broadcast/*
broadcast/*/31337/
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

21 changes: 14 additions & 7 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# directories
/broadcast
/cache
/lib
/node_modules
/out
broadcast
cache
coverage
node_modules
out

# files
.env
yarn.lock
*.env
*.log
.DS_Store
.pnp.*
bun.lockb
lcov.info
package-lock.json
pnpm-lock.yaml
yarn.lock
7 changes: 7 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
bracketSpacing: true
printWidth: 120
proseWrap: "always"
singleQuote: false
tabWidth: 2
trailingComma: "all"
useTabs: false
13 changes: 5 additions & 8 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
{
"extends": "solhint:recommended",
"rules": {
"avoid-low-level-calls": "off",
"code-complexity": ["error", 9],
"compiler-version": ["error", ">=0.8.4"],
"contract-name-camelcase": "off",
"const-name-snakecase": "off",
"code-complexity": ["error", 8],
"compiler-version": ["error", ">=0.8.23"],
"func-name-mixedcase": "off",
"func-visibility": ["error", { "ignoreConstructors": true }],
"max-line-length": ["error", 123],
"max-line-length": ["error", 120],
"named-parameters-mapping": "warn",
"no-empty-blocks": "off",
"no-console": "off",
"not-rely-on-time": "off",
"var-name-mixedcase": "off"
"one-contract-per-file": "off"
}
}
5 changes: 2 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
"[solidity]": {
"editor.defaultFormatter": "NomicFoundation.hardhat-solidity"
},
"files.associations": {
".gas-snapshot": "julia"
"[toml]": {
"editor.defaultFormatter": "tamasfe.even-better-toml"
},
"editor.formatOnSave": true,
"solidity.formatter": "forge"
}
29 changes: 12 additions & 17 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
MIT License
This is free and unencumbered software released into the public domain.

Copyright (c) 2022 Andrei Vlad Birgaoanu
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or
as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

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:
In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright
interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the
detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of
all present and future rights to this software under copyright law.

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 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.

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.
For more information, please refer to <http://unlicense.org/>
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
# Foundry Template [![Github Actions][gha-badge]][gha] [![Foundry][foundry-badge]][foundry] [![License: MIT][license-badge]][license]
# Foundry Template [![Github Actions][gha-badge]][gha] [![Foundry][foundry-badge]][foundry] [![License: MIT]]

[gha]: https://github.com/andreivladbrg/foundry-template/actions
[gha-badge]: https://github.com/andreivladbrg/foundry-template/actions/workflows/ci.yml/badge.svg
[foundry]: https://getfoundry.sh/
[foundry-badge]: https://img.shields.io/badge/Built%20with-Foundry-FFDB1C.svg
[license]: https://opensource.org/licenses/MIT
[license-badge]: https://img.shields.io/badge/License-MIT-blue.svg
[license]: http://unlicense.org/

Ethereum smart contracts template with foundry.
Ethereum smart contracts template with [Foundry](https://github.com/foundry-rs/foundry).

It requires [Foundry](https://github.com/foundry-rs/foundry) installed to run. You can find instructions here [Foundry installation](https://book.getfoundry.sh/getting-started/installation).
It requires [Foundry](https://book.getfoundry.sh/getting-started/installation) and
[Bun](https://bun.sh/docs/installation) installed to run.

Inspired from [here](https://github.com/paulrberg/foundry-template).

## Getting started

```
git clone https://github.com/andreivladbrg/foundry-template.git
cd foundry-template
forge install
yarn install
bun install
```

## Commands
Expand All @@ -26,4 +27,3 @@ yarn install
- `forge clean` - remove compiled files
- `forge test` - run tests
- `forge test -vvv` - run tests and display failing tests
- `forge test --gas-report` - run tests and show gas report
Binary file added bun.lockb
Binary file not shown.
53 changes: 34 additions & 19 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
# Full reference https://github.com/foundry-rs/foundry/tree/master/config
# Full reference https://github.com/foundry-rs/foundry/tree/master/crates/config

[profile.default]
auto_detect_solc = false
bytecode_hash = "none"
gas_reports = ["*"]
optimizer = true
optimizer_runs = 10_000
solc = "0.8.17"

[profile.ci]
fuzz_runs = 10_000
verbosity = 4
auto_detect_solc = false
block_timestamp = 1_704_067_200 # January 1, 2024 at 00:00 GMT
bytecode_hash = "none"
evm_version = "paris" # See https://www.evmdiff.com/features?name=PUSH0&kind=opcode
fuzz = { runs = 1_000 }
gas_reports = ["*"]
optimizer = true
optimizer_runs = 10_000
out = "out"
script = "script"
solc = "0.8.23"
src = "src"
test = "test"
libs = ["node_modules", "lib"]

[fmt]
bracket_spacing = true
int_types = "long"
line_length = 120
multiline_func_header = "all"
number_underscore = "thousands"
quote_style = "double"
tab_width = 4
wrap_comments = true
bracket_spacing = true
int_types = "long"
line_length = 120
multiline_func_header = "all"
number_underscore = "thousands"
quote_style = "double"
tab_width = 4
wrap_comments = true

[rpc_endpoints]
arbitrum = "https://arbitrum-mainnet.infura.io/v3/${API_KEY_INFURA}"
avalanche = "https://avalanche-mainnet.infura.io/v3/${API_KEY_INFURA}"
bnb_smart_chain = "https://bsc-dataseed.binance.org"
gnosis_chain = "https://rpc.gnosischain.com"
localhost = "http://localhost:8545"
mainnet = "https://mainnet.infura.io/v3/${API_KEY_INFURA}"
optimism = "https://optimism-mainnet.infura.io/v3/${API_KEY_INFURA}"
polygon = "https://polygon-mainnet.infura.io/v3/${API_KEY_INFURA}"
sepolia = "https://sepolia.infura.io/v3/${API_KEY_INFURA}"
1 change: 0 additions & 1 deletion lib/forge-std
Submodule forge-std deleted from a2edd3
Loading

0 comments on commit 6ff84c4

Please sign in to comment.