forked from immutable/contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImmutableERC721.sol
137 lines (123 loc) · 5.14 KB
/
ImmutableERC721.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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// Copyright Immutable Pty Ltd 2018 - 2023
// SPDX-License-Identifier: Apache 2.0
pragma solidity 0.8.19;
import {ImmutableERC721HybridBase} from "../abstract/ImmutableERC721HybridBase.sol";
contract ImmutableERC721 is ImmutableERC721HybridBase {
/// ===== Constructor =====
/**
* @notice Grants `DEFAULT_ADMIN_ROLE` to the supplied `owner` address
* @param owner_ The address to grant the `DEFAULT_ADMIN_ROLE` to
* @param name_ The name of the collection
* @param symbol_ The symbol of the collection
* @param baseURI_ The base URI for the collection
* @param contractURI_ The contract URI for the collection
* @param operatorAllowlist_ The address of the operator allowlist
* @param royaltyReceiver_ The address of the royalty receiver
* @param feeNumerator_ The royalty fee numerator
* @dev the royalty receiver and amount (this can not be changed once set)
*/
constructor(
address owner_,
string memory name_,
string memory symbol_,
string memory baseURI_,
string memory contractURI_,
address operatorAllowlist_,
address royaltyReceiver_,
uint96 feeNumerator_
)
ImmutableERC721HybridBase(
owner_,
name_,
symbol_,
baseURI_,
contractURI_,
operatorAllowlist_,
royaltyReceiver_,
feeNumerator_
)
{}
/**
* @notice Allows minter to mint a token by ID to a specified address
* @param to the address to mint the token to
* @param tokenId the ID of the token to mint
*/
function mint(address to, uint256 tokenId) external onlyRole(MINTER_ROLE) {
_mintByID(to, tokenId);
}
/**
* @notice Allows minter to mint a token by ID to a specified address with hooks and checks
* @param to the address to mint the token to
* @param tokenId the ID of the token to mint
*/
function safeMint(address to, uint256 tokenId) external onlyRole(MINTER_ROLE) {
_safeMintByID(to, tokenId);
}
/**
* @notice Allows minter to mint a number of tokens sequentially to a specified address
* @param to the address to mint the token to
* @param quantity the number of tokens to mint
*/
function mintByQuantity(address to, uint256 quantity) external onlyRole(MINTER_ROLE) {
_mintByQuantity(to, quantity);
}
/**
* @notice Allows minter to mint a number of tokens sequentially to a specified address with hooks
* and checks
* @param to the address to mint the token to
* @param quantity the number of tokens to mint
*/
function safeMintByQuantity(address to, uint256 quantity) external onlyRole(MINTER_ROLE) {
_safeMintByQuantity(to, quantity);
}
/**
* @notice Allows minter to mint a number of tokens sequentially to a number of specified addresses
* @param mints the list of Mint struct containing the to, and the number of tokens to mint
*/
function mintBatchByQuantity(Mint[] calldata mints) external onlyRole(MINTER_ROLE) {
_mintBatchByQuantity(mints);
}
/**
* @notice Allows minter to safe mint a number of tokens sequentially to a number of specified addresses
* @param mints the list of Mint struct containing the to, and the number of tokens to mint
*/
function safeMintBatchByQuantity(Mint[] calldata mints) external onlyRole(MINTER_ROLE) {
_safeMintBatchByQuantity(mints);
}
/**
* @notice Allows minter to safe mint a number of tokens by ID to a number of specified
* addresses with hooks and checks. Check ERC721Hybrid for details on _mintBatchByIDToMultiple
* @param mints the list of IDMint struct containing the to, and tokenIds
*/
function mintBatch(IDMint[] calldata mints) external onlyRole(MINTER_ROLE) {
_mintBatchByIDToMultiple(mints);
}
/**
* @notice Allows minter to safe mint a number of tokens by ID to a number of specified
* addresses with hooks and checks. Check ERC721Hybrid for details on _safeMintBatchByIDToMultiple
* @param mints the list of IDMint struct containing the to, and tokenIds
*/
function safeMintBatch(IDMint[] calldata mints) external onlyRole(MINTER_ROLE) {
_safeMintBatchByIDToMultiple(mints);
}
/**
* @notice Allows caller to a burn a number of tokens by ID from a specified address
* @param burns the IDBurn struct containing the to, and tokenIds
*/
function safeBurnBatch(IDBurn[] calldata burns) external {
_safeBurnBatch(burns);
}
/**
* @notice Allows caller to a transfer a number of tokens by ID from a specified
* address to a number of specified addresses
* @param tr the TransferRequest struct containing the from, tos, and tokenIds
*/
function safeTransferFromBatch(TransferRequest calldata tr) external {
if (tr.tokenIds.length != tr.tos.length) {
revert IImmutableERC721MismatchedTransferLengths();
}
for (uint256 i = 0; i < tr.tokenIds.length; i++) {
safeTransferFrom(tr.from, tr.tos[i], tr.tokenIds[i]);
}
}
}