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
69f3cce1
Unverified
Commit
69f3cce1
authored
Oct 25, 2023
by
Maurelian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(ctb): Add _onlySafe function
parent
3f6470e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
5 deletions
+9
-5
LivenessGuard.sol
packages/contracts-bedrock/src/Safe/LivenessGuard.sol
+8
-4
LivenessGuard.t.sol
packages/contracts-bedrock/test/LivenessGuard.t.sol
+1
-1
No files found.
packages/contracts-bedrock/src/Safe/LivenessGuard.sol
View file @
69f3cce1
...
...
@@ -47,6 +47,11 @@ contract LivenessGuard is ISemver, BaseGuard {
SAFE = _safe;
}
/// @notice Internal function to ensure that only the Safe can call certain functions.
function _onlySafe() internal view {
require(msg.sender == address(SAFE), "LivenessGuard: only Safe can call this function");
}
/// @notice Records the most recent time which any owner has signed a transaction.
/// @dev Called by the Safe contract before execution of a transaction.
function checkTransaction(
...
...
@@ -65,7 +70,7 @@ contract LivenessGuard is ISemver, BaseGuard {
external
{
msgSender; // silence unused variable warning
require(msg.sender == address(SAFE), "LivenessGuard: only Safe can call this function"
);
_onlySafe(
);
// Cache the set of owners prior to execution.
// This will be used in the checkAfterExecution method.
...
...
@@ -106,8 +111,7 @@ contract LivenessGuard is ISemver, BaseGuard {
/// 1. Add new owners to the lastLive mapping
/// 2. Delete removed owners from the lastLive mapping
function checkAfterExecution(bytes32, bool) external {
require(msg.sender == address(SAFE), "LivenessGuard: only Safe can call this function");
_onlySafe();
// Get the current set of owners
address[] memory ownersAfter = SAFE.getOwners();
...
...
@@ -132,7 +136,7 @@ contract LivenessGuard is ISemver, BaseGuard {
/// @notice Enables an owner to demonstrate liveness by calling this method directly.
/// This is useful for owners who have not recently signed a transaction via the Safe.
function showLiveness() external {
require(SAFE.isOwner(msg.sender), "LivenessGuard: only Safe owners may demon
t
strate liveness");
require(SAFE.isOwner(msg.sender), "LivenessGuard: only Safe owners may demonstrate liveness");
lastLive[msg.sender] = block.timestamp;
emit OwnerRecorded(0x0, msg.sender);
...
...
packages/contracts-bedrock/test/LivenessGuard.t.sol
View file @
69f3cce1
...
...
@@ -93,7 +93,7 @@ contract LivenessGuard_CheckAfterExecution_Test is LivenessGuard_TestInit { }
contract LivenessGuard_ShowLiveness_TestFail is LivenessGuard_TestInit {
/// @dev Tests that the showLiveness function reverts if the caller is not an owner
function test_showLiveness_callIsNotSafeOwner_reverts() external {
vm.expectRevert("LivenessGuard: only Safe owners
can call this function
");
vm.expectRevert("LivenessGuard: only Safe owners
may demonstrate liveness
");
livenessGuard.showLiveness();
}
}
...
...
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