Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions contracts/token/ERC1155/ERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ abstract contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI, IER
* - `operator` cannot be the zero address.
*/
function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
if (owner == address(0)) {
revert ERC1155InvalidApprover(address(0));
}
if (operator == address(0)) {
revert ERC1155InvalidOperator(address(0));
}
Expand Down
8 changes: 8 additions & 0 deletions test/token/ERC1155/ERC1155.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ describe('ERC1155', function () {
});
});
});

describe('_setApprovalForAll', function () {
it("reverts when adding an operator over the zero account's tokens", async function () {
await expect(this.token.$_setApprovalForAll(ethers.ZeroAddress, this.operator, true))
.to.be.revertedWithCustomError(this.token, 'ERC1155InvalidApprover')
.withArgs(ethers.ZeroAddress);
});
});
});

describe('ERC1155MetadataURI', function () {
Expand Down