From 8c17646beb97ccaae0c42cad5bc15dd1fb55c182 Mon Sep 17 00:00:00 2001 From: Marcel Cutts Date: Wed, 19 Jan 2022 11:55:02 +0000 Subject: [PATCH] Update all token transfer ownership requirement messages to include 'token', distinguishing from contract ownership #3120 --- contracts/token/ERC1155/ERC1155.sol | 4 ++-- contracts/token/ERC1155/extensions/ERC1155Burnable.sol | 4 ++-- contracts/token/ERC721/ERC721.sol | 6 +++--- contracts/token/ERC721/extensions/ERC721Burnable.sol | 2 +- test/token/ERC1155/ERC1155.behavior.js | 4 ++-- test/token/ERC1155/extensions/ERC1155Burnable.test.js | 4 ++-- test/token/ERC721/ERC721.behavior.js | 6 +++--- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index ffdd8cd788d..34a2f5d89d7 100644 --- a/contracts/token/ERC1155/ERC1155.sol +++ b/contracts/token/ERC1155/ERC1155.sol @@ -123,7 +123,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), - "ERC1155: caller is not owner nor approved" + "ERC1155: transfer caller is not token owner nor approved" ); _safeTransferFrom(from, to, id, amount, data); } @@ -140,7 +140,7 @@ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), - "ERC1155: transfer caller is not owner nor approved" + "ERC1155: transfer caller is not token owner nor approved" ); _safeBatchTransferFrom(from, to, ids, amounts, data); } diff --git a/contracts/token/ERC1155/extensions/ERC1155Burnable.sol b/contracts/token/ERC1155/extensions/ERC1155Burnable.sol index 4a7c86e1b20..72a8faaee53 100644 --- a/contracts/token/ERC1155/extensions/ERC1155Burnable.sol +++ b/contracts/token/ERC1155/extensions/ERC1155Burnable.sol @@ -19,7 +19,7 @@ abstract contract ERC1155Burnable is ERC1155 { ) public virtual { require( account == _msgSender() || isApprovedForAll(account, _msgSender()), - "ERC1155: caller is not owner nor approved" + "ERC1155: caller is not token owner nor approved" ); _burn(account, id, value); @@ -32,7 +32,7 @@ abstract contract ERC1155Burnable is ERC1155 { ) public virtual { require( account == _msgSender() || isApprovedForAll(account, _msgSender()), - "ERC1155: caller is not owner nor approved" + "ERC1155: caller is not token owner nor approved" ); _burnBatch(account, ids, values); diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index 7b26343ac66..185967e8b6d 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -115,7 +115,7 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), - "ERC721: approve caller is not owner nor approved for all" + "ERC721: approve caller is not token owner nor approved for all" ); _approve(to, tokenId); @@ -153,7 +153,7 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length - require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); + require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not token owner nor approved"); _transfer(from, to, tokenId); } @@ -178,7 +178,7 @@ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { uint256 tokenId, bytes memory _data ) public virtual override { - require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); + require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not token owner nor approved"); _safeTransfer(from, to, tokenId, _data); } diff --git a/contracts/token/ERC721/extensions/ERC721Burnable.sol b/contracts/token/ERC721/extensions/ERC721Burnable.sol index 063997ddf08..e785cab5317 100644 --- a/contracts/token/ERC721/extensions/ERC721Burnable.sol +++ b/contracts/token/ERC721/extensions/ERC721Burnable.sol @@ -20,7 +20,7 @@ abstract contract ERC721Burnable is Context, ERC721 { */ function burn(uint256 tokenId) public virtual { //solhint-disable-next-line max-line-length - require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved"); + require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not token owner nor approved"); _burn(tokenId); } } diff --git a/test/token/ERC1155/ERC1155.behavior.js b/test/token/ERC1155/ERC1155.behavior.js index 13b08ac638c..e64ddc6f78e 100644 --- a/test/token/ERC1155/ERC1155.behavior.js +++ b/test/token/ERC1155/ERC1155.behavior.js @@ -293,7 +293,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, this.token.safeTransferFrom(multiTokenHolder, recipient, firstTokenId, firstAmount, '0x', { from: proxy, }), - 'ERC1155: caller is not owner nor approved', + 'ERC1155: transfer caller is not token owner nor approved', ); }); }); @@ -569,7 +569,7 @@ function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, [firstAmount, secondAmount], '0x', { from: proxy }, ), - 'ERC1155: transfer caller is not owner nor approved', + 'ERC1155: transfer caller is not token owner nor approved', ); }); }); diff --git a/test/token/ERC1155/extensions/ERC1155Burnable.test.js b/test/token/ERC1155/extensions/ERC1155Burnable.test.js index b17f8d07391..caa4d1648ab 100644 --- a/test/token/ERC1155/extensions/ERC1155Burnable.test.js +++ b/test/token/ERC1155/extensions/ERC1155Burnable.test.js @@ -36,7 +36,7 @@ contract('ERC1155Burnable', function (accounts) { it('unapproved accounts cannot burn the holder\'s tokens', async function () { await expectRevert( this.token.burn(holder, tokenIds[0], amounts[0].subn(1), { from: other }), - 'ERC1155: caller is not owner nor approved', + 'ERC1155: caller is not token owner nor approved', ); }); }); @@ -60,7 +60,7 @@ contract('ERC1155Burnable', function (accounts) { it('unapproved accounts cannot burn the holder\'s tokens', async function () { await expectRevert( this.token.burnBatch(holder, tokenIds, [ amounts[0].subn(1), amounts[1].subn(2) ], { from: other }), - 'ERC1155: caller is not owner nor approved', + 'ERC1155: caller is not token owner nor approved', ); }); }); diff --git a/test/token/ERC721/ERC721.behavior.js b/test/token/ERC721/ERC721.behavior.js index 67fa98a473c..40adb1d5f2a 100644 --- a/test/token/ERC721/ERC721.behavior.js +++ b/test/token/ERC721/ERC721.behavior.js @@ -192,7 +192,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another it('reverts', async function () { await expectRevert( transferFunction.call(this, owner, other, tokenId, { from: other }), - 'ERC721: transfer caller is not owner nor approved', + 'ERC721: transfer caller is not token owner nor approved', ); }); }); @@ -509,7 +509,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another context('when the sender does not own the given token ID', function () { it('reverts', async function () { await expectRevert(this.token.approve(approved, tokenId, { from: other }), - 'ERC721: approve caller is not owner nor approved'); + 'ERC721: approve caller is not token owner nor approved'); }); }); @@ -517,7 +517,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another it('reverts', async function () { await this.token.approve(approved, tokenId, { from: owner }); await expectRevert(this.token.approve(anotherApproved, tokenId, { from: approved }), - 'ERC721: approve caller is not owner nor approved for all'); + 'ERC721: approve caller is not token owner nor approved for all'); }); });