-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathImmutableERC721MintByID.sol
More file actions
108 lines (98 loc) · 3.91 KB
/
Copy pathImmutableERC721MintByID.sol
File metadata and controls
108 lines (98 loc) · 3.91 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
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
// Copyright Immutable Pty Ltd 2018 - 2026
// SPDX-License-Identifier: Apache 2.0
pragma solidity >=0.8.19 <=0.8.27;
import {ImmutableERC721Base} from "../abstract/ImmutableERC721Base.sol";
contract ImmutableERC721MintByID is ImmutableERC721Base {
/// ===== 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_
)
ImmutableERC721Base(
owner_, name_, symbol_, baseURI_, contractURI_, operatorAllowlist_, royaltyReceiver_, feeNumerator_
)
{}
/**
* @notice Allows minter to mint `tokenID` to `to`
* @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) {
_totalSupply++;
_safeMint(to, tokenID, "");
}
/**
* @notice Allows minter to safe mint `tokenID` to `to`
* @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) {
_totalSupply++;
_mint(to, tokenID);
}
/**
* @notice Allows minter to safe mint a batch of tokens to a specified list of addresses
* @param mintRequests an array of IDmint requests with the token IDs and address to mint to
*/
function safeMintBatch(IDMint[] calldata mintRequests) external onlyRole(MINTER_ROLE) {
for (uint256 i = 0; i < mintRequests.length; i++) {
_safeBatchMint(mintRequests[i]);
}
}
/**
* @notice Allows minter to mint a batch of tokens to a specified list of addresses
* @param mintRequests an array of IDmint requests with the token IDs and address to mint to
*/
function mintBatch(IDMint[] calldata mintRequests) external onlyRole(MINTER_ROLE) {
for (uint256 i = 0; i < mintRequests.length; i++) {
_batchMint(mintRequests[i]);
}
}
/**
* @notice Allows owner or operator to burn a batch of tokens
* @param tokenIDs an array of token IDs to burn
*/
function burnBatch(uint256[] calldata tokenIDs) external {
for (uint256 i = 0; i < tokenIDs.length; i++) {
burn(tokenIDs[i]);
}
}
/**
* @notice Burn a batch of tokens, checking the owner of each token first.
* @param burns an array of IDBurn requests with the token IDs and address to burn from
*/
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]);
}
}
}