Skip to content

Commit

Permalink
Merge pull request #19 from axieinfinity/feature/NFT-ticket-sale
Browse files Browse the repository at this point in the history
feat: add template NFTPresaleCommon
  • Loading branch information
huyhuynh3103 authored Nov 5, 2024
2 parents 862fdff + 314b736 commit fa86760
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
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;
}
}

0 comments on commit fa86760

Please sign in to comment.