Skip to content

Commit

Permalink
update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideSilva committed Apr 26, 2024
1 parent a95e70b commit 4d87640
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 30 deletions.
6 changes: 2 additions & 4 deletions packages/contracts/contracts/token/Sale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ contract Sale is ISale, RisingTide, ERC165, AccessControl, ReentrancyGuard {
uint256 _minTarget,
uint256 _maxTarget,
uint256 _startRegistration,
uint256 _endRegistration,
bytes32 _merkleRoot
uint256 _endRegistration
) {
require(_paymentToken != address(0), "can't be zero");
require(_rate > 0, "can't be zero");
Expand All @@ -162,7 +161,6 @@ contract Sale is ISale, RisingTide, ERC165, AccessControl, ReentrancyGuard {
maxTarget = _maxTarget;
startRegistration = _startRegistration;
endRegistration = _endRegistration;
merkleRoot = _merkleRoot;

_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(CAP_VALIDATOR_ROLE, msg.sender);
Expand Down Expand Up @@ -372,7 +370,7 @@ contract Sale is ISale, RisingTide, ERC165, AccessControl, ReentrancyGuard {

function setMerkleRoot(
bytes32 _merkleRoot
) external onlyRole(DEFAULT_ADMIN_ROLE) nonReentrant {
) external onlyRole(DEFAULT_ADMIN_ROLE) beforeSale nonReentrant {
merkleRoot = _merkleRoot;
}

Expand Down
29 changes: 13 additions & 16 deletions packages/contracts/script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,34 @@
pragma solidity ^0.8.20;

import {Script} from "lib/forge-std/src/Script.sol";

import {MockERC20} from "contracts/test/MockERC20.sol";
import {Sale} from "contracts/token/Sale.sol";

contract DeployScript is Script {
function run() public {
vm.startBroadcast();

uint256 start = 1713866628;
uint256 end = 1714780799;
uint256 startRegistration = 1713866628;
uint256 endRegistration = 1714780799;

// MockERC20 token = new MockERC20("USDC", "USDC", 18);
uint256 startRegistration = 1714953600;
uint256 endRegistration = 1715212800;
uint256 start = 1715299200;
uint256 end = 1715385599;

bytes32 merkleRoot = 0x56dc9b99234caefd2202e000b075dd65d221f7e17d06f7e083a07907a7b7548a;
address token = 0x1fD476786D370219F94fF2421cD7f5D7C8CA86c0;
address USDC = 0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238;

new Sale(
token,
Sale sale = new Sale(
USDC,
5 ether,
start,
end,
1000,
1000000,
2000000,
1000000 ether,
2000000 ether,
startRegistration,
endRegistration,
merkleRoot
endRegistration
);

sale.setMinContribution(200 ether);
sale.setMaxContribution(400 ether);

vm.stopBroadcast();
}
}
16 changes: 8 additions & 8 deletions packages/contracts/script/DevDeploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ contract DevDeployScript is Script {

bytes32 merkleRoot = 0xa5c09e2a9128afef7246a5900cfe02c4bd2cfcac8ac4286f0159a699c8455a49;

startRegistration = 1713866628;
endRegistration = 1714780799;
start = 1713866628;
end = 1714780799;
startRegistration = 1714953600;
endRegistration = 1715212800;
start = 1715299200;
end = 1715385599;

// start = vm.getBlockTimestamp();
// end = start + 60 * 60 * 24;

MockERC20 token = new MockERC20("USDC", "USDC", 18);
Citizend citizend = new Citizend(owner, end);
Expand All @@ -55,10 +53,12 @@ contract DevDeployScript is Script {
1000000,
2000000,
startRegistration,
endRegistration,
merkleRoot
endRegistration
);

sale.setMerkleRoot(merkleRoot);
sale.setMinContribution(200 ether);
sale.setMaxContribution(400 ether);
citizend.transfer(address(sale), 1000 ether);

bool success = token.approve(address(sale), 1000 ether);
Expand Down
5 changes: 3 additions & 2 deletions packages/contracts/test/contracts/token/Sale.d.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ contract SaleTest is Test {
5 ether,
15 ether,
startRegistration,
endRegistration,
merkleRoot
endRegistration
);

sale.setMerkleRoot(merkleRoot);
sale.setToken(address(token));
sale.setMinContribution(0.2 ether);
sale.setMaxContribution(10 ether);

token.transfer(address(sale), 1000000 ether);
Expand Down

0 comments on commit 4d87640

Please sign in to comment.