Unverified Commit ecf0725d by GuiCz Committed by GitHub

Documentation/erc721 contracts (#2218)

* Adds / Updates documentation of ERC721 contract

* Improve ERC721Burnable documentation

* Fix typo

* Revert changes on ERC721 private functions

* Add documentation to the ERC721 contract's constructor

* Add IERC721Receiver & ERC721Holder documentations

* Add references to IERC721 functions

* Add references to IERC721Metadata/Receiver

* PR fixes

* Fixes to ERC721 documentation

* Add missing fixes

Co-authored-by: Nicolás Venturo <nicolas.venturo@gmail.com>
parent d3ef93a9
...@@ -11,8 +11,11 @@ import "./ERC721.sol"; ...@@ -11,8 +11,11 @@ import "./ERC721.sol";
*/ */
abstract contract ERC721Burnable is Context, ERC721 { abstract contract ERC721Burnable is Context, ERC721 {
/** /**
* @dev Burns a specific ERC721 token. * @dev Burns `tokenId`. See {ERC721-_burn}.
* @param tokenId uint256 id of the ERC721 token to be burned. *
* Requirements:
*
* - The caller must own `tokenId` or be an approved operator.
*/ */
function burn(uint256 tokenId) public virtual { function burn(uint256 tokenId) public virtual {
//solhint-disable-next-line max-line-length //solhint-disable-next-line max-line-length
......
...@@ -4,7 +4,19 @@ pragma solidity ^0.6.0; ...@@ -4,7 +4,19 @@ pragma solidity ^0.6.0;
import "./IERC721Receiver.sol"; import "./IERC721Receiver.sol";
/**
* @dev Implementation of the {IERC721Receiver} interface.
*
* Accepts all token transfers.
* Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.
*/
contract ERC721Holder is IERC721Receiver { contract ERC721Holder is IERC721Receiver {
/**
* @dev See {IERC721Receiver-onERC721Received}.
*
* Always returns `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) { function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) {
return this.onERC721Received.selector; return this.onERC721Received.selector;
} }
......
...@@ -43,7 +43,8 @@ interface IERC721 is IERC165 { ...@@ -43,7 +43,8 @@ interface IERC721 is IERC165 {
* *
* Requirements: * Requirements:
* *
* - `from`, `to` cannot be zero. * - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`. * - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
...@@ -59,7 +60,8 @@ interface IERC721 is IERC165 { ...@@ -59,7 +60,8 @@ interface IERC721 is IERC165 {
* *
* Requirements: * Requirements:
* *
* - `from`, `to` cannot be zero. * - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`. * - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* *
...@@ -115,7 +117,8 @@ interface IERC721 is IERC165 { ...@@ -115,7 +117,8 @@ interface IERC721 is IERC165 {
* *
* Requirements: * Requirements:
* *
* - `from`, `to` cannot be zero. * - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`. * - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
......
...@@ -9,18 +9,13 @@ pragma solidity ^0.6.0; ...@@ -9,18 +9,13 @@ pragma solidity ^0.6.0;
*/ */
interface IERC721Receiver { interface IERC721Receiver {
/** /**
* @notice Handle the receipt of an NFT * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* @dev The ERC721 smart contract calls this function on the recipient * by `operator` from `from`, this function is called.
* after a {IERC721-safeTransferFrom}. This function MUST return the function selector, *
* otherwise the caller will revert the transaction. The selector to be * It must return its Solidity selector to confirm the token transfer.
* returned can be obtained as `this.onERC721Received.selector`. This * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
* function MAY throw to revert and reject the transfer. *
* Note: the ERC721 contract address is always the message sender. * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
* @param operator The address which called `safeTransferFrom` function
* @param from The address which previously owned the token
* @param tokenId The NFT identifier which is being transferred
* @param data Additional data with no specified format
* @return bytes4 `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
*/ */
function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data)
external returns (bytes4); external returns (bytes4);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment