remove setStart and add start to constructor

This commit is contained in:
CounterFire2023 2024-09-08 10:13:09 +08:00
parent 58966e3106
commit fe4a52d59a
4 changed files with 9 additions and 11 deletions

View File

@ -41,10 +41,12 @@ contract CECDistributor is ReentrancyGuard, Pausable, Ownable, Governable {
constructor(
string memory _name,
address _cecToken
address _cecToken,
uint256 _start
) {
name = _name;
cecToken = IERC20(_cecToken);
start = _start;
}
/**
@ -74,11 +76,6 @@ contract CECDistributor is ReentrancyGuard, Pausable, Ownable, Governable {
_unpause();
}
function setStart(uint256 newStart) external ownerOrGov {
require(newStart > 0 && start == 0, "CECDistributor: it's already initialized");
start = newStart;
}
function withdrawToken(address to, uint256 amount) external onlyOwner {
cecToken.safeTransfer(to, amount);
}

View File

@ -13,7 +13,8 @@ const deployCECDistributor: DeployFunction =
const { cec } = config.staking
// update distributor wallet
const wallet = admin;
const params: any[] = [ 'first', cec]
const start = (Date.now() / 1000 + 3600) | 0 // one hour later
const params: any[] = [ 'first', cec, start]
// const params: any[] = [ 'first', cec, wallet, 0, 10, 500000]
const ret = await hre.deployments.deploy("CECDistributor", {
from,

View File

@ -81,6 +81,6 @@
"name": "CECDistributor",
"type": "logic",
"json": "assets/contracts/CECDistributor.json",
"address": "0xee15c5efFBB66Ca27ff979f03Ad0eddA84407b66"
"address": "0x19E3F7E52AbbEED5A0A0e3e2F8892F4dd1079239"
}
]

View File

@ -22,12 +22,12 @@ describe('TestCECDistributor', function() {
const CECDistributor = await hre.ethers.getContractFactory("CECDistributor");
const lockDuration = ONE_DAY; // one day
const distributor = await CECDistributor.deploy("first", cec.target);
const start = (Date.now() / 1000 + 3600) | 0 // one hour later
const distributor = await CECDistributor.deploy("first", cec.target, start);
await cec.mint(distributor.target, expandDecimals(15000, 18))
const chainId = hre.network.config.chainId
const start = (Date.now() / 1000 + 3600) | 0 // one hour later
await distributor.setStart(start)
expect(await distributor.name()).to.equal("first")
await distributor.updateInfo([user1.address], [[expandDecimals(1000, 18), 10, 300000, lockDuration]])
return { distributor, owner, user0, user1, user2, chainId, cec, start };