forked from Vectorized/closedsea
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExampleERC1155.sol
47 lines (42 loc) · 1.56 KB
/
ExampleERC1155.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
41
42
43
44
45
46
47
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import {ERC1155} from "openzeppelin-contracts/token/ERC1155/ERC1155.sol";
import {OperatorFilterer} from "../OperatorFilterer.sol";
import {Ownable} from "openzeppelin-contracts/access/Ownable.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 transferFrom and both safeTransferFrom methods ensures that
* the msg.sender (operator) is allowed by the OperatorFilterRegistry.
*/
abstract contract ExampleERC1155 is ERC1155, OperatorFilterer, Ownable {
constructor() ERC1155("") {
_registerForOperatorFiltering();
}
function setApprovalForAll(address operator, bool approved)
public
override
onlyAllowedOperatorApproval(operator)
{
super.setApprovalForAll(operator, approved);
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
uint256 amount,
bytes memory data
) public override onlyAllowedOperator(from) {
super.safeTransferFrom(from, to, tokenId, amount, data);
}
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);
}
}