@@ -7,6 +7,7 @@ import {ERC1155} from "@solady/tokens/ERC1155.sol";
7
7
import {ModularCore} from "../../ModularCore.sol " ;
8
8
9
9
import {BeforeMintCallbackERC1155} from "../../callback/BeforeMintCallbackERC1155.sol " ;
10
+ import {BeforeBatchMintCallbackERC1155} from "../../callback/BeforeBatchMintCallbackERC1155.sol " ;
10
11
import {BeforeTransferCallbackERC1155} from "../../callback/BeforeTransferCallbackERC1155.sol " ;
11
12
import {BeforeBatchTransferCallbackERC1155} from "../../callback/BeforeBatchTransferCallbackERC1155.sol " ;
12
13
import {BeforeBurnCallbackERC1155} from "../../callback/BeforeBurnCallbackERC1155.sol " ;
@@ -19,13 +20,13 @@ contract ERC1155Core is ERC1155, ModularCore, Multicallable {
19
20
//////////////////////////////////////////////////////////////*/
20
21
21
22
/// @notice The name of the NFT collection.
22
- string private _name ;
23
+ string private name_ ;
23
24
24
25
/// @notice The symbol of the NFT collection.
25
- string private _symbol ;
26
+ string private symbol_ ;
26
27
27
28
/// @notice The contract metadata URI of the contract.
28
- string private _contractURI ;
29
+ string private contractURI_ ;
29
30
30
31
/// @notice The total supply of a tokenId of the NFT collection.
31
32
mapping (uint256 => uint256 ) private _totalSupply;
@@ -42,23 +43,23 @@ contract ERC1155Core is ERC1155, ModularCore, Multicallable {
42
43
//////////////////////////////////////////////////////////////*/
43
44
44
45
constructor (
45
- string memory name ,
46
- string memory symbol ,
47
- string memory contractURI ,
48
- address owner ,
49
- address [] memory extensions ,
50
- bytes [] memory extensionInstallData
46
+ string memory _name ,
47
+ string memory _symbol ,
48
+ string memory _contractURI ,
49
+ address _owner ,
50
+ address [] memory _extensions ,
51
+ bytes [] memory _extensionInstallData
51
52
) payable {
52
53
// Set contract metadata
53
- _name = _name;
54
- _symbol = _symbol;
55
- _setupContractURI (contractURI );
56
- _initializeOwner (owner );
54
+ name_ = _name;
55
+ symbol_ = _symbol;
56
+ _setupContractURI (_contractURI );
57
+ _initializeOwner (_owner );
57
58
58
59
// Install and initialize extensions
59
- require (extensions .length == extensions .length );
60
- for (uint256 i = 0 ; i < extensions .length ; i++ ) {
61
- _installExtension (extensions [i], extensionInstallData [i]);
60
+ require (_extensions .length == _extensionInstallData .length );
61
+ for (uint256 i = 0 ; i < _extensions .length ; i++ ) {
62
+ _installExtension (_extensions [i], _extensionInstallData [i]);
62
63
}
63
64
}
64
65
@@ -68,20 +69,20 @@ contract ERC1155Core is ERC1155, ModularCore, Multicallable {
68
69
69
70
/// @notice Returns the name of the NFT Collection.
70
71
function name () public view returns (string memory ) {
71
- return _name ;
72
+ return name_ ;
72
73
}
73
74
74
75
/// @notice Returns the symbol of the NFT Collection.
75
76
function symbol () public view returns (string memory ) {
76
- return _symbol ;
77
+ return symbol_ ;
77
78
}
78
79
79
80
/**
80
81
* @notice Returns the contract URI of the contract.
81
82
* @return uri The contract URI of the contract.
82
83
*/
83
84
function contractURI () external view returns (string memory ) {
84
- return _contractURI ;
85
+ return contractURI_ ;
85
86
}
86
87
87
88
/**
@@ -110,7 +111,8 @@ contract ERC1155Core is ERC1155, ModularCore, Multicallable {
110
111
return interfaceId == 0x01ffc9a7 // ERC165 Interface ID for ERC165
111
112
|| interfaceId == 0xd9b67a26 // ERC165 Interface ID for ERC1155
112
113
|| interfaceId == 0x0e89341c // ERC165 Interface ID for ERC1155MetadataURI
113
- || interfaceId == 0x2a55205a // ERC165 Interface ID for ERC-2981
114
+ || interfaceId == 0xe8a3d485 // ERC-7572
115
+ || interfaceId == 0x7f5828d0 // ERC-173
114
116
|| super .supportsInterface (interfaceId); // right-most ModularCore
115
117
}
116
118
@@ -120,7 +122,7 @@ contract ERC1155Core is ERC1155, ModularCore, Multicallable {
120
122
override
121
123
returns (SupportedCallbackFunction[] memory supportedCallbackFunctions )
122
124
{
123
- supportedCallbackFunctions = new SupportedCallbackFunction [](6 );
125
+ supportedCallbackFunctions = new SupportedCallbackFunction [](7 );
124
126
supportedCallbackFunctions[0 ] = SupportedCallbackFunction ({
125
127
selector: BeforeMintCallbackERC1155.beforeMintERC1155.selector ,
126
128
mode: CallbackMode.REQUIRED
@@ -143,6 +145,10 @@ contract ERC1155Core is ERC1155, ModularCore, Multicallable {
143
145
});
144
146
supportedCallbackFunctions[5 ] =
145
147
SupportedCallbackFunction ({selector: OnTokenURICallback.onTokenURI.selector , mode: CallbackMode.REQUIRED});
148
+ supportedCallbackFunctions[6 ] = SupportedCallbackFunction ({
149
+ selector: BeforeBatchMintCallbackERC1155.beforeBatchMintERC1155.selector ,
150
+ mode: CallbackMode.REQUIRED
151
+ });
146
152
}
147
153
148
154
/*//////////////////////////////////////////////////////////////
@@ -168,9 +174,30 @@ contract ERC1155Core is ERC1155, ModularCore, Multicallable {
168
174
*/
169
175
function mint (address to , uint256 tokenId , uint256 value , bytes memory data ) external payable {
170
176
_beforeMint (to, tokenId, value, data);
171
- _mint (to, tokenId, value, "" );
172
177
173
178
_totalSupply[tokenId] += value;
179
+ _mint (to, tokenId, value, "" );
180
+ }
181
+
182
+ /**
183
+ * @notice Batch mints tokens. Calls the beforeBatchMint hook.
184
+ * @dev Reverts if beforeBatchMint hook is absent or unsuccessful.
185
+ * @param to The address to mint the token to.
186
+ * @param ids The tokenIds to mint.
187
+ * @param amounts The amounts of tokens to mint.
188
+ * @param data ABI encoded data to pass to the beforeBatchMint hook.
189
+ */
190
+ function batchMint (address to , uint256 [] memory ids , uint256 [] memory amounts , bytes memory data )
191
+ external
192
+ payable
193
+ {
194
+ _beforeBatchMint (to, ids, amounts, data);
195
+
196
+ for (uint256 i = 0 ; i < ids.length ; i++ ) {
197
+ _totalSupply[ids[i]] += amounts[i];
198
+ }
199
+
200
+ _batchMint (to, ids, amounts, "" );
174
201
}
175
202
176
203
/**
@@ -181,11 +208,11 @@ contract ERC1155Core is ERC1155, ModularCore, Multicallable {
181
208
* @param value The amount of tokens to burn.
182
209
* @param data ABI encoded data to pass to the beforeBurn hook.
183
210
*/
184
- function burn (address from , uint256 tokenId , uint256 value , bytes memory data ) external {
211
+ function burn (address from , uint256 tokenId , uint256 value , bytes memory data ) external payable {
185
212
_beforeBurn (from, tokenId, value, data);
186
- _burn (msg .sender , from, tokenId, value);
187
213
188
214
_totalSupply[tokenId] -= value;
215
+ _burn (msg .sender , from, tokenId, value);
189
216
}
190
217
191
218
/**
@@ -239,8 +266,8 @@ contract ERC1155Core is ERC1155, ModularCore, Multicallable {
239
266
//////////////////////////////////////////////////////////////*/
240
267
241
268
/// @dev Sets contract URI
242
- function _setupContractURI (string memory uri ) internal {
243
- _contractURI = uri ;
269
+ function _setupContractURI (string memory _contractURI ) internal {
270
+ contractURI_ = _contractURI ;
244
271
emit ContractURIUpdated ();
245
272
}
246
273
@@ -256,6 +283,17 @@ contract ERC1155Core is ERC1155, ModularCore, Multicallable {
256
283
);
257
284
}
258
285
286
+ /// @dev Calls the beforeBatchMint hook.
287
+ function _beforeBatchMint (address to , uint256 [] memory ids , uint256 [] memory amounts , bytes memory data )
288
+ internal
289
+ virtual
290
+ {
291
+ _executeCallbackFunction (
292
+ BeforeBatchMintCallbackERC1155.beforeBatchMintERC1155.selector ,
293
+ abi.encodeCall (BeforeBatchMintCallbackERC1155.beforeBatchMintERC1155, (to, ids, amounts, data))
294
+ );
295
+ }
296
+
259
297
/// @dev Calls the beforeTransfer hook, if installed.
260
298
function _beforeTransfer (address from , address to , uint256 tokenId , uint256 value ) internal virtual {
261
299
_executeCallbackFunction (
0 commit comments