diff --git a/src/interfaces/launchpad/INFTPresale.sol b/src/interfaces/launchpad/INFTPresale.sol new file mode 100644 index 0000000..d739042 --- /dev/null +++ b/src/interfaces/launchpad/INFTPresale.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.19; + +/// @dev Interface for the NFT contract that compatible with the contract MavisPresale. +/// MUST be included ERC165 interface to support the detection of the contract's capabilities. +interface INFTPresale { + /** + * @dev Mint NFTs for the presale. + * + * Requirements: + * - The mintedTokenIds and mintedAmounts should have the same length. + * - The mintedTokenIds array should be unique. + * - For ERC721 NFTs, each minted token's quantity should always be 1. + * - For ERC1155 NFTs, each minted token's quantity should be actual minted amounts. + * - The total of minted amounts can be different from the input `quantity`. + * + * Examples: + * - ERC1155: If mintedTokenIds = [1, 2], then mintedAmounts = [10, 20] + * - ERC721: If mintedTokenIds = [1, 2], then mintedAmounts = [1, 1] + * + * @param to The address to mint the NFTs to. + * @param quantity The quantity of NFTs to mint. + * @param extraData The extra data for further customization. + * @return mintedTokenIds The token IDs of the minted NFTs. + * @return mintedAmounts The minted amounts according to the `mintedTokenIds`. + */ + function mintPresale(address to, uint256 quantity, bytes calldata extraData) + external + returns (uint256[] memory mintedTokenIds, uint256[] memory mintedAmounts); +} diff --git a/src/launchpad/NFTLaunchpadCommon.sol b/src/launchpad/NFTLaunchpadCommon.sol index f16f68e..08a0d73 100644 --- a/src/launchpad/NFTLaunchpadCommon.sol +++ b/src/launchpad/NFTLaunchpadCommon.sol @@ -8,6 +8,6 @@ import { INFTLaunchpad } from "../interfaces/launchpad/INFTLaunchpad.sol"; abstract contract NFTLaunchpadCommon is IERC165, INFTLaunchpad { /// @dev Returns whether the contract supports the NFT launchpad interface. function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { - return interfaceId == type(INFTLaunchpad).interfaceId; + return interfaceId == type(INFTLaunchpad).interfaceId || interfaceId == type(IERC165).interfaceId; } } diff --git a/src/launchpad/NFTPresaleCommon.sol b/src/launchpad/NFTPresaleCommon.sol new file mode 100644 index 0000000..16ca8f2 --- /dev/null +++ b/src/launchpad/NFTPresaleCommon.sol @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.22; + +import { IERC165 } from "@openzeppelin/contracts/interfaces/IERC165.sol"; + +import { INFTPresale } from "../interfaces/launchpad/INFTPresale.sol"; + +abstract contract NFTPresaleCommon is IERC165, INFTPresale { + /// @dev Returns whether the contract supports the NFT presale interface. + function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { + return interfaceId == type(INFTPresale).interfaceId || interfaceId == type(IERC165).interfaceId; + } +}