Commit 41c9a3d4 authored by Maurelian's avatar Maurelian

refactor(ctb): Simplify require statements by nesting in an if()

Rather than using an OR clause we put them inside an if statement. This allows us to

clarify the error message and is more testable.
parent 2f3965fc
...@@ -74,10 +74,10 @@ contract LivenessModule is ISemver { ...@@ -74,10 +74,10 @@ contract LivenessModule is ISemver {
uint256 ownersCount = SAFE.getOwners().length; uint256 ownersCount = SAFE.getOwners().length;
for (uint256 i = 0; i < _previousOwners.length; i++) { for (uint256 i = 0; i < _previousOwners.length; i++) {
ownersCount--; ownersCount--;
require( if (ownersCount >= MIN_OWNERS) {
ownersCount < MIN_OWNERS || _canRemove(_ownersToRemove[i]), require(_canRemove(_ownersToRemove[i]), "LivenessModule: the owner to remove has signed recently");
"LivenessModule: the safe still has sufficient owners, or the owner to remove has signed recently" }
);
_removeOwner({ _removeOwner({
_prevOwner: _previousOwners[i], _prevOwner: _previousOwners[i],
_ownerToRemove: _ownersToRemove[i], _ownerToRemove: _ownersToRemove[i],
...@@ -154,10 +154,14 @@ contract LivenessModule is ISemver { ...@@ -154,10 +154,14 @@ contract LivenessModule is ISemver {
address[] memory owners = SAFE.getOwners(); address[] memory owners = SAFE.getOwners();
uint256 numOwners = owners.length; uint256 numOwners = owners.length;
// Ensure that the safe is not being left in an unsafe state with too few owners. // Ensure that the safe is not being left in an unsafe state with too few owners.
require( if (numOwners == 1) {
numOwners >= MIN_OWNERS || (numOwners == 1 && owners[0] == FALLBACK_OWNER), require(owners[0] == FALLBACK_OWNER, "LivenessModule: must transfer ownership to fallback owner");
"LivenessModule: Safe must have the minimum number of owners or be owned solely by the fallback owner" } else {
); require(
numOwners >= MIN_OWNERS,
"LivenessModule: must remove all owners and transfer to fallback owner if numOwners < minOwners"
);
}
// Check that the threshold is correct. This check is also correct when there is a single // Check that the threshold is correct. This check is also correct when there is a single
// owner, because get75PercentThreshold(1) returns 1. // owner, because get75PercentThreshold(1) returns 1.
......
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