Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved 'to != owner' from ERC721.approval to ERC721._approval #4159

Closed
wants to merge 5 commits into from
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
7 changes: 4 additions & 3 deletions contracts/token/ERC721/ERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ 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()),
"ERC721: approve caller is not token owner or approved for all"
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