Commit 7ce3e4dc authored by Maurelian's avatar Maurelian

refactor(ctb): Only emit a single address from SignerRecorded

parent 927bcaaa
......@@ -21,9 +21,9 @@ import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableS
contract LivenessGuard is ISemver, BaseGuard {
using EnumerableSet for EnumerableSet.AddressSet;
/// @notice Emitted when a new set of signers is recorded.
/// @param signers An arrary of signer addresses.
event SignersRecorded(bytes32 indexed txHash, address[] signers);
/// @notice Emitted when a signer is recorded.
/// @param signer The signer's address.
event SignerRecorded(bytes32 indexed txHash, address signer);
/// @notice Semantic version.
/// @custom:semver 1.0.0
......@@ -95,8 +95,8 @@ contract LivenessGuard is ISemver, BaseGuard {
for (uint256 i = 0; i < signers.length; i++) {
lastLive[signers[i]] = block.timestamp;
emit SignerRecorded(txHash, signers[i]);
}
emit SignersRecorded(txHash, signers);
}
/// @notice Update the lastLive mapping according to the set of owners before and after execution.
......@@ -134,10 +134,8 @@ contract LivenessGuard is ISemver, BaseGuard {
function showLiveness() external {
require(SAFE.isOwner(msg.sender), "LivenessGuard: only Safe owners may demontstrate liveness");
lastLive[msg.sender] = block.timestamp;
address[] memory signers = new address[](1);
signers[0] = msg.sender;
emit SignersRecorded(0x0, signers);
emit SignerRecorded(0x0, msg.sender);
}
/// @notice Getter function for the Safe contract instance
......
......@@ -21,7 +21,7 @@ import { LivenessGuard } from "src/Safe/LivenessGuard.sol";
contract LivenessGuard_TestInit is Test, SafeTestTools {
using SafeTestLib for SafeInstance;
event SignersRecorded(bytes32 indexed txHash, address[] signers);
event SignerRecorded(bytes32 indexed txHash, address signer);
LivenessGuard livenessGuard;
SafeInstance safeInstance;
......@@ -69,9 +69,11 @@ contract LivenessGuard_CheckTx_Test is LivenessGuard_TestInit {
signers[0] = safeInstance.owners[0];
signers[1] = safeInstance.owners[1];
// Don't check topic1 so that we can avoid the ugly txHash calculation.
vm.expectEmit(false, true, true, true, address(livenessGuard));
emit SignersRecorded(0x0, signers);
for (uint256 i; i < signers.length; i++) {
// Don't check topic1 so that we can avoid the ugly txHash calculation.
vm.expectEmit(false, true, true, true, address(livenessGuard));
emit SignerRecorded(0x0, signers[i]);
}
vm.expectCall(address(safeInstance.safe), abi.encodeWithSignature("nonce()"));
vm.expectCall(address(safeInstance.safe), abi.encodeCall(OwnerManager.getThreshold, ()));
safeInstance.execTransaction({ to: address(1111), value: 0, data: hex"abba" });
......@@ -96,11 +98,8 @@ contract LivenessGuard_ShowLiveness_Test is LivenessGuard_TestInit {
// Cache the caller
address caller = safeInstance.owners[0];
// Construct a signers array with just the caller to identify the expected event.
address[] memory signers = new address[](1);
signers[0] = caller;
vm.expectEmit(address(livenessGuard));
emit SignersRecorded(0x0, signers);
emit SignerRecorded(0x0, caller);
vm.prank(caller);
livenessGuard.showLiveness();
......
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