diff --git a/contracts/activity/CECDistributor.sol b/contracts/activity/CECDistributor.sol index a853588..4dbde93 100644 --- a/contracts/activity/CECDistributor.sol +++ b/contracts/activity/CECDistributor.sol @@ -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); } diff --git a/deploy/10_deploy_cecdistributor.ts b/deploy/10_deploy_cecdistributor.ts index 6379b7b..9c29ff5 100644 --- a/deploy/10_deploy_cecdistributor.ts +++ b/deploy/10_deploy_cecdistributor.ts @@ -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, diff --git a/out/bsc_test_dev.json b/out/bsc_test_dev.json index 3c735a4..9370a41 100644 --- a/out/bsc_test_dev.json +++ b/out/bsc_test_dev.json @@ -81,6 +81,6 @@ "name": "CECDistributor", "type": "logic", "json": "assets/contracts/CECDistributor.json", - "address": "0xee15c5efFBB66Ca27ff979f03Ad0eddA84407b66" + "address": "0x19E3F7E52AbbEED5A0A0e3e2F8892F4dd1079239" } ] \ No newline at end of file diff --git a/test/testCECDistributor.ts b/test/testCECDistributor.ts index 19a1f3f..1502145 100644 --- a/test/testCECDistributor.ts +++ b/test/testCECDistributor.ts @@ -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 };