Set new deadline
Set a new deadline. You can't set a new deadline if the current deadline is passed or if is there is less than one day between the current one.
Coming soon
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { SchemaResolver } from "../SchemaResolver.sol";
import { IEAS, Attestation } from "../../IEAS.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
/**
* @title Time Checker Schema Resolver
* This resolver allows operations until a certain deadline, which can only be set by the owner and must extend the current one without updating past deadlines.
*/
contract TimeCheckerResolver is SchemaResolver, Ownable {
uint256 public _deadline;
uint256 public _startDate;
constructor(IEAS eas, uint256 initialStartDate, uint256 initialDeadline) SchemaResolver(eas) {
require(initialStartDate > block.timestamp, "Initial startDate must be in the future.");
require(initialDeadline > block.timestamp, "Initial deadline must be in the future.");
_startDate = initialStartDate;
_deadline = initialDeadline;
}
function setDeadline(uint256 newDeadline) public onlyOwner {
require(_deadline > block.timestamp, "Cannot update deadline if the current deadline is already past.");
require(newDeadline >= _deadline + 1 days, "New deadline must be at least one day ahead of the current deadline.");
_deadline = newDeadline;
}
function onAttest(Attestation calldata /*attestation*/, uint256 /*value*/) internal view override returns (bool) {
return block.timestamp < _deadline;
}
function onRevoke(Attestation calldata /*attestation*/, uint256 /*value*/) internal view override returns (bool) {
return block.timestamp < _deadline;
}
}