Commit 5a1baf8f authored by Maurelian's avatar Maurelian

feat(ctb): Clean up and comment the checkAfterExecution hook

parent 0831cd6d
...@@ -34,22 +34,23 @@ contract LivenessGuard is ISemver, GetSigners, BaseGuard { ...@@ -34,22 +34,23 @@ contract LivenessGuard is ISemver, GetSigners, BaseGuard {
/// 1. Add new owners to the lastSigned mapping /// 1. Add new owners to the lastSigned mapping
/// 2. Delete removed owners from the lastSigned mapping /// 2. Delete removed owners from the lastSigned mapping
function checkAfterExecution(bytes32, bool) external { function checkAfterExecution(bytes32, bool) external {
// Get the current set of owners
address[] memory ownersAfter = safe.getOwners(); address[] memory ownersAfter = safe.getOwners();
// Iterate over the current owners, and remove one at a time from the ownersBefore set.
for (uint256 i = 0; i < ownersAfter.length; i++) { for (uint256 i = 0; i < ownersAfter.length; i++) {
if (ownersBefore.contains(ownersAfter[i])) { // If the value was present, remove() returns true.
// This address was already present, no change, remove it from the set. if (ownersBefore.remove(ownersAfter[i]) == false) {
ownersBefore.remove(ownersAfter[i]); // This address was not already an owner, add it to the lastSigned mapping
} else {
// This address is newly added, add it to the lastSigned mapping
lastSigned[ownersAfter[i]] = block.timestamp; lastSigned[ownersAfter[i]] = block.timestamp;
} }
// Iterate over ownersSet. Any remaining addresses are no longer an owner, so we delete }
// it from the lastSigned mapping. // Now iterate over the remaining ownersBefore entries. Any remaining addresses are no longer an owner, so we
// delete them from the lastSigned mapping.
for (uint256 j = 0; j < ownersBefore.length(); j++) { for (uint256 j = 0; j < ownersBefore.length(); j++) {
address owner = ownersBefore.at(j); address owner = ownersBefore.at(j);
delete lastSigned[owner]; delete lastSigned[owner];
} }
}
return; return;
} }
......
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