Skip to content

Commit

Permalink
feat: add sample presale contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
huyhuynh3103 committed Dec 29, 2024
1 parent e0ec6e8 commit 5737e35
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/mock/launchpad/SampleNFT1155Presale.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import { NFTPresaleCommon } from "../../launchpad/NFTPresaleCommon.sol";
import { ERC1155Common, SampleERC1155 } from "../SampleERC1155.sol";

contract SampleNFT1155Presale is SampleERC1155, NFTPresaleCommon {
constructor(
address admin,
string memory name,
string memory symbol,
string memory uri
) SampleERC1155(admin, name, symbol, uri) { }

/// @dev Mint NFTs for the launchpad.
function mintPresale(
address to,
uint256 quantity,
bytes calldata /* extraData */
) external onlyRole(MINTER_ROLE) returns (uint256[] memory tokenIds, uint256[] memory amounts) {
_mint(to, 3, quantity, "");
_mint(to, 4, 1, "");

tokenIds = new uint256[](2);
amounts = new uint256[](2);
tokenIds[0] = 3;
tokenIds[1] = 4;

amounts[0] = quantity;
amounts[1] = 1;
}

function supportsInterface(
bytes4 interfaceId
) public view virtual override(ERC1155Common, NFTPresaleCommon) returns (bool) {
return ERC1155Common.supportsInterface(interfaceId) || NFTPresaleCommon.supportsInterface(interfaceId);
}
}
32 changes: 32 additions & 0 deletions src/mock/launchpad/SampleNFT721Presale.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import { SampleERC721 } from "../SampleERC721.sol";

import { ERC721Common } from "../../ERC721Common.sol";
import { NFTPresaleCommon } from "../../launchpad/NFTPresaleCommon.sol";
import { SampleERC721 } from "../SampleERC721.sol";

contract SampleNFT721Presale is SampleERC721, NFTPresaleCommon {
constructor(string memory name_, string memory symbol_, string memory uri_) SampleERC721(name_, symbol_, uri_) { }

/// @dev Mint NFTs for the presale.
function mintPresale(
address to,
uint256 quantity,
bytes calldata /* extraData */
) external onlyRole(MINTER_ROLE) returns (uint256[] memory tokenIds, uint256[] memory amounts) {
tokenIds = new uint256[](quantity);
amounts = new uint256[](quantity);
for (uint256 i; i < quantity; ++i) {
tokenIds[i] = _mintFor(to);
amounts[i] = 1;
}
}

function supportsInterface(
bytes4 interfaceId
) public view virtual override(ERC721Common, NFTPresaleCommon) returns (bool) {
return ERC721Common.supportsInterface(interfaceId) || NFTPresaleCommon.supportsInterface(interfaceId);
}
}

0 comments on commit 5737e35

Please sign in to comment.