Commit 2103d61d authored by Maurelian's avatar Maurelian

refactor(ctb): Extract guard check into _verifyGuard()

parent 4a042355
...@@ -67,10 +67,7 @@ contract LivenessModule is ISemver { ...@@ -67,10 +67,7 @@ contract LivenessModule is ISemver {
/// ownership of the Safe is transferred to the fallback owner. /// ownership of the Safe is transferred to the fallback owner.
function removeOwner(address owner) external { function removeOwner(address owner) external {
// Check that the guard has not been changed // Check that the guard has not been changed
require( _verifyGuard();
address(livenessGuard) == address(uint160(uint256(bytes32(safe.getStorageAt(GUARD_STORAGE_SLOT, 1))))),
"LivenessModule: guard has been changed"
);
// Check that the owner to remove has not signed a transaction in the last 30 days // Check that the owner to remove has not signed a transaction in the last 30 days
require( require(
...@@ -142,14 +139,20 @@ contract LivenessModule is ISemver { ...@@ -142,14 +139,20 @@ contract LivenessModule is ISemver {
"LivenessModule: Safe must have the minimum number of owners, or be owned solely by the fallback owner" "LivenessModule: Safe must have the minimum number of owners, or be owned solely by the fallback owner"
); );
// Check that the threshold is correct // Check that the threshold is correct. This check is also correct when there is a single
// owner, because get75PercentThreshold(1) returns 1.
uint256 threshold = safe.getThreshold(); uint256 threshold = safe.getThreshold();
require( require(
threshold == get75PercentThreshold(numOwners), threshold == get75PercentThreshold(numOwners),
"LivenessModule: threshold must be 75% of the number of owners" "LivenessModule: threshold must be 75% of the number of owners"
); );
// Check that the guard has not been changed // Check that the guard has not been changed.
_verifyGuard();
}
/// @notice Reverts if the guard address does not match the expected value.
function _verifyGuard() internal view {
require( require(
address(livenessGuard) == address(uint160(uint256(bytes32(safe.getStorageAt(GUARD_STORAGE_SLOT, 1))))), address(livenessGuard) == address(uint160(uint256(bytes32(safe.getStorageAt(GUARD_STORAGE_SLOT, 1))))),
"LivenessModule: guard has been changed" "LivenessModule: guard has been changed"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment