修改pause和unpause的执行权限, 可以跳过timelock执行

This commit is contained in:
CounterFire2023 2024-09-05 17:02:38 +08:00
parent 24ee9282e9
commit 8d1bf19299

View File

@ -6,13 +6,14 @@ import {Pausable} from "@openzeppelin/contracts/security/Pausable.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {Governable} from "../core/Governable.sol";
/** /**
* @title CECDistributor * @title CECDistributor
* @dev CECDistributor is a contract for distributing CEC token with unlock time * @dev CECDistributor is a contract for distributing CEC token with unlock time
* after all data is set, transfer owner to timelock contract * 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; using SafeERC20 for IERC20;
mapping(address account => uint256 amount) public balanceMap; mapping(address account => uint256 amount) public balanceMap;
@ -29,17 +30,31 @@ contract CECDistributor is ReentrancyGuard, Pausable, Ownable {
cecToken = IERC20(_cecToken); cecToken = IERC20(_cecToken);
unlockTime = _unlockTime; 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 * @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(); _pause();
} }
/** /**
* @dev update unpause state * @dev update unpause state
*/ */
function unpause() external onlyOwner { function unpause() external ownerOrGov {
_unpause(); _unpause();
} }