-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add TimestampAsserter to sync-layer-stable (#1057)
- Loading branch information
1 parent
9de1edc
commit 2451c42
Showing
4 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: 20 additions & 0 deletions
20
l2-contracts/contracts/dev-contracts/TimestampAsserter.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
import {ITimestampAsserter} from "./ITimestampAsserter.sol"; | ||
|
||
error TimestampOutOfRange(uint256 currentTimestamp, uint256 start, uint256 end); | ||
|
||
/// @title TimestampAsserter | ||
/// @author Matter Labs | ||
/// @custom:security-contact [email protected] | ||
/// @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) external view { | ||
if (block.timestamp < _start || block.timestamp > _end) { | ||
revert TimestampOutOfRange(block.timestamp, _start, _end); | ||
} | ||
} | ||
} |