Remove redundant require in ERC721 (#3434)

Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
pull/3444/head
rotcivegaf 3 years ago committed by GitHub
parent 488dd562fb
commit 82a63f6389
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 1
      contracts/token/ERC721/ERC721.sol
  3. 4
      test/token/ERC721/ERC721.behavior.js
  4. 2
      test/token/ERC721/extensions/ERC721Burnable.test.js

@ -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)

@ -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);
}

@ -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',
);
});
});
@ -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',
);
});
});

@ -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',
);
});
});

Loading…
Cancel
Save