-
Notifications
You must be signed in to change notification settings - Fork 4
/
Governable.sol
35 lines (29 loc) · 964 Bytes
/
Governable.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.17;
/// @title Governable
/// @notice Basic access control mechanism, gov has access to certain functions
contract Governable {
address public gov;
event SetGov(address prevGov, address nextGov);
/// @dev Initializes the contract setting the deployer address as governance
constructor() {
_setGov(msg.sender);
}
/// @dev Reverts if called by any account other than gov
modifier onlyGov() {
require(msg.sender == gov, '!gov');
_;
}
/// @notice Sets a new governance address
/// @dev Only callable by governance
function setGov(address _gov) external onlyGov {
_setGov(_gov);
}
/// @notice Sets a new governance address
/// @dev Internal function without access restriction
function _setGov(address _gov) internal {
address prevGov = gov;
gov = _gov;
emit SetGov(prevGov, _gov);
}
}