From 1caf48a21a0d29d3fb851bd099c6d493e2ac5348 Mon Sep 17 00:00:00 2001 From: kanedaaaa Date: Wed, 9 Mar 2022 18:14:32 +0100 Subject: [PATCH] fix: make error messages more consistent --- contracts/token/ERC1155/ERC1155.sol | 2 +- contracts/token/ERC1155/extensions/ERC1155Burnable.sol | 4 ++-- contracts/token/ERC721/ERC721.sol | 2 +- contracts/token/ERC721/extensions/ERC721Burnable.sol | 2 +- test/token/ERC1155/ERC1155.behavior.js | 2 +- test/token/ERC1155/extensions/ERC1155Burnable.test.js | 4 ++-- test/token/ERC721/ERC721.behavior.js | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/contracts/token/ERC1155/ERC1155.sol b/contracts/token/ERC1155/ERC1155.sol index 5e32982f6e4..1f99cb4eec3 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: caller is not token owner nor approved" ); _safeTransferFrom(from, to, id, amount, 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 a62559b681d..97c8ce2f64f 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); 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 8230d5f67b6..2bc58ab6857 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: 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 11faca42b9b..a21398cfbcb 100644 --- a/test/token/ERC721/ERC721.behavior.js +++ b/test/token/ERC721/ERC721.behavior.js @@ -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'); }); });