-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from axieinfinity/release/v0.2.0
feat: add ERC1155Common, support launchpad/presale and adapt OZ v5.
Showing
34 changed files
with
500 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,12 +7,16 @@ on: | |
- dev | ||
- "feature/*" | ||
- "features/*" | ||
- "feature/*" | ||
- "features/*" | ||
pull_request: | ||
branches: | ||
- main | ||
- dev | ||
- "feature/*" | ||
- "features/*" | ||
- "feature/*" | ||
- "features/*" | ||
|
||
env: | ||
FOUNDRY_PROFILE: ci | ||
|
@@ -24,6 +28,7 @@ jobs: | |
|
||
name: Foundry project | ||
runs-on: ubuntu-latest | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
|
@@ -36,7 +41,7 @@ jobs: | |
|
||
- name: Install dependencies | ||
run: | | ||
forge install | ||
forge soldeer update | ||
id: install | ||
|
||
- name: Run Forge build | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,5 @@ artifacts/ | |
typechain-types/ | ||
.idea | ||
.env | ||
|
||
dependencies |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule forge-std
deleted from
fc560f
Submodule openzeppelin-contracts
deleted from
d00ace
Submodule openzeppelin-contracts-upgradeable
deleted from
a40cb0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
forge-std/=lib/forge-std/src/ | ||
ds-test/=lib/forge-std/lib/ds-test/src/ | ||
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/ | ||
@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts | ||
forge-std/=dependencies/forge-std-1.9.3/src/ | ||
@openzeppelin/contracts/=dependencies/openzeppelin-5.0.2/contracts/ | ||
@openzeppelin/contracts-upgradeable/=dependencies/openzeppelin-upgradeable-5.0.2/contracts/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[[dependencies]] | ||
name = "contract-template" | ||
version = "0.1.0" | ||
source = "https://github.com/axieinfinity/contract-template/archive/refs/tags/release-v0.1.0.zip" | ||
checksum = "56676e92b8825974abab8e381a98d0cc55da7057a18b3d325a13def760fa69d3" | ||
integrity = "9fda9db2e8c24bb37378b1a14f41e1338967d101282bcdc0df9e98d7cf0edcda" | ||
|
||
[[dependencies]] | ||
name = "forge-std" | ||
version = "1.9.3" | ||
source = "https://github.com/foundry-rs/forge-std/archive/refs/tags/v1.9.3.zip" | ||
checksum = "cc61148ae1a47f2415956a95ada670501b10ebd7f65cc00eda6ea7025770f42b" | ||
integrity = "d53734fbd7201cd9e44de730ae045ed8958dd2c7b9493c30b322f6e6c21ca8b2" | ||
|
||
[[dependencies]] | ||
name = "openzeppelin" | ||
version = "5.0.2" | ||
source = "https://github.com/OpenZeppelin/openzeppelin-contracts/archive/refs/tags/v5.0.2.zip" | ||
checksum = "ca49e0776066328da0087977864dfaef0d5e54a0ea9859236a7cd9ad02abb9e5" | ||
integrity = "6f8fc028520b958667ef1e96460c64140f42fef60ff02bc63110780c557b7c7e" | ||
|
||
[[dependencies]] | ||
name = "openzeppelin-upgradeable" | ||
version = "5.0.2" | ||
source = "https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/archive/refs/tags/v5.0.2.zip" | ||
checksum = "4790d4f592cb46c868916ea50613997df1e28fd42b4d32e0999f0a4b9d1a7cf8" | ||
integrity = "085dfc37ec3b96f0ea95ae99d8c044b0b407eab88a78d7cb552284bccf1130ba" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.0; | ||
|
||
import "../ERC721Common.sol"; | ||
import { ERC721Common } from "../ERC721Common.sol"; | ||
|
||
contract SampleERC721 is ERC721Common { | ||
constructor(string memory name, string memory symbol, string memory baseTokenURI) | ||
ERC721Common(name, symbol, baseTokenURI) | ||
{ } | ||
constructor( | ||
string memory name_, | ||
string memory symbol_, | ||
string memory baseTokenURI | ||
) ERC721Common(name_, symbol_, baseTokenURI) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.0; | ||
|
||
import "../upgradeable/ERC721CommonUpgradeable.sol"; | ||
import { ERC721CommonUpgradeable } from "../upgradeable/ERC721CommonUpgradeable.sol"; | ||
|
||
contract SampleERC721Upgradeable is ERC721CommonUpgradeable { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 SampleERC1155Presale 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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 SampleERC721Presale 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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
|
||
import { SampleERC1155, SampleERC1155Presale } from "../../src/mock/launchpad/SampleERC1155Presale.sol"; | ||
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol"; | ||
import "forge-std/Test.sol"; | ||
|
||
import { IAccessControlEnumerable, IERC1155, IERC1155Common } from "src/interfaces/IERC1155Common.sol"; | ||
import { INFTPresale } from "src/interfaces/launchpad/INFTPresale.sol"; | ||
|
||
contract SampleERC1155PresaleTest is Test { | ||
using Strings for uint256; | ||
|
||
address admin = makeAddr("admin"); | ||
string public constant NAME = "SampleERC721"; | ||
string public constant SYMBOL = "NFT"; | ||
string public constant BASE_URI = "http://example.com/"; | ||
|
||
SampleERC1155Presale internal _t; | ||
|
||
function setUp() public virtual { | ||
_t = new SampleERC1155Presale(admin, NAME, SYMBOL, BASE_URI); | ||
} | ||
|
||
function testSupportsInterface() public view { | ||
assertEq(_token().supportsInterface(type(INFTPresale).interfaceId), true); | ||
assertEq(_token().supportsInterface(type(IERC1155Common).interfaceId), true); | ||
assertEq(_token().supportsInterface(type(IAccessControlEnumerable).interfaceId), true); | ||
assertEq(_token().supportsInterface(type(IERC1155).interfaceId), true); | ||
} | ||
|
||
function _token() internal view virtual returns (SampleERC1155Presale) { | ||
return _t; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
|
||
import { SampleERC721Presale } from "../../src/mock/launchpad/SampleERC721Presale.sol"; | ||
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol"; | ||
import "forge-std/Test.sol"; | ||
|
||
import { IERC721Common } from "src/interfaces/IERC721Common.sol"; | ||
import { INFTPresale } from "src/interfaces/launchpad/INFTPresale.sol"; | ||
|
||
contract SampleERC721PresaleTest is Test { | ||
using Strings for uint256; | ||
|
||
string public constant NAME = "SampleERC721"; | ||
string public constant SYMBOL = "NFT"; | ||
string public constant BASE_URI = "http://example.com/"; | ||
|
||
SampleERC721Presale internal _t; | ||
|
||
function setUp() public virtual { | ||
_t = new SampleERC721Presale(NAME, SYMBOL, BASE_URI); | ||
} | ||
|
||
function testSupportInterface() public view { | ||
assertEq(_token().supportsInterface(type(INFTPresale).interfaceId), true); | ||
assertEq(_token().supportsInterface(type(IERC721Common).interfaceId), true); | ||
} | ||
|
||
function _token() internal view virtual returns (SampleERC721Presale) { | ||
return _t; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters