Skip to content

Commit

Permalink
Remove redundant require in ERC721 (#3434)
Browse files Browse the repository at this point in the history
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
  • Loading branch information
rotcivegaf and frangio committed May 27, 2022
1 parent 488dd56 commit 82a63f6
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -12,6 +12,7 @@
* `SafeCast`: add support for many more types, using procedural code generation. ([#3245](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3245))
* `MerkleProof`: add `multiProofVerify` to prove multiple values are part of a Merkle tree. ([#3276](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3276))
* `ERC721`, `ERC1155`: simplified revert reasons. ([#3254](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3254))
* `ERC721`: removed redundant require statement. ([#3434](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3434))

## 4.6.0 (2022-04-26)

Expand Down
1 change: 0 additions & 1 deletion contracts/token/ERC721/ERC721.sol
Expand Up @@ -230,7 +230,6 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);
}
Expand Down
4 changes: 2 additions & 2 deletions test/token/ERC721/ERC721.behavior.js
Expand Up @@ -201,7 +201,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
it('reverts', async function () {
await expectRevert(
transferFunction.call(this, owner, other, nonExistentTokenId, { from: owner }),
'ERC721: operator query for nonexistent token',
'ERC721: owner query for nonexistent token',
);
});
});
Expand Down Expand Up @@ -276,7 +276,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
nonExistentTokenId,
{ from: owner },
),
'ERC721: operator query for nonexistent token',
'ERC721: owner query for nonexistent token',
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/token/ERC721/extensions/ERC721Burnable.test.js
Expand Up @@ -69,7 +69,7 @@ contract('ERC721Burnable', function (accounts) {
describe('when the given token ID was not tracked by this contract', function () {
it('reverts', async function () {
await expectRevert(
this.token.burn(unknownTokenId, { from: owner }), 'ERC721: operator query for nonexistent token',
this.token.burn(unknownTokenId, { from: owner }), 'ERC721: owner query for nonexistent token',
);
});
});
Expand Down

0 comments on commit 82a63f6

Please sign in to comment.