Skip to content

Commit 17db887

Browse files
committed
Removed bugs, added deploy scripts
1 parent 9c2039a commit 17db887

5 files changed

Lines changed: 48 additions & 27 deletions

File tree

‎Makefile‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-include .env
22

33
deploy-anvil:
4-
forge script script/DeployLowkickStarter.s.sol:DeployLowkickStarter \
4+
forge script script/DeployForestOnchain.s.sol:DeployForestOnchainLocal \
55
--rpc-url $(ANVIL_RPC_URL) \
66
--broadcast \
77
--private-key $(ANVIL_PRIVATE_KEY) \
@@ -11,6 +11,8 @@ test-specific:
1111
forge test --mt $(TEST) -vvvv
1212

1313
deploy-sepolia:
14-
forge script script/DeployLowkickStarter.s.sol:DeployLowkickStarterSepolia \
14+
forge script script/DeployForestOnchain.s.sol:DeployForestOnchainSepolia \
1515
--rpc-url $(SEPOLIA_RPC_URL) \
16-
--broadcast
16+
--broadcast \
17+
--verify \
18+
--etherscan-api-key $(ETHERSCAN_API_KEY)

‎script/Counter.s.sol‎

Lines changed: 0 additions & 19 deletions
This file was deleted.

‎script/DeployForestOnchain.s.sol‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.13;
3+
4+
import {Script, console2} from "forge-std/Script.sol";
5+
import {ForestOnchain} from "../src/ForestOnchain.sol";
6+
7+
contract DeployForestOnchainLocal is Script {
8+
uint public constant COST_PER_TREE = 1e9;
9+
ForestOnchain public forestOnchain;
10+
11+
function setUp() public {}
12+
13+
function run() public {
14+
vm.startBroadcast();
15+
forestOnchain = new ForestOnchain(COST_PER_TREE);
16+
vm.stopBroadcast();
17+
}
18+
}
19+
20+
contract DeployForestOchainSepolia is Script {
21+
uint public constant COST_PER_TREE = 1e9;
22+
23+
function run() external {
24+
require(
25+
block.chainid == 11155111,
26+
"DeployGovernanceSepolia: wrong network (not Sepolia)"
27+
);
28+
29+
uint256 deployerKey = vm.envUint("PRIVATE_KEY");
30+
31+
vm.startBroadcast(deployerKey);
32+
ForestOnchain forestOnchain = new ForestOnchain(COST_PER_TREE);
33+
vm.stopBroadcast();
34+
35+
console2.log("Sepolia ForestOnchain: %s", address(forestOnchain));
36+
console2.log("Deployer: %s", vm.addr(deployerKey));
37+
console2.log("Chain ID: %s", block.chainid);
38+
}
39+
}

‎src/ForestOnchain.sol‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ contract ForestOnchain {
237237
if (msg.value != stakeAmount) {
238238
revert ForestOnchain__IncorrectStakeSent(
239239
msg.value,
240-
requiredStake
240+
stakeAmount
241241
);
242242
}
243243
userGoals[msg.sender][_activityType].activityType = _activityType;
@@ -309,9 +309,7 @@ contract ForestOnchain {
309309
return users;
310310
}
311311

312-
function getStakeAmount(
313-
uint _numOfTrees
314-
) public returns (address[] memory) {
312+
function getStakeAmount(uint _numOfTrees) public returns (uint) {
315313
return _numOfTrees * cost_per_tree;
316314
}
317315
}

‎test/ForestOnchain.t.sol‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ contract ForestOnchainTest is Test {
88
ForestOnchain public forestOnchain;
99
uint public CONTRACT_FUND_AMOUNT = 1e17;
1010
address USER1 = makeAddr("USER1");
11+
uint public constant COST_PER_TREE = 1e9;
1112

1213
function setUp() public {
13-
forestOnchain = new ForestOnchain();
14+
forestOnchain = new ForestOnchain(COST_PER_TREE);
1415
vm.deal(address(forestOnchain), CONTRACT_FUND_AMOUNT);
1516
}
1617

0 commit comments

Comments
 (0)