@@ -7,6 +7,7 @@ import {ERC1155} from "@solady/tokens/ERC1155.sol";
77import {ModularCore} from "../../ModularCore.sol " ;
88
99import {BeforeMintCallbackERC1155} from "../../callback/BeforeMintCallbackERC1155.sol " ;
10+ import {BeforeBatchMintCallbackERC1155} from "../../callback/BeforeBatchMintCallbackERC1155.sol " ;
1011import {BeforeTransferCallbackERC1155} from "../../callback/BeforeTransferCallbackERC1155.sol " ;
1112import {BeforeBatchTransferCallbackERC1155} from "../../callback/BeforeBatchTransferCallbackERC1155.sol " ;
1213import {BeforeBurnCallbackERC1155} from "../../callback/BeforeBurnCallbackERC1155.sol " ;
@@ -19,13 +20,13 @@ contract ERC1155Core is ERC1155, ModularCore, Multicallable {
1920 //////////////////////////////////////////////////////////////*/
2021
2122 /// @notice The name of the NFT collection.
22- string private _name ;
23+ string private name_ ;
2324
2425 /// @notice The symbol of the NFT collection.
25- string private _symbol ;
26+ string private symbol_ ;
2627
2728 /// @notice The contract metadata URI of the contract.
28- string private _contractURI ;
29+ string private contractURI_ ;
2930
3031 /// @notice The total supply of a tokenId of the NFT collection.
3132 mapping (uint256 => uint256 ) private _totalSupply;
@@ -42,23 +43,23 @@ contract ERC1155Core is ERC1155, ModularCore, Multicallable {
4243 //////////////////////////////////////////////////////////////*/
4344
4445 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
5152 ) payable {
5253 // 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 );
5758
5859 // 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]);
6263 }
6364 }
6465
@@ -68,20 +69,20 @@ contract ERC1155Core is ERC1155, ModularCore, Multicallable {
6869
6970 /// @notice Returns the name of the NFT Collection.
7071 function name () public view returns (string memory ) {
71- return _name ;
72+ return name_ ;
7273 }
7374
7475 /// @notice Returns the symbol of the NFT Collection.
7576 function symbol () public view returns (string memory ) {
76- return _symbol ;
77+ return symbol_ ;
7778 }
7879
7980 /**
8081 * @notice Returns the contract URI of the contract.
8182 * @return uri The contract URI of the contract.
8283 */
8384 function contractURI () external view returns (string memory ) {
84- return _contractURI ;
85+ return contractURI_ ;
8586 }
8687
8788 /**
@@ -110,7 +111,8 @@ contract ERC1155Core is ERC1155, ModularCore, Multicallable {
110111 return interfaceId == 0x01ffc9a7 // ERC165 Interface ID for ERC165
111112 || interfaceId == 0xd9b67a26 // ERC165 Interface ID for ERC1155
112113 || 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
114116 || super .supportsInterface (interfaceId); // right-most ModularCore
115117 }
116118
@@ -120,7 +122,7 @@ contract ERC1155Core is ERC1155, ModularCore, Multicallable {
120122 override
121123 returns (SupportedCallbackFunction[] memory supportedCallbackFunctions )
122124 {
123- supportedCallbackFunctions = new SupportedCallbackFunction [](6 );
125+ supportedCallbackFunctions = new SupportedCallbackFunction [](7 );
124126 supportedCallbackFunctions[0 ] = SupportedCallbackFunction ({
125127 selector: BeforeMintCallbackERC1155.beforeMintERC1155.selector ,
126128 mode: CallbackMode.REQUIRED
@@ -143,6 +145,10 @@ contract ERC1155Core is ERC1155, ModularCore, Multicallable {
143145 });
144146 supportedCallbackFunctions[5 ] =
145147 SupportedCallbackFunction ({selector: OnTokenURICallback.onTokenURI.selector , mode: CallbackMode.REQUIRED});
148+ supportedCallbackFunctions[6 ] = SupportedCallbackFunction ({
149+ selector: BeforeBatchMintCallbackERC1155.beforeBatchMintERC1155.selector ,
150+ mode: CallbackMode.REQUIRED
151+ });
146152 }
147153
148154 /*//////////////////////////////////////////////////////////////
@@ -168,9 +174,30 @@ contract ERC1155Core is ERC1155, ModularCore, Multicallable {
168174 */
169175 function mint (address to , uint256 tokenId , uint256 value , bytes memory data ) external payable {
170176 _beforeMint (to, tokenId, value, data);
171- _mint (to, tokenId, value, "" );
172177
173178 _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, "" );
174201 }
175202
176203 /**
@@ -181,11 +208,11 @@ contract ERC1155Core is ERC1155, ModularCore, Multicallable {
181208 * @param value The amount of tokens to burn.
182209 * @param data ABI encoded data to pass to the beforeBurn hook.
183210 */
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 {
185212 _beforeBurn (from, tokenId, value, data);
186- _burn (msg .sender , from, tokenId, value);
187213
188214 _totalSupply[tokenId] -= value;
215+ _burn (msg .sender , from, tokenId, value);
189216 }
190217
191218 /**
@@ -239,8 +266,8 @@ contract ERC1155Core is ERC1155, ModularCore, Multicallable {
239266 //////////////////////////////////////////////////////////////*/
240267
241268 /// @dev Sets contract URI
242- function _setupContractURI (string memory uri ) internal {
243- _contractURI = uri ;
269+ function _setupContractURI (string memory _contractURI ) internal {
270+ contractURI_ = _contractURI ;
244271 emit ContractURIUpdated ();
245272 }
246273
@@ -256,6 +283,17 @@ contract ERC1155Core is ERC1155, ModularCore, Multicallable {
256283 );
257284 }
258285
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+
259297 /// @dev Calls the beforeTransfer hook, if installed.
260298 function _beforeTransfer (address from , address to , uint256 tokenId , uint256 value ) internal virtual {
261299 _executeCallbackFunction (
0 commit comments