Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
24e9a030
Unverified
Commit
24e9a030
authored
Oct 27, 2023
by
Maurelian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(ctb): Make canRemove a public function
parent
f2cf018e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
8 deletions
+27
-8
LivenessModule.sol
packages/contracts-bedrock/src/Safe/LivenessModule.sol
+9
-8
LivenessModule.t.sol
packages/contracts-bedrock/test/LivenessModule.t.sol
+18
-0
No files found.
packages/contracts-bedrock/src/Safe/LivenessModule.sol
View file @
24e9a030
...
...
@@ -98,6 +98,14 @@ contract LivenessModule is ISemver {
fallbackOwner_ = FALLBACK_OWNER;
}
/// @notice Checks if the owner can be removed
/// @param _owner The owner to be removed
/// @return canRemove_ bool indicating if the owner can be removed
function canRemove(address _owner) public view returns (bool canRemove_) {
require(SAFE.isOwner(_owner), "LivenessModule: the owner to remove must be an owner of the Safe");
canRemove_ = LIVENESS_GUARD.lastLive(_owner) + LIVENESS_INTERVAL < block.timestamp;
}
/// @notice This function can be called by anyone to remove a set of owners that have not signed a transaction
/// during the liveness interval. If the number of owners drops below the minimum, then all owners
/// must be removed.
...
...
@@ -111,7 +119,7 @@ contract LivenessModule is ISemver {
for (uint256 i = 0; i < _previousOwners.length; i++) {
ownersCount--;
if (ownersCount >= MIN_OWNERS) {
require(
_
canRemove(_ownersToRemove[i]), "LivenessModule: the owner to remove has signed recently");
require(canRemove(_ownersToRemove[i]), "LivenessModule: the owner to remove has signed recently");
}
_removeOwner({
...
...
@@ -170,13 +178,6 @@ contract LivenessModule is ISemver {
);
}
/// @notice Checks if the owner can be removed
/// @param _owner The owner to be removed
/// @return canRemove_ bool indicating if the owner can be removed
function _canRemove(address _owner) internal view returns (bool canRemove_) {
canRemove_ = LIVENESS_GUARD.lastLive(_owner) + LIVENESS_INTERVAL < block.timestamp;
}
/// @notice A FREI-PI invariant check enforcing requirements on number of owners and threshold.
function _verifyFinalState() internal view {
address[] memory owners = SAFE.getOwners();
...
...
packages/contracts-bedrock/test/LivenessModule.t.sol
View file @
24e9a030
...
...
@@ -105,6 +105,24 @@ contract LivenessModule_Getters_Test is LivenessModule_TestInit {
}
}
contract LivenessModule_CanRemove_TestFail is LivenessModule_TestInit {
/// @dev Tests if canRemove work correctly
function test_canRemove_notSafeOwner_reverts() external {
address nonOwner = makeAddr("nonOwner");
vm.expectRevert("LivenessModule: the owner to remove must be an owner of the Safe");
livenessModule.canRemove(nonOwner);
}
}
contract LivenessModule_CanRemove_Test is LivenessModule_TestInit {
/// @dev Tests if canRemove work correctly
function test_canRemove_works() external {
_warpPastLivenessInterval();
bool canRemove = livenessModule.canRemove(safeInstance.owners[0]);
assertTrue(canRemove);
}
}
contract LivenessModule_Get75PercentThreshold_Test is LivenessModule_TestInit {
/// @dev check the return values of the get75PercentThreshold function against manually
/// calculated values.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment