Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: reuse time since rotation func #204

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions contracts/governance/BaseWeightedMultisig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@ abstract contract BaseWeightedMultisig is IBaseWeightedMultisig {
* @notice This function returns the timestamp for the last signer rotation
* @return uint256 The last rotation timestamp
*/
function lastRotationTimestamp() external view returns (uint256) {
function lastRotationTimestamp() public view returns (uint256) {
return _baseWeightedMultisigStorage().lastRotationTimestamp;
}

/**
* @notice This function returns the time elapsed (in secs) since the last rotation
* @return uint256 The time since the last rotation
*/
function timeSinceRotation() external view returns (uint256) {
return block.timestamp - _baseWeightedMultisigStorage().lastRotationTimestamp;
function timeSinceRotation() public view returns (uint256) {
return block.timestamp - lastRotationTimestamp();
}

/*************************\
Expand Down Expand Up @@ -168,18 +168,13 @@ abstract contract BaseWeightedMultisig is IBaseWeightedMultisig {
* @dev Updates the last rotation timestamp, and enforces the minimum rotation delay if specified
*/
function _updateRotationTimestamp(bool enforceRotationDelay) internal {
uint256 lastRotationTimestamp_ = _baseWeightedMultisigStorage().lastRotationTimestamp;
uint256 currentTimestamp = block.timestamp;

if (enforceRotationDelay && (currentTimestamp - lastRotationTimestamp_) < minimumRotationDelay) {
revert InsufficientRotationDelay(
minimumRotationDelay,
lastRotationTimestamp_,
currentTimestamp - lastRotationTimestamp_
);
uint256 timeSinceRotation_ = timeSinceRotation();

if (enforceRotationDelay && timeSinceRotation_ < minimumRotationDelay) {
revert InsufficientRotationDelay(minimumRotationDelay, lastRotationTimestamp(), timeSinceRotation_);
}

_baseWeightedMultisigStorage().lastRotationTimestamp = currentTimestamp;
_baseWeightedMultisigStorage().lastRotationTimestamp = block.timestamp;
ahramy marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading