Skip to content

Commit acb8921

Browse files
committed
Replace _getGuard with isGuardEnabled
1 parent 3b25e74 commit acb8921

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

packages/contracts-bedrock/src/safe/TimelockGuard.sol

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ contract TimelockGuard is IGuard, ISemver {
6767
/// @param _timelockDelay The timelock delay in seconds
6868
function configureTimelockGuard(uint256 _timelockDelay) external {
6969
// Validate timelock delay - must be non-zero and not longer than 1 year
70-
if (_timelockDelay == 0 || _timelockDelay > 365 days) {
70+
if (_timelockDelay > 365 days) {
7171
revert TimelockGuard_InvalidTimelockDelay();
7272
}
7373

7474
// Check that this guard is enabled on the calling Safe
75-
if (_getGuard(msg.sender) != address(this)) {
75+
if (!_isGuardEnabled(msg.sender)) {
7676
revert TimelockGuard_GuardNotEnabled();
7777
}
7878

@@ -96,7 +96,7 @@ contract TimelockGuard is IGuard, ISemver {
9696
}
9797

9898
// Check that this guard is NOT enabled on the calling Safe
99-
if (_getGuard(msg.sender) == address(this)) {
99+
if (_isGuardEnabled(msg.sender)) {
100100
revert TimelockGuard_GuardStillEnabled();
101101
}
102102

@@ -114,7 +114,7 @@ contract TimelockGuard is IGuard, ISemver {
114114
/// @return The current cancellation threshold
115115
function cancellationThreshold(address _safe) public view returns (uint256) {
116116
// Return 0 if guard is not enabled
117-
if (_getGuard(_safe) != address(this)) {
117+
if (!_isGuardEnabled(_safe)) {
118118
return 0;
119119
}
120120

@@ -124,11 +124,12 @@ contract TimelockGuard is IGuard, ISemver {
124124
/// @notice Internal helper to get the guard address from a Safe
125125
/// @param _safe The Safe address
126126
/// @return The current guard address
127-
function _getGuard(address _safe) internal view returns (address) {
127+
function _isGuardEnabled(address _safe) internal view returns (bool) {
128128
// keccak256("guard_manager.guard.address") from GuardManager
129129
bytes32 guardSlot = 0x4a204f620c8c5ccdca3fd54d003badd85ba500436a431f0cbda4f558c93c34c8;
130130
Safe safe = Safe(payable(_safe));
131-
return abi.decode(safe.getStorageAt(uint256(guardSlot), 1), (address));
131+
address guard = abi.decode(safe.getStorageAt(uint256(guardSlot), 1), (address));
132+
return guard == address(this);
132133
}
133134

134135
/// @notice Schedule a transaction for execution after the timelock delay

0 commit comments

Comments
 (0)