forked from Vectorized/closedsea
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleERC721.sol
More file actions
78 lines (66 loc) · 2.34 KB
/
ExampleERC721.sol
File metadata and controls
78 lines (66 loc) · 2.34 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import {ERC721} from "openzeppelin-contracts/token/ERC721/ERC721.sol";
import {OperatorFilterer} from "../OperatorFilterer.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.
*/
abstract contract ExampleERC721 is ERC721, OperatorFilterer, Ownable {
bool public operatorFilteringEnabled;
constructor() ERC721("Example", "EXAMPLE") {
_registerForOperatorFiltering();
operatorFilteringEnabled = true;
}
function repeatRegistration() public {
_registerForOperatorFiltering();
}
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);
}
function tokenURI(uint256) public pure override returns (string memory) {
return "";
}
function setOperatorFilteringEnabled(bool value) public onlyOwner {
operatorFilteringEnabled = value;
}
function _operatorFilteringEnabled() internal view virtual override returns (bool) {
return operatorFilteringEnabled;
}
}