generated from ZeframLou/foundry-template
-
Notifications
You must be signed in to change notification settings - Fork 9
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 af9881a
Showing
14 changed files
with
878 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,10 @@ | ||
# Network and account info | ||
RPC_URL_MAINNET=XXX | ||
RPC_URL_GOERLI=XXX | ||
|
||
PRIVATE_KEY=XXX | ||
|
||
ETHERSCAN_KEY=XXX | ||
|
||
# Deploy configs | ||
VERSION="1.0.0" |
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,34 @@ | ||
name: test | ||
|
||
on: workflow_dispatch | ||
|
||
env: | ||
FOUNDRY_PROFILE: ci | ||
|
||
jobs: | ||
check: | ||
strategy: | ||
fail-fast: true | ||
|
||
name: Foundry project | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
|
||
- name: Run Forge build | ||
run: | | ||
forge --version | ||
forge build --sizes | ||
id: build | ||
|
||
- name: Run Forge tests | ||
run: | | ||
FOUNDRY_PROFILE=ci forge test -vvv | ||
id: 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,13 @@ | ||
# Compiler files | ||
cache/ | ||
out/ | ||
|
||
# Ignores development broadcast logs | ||
!/broadcast | ||
/broadcast/*/31337/ | ||
/broadcast/**/dry-run/ | ||
|
||
# Dotenv file | ||
.env | ||
|
||
.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,9 @@ | ||
[submodule "lib/solmate"] | ||
path = lib/solmate | ||
url = https://github.com/rari-capital/solmate | ||
[submodule "lib/forge-std"] | ||
path = lib/forge-std | ||
url = https://github.com/foundry-rs/forge-std | ||
[submodule "lib/create3-factory"] | ||
path = lib/create3-factory | ||
url = https://github.com/zeframlou/create3-factory |
Large diffs are not rendered by default.
Oops, something went wrong.
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,55 @@ | ||
# Foundry template | ||
|
||
This is a template for a Foundry project. | ||
|
||
## Installation | ||
|
||
To install with [DappTools](https://github.com/dapphub/dapptools): | ||
|
||
``` | ||
dapp install [user]/[repo] | ||
``` | ||
|
||
To install with [Foundry](https://github.com/gakonst/foundry): | ||
|
||
``` | ||
forge install [user]/[repo] | ||
``` | ||
|
||
## Local development | ||
|
||
This project uses [Foundry](https://github.com/gakonst/foundry) as the development framework. | ||
|
||
### Dependencies | ||
|
||
``` | ||
forge install | ||
``` | ||
|
||
### Compilation | ||
|
||
``` | ||
forge build | ||
``` | ||
|
||
### Testing | ||
|
||
``` | ||
forge test | ||
``` | ||
|
||
### Contract deployment | ||
|
||
Please create a `.env` file before deployment. An example can be found in `.env.example`. | ||
|
||
#### Dryrun | ||
|
||
``` | ||
forge script script/Deploy.s.sol -f [network] | ||
``` | ||
|
||
### Live | ||
|
||
``` | ||
forge script script/Deploy.s.sol -f [network] --verify --broadcast | ||
``` |
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,16 @@ | ||
[profile.default] | ||
optimizer_runs = 1000000 | ||
verbosity = 1 | ||
|
||
# Extreme Fuzzing CI Profile :P | ||
[profile.ci] | ||
fuzz_runs = 100_000 | ||
verbosity = 4 | ||
|
||
[rpc_endpoints] | ||
goerli = "${RPC_URL_GOERLI}" | ||
mainnet = "${RPC_URL_MAINNET}" | ||
|
||
[etherscan] | ||
goerli = {key = "${ETHERSCAN_KEY}", url = "https://api-goerli.etherscan.io/api"} | ||
mainnet = {key = "${ETHERSCAN_KEY}"} |
Submodule create3-factory
added at
d68b7b
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,26 @@ | ||
// SPDX-License-Identifier: AGPL-3.0 | ||
pragma solidity ^0.8.13; | ||
|
||
import {CREATE3Script} from "./base/CREATE3Script.sol"; | ||
import {Contract} from "../src/Contract.sol"; | ||
|
||
contract DeployScript is CREATE3Script { | ||
constructor() CREATE3Script(vm.envString("VERSION")) {} | ||
|
||
function run() external returns (Contract c) { | ||
uint256 deployerPrivateKey = uint256(vm.envBytes32("PRIVATE_KEY")); | ||
|
||
uint256 param = 123; | ||
|
||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
c = Contract( | ||
create3.deploy( | ||
getCreate3ContractSalt("Contract"), | ||
bytes.concat(type(Contract).creationCode, abi.encode(param)) | ||
) | ||
); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
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 @@ | ||
// SPDX-License-Identifier: AGPL-3.0 | ||
pragma solidity ^0.8.13; | ||
|
||
import {CREATE3Factory} from "create3-factory/CREATE3Factory.sol"; | ||
|
||
import "forge-std/Script.sol"; | ||
|
||
abstract contract CREATE3Script is Script { | ||
CREATE3Factory internal constant create3 = CREATE3Factory(0x9fBB3DF7C40Da2e5A0dE984fFE2CCB7C47cd0ABf); | ||
|
||
string internal version; | ||
|
||
constructor(string memory version_) { | ||
version = version_; | ||
} | ||
|
||
function getCreate3Contract(string memory name) internal view virtual returns (address) { | ||
uint256 deployerPrivateKey = uint256(vm.envBytes32("PRIVATE_KEY")); | ||
address deployer = vm.addr(deployerPrivateKey); | ||
|
||
return create3.getDeployed(deployer, getCreate3ContractSalt(name)); | ||
} | ||
|
||
function getCreate3ContractSalt(string memory name) internal view virtual returns (bytes32) { | ||
return keccak256(bytes(string.concat(name, "-v", version))); | ||
} | ||
} |
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 @@ | ||
// SPDX-License-Identifier: Unlicense | ||
pragma solidity ^0.8.4; | ||
|
||
contract Contract { | ||
uint256 public immutable param; | ||
|
||
constructor(uint256 param_) { | ||
param = param_; | ||
} | ||
} |
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 @@ | ||
// SPDX-License-Identifier: Unlicense | ||
pragma solidity ^0.8.4; | ||
|
||
import "forge-std/Test.sol"; | ||
|
||
contract ContractTest is Test { | ||
function setUp() public {} | ||
|
||
function testExample() public { | ||
vm.startPrank(address(0xB0B)); | ||
console2.log("Hello world!"); | ||
assertTrue(true); | ||
} | ||
} |