// SPDX-License-Identifier: CC0-1.0
pragmasolidity>=0.8.0<0.9.0;/**
* @title ERC-7858: Expirable NFTs and SBTs
* @notice unique/granular expiry
*/// import "./IERC721.sol";
// The EIP-165 identifier of this interface is `0x3ebdfa31`.
interfaceIERC7858/**is IERC721 */{enumEXPIRY_TYPE{BLOCKS_BASED,// block.number
TIME_BASED// block.timestamp
}/**
* @dev Emitted when the expiration date of a token is set or updated.
* @param tokenId The identifier of the token ERC721 `tokenId`.
* @param startTime The start time of the token (block number or timestamp based on `expiryType`).
* @param endTime The end time of the token (block number or timestamp based on `expiryType`).
*/eventTokenExpiryUpdated(uint256indexedtokenId,uint256indexedstartTime,uint256indexedendTime);/**
* @dev Returns the type of the expiry.
* @return EXPIRY_TYPE Enum value indicating the unit of an expiry.
*/functionexpiryType()externalviewreturns(EXPIRY_TYPE);/**
* @dev Checks whether a specific token is expired.
* @param tokenId The identifier representing the `tokenId` (ERC721).
* @return bool True if the token is expired, false otherwise.
*/functionisTokenExpired(uint256tokenId)externalviewreturns(bool);// return depends on the type `block.timestamp` or `block.number`
// {ERC-5007} return in uint64 MAY not suitable for `block.number` based.
functionstartTime(uint256tokenId)externalviewreturns(uint256);functionendTime(uint256tokenId)externalviewreturns(uint256);}
// SPDX-License-Identifier: CC0-1.0
pragmasolidity>=0.8.0<0.9.0;/**
* @title ERC-7858: Expirable NFTs and SBTs
* @notice epoch expiry extension
*/// import "./IERC7858.sol";
// The EIP-165 identifier of this interface is `0x8f55b98a`.
interfaceIERC7858Epoch/** is IERC7858 */{/**
* @dev Retrieves the current epoch of the contract.
* @return uint256 The current epoch of the token contract,
* often used for determining active/expired states.
*/functioncurrentEpoch()externalviewreturns(uint256);/**
* @dev Retrieves the duration of a single epoch.
* @return uint256 The duration of a single epoch.
* @notice The unit of the epoch length is determined by the `validityPeriodType` function.
*/functionepochLength()externalviewreturns(uint256);/**
* @dev Returns the type of the epoch.
* @return EXPIRY_TYPE Enum value indicating the unit of an epoch.
*/functionepochType()externalviewreturns(EXPIRY_TYPE);/**
* @dev Checks whether a specific `epoch` is expired.
* @param epoch The `epoch` to check.
* @return bool True if the token is expired, false otherwise.
* @notice Implementing contracts "MUST" define and document the logic for determining expiration,
* typically by comparing the latest epoch with the given `epoch` value,
* based on the `EXPIRY_TYPE` measurement (e.g., block count or time duration).
*/functionisEpochExpired(uint256epoch)externalviewreturns(bool);/**
* @dev Retrieves the balance of unexpired tokens owned by an account.
* @param account The address of the account.
* @return uint256 The amount of unexpired tokens owned by an account.
*/functionunexpiredBalanceOf(addressaccount)externalviewreturns(uint256);/**
* @dev Retrieves the balance of a specific `epoch` owned by an account.
* @param epoch The `epoch for which the balance is checked.
* @param account The address of the account.
* @return uint256 The balance of the specified `epoch`.
* @notice "MUST" return 0 if the specified `epoch` is expired.
*/functionunexpiredBalanceOfAtEpoch(uint256epoch,addressaccount)externalviewreturns(uint256);/**
* @dev Retrieves the validity duration of each token.
* @return uint256 The validity duration of each token in `epoch` unit.
*/functionvalidityDuration()externalviewreturns(uint256);}