forked from ProjectOpenSea/operator-filter-registry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExampleERC721.sol
40 lines (34 loc) · 1.8 KB
/
ExampleERC721.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import {ERC721} from "openzeppelin-contracts/token/ERC721/ERC721.sol";
import {DefaultOperatorFilterer} from "../DefaultOperatorFilterer.sol";
import {Ownable} from "openzeppelin-contracts/access/Ownable.sol";
/**
* @title ExampleERC721
* @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 transferFrom and both safeTransferFrom methods ensures that
* the msg.sender (operator) is allowed by the OperatorFilterRegistry. Adding the onlyAllowedOperatorApproval
* modifier to the approval methods ensures that owners do not approve operators that are not allowed.
*/
abstract contract ExampleERC721 is ERC721("Example", "EXAMPLE"), DefaultOperatorFilterer, Ownable {
function setApprovalForAll(address operator, bool approved) public override onlyAllowedOperatorApproval(operator) {
super.setApprovalForAll(operator, approved);
}
function approve(address operator, uint256 tokenId) public override onlyAllowedOperatorApproval(operator) {
super.approve(operator, tokenId);
}
function transferFrom(address from, address to, uint256 tokenId) public override onlyAllowedOperator(from) {
super.transferFrom(from, to, tokenId);
}
function safeTransferFrom(address from, address to, uint256 tokenId) public override onlyAllowedOperator(from) {
super.safeTransferFrom(from, to, tokenId);
}
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data)
public
override
onlyAllowedOperator(from)
{
super.safeTransferFrom(from, to, tokenId, data);
}
}