all files / contracts/peripherals/ Governable.sol

0% Statements 0/8
0% Branches 0/6
0% Functions 0/5
0% Lines 0/11
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 36 37 38 39 40 41 42 43                                                                                     
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4 <0.9.0;
 
import '../../interfaces/peripherals/IGovernable.sol';
 
abstract contract Governable is IGovernable {
  /// @inheritdoc IGovernable
  address public override governance;
 
  /// @inheritdoc IGovernable
  address public override pendingGovernance;
 
  constructor(address _governance) {
    if (_governance == address(0)) revert NoGovernanceZeroAddress();
    governance = _governance;
  }
 
  /// @inheritdoc IGovernable
  function setGovernance(address _governance) external override onlyGovernance {
    pendingGovernance = _governance;
    emit GovernanceProposal(_governance);
  }
 
  /// @inheritdoc IGovernable
  function acceptGovernance() external override onlyPendingGovernance {
    governance = pendingGovernance;
    delete pendingGovernance;
    emit GovernanceSet(governance);
  }
 
  /// @notice Functions with this modifier can only be called by governance
  modifier onlyGovernance {
    if (msg.sender != governance) revert OnlyGovernance();
    _;
  }
 
  /// @notice Functions with this modifier can only be called by pendingGovernance
  modifier onlyPendingGovernance {
    if (msg.sender != pendingGovernance) revert OnlyPendingGovernance();
    _;
  }
}