diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index 428338d900c..9d0034f2669 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -111,7 +111,6 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); - require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), @@ -364,8 +363,10 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { + address owner = ERC721.ownerOf(tokenId); + require(to != owner, "ERC721: approval to current owner"); _tokenApprovals[tokenId] = to; - emit Approval(ERC721.ownerOf(tokenId), to, tokenId); + emit Approval(owner, to, tokenId); } /**