Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add template NFTPresaleCommon #19

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/interfaces/launchpad/INFTPresale.sol
Original file line number Diff line number Diff line change
@@ -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);
}
2 changes: 1 addition & 1 deletion src/launchpad/NFTLaunchpadCommon.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
13 changes: 13 additions & 0 deletions src/launchpad/NFTPresaleCommon.sol
Original file line number Diff line number Diff line change
@@ -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;
}
}
Loading