11// SPDX-License-Identifier: Apache-2.0
22pragma solidity ^ 0.8.0 ;
33
4- import "./ERC1155SignatureMint.sol " ;
5-
4+ import { ERC1155 } from "../eip/ERC1155.sol " ;
5+
6+ import "../extension/ContractMetadata.sol " ;
7+ import "../extension/Multicall.sol " ;
8+ import "../extension/Ownable.sol " ;
9+ import "../extension/Royalty.sol " ;
10+ import "../extension/BatchMintMetadata.sol " ;
11+ import "../extension/PrimarySale.sol " ;
12+ import "../extension/SignatureMintERC1155.sol " ;
613import "../extension/DropSinglePhase1155.sol " ;
714import "../extension/LazyMint.sol " ;
815import "../extension/DelayedReveal.sol " ;
916
17+ import "../lib/CurrencyTransferLib.sol " ;
18+ import "../lib/TWStrings.sol " ;
19+
1020/**
1121 * BASE: ERC1155Base
1222 * EXTENSION: SignatureMintERC1155, DropSinglePhase1155
@@ -24,9 +34,31 @@ import "../extension/DelayedReveal.sol";
2434 * via the drop mechanism.
2535 */
2636
27- contract ERC1155Drop is ERC1155SignatureMint , LazyMint , DelayedReveal , DropSinglePhase1155 {
37+ contract ERC1155Drop is
38+ ERC1155 ,
39+ ContractMetadata ,
40+ Ownable ,
41+ Royalty ,
42+ Multicall ,
43+ BatchMintMetadata ,
44+ PrimarySale ,
45+ SignatureMintERC1155 ,
46+ LazyMint ,
47+ DelayedReveal ,
48+ DropSinglePhase1155
49+ {
2850 using TWStrings for uint256 ;
2951
52+ /*//////////////////////////////////////////////////////////////
53+ Mappings
54+ //////////////////////////////////////////////////////////////*/
55+
56+ /**
57+ * @notice Returns the total supply of NFTs of a given tokenId
58+ * @dev Mapping from tokenId => total circulating supply of NFTs of that tokenId.
59+ */
60+ mapping (uint256 => uint256 ) public totalSupply;
61+
3062 /*///////////////////////////////////////////////////////////////
3163 Constructor
3264 //////////////////////////////////////////////////////////////*/
@@ -37,7 +69,11 @@ contract ERC1155Drop is ERC1155SignatureMint, LazyMint, DelayedReveal, DropSingl
3769 address _royaltyRecipient ,
3870 uint128 _royaltyBps ,
3971 address _primarySaleRecipient
40- ) ERC1155SignatureMint (_name, _symbol, _royaltyRecipient, _royaltyBps, _primarySaleRecipient) {}
72+ ) ERC1155 (_name, _symbol) {
73+ _setupOwner (msg .sender );
74+ _setupDefaultRoyaltyInfo (_royaltyRecipient, _royaltyBps);
75+ _setupPrimarySaleRecipient (_primarySaleRecipient);
76+ }
4177
4278 /*///////////////////////////////////////////////////////////////
4379 Overriden metadata logic
@@ -95,7 +131,12 @@ contract ERC1155Drop is ERC1155SignatureMint, LazyMint, DelayedReveal, DropSingl
95131 address receiver = _req.to == address (0 ) ? msg .sender : _req.to;
96132
97133 // Collect price
98- collectPriceOnClaim (primarySaleRecipient (), _req.quantity, _req.currency, _req.pricePerToken);
134+ collectPriceOnClaim (_req.primarySaleRecipient, _req.quantity, _req.currency, _req.pricePerToken);
135+
136+ // Set royalties, if applicable.
137+ if (_req.royaltyRecipient != address (0 ) && _req.royaltyBps != 0 ) {
138+ _setupRoyaltyInfoForToken (tokenIdToMint, _req.royaltyRecipient, _req.royaltyBps);
139+ }
99140
100141 // Mint tokens.
101142 _mint (receiver, tokenIdToMint, _req.quantity, "" );
@@ -154,10 +195,23 @@ contract ERC1155Drop is ERC1155SignatureMint, LazyMint, DelayedReveal, DropSingl
154195 }
155196
156197 /// @notice The tokenId assigned to the next new NFT to be lazy minted.
157- function nextTokenIdToMint () public view virtual override returns (uint256 ) {
198+ function nextTokenIdToMint () public view virtual returns (uint256 ) {
158199 return nextTokenIdToLazyMint;
159200 }
160201
202+ /*//////////////////////////////////////////////////////////////
203+ ERC165 Logic
204+ //////////////////////////////////////////////////////////////*/
205+
206+ /// @notice Returns whether this contract supports the given interface.
207+ function supportsInterface (bytes4 interfaceId ) public view virtual override (ERC1155 , IERC165 ) returns (bool ) {
208+ return
209+ interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
210+ interfaceId == 0xd9b67a26 || // ERC165 Interface ID for ERC1155
211+ interfaceId == 0x0e89341c || // ERC165 Interface ID for ERC1155MetadataURI
212+ interfaceId == type (IERC2981 ).interfaceId; // ERC165 ID for ERC2981
213+ }
214+
161215 /*///////////////////////////////////////////////////////////////
162216 Internal functions
163217 //////////////////////////////////////////////////////////////*/
@@ -184,7 +238,7 @@ contract ERC1155Drop is ERC1155SignatureMint, LazyMint, DelayedReveal, DropSingl
184238 uint256 _quantityToClaim ,
185239 address _currency ,
186240 uint256 _pricePerToken
187- ) internal virtual override (DropSinglePhase1155, ERC1155SignatureMint ) {
241+ ) internal virtual override {
188242 if (_pricePerToken == 0 ) {
189243 return ;
190244 }
@@ -210,6 +264,30 @@ contract ERC1155Drop is ERC1155SignatureMint, LazyMint, DelayedReveal, DropSingl
210264 _mint (_to, _tokenId, _quantityBeingClaimed, "" );
211265 }
212266
267+ /// @dev Runs before every token transfer / mint / burn.
268+ function _beforeTokenTransfer (
269+ address operator ,
270+ address from ,
271+ address to ,
272+ uint256 [] memory ids ,
273+ uint256 [] memory amounts ,
274+ bytes memory data
275+ ) internal virtual override {
276+ super ._beforeTokenTransfer (operator, from, to, ids, amounts, data);
277+
278+ if (from == address (0 )) {
279+ for (uint256 i = 0 ; i < ids.length ; ++ i) {
280+ totalSupply[ids[i]] += amounts[i];
281+ }
282+ }
283+
284+ if (to == address (0 )) {
285+ for (uint256 i = 0 ; i < ids.length ; ++ i) {
286+ totalSupply[ids[i]] -= amounts[i];
287+ }
288+ }
289+ }
290+
213291 /// @dev Checks whether primary sale recipient can be set in the given execution context.
214292 function _canSetPrimarySaleRecipient () internal view virtual override returns (bool ) {
215293 return msg .sender == owner ();
@@ -244,4 +322,9 @@ contract ERC1155Drop is ERC1155SignatureMint, LazyMint, DelayedReveal, DropSingl
244322 function _canReveal () internal view virtual returns (bool ) {
245323 return msg .sender == owner ();
246324 }
325+
326+ /// @dev Returns whether a given address is authorized to sign mint requests.
327+ function _canSignMintRequest (address _signer ) internal view virtual override returns (bool ) {
328+ return _signer == owner ();
329+ }
247330}
0 commit comments