Working tree is now the canonical repo. Off-chain play-money + trustless on-chain (FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution, mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
74 lines
2.0 KiB
Solidity
74 lines
2.0 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
// OpenZeppelin Contracts v4.4.1 (utils/Timers.sol)
|
|
|
|
pragma solidity ^0.8.0;
|
|
|
|
/**
|
|
* @dev Tooling for timepoints, timers and delays
|
|
*/
|
|
library Timers {
|
|
struct Timestamp {
|
|
uint64 _deadline;
|
|
}
|
|
|
|
function getDeadline(Timestamp memory timer) internal pure returns (uint64) {
|
|
return timer._deadline;
|
|
}
|
|
|
|
function setDeadline(Timestamp storage timer, uint64 timestamp) internal {
|
|
timer._deadline = timestamp;
|
|
}
|
|
|
|
function reset(Timestamp storage timer) internal {
|
|
timer._deadline = 0;
|
|
}
|
|
|
|
function isUnset(Timestamp memory timer) internal pure returns (bool) {
|
|
return timer._deadline == 0;
|
|
}
|
|
|
|
function isStarted(Timestamp memory timer) internal pure returns (bool) {
|
|
return timer._deadline > 0;
|
|
}
|
|
|
|
function isPending(Timestamp memory timer) internal view returns (bool) {
|
|
return timer._deadline > block.timestamp;
|
|
}
|
|
|
|
function isExpired(Timestamp memory timer) internal view returns (bool) {
|
|
return isStarted(timer) && timer._deadline <= block.timestamp;
|
|
}
|
|
|
|
struct BlockNumber {
|
|
uint64 _deadline;
|
|
}
|
|
|
|
function getDeadline(BlockNumber memory timer) internal pure returns (uint64) {
|
|
return timer._deadline;
|
|
}
|
|
|
|
function setDeadline(BlockNumber storage timer, uint64 timestamp) internal {
|
|
timer._deadline = timestamp;
|
|
}
|
|
|
|
function reset(BlockNumber storage timer) internal {
|
|
timer._deadline = 0;
|
|
}
|
|
|
|
function isUnset(BlockNumber memory timer) internal pure returns (bool) {
|
|
return timer._deadline == 0;
|
|
}
|
|
|
|
function isStarted(BlockNumber memory timer) internal pure returns (bool) {
|
|
return timer._deadline > 0;
|
|
}
|
|
|
|
function isPending(BlockNumber memory timer) internal view returns (bool) {
|
|
return timer._deadline > block.number;
|
|
}
|
|
|
|
function isExpired(BlockNumber memory timer) internal view returns (bool) {
|
|
return isStarted(timer) && timer._deadline <= block.number;
|
|
}
|
|
}
|