Skip to content

Commit

Permalink
chore: simplify Managed contract
Browse files Browse the repository at this point in the history
Signed-off-by: Tomás Migone <[email protected]>
  • Loading branch information
tmigone committed May 21, 2024
1 parent 5e12031 commit 5d1f327
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { HorizonStakingV1Storage } from "./HorizonStakingStorage.sol";
* Note that this contract delegates part of its functionality to a StakingExtension contract.
* This is due to the 24kB contract size limit on Ethereum.
*/
abstract contract StakingBackwardsCompatibility is HorizonStakingV1Storage, IStakingBackwardsCompatibility {
abstract contract StakingBackwardsCompatibility is Managed, HorizonStakingV1Storage, IStakingBackwardsCompatibility {
/// @dev 100% in parts per million
uint32 internal constant MAX_PPM = 1000000;

Expand Down
43 changes: 5 additions & 38 deletions packages/horizon/contracts/staking/utilities/Managed.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,43 +30,39 @@ abstract contract Managed is IManaged, GraphDirectory {

/// Emitted when a contract parameter has been updated
event ParameterUpdated(string param);
/// (Deprecated) Emitted when the controller address has been set
event SetController(address controller);

///(Deprecated) Emitted when contract with `nameHash` is synced to `contractAddress`.
event ContractSynced(bytes32 indexed nameHash, address contractAddress);

error ManagedSetControllerDeprecated();

/**
* @dev Revert if the controller is paused or partially paused
*/
modifier notPartialPaused() {
_notPartialPaused();
require(!controller().paused(), "Paused");
require(!controller().partialPaused(), "Partial-paused");
_;
}

/**
* @dev Revert if the controller is paused
*/
modifier notPaused() {
_notPaused();
require(!controller().paused(), "Paused");
_;
}

/**
* @dev Revert if the caller is not the Controller
*/
modifier onlyController() {
_onlyController();
require(msg.sender == CONTROLLER, "Caller must be Controller");
_;
}

/**
* @dev Revert if the caller is not the governor
*/
modifier onlyGovernor() {
_onlyGovernor();
require(msg.sender == controller().getGovernor(), "Only Controller governor");
_;
}

Expand All @@ -82,33 +78,4 @@ abstract contract Managed is IManaged, GraphDirectory {
function controller() public view override returns (IController) {
return IController(CONTROLLER);
}

/**
* @dev Revert if the controller is paused or partially paused
*/
function _notPartialPaused() internal view {
require(!controller().paused(), "Paused");
require(!controller().partialPaused(), "Partial-paused");
}

/**
* @dev Revert if the controller is paused
*/
function _notPaused() internal view virtual {
require(!controller().paused(), "Paused");
}

/**
* @dev Revert if the caller is not the governor
*/
function _onlyGovernor() internal view {
require(msg.sender == controller().getGovernor(), "Only Controller governor");
}

/**
* @dev Revert if the caller is not the Controller
*/
function _onlyController() internal view {
require(msg.sender == CONTROLLER, "Caller must be Controller");
}
}

0 comments on commit 5d1f327

Please sign in to comment.