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