// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; import {ERC1155} from "openzeppelin-contracts/token/ERC1155/ERC1155.sol"; import {ERC2981} from "openzeppelin-contracts/token/common/ERC2981.sol"; import {Ownable} from "openzeppelin-contracts/access/Ownable.sol"; import {DefaultOperatorFilterer} from "../DefaultOperatorFilterer.sol"; /** * @title ExampleERC1155 * @notice This example contract is configured to use the DefaultOperatorFilterer, which automatically registers the * token and subscribes it to OpenSea's curated filters. * Adding the onlyAllowedOperator modifier to the safeTransferFrom methods ensures that * the msg.sender (operator) is allowed by the OperatorFilterRegistry. Adding the onlyAllowedOperatorApproval * modifier to the setApprovalForAll method ensures that owners do not approve operators that are not allowed. */ abstract contract ExampleERC1155 is ERC1155(""), ERC2981, DefaultOperatorFilterer, Ownable { /** * @dev See {IERC1155-setApprovalForAll}. * In this example the added modifier ensures that the operator is allowed by the OperatorFilterRegistry. */ function setApprovalForAll(address operator, bool approved) public override onlyAllowedOperatorApproval(operator) { super.setApprovalForAll(operator, approved); } /** * @dev See {IERC1155-safeTransferFrom}. * In this example the added modifier ensures that the operator is allowed by the OperatorFilterRegistry. */ function safeTransferFrom(address from, address to, uint256 tokenId, uint256 amount, bytes memory data) public override onlyAllowedOperator(from) { super.safeTransferFrom(from, to, tokenId, amount, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. * In this example the added modifier ensures that the operator is allowed by the OperatorFilterRegistry. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public virtual override onlyAllowedOperator(from) { super.safeBatchTransferFrom(from, to, ids, amounts, data); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC1155, ERC2981) returns (bool) { return ERC1155.supportsInterface(interfaceId) || ERC2981.supportsInterface(interfaceId); } }