/**
* @title IERC5501: Rental & Delegation NFT - EIP-721 Extension
* @notice the EIP-165 identifier for this interface is 0xf808ec37.
*/interfaceIERC5501/* is IERC721 */{/**
* @dev Emitted when the user of an NFT is modified.
*/eventUpdateUser(uint256indexed_tokenId,addressindexed_user,uint64_expires,bool_isBorrowed);/**
* @notice Set the user info of an NFT.
* @dev User address cannot be zero address.
* Only approved operator or NFT owner can set the user.
* If NFT is borrowed, the user info cannot be changed until user status expires.
* @param _tokenId uint256 ID of the token to set user info for
* @param _user address of the new user
* @param _expires Unix timestamp when user info expires
* @param _isBorrowed flag whether or not the NFT is borrowed
*/functionsetUser(uint256_tokenId,address_user,uint64_expires,bool_isBorrowed)external;/**
* @notice Get the user address of an NFT.
* @dev Reverts if user is not set.
* @param _tokenId uint256 ID of the token to get the user address for
* @return address user address for this NFT
*/functionuserOf(uint256_tokenId)externalviewreturns(address);/**
* @notice Get the user expires of an NFT.
* @param _tokenId uint256 ID of the token to get the user expires for
* @return uint64 user expires for this NFT
*/functionuserExpires(uint256_tokenId)externalviewreturns(uint64);/**
* @notice Get the user isBorrowed of an NFT.
* @param _tokenId uint256 ID of the token to get the user isBorrowed for
* @return bool user isBorrowed for this NFT
*/functionuserIsBorrowed(uint256_tokenId)externalviewreturns(bool);}
当 user 更改时,必须发出 UpdateUser 事件。
除非 msg.sender 是 owner 或批准的操作员,否则 setUser(uint256 _tokenId, address _user, uint64 _expires, bool _isBorrowed) 函数应 revert。如果代币被借用且状态尚未过期,则必须 revert。它可以是 public 或 external。
如果 user 未设置或已过期,则 userOf(uint256 _tokenId) 函数应 revert。
userExpires(uint256 _tokenId) 函数返回用户状态过期的unix时间戳。
userIsBorrowed(uint256 _tokenId) 函数返回 NFT 是否被借用。
当使用 0xf808ec37 调用时,supportsInterface 函数必须返回 true。
在每次 transfer 时,如果代币未被借用,则必须重置 user。如果代币被借用,则 user 必须保持不变。
余额扩展是可选的。 这提供了查询 user 拥有的代币数量的选项。
/**
* @title IERC5501Balance
* Extension for ERC5501 which adds userBalanceOf to query how many tokens address is userOf.
* @notice the EIP-165 identifier for this interface is 0x0cb22289.
*/interfaceIERC5501Balance/* is IERC5501 */{/**
* @notice Count of all NFTs assigned to a user.
* @dev Reverts if user is zero address.
* @param _user an address for which to query the balance
* @return uint256 the number of NFTs the user has
*/functionuserBalanceOf(address_user)externalviewreturns(uint256);}
对于零地址,userBalanceOf(address _user) 函数应 revert。
可枚举扩展是可选的。 这允许迭代用户余额。
/**
* @title IERC5501Enumerable
* This extension for ERC5501 adds the option to iterate over user tokens.
* @notice the EIP-165 identifier for this interface is 0x1d350ef8.
*/interfaceIERC5501Enumerable/* is IERC5501Balance, IERC5501 */{/**
* @notice Enumerate NFTs assigned to a user.
* @dev Reverts if user is zero address or _index >= userBalanceOf(_owner).
* @param _user an address to iterate over its tokens
* @return uint256 the token ID for given index assigned to _user
*/functiontokenOfUserByIndex(address_user,uint256_index)externalviewreturns(uint256);}
对于零地址,tokenOfUserByIndex(address _user, uint256 _index) 函数应 revert,如果索引大于或等于 user 余额,则应 throw。
可终止扩展是可选的。 如果双方同意,这允许提前终止租金。
/**
* @title IERC5501Terminable
* This extension for ERC5501 adds the option to terminate borrowing if both parties agree.
* @notice the EIP-165 identifier for this interface is 0x6a26417e.
*/interfaceIERC5501Terminable/* is IERC5501 */{/**
* @dev Emitted when one party from borrowing contract approves termination of agreement.
* @param _isLender true for lender, false for borrower
*/eventAgreeToTerminateBorrow(uint256indexed_tokenId,addressindexed_party,bool_isLender);/**
* @dev Emitted when agreements to terminate borrow are reset.
*/eventResetTerminationAgreements(uint256indexed_tokenId);/**
* @dev Emitted when borrow of token ID is terminated.
*/eventTerminateBorrow(uint256indexed_tokenId,addressindexed_lender,addressindexed_borrower,address_caller);/**
* @notice Agree to terminate a borrowing.
* @dev Lender must be ownerOf token ID. Borrower must be userOf token ID.
* If lender and borrower are the same, set termination agreement for both at once.
* @param _tokenId uint256 ID of the token to set termination info for
*/functionsetBorrowTermination(uint256_tokenId)external;/**
* @notice Get if it is possible to terminate a borrow agreement.
* @param _tokenId uint256 ID of the token to get termination info for
* @return bool, bool first indicates lender agrees, second indicates borrower agrees
*/functiongetBorrowTermination(uint256_tokenId)externalviewreturns(bool,bool);/**
* @notice Terminate a borrow if both parties agreed.
* @dev Both parties must have agreed, otherwise revert.
* @param _tokenId uint256 ID of the token to terminate borrow of
*/functionterminateBorrow(uint256_tokenId)external;}