Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Move to != owner check from ERC721.approval to ERC721._approval
  • Loading branch information
Saksham010 committed Apr 7, 2023
commit 98a9412bf54cf11626b332806623e56d6dd3bab8
5 changes: 3 additions & 2 deletions contracts/token/ERC721/ERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down Expand Up @@ -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);
}

/**
Expand Down