Commit c7d5b2b9 authored by Maurelian's avatar Maurelian

refactor(ctb): Clean up in LivenessGuard

parent 6368229c
...@@ -47,20 +47,21 @@ contract LivenessGuard is ISemver, BaseGuard { ...@@ -47,20 +47,21 @@ contract LivenessGuard is ISemver, BaseGuard {
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. // Iterate over the current owners, and remove one at a time from the ownersBefore set.
for (uint256 i = 0; i < ownersAfter.length; i++) { uint256 ownersAfterLength = ownersAfter.length;
for (uint256 i = 0; i < ownersAfterLength; i++) {
// If the value was present, remove() returns true. // If the value was present, remove() returns true.
if (ownersBefore.remove(ownersAfter[i]) == false) { address ownerAfter = ownersAfter[i];
if (ownersBefore.remove(ownerAfter) == false) {
// This address was not already an owner, add it to the lastSigned mapping // This address was not already an owner, add it to the lastSigned mapping
lastLive[ownersAfter[i]] = block.timestamp; lastLive[ownerAfter] = block.timestamp;
} }
} }
// Now iterate over the remaining ownersBefore entries. Any remaining addresses are no longer an owner, so we // Now iterate over the remaining ownersBefore entries. Any remaining addresses are no longer an owner, so we
// delete them from the lastSigned mapping. // 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 ownerBefore = ownersBefore.at(j);
delete lastLive[owner]; delete lastLive[ownerBefore];
} }
return;
} }
/// @notice Records the most recent time which any owner has signed a transaction. /// @notice Records the most recent time which any owner has signed a transaction.
...@@ -92,21 +93,18 @@ contract LivenessGuard is ISemver, BaseGuard { ...@@ -92,21 +93,18 @@ contract LivenessGuard is ISemver, BaseGuard {
// This call will reenter to the Safe which is calling it. This is OK because it is only reading the // This call will reenter to the Safe which is calling it. This is OK because it is only reading the
// nonce, and using the getTransactionHash() method. // nonce, and using the getTransactionHash() method.
bytes32 txHash = Safe(payable(msg.sender)).getTransactionHash( bytes32 txHash = Safe(payable(msg.sender)).getTransactionHash({
// Transaction info to: to,
to, value: value,
value, data: data,
data, operation: operation,
operation, safeTxGas: safeTxGas,
safeTxGas, baseGas: baseGas,
// Payment info gasPrice: gasPrice,
baseGas, gasToken: gasToken,
gasPrice, refundReceiver: refundReceiver,
gasToken, _nonce: Safe(payable(msg.sender)).nonce() - 1
refundReceiver, });
// Signature info
Safe(payable(msg.sender)).nonce() - 1
);
uint256 threshold = safe.getThreshold(); uint256 threshold = safe.getThreshold();
address[] memory signers = address[] memory signers =
......
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