-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PolicyEnabler mix-in #40
base: develop
Are you sure you want to change the base?
Conversation
src/libraries/Enableable.sol
Outdated
/// 5. Emits the `Enabled` event | ||
/// | ||
/// @param enableData_ The data to pass to the implementation-specific `_enable()` function | ||
function enable(bytes calldata enableData_) public onlyRole(ROLE) whenDisabled { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is can be pulled into all policies - I wonder if it'd be worth reducing bytecode by having a toggleIsEnabled()
instead of distinct enable and disable functions?
The modifier could be also be a single:
modifier whenEnabledIs(bool condition) {
if (isEnabled == condition) revert IsEnabledNotMatching(condition);
_;
}
Tradeoff with being explicit - so don't mind, just throwing it out there (MonoCooler is kinda chunky which is why i bring up)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel that the simplicity would be lost, and it also adds ambiguity.
e.g. the whenEnabledIs(bool condition)
modifier you shared is reverting if isEnabled == condition
, but I would have interpreted it the other way - whenEnabledIs(true)
would revert if isEnabled != true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally fair and agree, thought i'd just throw it in the mix.
LGTM. So the next question is what functions do we add this modifier to on MonoCooler... |
Adds an abstract contract,
PolicyEnabler
, that can be added to contracts that require the ability to be enabled/disabled. Most policies implement this functionality every time, so this mix-in standardizes the approach and role.