Skip to content

Commit

Permalink
Merge pull request #15 from axieinfinity/feature/nft-contract-template
Browse files Browse the repository at this point in the history
feat: add NFTLaunchpad template
  • Loading branch information
huyhuynh3103 authored Jun 27, 2024
2 parents 29afeb2 + 2deff4a commit 862fdff
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
13 changes: 13 additions & 0 deletions src/launchpad/NFTLaunchpadCommon.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 { 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;
}
}
14 changes: 10 additions & 4 deletions src/mock/launchpad/SampleNFT1155Launchpad.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ pragma solidity ^0.8.19;

import { ERC1155 } from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import { AccessControl } from "@openzeppelin/contracts/access/AccessControl.sol";
import { INFTLaunchpad } from "../../interfaces/launchpad/INFTLaunchpad.sol";
import { NFTLaunchpadCommon } from "../../launchpad/NFTLaunchpadCommon.sol";

contract SampleNFT1155Launchpad is ERC1155, AccessControl, INFTLaunchpad {
contract SampleNFT1155Launchpad is ERC1155, AccessControl, NFTLaunchpadCommon {
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");

constructor(address admin, address minter, string memory uri_) ERC1155(uri_) {
Expand All @@ -31,7 +31,13 @@ contract SampleNFT1155Launchpad is ERC1155, AccessControl, INFTLaunchpad {
amounts[1] = 1;
}

function supportsInterface(bytes4 interfaceId) public view virtual override(ERC1155, AccessControl) returns (bool) {
return interfaceId == type(INFTLaunchpad).interfaceId || super.supportsInterface(interfaceId);
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC1155, AccessControl, NFTLaunchpadCommon)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}
17 changes: 12 additions & 5 deletions src/mock/launchpad/SampleNFT721Launchpad.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
pragma solidity ^0.8.19;

import { SampleERC721 } from "../SampleERC721.sol";
import { ERC165 } from "@openzeppelin/contracts/utils/introspection/ERC165.sol";

import { INFTLaunchpad } from "../../interfaces/launchpad/INFTLaunchpad.sol";
import { SampleERC721 } from "../SampleERC721.sol";
import { ERC721Common } from "../../ERC721Common.sol";
import { NFTLaunchpadCommon } from "../../launchpad/NFTLaunchpadCommon.sol";

contract SampleNFT721Launchpad is SampleERC721, INFTLaunchpad {
contract SampleNFT721Launchpad is SampleERC721, NFTLaunchpadCommon {
constructor(string memory name_, string memory symbol_, string memory uri_) SampleERC721(name_, symbol_, uri_) { }

/// @dev Mint NFTs for the launchpad.
Expand All @@ -23,7 +24,13 @@ contract SampleNFT721Launchpad is SampleERC721, INFTLaunchpad {
}
}

function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(INFTLaunchpad).interfaceId || super.supportsInterface(interfaceId);
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC721Common, NFTLaunchpadCommon)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}

0 comments on commit 862fdff

Please sign in to comment.