chore: forge init
This commit is contained in:
		
						commit
						150f9ab9a6
					
				
							
								
								
									
										34
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -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@v4 | ||||
|         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: | | ||||
|           forge test -vvv | ||||
|         id: test | ||||
							
								
								
									
										14
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,14 @@ | ||||
| # Compiler files | ||||
| cache/ | ||||
| out/ | ||||
| 
 | ||||
| # Ignores development broadcast logs | ||||
| !/broadcast | ||||
| /broadcast/*/31337/ | ||||
| /broadcast/**/dry-run/ | ||||
| 
 | ||||
| # Docs | ||||
| docs/ | ||||
| 
 | ||||
| # Dotenv file | ||||
| .env | ||||
							
								
								
									
										66
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,66 @@ | ||||
| ## Foundry | ||||
| 
 | ||||
| **Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.** | ||||
| 
 | ||||
| Foundry consists of: | ||||
| 
 | ||||
| -   **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools). | ||||
| -   **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data. | ||||
| -   **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network. | ||||
| -   **Chisel**: Fast, utilitarian, and verbose solidity REPL. | ||||
| 
 | ||||
| ## Documentation | ||||
| 
 | ||||
| https://book.getfoundry.sh/ | ||||
| 
 | ||||
| ## Usage | ||||
| 
 | ||||
| ### Build | ||||
| 
 | ||||
| ```shell | ||||
| $ forge build | ||||
| ``` | ||||
| 
 | ||||
| ### Test | ||||
| 
 | ||||
| ```shell | ||||
| $ forge test | ||||
| ``` | ||||
| 
 | ||||
| ### Format | ||||
| 
 | ||||
| ```shell | ||||
| $ forge fmt | ||||
| ``` | ||||
| 
 | ||||
| ### Gas Snapshots | ||||
| 
 | ||||
| ```shell | ||||
| $ forge snapshot | ||||
| ``` | ||||
| 
 | ||||
| ### Anvil | ||||
| 
 | ||||
| ```shell | ||||
| $ anvil | ||||
| ``` | ||||
| 
 | ||||
| ### Deploy | ||||
| 
 | ||||
| ```shell | ||||
| $ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key> | ||||
| ``` | ||||
| 
 | ||||
| ### Cast | ||||
| 
 | ||||
| ```shell | ||||
| $ cast <subcommand> | ||||
| ``` | ||||
| 
 | ||||
| ### Help | ||||
| 
 | ||||
| ```shell | ||||
| $ forge --help | ||||
| $ anvil --help | ||||
| $ cast --help | ||||
| ``` | ||||
							
								
								
									
										6
									
								
								foundry.toml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								foundry.toml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | ||||
| [profile.default] | ||||
| src = "src" | ||||
| out = "out" | ||||
| libs = ["lib"] | ||||
| 
 | ||||
| # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options | ||||
							
								
								
									
										12
									
								
								script/Counter.s.sol
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								script/Counter.s.sol
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,12 @@ | ||||
| // SPDX-License-Identifier: UNLICENSED | ||||
| pragma solidity ^0.8.13; | ||||
| 
 | ||||
| import {Script, console} from "forge-std/Script.sol"; | ||||
| 
 | ||||
| contract CounterScript is Script { | ||||
|     function setUp() public {} | ||||
| 
 | ||||
|     function run() public { | ||||
|         vm.broadcast(); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										14
									
								
								src/Counter.sol
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								src/Counter.sol
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,14 @@ | ||||
| // SPDX-License-Identifier: UNLICENSED | ||||
| pragma solidity ^0.8.13; | ||||
| 
 | ||||
| contract Counter { | ||||
|     uint256 public number; | ||||
| 
 | ||||
|     function setNumber(uint256 newNumber) public { | ||||
|         number = newNumber; | ||||
|     } | ||||
| 
 | ||||
|     function increment() public { | ||||
|         number++; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										24
									
								
								test/Counter.t.sol
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								test/Counter.t.sol
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,24 @@ | ||||
| // SPDX-License-Identifier: UNLICENSED | ||||
| pragma solidity ^0.8.13; | ||||
| 
 | ||||
| import {Test, console} from "forge-std/Test.sol"; | ||||
| import {Counter} from "../src/Counter.sol"; | ||||
| 
 | ||||
| contract CounterTest is Test { | ||||
|     Counter public counter; | ||||
| 
 | ||||
|     function setUp() public { | ||||
|         counter = new Counter(); | ||||
|         counter.setNumber(0); | ||||
|     } | ||||
| 
 | ||||
|     function test_Increment() public { | ||||
|         counter.increment(); | ||||
|         assertEq(counter.number(), 1); | ||||
|     } | ||||
| 
 | ||||
|     function testFuzz_SetNumber(uint256 x) public { | ||||
|         counter.setNumber(x); | ||||
|         assertEq(counter.number(), x); | ||||
|     } | ||||
| } | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 unknown
						unknown