Skip to content

Commit

Permalink
Review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ischasny committed Oct 31, 2024
1 parent 4c69685 commit 9ed4ad0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
6 changes: 6 additions & 0 deletions l2-contracts/contracts/dev-contracts/ITimestampAsserter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

interface ITimestampAsserter {
function assertTimestampInRange(uint256 start, uint256 end) external view;
}
20 changes: 14 additions & 6 deletions l2-contracts/contracts/dev-contracts/TimestampAsserter.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

interface ITimestampAsserter {
function assertTimestampInRange(uint256 start, uint256 end) external view;
}
import "./ITimestampAsserter.sol";

error TimestampOutOfRange(uint256 currentTimestamp, uint256 start, uint256 end);

/// @title TimestampAsserter
/// @author Matter Labs
/// @custom:security-contact security@matterlabs.dev
/// @dev A contract that verifies if the current block timestamp falls within a specified range.
/// This is useful for custom account abstraction where time-bound checks are needed but accessing block.timestamp
/// directly is not possible.
contract TimestampAsserter is ITimestampAsserter {
function assertTimestampInRange(uint256 start, uint256 end) public view {
require(start < block.timestamp && end > block.timestamp, "Block timestamp is out of range");
function assertTimestampInRange(uint256 _start, uint256 _end) public view {
if (block.timestamp < _start || block.timestamp > _end) {
revert TimestampOutOfRange(block.timestamp, _start, _end);
}
}
}
}

0 comments on commit 9ed4ad0

Please sign in to comment.