Skip to content

Commit

Permalink
update template
Browse files Browse the repository at this point in the history
  • Loading branch information
giuseppecrj committed Sep 5, 2024
1 parent 1db256c commit 026a4ef
Show file tree
Hide file tree
Showing 21 changed files with 367 additions and 477 deletions.
16 changes: 12 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# EditorConfig http://EditorConfig.org

# top-most EditorConfig file
root = true

# All files
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.{js,json,yml}]
charset = utf-8
indent_style = space
indent_size = 2
[*.sol]
indent_size = 4

[*.tree]
indent_size = 1
18 changes: 11 additions & 7 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
GOERLI_RPC_URL=goerli_rpc
LOCAL_RPC_URL=local_rpc
LOCAL_PRIVATE_KEY=private_key
PRIVATE_KEY=private_key
ETHERSCAN_API_KEY=etherscan_key
GANACHE_PRIVATE_KEY=ganache_private_key
DEPLOYMENT_PATH=client
export API_KEY_ALCHEMY="YOUR_API_KEY_ALCHEMY"
export API_KEY_ARBISCAN="YOUR_API_KEY_ARBISCAN"
export API_KEY_BSCSCAN="YOUR_API_KEY_BSCSCAN"
export API_KEY_ETHERSCAN="YOUR_API_KEY_ETHERSCAN"
export API_KEY_GNOSISSCAN="YOUR_API_KEY_GNOSISSCAN"
export API_KEY_INFURA="YOUR_API_KEY_INFURA"
export API_KEY_OPTIMISTIC_ETHERSCAN="YOUR_API_KEY_OPTIMISTIC_ETHERSCAN"
export API_KEY_POLYGONSCAN="YOUR_API_KEY_POLYGONSCAN"
export API_KEY_SNOWTRACE="YOUR_API_KEY_SNOWTRACE"
export MNEMONIC="YOUR_MNEMONIC"
export FOUNDRY_PROFILE="default"
30 changes: 18 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# Compiler files
cache/
out/
# directories
cache
coverage
node_modules
out

# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/*/5/
/broadcast/**/dry-run/
# files
*.env
*.log
.DS_Store
.pnp.*
lcov.info
package-lock.json
pnpm-lock.yaml
yarn.lock

# Dotenv file
.env
node_modules
!.vscode
# broadcasts
!broadcast
broadcast/*
broadcast/*/31337/
20 changes: 15 additions & 5 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
build
# directories
broadcast
cache
coverage
out
lib
assets
node_modules
.next
out

# files
*.env
*.log
.DS_Store
.pnp.*
bun.lockb
lcov.info
package-lock.json
pnpm-lock.yaml
yarn.lock
20 changes: 11 additions & 9 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"extends": ["solhint:recommended"],
"extends": "solhint:recommended",
"rules": {
"prettier/prettier": "error",
"compiler-version": "off",
"avoid-throw": "off",
"avoid-suicide": "error",
"avoid-sha3": "warn",
"func-name-mixedcase": "off"
},
"plugins": ["prettier"]
"code-complexity": ["error", 8],
"compiler-version": ["error", ">=0.8.25"],
"func-name-mixedcase": "off",
"func-visibility": ["error", { "ignoreConstructors": true }],
"max-line-length": ["error", 120],
"named-parameters-mapping": "warn",
"no-console": "off",
"not-rely-on-time": "off",
"one-contract-per-file": "off"
}
}
18 changes: 9 additions & 9 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"NomicFoundation.hardhat-solidity",
"esbenp.prettier-vscode"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": []
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"NomicFoundation.hardhat-solidity",
"tamasfe.even-better-toml"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": []
}
8 changes: 5 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"[solidity]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "NomicFoundation.hardhat-solidity"
},
"solidity.formatter": "prettier",
"solidity.linter": "solhint"
"[toml]": {
"editor.defaultFormatter": "tamasfe.even-better-toml"
},
"solidity.formatter": "forge",
}
50 changes: 5 additions & 45 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,49 +1,9 @@
-include .env

.PHONY: all test clean deploy-anvil

