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
854db439
Unverified
Commit
854db439
authored
Oct 26, 2023
by
Maurelian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(ctb): LivenessGuard record current owners in constructor
parent
a51e82f3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
0 deletions
+18
-0
LivenessGuard.sol
packages/contracts-bedrock/src/Safe/LivenessGuard.sol
+6
-0
LivenessGuard.t.sol
packages/contracts-bedrock/test/LivenessGuard.t.sol
+12
-0
No files found.
packages/contracts-bedrock/src/Safe/LivenessGuard.sol
View file @
854db439
...
@@ -45,6 +45,12 @@ contract LivenessGuard is ISemver, BaseGuard {
...
@@ -45,6 +45,12 @@ contract LivenessGuard is ISemver, BaseGuard {
/// @param _safe The safe account for which this contract will be the guard.
/// @param _safe The safe account for which this contract will be the guard.
constructor(Safe _safe) {
constructor(Safe _safe) {
SAFE = _safe;
SAFE = _safe;
address[] memory owners = _safe.getOwners();
for (uint256 i = 0; i < owners.length; i++) {
address owner = owners[i];
lastLive[owner] = block.timestamp;
emit OwnerRecorded(0x0, owner);
}
}
}
/// @notice Internal function to ensure that only the Safe can call certain functions.
/// @notice Internal function to ensure that only the Safe can call certain functions.
...
...
packages/contracts-bedrock/test/LivenessGuard.t.sol
View file @
854db439
...
@@ -15,17 +15,29 @@ contract LivenessGuard_TestInit is Test, SafeTestTools {
...
@@ -15,17 +15,29 @@ contract LivenessGuard_TestInit is Test, SafeTestTools {
event OwnerRecorded(bytes32 indexed txHash, address signer);
event OwnerRecorded(bytes32 indexed txHash, address signer);
uint256 initTime = 10;
LivenessGuard livenessGuard;
LivenessGuard livenessGuard;
SafeInstance safeInstance;
SafeInstance safeInstance;
/// @dev Sets up the test environment
/// @dev Sets up the test environment
function setUp() public {
function setUp() public {
vm.warp(initTime);
safeInstance = _setupSafe();
safeInstance = _setupSafe();
livenessGuard = new LivenessGuard(safeInstance.safe);
livenessGuard = new LivenessGuard(safeInstance.safe);
safeInstance.setGuard(address(livenessGuard));
safeInstance.setGuard(address(livenessGuard));
}
}
}
}
contract LivenessGuard_Constructor_Test is LivenessGuard_TestInit {
function test_constructor_works() external {
address[] memory owners = safeInstance.owners;
livenessGuard = new LivenessGuard(safeInstance.safe);
for (uint256 i = 0; i < owners.length; i++) {
assertEq(livenessGuard.lastLive(owners[i]), initTime);
}
}
}
contract LivenessGuard_Getters_Test is LivenessGuard_TestInit {
contract LivenessGuard_Getters_Test is LivenessGuard_TestInit {
/// @dev Tests that the getters return the correct values
/// @dev Tests that the getters return the correct values
function test_getters_works() external {
function test_getters_works() external {
...
...
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