File tree Expand file tree Collapse file tree 7 files changed +84
-6
lines changed Expand file tree Collapse file tree 7 files changed +84
-6
lines changed Original file line number Diff line number Diff line change 1212
1313# Dotenv file
1414.env
15+
16+ broadcast /
17+
18+ lib /
Original file line number Diff line number Diff line change 66 url = https://github.com/smartcontractkit/chainlink-brownie-contracts
77[submodule "lib/foundry-devops "]
88 path = lib/foundry-devops
9- url = https://github.com/ChainAccelOrg /foundry-devops
9+ url = https://github.com/Cyfrin /foundry-devops
Original file line number Diff line number Diff line change 1+ -include .env
2+
3+ build :; forge build
4+
5+ deploy-sepolia :; forge script script/DeployFundMe.s.sol:DeployFundMe --fork-url $(SEPOLIA_RPC_URL ) --private-key $(PRIVATE_KEY ) --broadcast --verify --etherscan-api-key $(ETHERSCAN_API_KEY ) -vvvv
Original file line number Diff line number Diff line change @@ -3,5 +3,7 @@ src = "src"
33out = " out"
44libs = [" lib" ]
55remappings = [" @chainlink/=lib/chainlink-brownie-contracts/" ]
6+ ffi = true
7+
68
79# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
Original file line number Diff line number Diff line change 55
66pragma solidity ^ 0.8.18 ;
77
8- import {Script} from "forge-std/Script.sol " ;
8+ import {Script, console} from "forge-std/Script.sol " ;
9+ import {DevOpsTools} from "foundry-devops/src/DevOpsTools.sol " ;
10+ import {FundMe} from "../src/FundMe.sol " ;
911
1012contract FundFundMe is Script {
11- function run () external {}
13+ uint256 constant SEND_VALUE = 0.01 ether ;
14+
15+ function fundFundMe (address mostRecentlyDeployed ) public {
16+ vm.startBroadcast ();
17+ FundMe (payable (mostRecentlyDeployed)).fund {value: SEND_VALUE}();
18+ vm.stopBroadcast ();
19+ console.log ("Funded FundMe with %s " , SEND_VALUE);
20+ }
21+
22+ function run () external {
23+ address mostRecentlyDeployed = DevOpsTools.get_most_recent_deployment (
24+ "FundMe " ,
25+ block .chainid
26+ );
27+ vm.startBroadcast ();
28+ fundFundMe (mostRecentlyDeployed);
29+ vm.stopBroadcast ();
30+ }
1231}
1332
14- contract WithdrawFundMe is Script {}
33+ contract WithdrawFundMe is Script {
34+ function withdrawFundMe (address mostRecentlyDeployed ) public {
35+ vm.startBroadcast ();
36+ FundMe (payable (mostRecentlyDeployed)).withdraw ();
37+ vm.stopBroadcast ();
38+ }
39+
40+ function run () external {
41+ address mostRecentlyDeployed = DevOpsTools.get_most_recent_deployment (
42+ "FundMe " ,
43+ block .chainid
44+ );
45+ vm.startBroadcast ();
46+ withdrawFundMe (mostRecentlyDeployed);
47+ vm.stopBroadcast ();
48+ }
49+ }
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: MIT
2+
3+ pragma solidity ^ 0.8.18 ;
4+ import {Test, console} from "forge-std/Test.sol " ;
5+ import {FundMe} from "../../src/FundMe.sol " ;
6+ import {DeployFundMe} from "../../script/DeployFundMe.s.sol " ;
7+ import {FundFundMe, WithdrawFundMe} from "../../script/Interactions.s.sol " ;
8+
9+ contract InteractionsTest is Test {
10+ FundMe fundMe;
11+
12+ address USER = makeAddr ("user " );
13+ uint256 constant SEND_VALUE = 0.1 ether ;
14+ uint256 constant STARTING_BALANCE = 10 ether ;
15+ uint256 constant GAS_PRICE = 1 ;
16+
17+ function setUp () external {
18+ DeployFundMe deployFundMe = new DeployFundMe ();
19+ fundMe = deployFundMe.run ();
20+ vm.deal (USER, STARTING_BALANCE);
21+ }
22+
23+ function testUserCanFundInteractions () external {
24+ FundFundMe fundFundMe = new FundFundMe ();
25+ fundFundMe.fundFundMe (address (fundMe));
26+
27+ WithdrawFundMe withdrawFundMe = new WithdrawFundMe ();
28+ withdrawFundMe.withdrawFundMe (address (fundMe));
29+
30+ assert (address (fundMe).balance == 0 );
31+ }
32+ }
Original file line number Diff line number Diff line change 22
33pragma solidity ^ 0.8.18 ;
44import {Test, console} from "forge-std/Test.sol " ;
5- import {FundMe} from "../src/FundMe.sol " ;
6- import {DeployFundMe} from "../script/DeployFundMe.s.sol " ;
5+ import {FundMe} from "../../ src/FundMe.sol " ;
6+ import {DeployFundMe} from "../../ script/DeployFundMe.s.sol " ;
77
88contract FundMeTest is Test {
99 address USER = makeAddr ("user " );
You can’t perform that action at this time.
0 commit comments