diff --git a/contracts/activity/CECDistributor.sol b/contracts/activity/CECDistributor.sol index d8495f5..7f2c589 100644 --- a/contracts/activity/CECDistributor.sol +++ b/contracts/activity/CECDistributor.sol @@ -6,13 +6,14 @@ import {Pausable} from "@openzeppelin/contracts/security/Pausable.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; +import {Governable} from "../core/Governable.sol"; /** * @title CECDistributor * @dev CECDistributor is a contract for distributing CEC token with unlock time * after all data is set, transfer owner to timelock contract */ -contract CECDistributor is ReentrancyGuard, Pausable, Ownable { +contract CECDistributor is ReentrancyGuard, Pausable, Ownable, Governable { using SafeERC20 for IERC20; mapping(address account => uint256 amount) public balanceMap; @@ -29,17 +30,31 @@ contract CECDistributor is ReentrancyGuard, Pausable, Ownable { cecToken = IERC20(_cecToken); unlockTime = _unlockTime; } + + /** + * @dev Throws if called by any account other than the owner or gov. + */ + modifier ownerOrGov() { + require(msg.sender == owner() || msg.sender == gov, "CECDistributor: forbidden"); + _; + } + + function setGov(address _gov) external override onlyOwner { + gov = _gov; + } /** * @dev update pause state + * When encountering special circumstances that require an emergency pause of the contract, + * the pause function can be called by the gov account to quickly pause the contract and minimize losses. */ - function pause() external onlyOwner { + function pause() external ownerOrGov { _pause(); } /** * @dev update unpause state */ - function unpause() external onlyOwner { + function unpause() external ownerOrGov { _unpause(); }