-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from lidofinance/feature/split-dg-and-reseal-…
…functionality Split dg and reseal functionality
- Loading branch information
Showing
5 changed files
with
186 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.26; | ||
|
||
import {IResealManager} from "../interfaces/IResealManager.sol"; | ||
|
||
/// @title Resealer Library | ||
/// @dev Library for managing sealing operations for critical components of Lido protocol. | ||
library Resealer { | ||
// --- | ||
// Errors | ||
// --- | ||
error InvalidResealManager(address resealManager); | ||
error InvalidResealCommittee(address resealCommittee); | ||
error CallerIsNotResealCommittee(address caller); | ||
|
||
// --- | ||
// Events | ||
// --- | ||
event ResealCommitteeSet(address resealCommittee); | ||
event ResealManagerSet(address resealManager); | ||
|
||
// --- | ||
// Data Types | ||
// --- | ||
|
||
/// @dev Struct to hold the context of the reseal operations. | ||
/// @param resealManager The address of the Reseal Manager. | ||
/// @param resealCommittee The address of the Reseal Committee which is allowed to "reseal" sealables paused for a limited | ||
/// period of time when the Dual Governance proposal adoption is blocked. | ||
struct Context { | ||
IResealManager resealManager; | ||
address resealCommittee; | ||
} | ||
|
||
/// @dev Sets a new Reseal Manager contract address. | ||
/// @param self The context struct containing the current state. | ||
/// @param newResealManager The address of the new Reseal Manager. | ||
function setResealManager(Context storage self, address newResealManager) internal { | ||
if (newResealManager == address(self.resealManager) || newResealManager == address(0)) { | ||
revert InvalidResealManager(newResealManager); | ||
} | ||
self.resealManager = IResealManager(newResealManager); | ||
emit ResealManagerSet(newResealManager); | ||
} | ||
|
||
/// @dev Sets a new reseal committee address. | ||
/// @param self The context struct containing the current state. | ||
/// @param newResealCommittee The address of the new reseal committee. | ||
function setResealCommittee(Context storage self, address newResealCommittee) internal { | ||
if (newResealCommittee == self.resealCommittee) { | ||
revert InvalidResealCommittee(newResealCommittee); | ||
} | ||
self.resealCommittee = newResealCommittee; | ||
emit ResealCommitteeSet(newResealCommittee); | ||
} | ||
|
||
/// @dev Checks if the caller is the reseal committee. | ||
/// @param self The context struct containing the current state. | ||
function checkCallerIsResealCommittee(Context storage self) internal view { | ||
if (msg.sender != self.resealCommittee) { | ||
revert CallerIsNotResealCommittee(msg.sender); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.