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
6b67dc7c
Unverified
Commit
6b67dc7c
authored
Oct 02, 2023
by
Maurelian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(ctb): Emit SignersRecorded event
parent
8e2a6dec
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
LivenessGuard.sol
packages/contracts-bedrock/src/Safe/LivenessGuard.sol
+8
-1
LivenessGuard.t.sol
packages/contracts-bedrock/test/LivenessGuard.t.sol
+5
-0
No files found.
packages/contracts-bedrock/src/Safe/LivenessGuard.sol
View file @
6b67dc7c
...
@@ -7,6 +7,10 @@ import { SignatureDecoder } from "safe-contracts/common/SignatureDecoder.sol";
...
@@ -7,6 +7,10 @@ import { SignatureDecoder } from "safe-contracts/common/SignatureDecoder.sol";
import { Enum } from "safe-contracts/common/Enum.sol";
import { Enum } from "safe-contracts/common/Enum.sol";
contract LivenessGuard is SignatureDecoder, BaseGuard {
contract LivenessGuard is SignatureDecoder, BaseGuard {
/// @notice Emitted when a new set of signers is recorded.
/// @param signers An arrary of signer addresses.
event SignersRecorded(bytes32 indexed txHash, address[] signers);
Safe public safe;
Safe public safe;
mapping(address => uint256) public lastSigned;
mapping(address => uint256) public lastSigned;
...
@@ -41,7 +45,8 @@ contract LivenessGuard is SignatureDecoder, BaseGuard {
...
@@ -41,7 +45,8 @@ contract LivenessGuard is SignatureDecoder, BaseGuard {
// TODO(Maurelian): Figure out how to best address this.
// TODO(Maurelian): Figure out how to best address this.
}
}
// This is a bit of a hack, maybe just replicate the functionality here rather than calling home
// 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.
bytes32 txHash = Safe(payable(msg.sender)).getTransactionHash(
bytes32 txHash = Safe(payable(msg.sender)).getTransactionHash(
// Transaction info
// Transaction info
to,
to,
...
@@ -55,11 +60,13 @@ contract LivenessGuard is SignatureDecoder, BaseGuard {
...
@@ -55,11 +60,13 @@ contract LivenessGuard is SignatureDecoder, BaseGuard {
gasToken,
gasToken,
refundReceiver,
refundReceiver,
// Signature info
// Signature info
Safe(payable(msg.sender)).nonce() - 1
);
);
address[] memory signers = _getNSigners(txHash, signatures);
address[] memory signers = _getNSigners(txHash, signatures);
for (uint256 i = 0; i < signers.length; i++) {
for (uint256 i = 0; i < signers.length; i++) {
lastSigned[signers[i]] = block.timestamp;
lastSigned[signers[i]] = block.timestamp;
}
}
emit SignersRecorded(txHash, signers);
}
}
/// @notice Exctract the signers from a set of signatures.
/// @notice Exctract the signers from a set of signatures.
...
...
packages/contracts-bedrock/test/LivenessGuard.t.sol
View file @
6b67dc7c
...
@@ -21,6 +21,8 @@ import { LivenessGuard } from "src/Safe/LivenessGuard.sol";
...
@@ -21,6 +21,8 @@ import { LivenessGuard } from "src/Safe/LivenessGuard.sol";
contract LivnessGuard_TestInit is Test, SafeTestTools {
contract LivnessGuard_TestInit is Test, SafeTestTools {
using SafeTestLib for SafeInstance;
using SafeTestLib for SafeInstance;
event SignersRecorded(bytes32 indexed txHash, address[] signers);
LivenessGuard livenessGuard;
LivenessGuard livenessGuard;
SafeInstance safeInstance;
SafeInstance safeInstance;
...
@@ -35,6 +37,9 @@ contract LivnessGuard_TestCheckTx is LivnessGuard_TestInit {
...
@@ -35,6 +37,9 @@ contract LivnessGuard_TestCheckTx is LivnessGuard_TestInit {
using SafeTestLib for SafeInstance;
using SafeTestLib for SafeInstance;
function test_checkTransaction_succeeds() external {
function test_checkTransaction_succeeds() external {
// Don't check topic1 so that we can avoid the ugly txHash calculation.
vm.expectEmit(false, true, true, true, address(livenessGuard));
emit SignersRecorded(0x0, safeInstance.owners);
safeInstance.execTransaction({ to: address(1111), value: 0, data: hex"abba" });
safeInstance.execTransaction({ to: address(1111), value: 0, data: hex"abba" });
for (uint256 i; i < safeInstance.owners.length; i++) {
for (uint256 i; i < safeInstance.owners.length; i++) {
...
...
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