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

Remove redundant require in ERC721 #3434

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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