// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.6;
/**
* @title IGovernable
* @author solace.fi
* @notice Enforces access control for important functions to [**governor**](/docs/protocol/governance).
*
* Many contracts contain functionality that should only be accessible to a privileged user. The most common access control pattern is [OpenZeppelin's `Ownable`](https://docs.openzeppelin.com/contracts/4.x/access-control#ownership-and-ownable). We instead use `Governable` with a few key differences:
* - Transferring the governance role is a two step process. The current governance must [`setPendingGovernance(pendingGovernance_)`](#setpendinggovernance) then the new governance must [`acceptGovernance()`](#acceptgovernance). This is to safeguard against accidentally setting ownership to the wrong address and locking yourself out of your contract.
* - `governance` is a constructor argument instead of `msg.sender`. This is especially useful when deploying contracts via a [`SingletonFactory`](./ISingletonFactory).
* - We use `lockGovernance()` instead of `renounceOwnership()`. `renounceOwnership()` is a prerequisite for the reinitialization bug because it sets `owner = address(0x0)`. We also use the `governanceIsLocked()` flag.
*/
interface IGovernable {
/***************************************
EVENTS
***************************************/
/// @notice Emitted when pending Governance is set.
event GovernancePending(address pendingGovernance);
/// @notice Emitted when Governance is set.
event GovernanceTransferred(address oldGovernance, address newGovernance);
/// @notice Emitted when Governance is locked.
event GovernanceLocked();
/***************************************
VIEW FUNCTIONS
***************************************/
/// @notice Address of the current governor.
function governance() external view returns (address);
/// @notice Address of the governor to take over.
function pendingGovernance() external view returns (address);
/// @notice Returns true if governance is locked.
function governanceIsLocked() external view returns (bool);
/***************************************
MUTATORS
***************************************/
/**
* @notice Initiates transfer of the governance role to a new governor.
* Transfer is not complete until the new governor accepts the role.
* Can only be called by the current [**governor**](/docs/protocol/governance).
* @param pendingGovernance_ The new governor.
*/
function setPendingGovernance(address pendingGovernance_) external;
/**
* @notice Accepts the governance role.
* Can only be called by the new governor.
*/
function acceptGovernance() external;
/**
* @notice Permanently locks this contract's governance role and any of its functions that require the role.
* This action cannot be reversed.
* Before you call it, ask yourself:
* - Is the contract self-sustaining?
* - Is there a chance you will need governance privileges in the future?
* Can only be called by the current [**governor**](/docs/protocol/governance).
*/
function lockGovernance() external;
}
|