all: clean remove install update build

# Clean the repo
clean :; forge clean

# Remappings
remap :; forge remappings > remappings.txt

# Remove modules
remove :; rm -rf .gitmodules && rm -rf .git/modules/* && rm -rf lib

install :; yarn

# Update Dependencies
update:; forge update

build:; forge build

test :; forge test

snapshot :; forge snapshot

slither :; slither ./src

format :; prettier --write src/**/*.sol && prettier --write src/*.sol

# solhint should be installed globally
lint :; solhint src/**/*.sol && solhint src/*.sol

anvil :; anvil -m 'test test test test test test test test test test test junk'

fund :; cast send ${account} --value 1ether -f 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

# use the "@" to hide the command from your shell
deploy-sepolia :; @forge script scripts/${contract}.s.sol:${contract} --rpc-url ${SEPOLIA_RPC_URL} --private-key ${PRIVATE_KEY} --broadcast --verify --etherscan-api-key ${ETHERSCAN_API_KEY} -vvvv

deploy-base-sepolia :;
@forge build
@forge script scripts/${contract}.s.sol:${contract} --rpc-url ${BASE_RPC_URL} --private-key ${BASE_PRIVATE_KEY} --verifier-url https://api-sepolia.basescan.org/api --etherscan-api-key ${BLOCKSCOUT_API_KEY} --broadcast --verify -vvvv

# This is the private key of account from the mnemonic from the "make anvil" command
deploy-anvil :;
@LOCAL_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 ETHERSCAN_API_KEY=test forge script scripts/${contract}.s.sol:${contract} --rpc-url http://localhost:8545 --broadcast

deploy-ganache :; @forge script scripts/${contract}.s.sol:${contract} --rpc-url http://localhost:8545 --private-key ${GANACHE_PRIVATE_KEY} --broadcast
deploy-any :;
@echo "Running $(contract) on remote network"
@SAVE_DEPLOYMENTS=1 $(if $(context),DEPLOYMENT_CONTEXT=$(context)) \
forge script scripts/${contract}.s.sol:${contract} \
--rpc-url ${rpc} --private-key ${private_key} --broadcast
5 changes: 0 additions & 5 deletions client/deploy.json

This file was deleted.

35 changes: 0 additions & 35 deletions client/index.js

This file was deleted.

75 changes: 50 additions & 25 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -1,30 +1,55 @@
# Full reference https://github.com/foundry-rs/foundry/tree/master/crates/config

[profile.default]
auto_detect_solc = false # Foundry will automatically try to resolve appropriate Solidity compiler versions
block_timestamp = 1_680_220_800 # The value of block.timestamp in tests. March 31, 2023 at 00:00 GMT
bytecode_hash = "none" # Determines the hash method for the metadata hash that is appended to the bytecode
cbor_metadata = false # Remove all metadata hashes from your contract's bytecode.
evm_version = "paris" # The EVM version to use during tests.
fuzz = { runs = 256 } # The amount of fuzz runs to perform for each fuzz test case.
gas_reports = ["*"] # The contracts to print gas reports for.
libs = ["node_modules", "lib"]
optimizer = true # Whether or not to enable the Solidity optimizer.
optimizer_runs = 200 # The amount of optimizer runs to perform.
out = "out" # The path to put contract artifacts in, relative to the root of the project.
script = "scripts" # The path to the contract scripts relative to the root of the project.
solc_version = "0.8.25" # Uses a single Solidity compiler version for the project
src = "src" # The path to the contract sources relative to the root of the project.
test = "test" # The path to the test contract sources relative to the root of the project.
verbosity = 3 # The verbosity level to use during tests.
fs_permissions = [
{ access = "read-write", path = "./client" },
] # Configures permissions for cheatcodes that touch the filesystem
extra_output = ["metadata", "abi", "bin"]
extra_output_files = ["metadata", "abi", "bin"]
auto_detect_solc = false
block_timestamp = 1_680_220_800 # March 31, 2023 at 00:00 GMT
bytecode_hash = "none"
evm_version = "shanghai"
fuzz = { runs = 1_000 }
gas_reports = ["*"]
optimizer = true
optimizer_runs = 10_000
out = "out"
script = "script"
solc = "0.8.25"
src = "src"
test = "test"
fs_permissions = [{ access = "read-write", path = "./client" }]

[rpc_endpoints]
sepolia = "${SEPOLIA_RPC_URL}"
[profile.ci]
fuzz = { runs = 10_000 }
verbosity = 4

[etherscan]
sepolia = { key = "${ETHERSCAN_API_KEY}" }
arbitrum = { key = "${API_KEY_ARBISCAN}" }
avalanche = { key = "${API_KEY_SNOWTRACE}" }
base = { key = "${API_KEY_BASESCAN}" }
gnosis_chain = { key = "${API_KEY_GNOSISSCAN}" }
goerli = { key = "${API_KEY_ETHERSCAN}" }
mainnet = { key = "${API_KEY_ETHERSCAN}" }
optimism = { key = "${API_KEY_OPTIMISTIC_ETHERSCAN}" }
polygon = { key = "${API_KEY_POLYGONSCAN}" }
sepolia = { key = "${API_KEY_ETHERSCAN}" }

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
[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

[rpc_endpoints]
arbitrum = "https://arbitrum-mainnet.infura.io/v3/${API_KEY_INFURA}"
avalanche = "https://avalanche-mainnet.infura.io/v3/${API_KEY_INFURA}"
base = "https://mainnet.base.org"
bnb_smart_chain = "https://bsc-dataseed.binance.org"
gnosis_chain = "https://rpc.gnosischain.com"
goerli = "https://goerli.infura.io/v3/${API_KEY_INFURA}"
localhost = "http://localhost:8545"
mainnet = "https://eth-mainnet.g.alchemy.com/v2/${API_KEY_ALCHEMY}"
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}"
31 changes: 16 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
{
"name": "template",
"name": "forge-template-base",
"version": "1.0.0",
"main": "client/index.js",
"type": "module",
"author": "g <[email protected]>",
"license": "MIT",
"scripts": {
"solhint": "solhint -f table src/**/*.sol",
"prettier:solidity": "prettier --write src/**/*.sol"
"clean": "rm -rf cache out coverage lcov.info",
"build": "forge build",
"lint": "yarn run lint:sol && yarn run prettier:check",
"lint:sol": "forge fmt --check && yarn solhint -f table {script,src,test}/**/*.sol",
"prettier:check": "prettier --check \"**/*.{json,md,yml}\" --ignore-path \".prettierignore\"",
"prettier:write": "prettier --write \"**/*.{json,md,yml}\" --ignore-path \".prettierignore\"",
"test": "forge test",
"test:coverage": "forge coverage --no-match-coverage '(test|scripts)'",
"test:coverage:report": "forge coverage --no-match-coverage '(test|scripts)' --report lcov && genhtml lcov.info --branch-coverage --output-dir coverage --rc derive_function_end_line=0"
},
"dependencies": {
"@openzeppelin/contracts": "^5.0.2"
},
"devDependencies": {
"@openzeppelin/contracts": "^5.0.2",
"dotenv": "^16.0.3",
"ds-test": "github:dapphub/ds-test",
"ethers": "^6.1.0",
"forge-std": "github:foundry-rs/forge-std#v1",
"husky": "^8.0.1",
"prettier": "^2.7.1",
"prettier-plugin-solidity": "^1.1.3",
"solhint": "^3.3.7",
"solhint-plugin-prettier": "^0.0.5"
"forge-std": "github:foundry-rs/forge-std#v1.8.1",
"prettier": "^3.0.0",
"solhint": "^3.6.2"
}
}
12 changes: 6 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ pragma solidity 0.8.10;
import "forge-std/Test.sol";
contract ContractTest is Test {
function testExample() public {
vm.roll(100);
console.log(1);
emit log("hi");
assertTrue(true);
}
function testExample() public {
vm.roll(100);
console.log(1);
emit log("hi");
assertTrue(true);
}
}
```

Expand Down
Loading

0 comments on commit 026a4ef

Please sign in to comment.