|
| 1 | +// SPDX-License-Identifier: MIT |
| 2 | +pragma solidity ^0.8.13; |
| 3 | + |
| 4 | +import {ERC721Upgradeable} from "openzeppelin-contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; |
| 5 | +import {DefaultOperatorFilterer721Upgradeable} from "./DefaultOperatorFilterer721Upgradeable.sol"; |
| 6 | +import {OwnableUpgradeable} from "openzeppelin-contracts-upgradeable/access/OwnableUpgradeable.sol"; |
| 7 | + |
| 8 | +/** |
| 9 | + * @title ExampleERC721Upgradeable |
| 10 | + * @notice This example contract is configured to use the DefaultOperatorFilterer, which automatically registers the |
| 11 | + * token and subscribes it to OpenSea's curated filters. |
| 12 | + * Adding the onlyAllowedOperator modifier to the transferFrom and both safeTransferFrom methods ensures that |
| 13 | + * the msg.sender (operator) is allowed by the OperatorFilterRegistry. |
| 14 | + */ |
| 15 | +abstract contract ExampleERC721Upgradeable is |
| 16 | + ERC721Upgradeable, |
| 17 | + DefaultOperatorFilterer721Upgradeable, |
| 18 | + OwnableUpgradeable |
| 19 | +{ |
| 20 | + function initialize() public initializer { |
| 21 | + __ERC721_init("Example", "EXAMPLE"); |
| 22 | + __Ownable_init(); |
| 23 | + __DefaultOperatorFilterer721_init(); |
| 24 | + } |
| 25 | + |
| 26 | + function transferFrom(address from, address to, uint256 tokenId) public override onlyAllowedOperator(from) { |
| 27 | + super.transferFrom(from, to, tokenId); |
| 28 | + } |
| 29 | + |
| 30 | + function safeTransferFrom(address from, address to, uint256 tokenId) public override onlyAllowedOperator(from) { |
| 31 | + super.safeTransferFrom(from, to, tokenId); |
| 32 | + } |
| 33 | + |
| 34 | + function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) |
| 35 | + public |
| 36 | + override |
| 37 | + onlyAllowedOperator(from) |
| 38 | + { |
| 39 | + super.safeTransferFrom(from, to, tokenId, data); |
| 40 | + } |
| 41 | + |
| 42 | + function tokenURI(uint256) public pure override returns (string memory) { |
| 43 | + return ""; |
| 44 | + } |
| 45 | +} |
0 commit comments