drops testing

This commit is contained in:
owen05
2021-05-24 20:32:05 +08:00
parent c080031b8b
commit d85411e8d9
10 changed files with 315 additions and 22 deletions

View File

@@ -37,6 +37,15 @@ contract NFTCollateralVault is InitializableOwnable, IERC721Receiver, IERC1155Re
event RemoveNftToken(address nftContract, uint256 tokenId, uint256 amount);
event AddNftToken(address nftContract, uint256 tokenId, uint256 amount);
// ============ TransferFrom NFT ============
function depositERC721(address nftContract, uint256[] memory tokenIds) public {
}
function depoistERC1155(address nftContract, uint256[] memory tokenIds, uint256[] memory amounts) public {
}
// ============ Ownable ============
function directTransferOwnership(address newOwner) external onlyOwner {

View File

@@ -82,15 +82,13 @@ contract BaseDrops is InitializableMintableERC20, ReentrancyGuard {
function init(
address[] memory addrList, //0 owner, 1 buyToken, 2 feeModel, 3 defaultMaintainer 4 rng 5 nftToken
uint256[][] memory sellingInfoList, //0 sellingTimeInterval, 1 sellingPrice, 2 sellingAmount
uint256[] memory probInterval,
uint256[][] memory tokenIdMap,
uint256[] memory tokenIdList,
uint256[] memory sellingTimeInterval,
uint256[] memory sellingPrice,
uint256[] memory sellingAmount,
uint256 redeemAllowedTime,
bool isRevealMode,
bool isProbMode
) public {
initOwner(addrList[0]);
_BUY_TOKEN_ = addrList[1];
_FEE_MODEL_ = addrList[2];
_MAINTAINER_ = payable(addrList[3]);
@@ -101,18 +99,21 @@ contract BaseDrops is InitializableMintableERC20, ReentrancyGuard {
_IS_PROB_MODE_ = isProbMode;
_REDEEM_ALLOWED_TIME_ = redeemAllowedTime;
if(sellingInfoList.length > 0) _setSellingInfo(sellingInfoList[0], sellingInfoList[1], sellingInfoList[2]);
if(sellingTimeInterval.length > 0) _setSellingInfo(sellingTimeInterval, sellingPrice, sellingAmount);
if(isProbMode) {
if(probInterval.length > 0) _setProbInfo(probInterval, tokenIdMap);
}else {
if(tokenIdList.length > 0) _setFixedAmountInfo(tokenIdList);
}
// if(isProbMode) {
// // (uint256[][] memory tokenIdMap) = abi.decode(tokenIdMapBytes, (uint256[][]));
// // if(probInterval.length > 0) _setProbInfo(probInterval, tokenIdMap);
// }else {
// // if(tokenIdList.length > 0) _setFixedAmountInfo(tokenIdList);
// }
string memory prefix = "DROPS_";
name = string(abi.encodePacked(prefix, addressToShortString(address(this))));
symbol = name;
decimals = 0;
//init Owner
super.init(addrList[0], 0, name, symbol, decimals);
}
@@ -238,7 +239,9 @@ contract BaseDrops is InitializableMintableERC20, ReentrancyGuard {
_setSellingInfo(sellingTimeIntervals, prices, amounts);
}
function setProbInfo(uint256[] memory probIntervals,uint256[][] memory tokenIdMap) external notStart() onlyOwner {
//TODO: 待测试
function setProbInfo(uint256[] memory probIntervals,bytes memory tokenIdMapBytes) external notStart() onlyOwner {
(uint256[][] memory tokenIdMap) = abi.decode(tokenIdMapBytes, (uint256[][]));
_setProbInfo(probIntervals, tokenIdMap);
}

View File

@@ -6,12 +6,15 @@
*/
pragma solidity 0.6.9;
pragma experimental ABIEncoderV2;
import {ERC1155} from "../../external/ERC1155/ERC1155.sol";
import {InitializableOwnable} from "../../lib/InitializableOwnable.sol";
contract DropsERC1155 is ERC1155, InitializableOwnable {
mapping (address => bool) public _IS_ALLOWED_MINT_;
mapping (uint256 => string) private _tokenURIs;
string internal _baseUri = "";
// ============ Event =============
event addMinter(address account);
@@ -32,11 +35,33 @@ contract DropsERC1155 is ERC1155, InitializableOwnable {
string memory uri
) public {
initOwner(owner);
_setURI(uri);
_baseUri = uri;
}
function mint(address account, uint256 id, uint256 amount, bytes memory data) external {
require(_IS_ALLOWED_MINT_[msg.sender], "Mint restricted");
_mint(account, id, amount, data);
}
function batchSetTokenURI(uint256[] calldata ids, string[] calldata urls) external onlyOwner {
require(ids.length == urls.length, "NOT_MATCH");
for(uint256 i = 0; i < ids.length; i++) {
_setTokenURI(ids[i], urls[i]);
}
}
function uri(uint256 tokenId) public view override returns (string memory) {
string memory _tokenURI = _tokenURIs[tokenId];
string memory base = _baseUri;
if (bytes(base).length == 0) {
return _tokenURI;
}
return string(abi.encodePacked(base, _tokenURI));
}
function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal {
_tokenURIs[tokenId] = _tokenURI;
}
}

View File

@@ -6,11 +6,12 @@
*/
pragma solidity 0.6.9;
pragma experimental ABIEncoderV2;
import {ERC721} from "../../external/ERC721/ERC721.sol";
import {ERC721URIStorage} from "../../external/ERC721/ERC721URIStorage.sol";
import {InitializableOwnable} from "../../lib/InitializableOwnable.sol";
contract DropsERC721 is ERC721, InitializableOwnable {
contract DropsERC721 is ERC721URIStorage, InitializableOwnable {
mapping (address => bool) public _IS_ALLOWED_MINT_;
// ============ Event =============
@@ -40,7 +41,14 @@ contract DropsERC721 is ERC721, InitializableOwnable {
}
function mint(address to, uint256 tokenId) external {
require(_IS_ALLOWED_MINT_[msg.sender], "Mint restricted");
require(_IS_ALLOWED_MINT_[msg.sender], "restricted");
_mint(to, tokenId);
}
function batchSetTokenURI(uint256[] calldata ids, string[] calldata urls) external onlyOwner {
require(ids.length == urls.length, "NOT_MATCH");
for(uint256 i = 0; i < ids.length; i++) {
_setTokenURI(ids[i], urls[i]);
}
}
}

View File

@@ -34,7 +34,7 @@ contract UpCrowdPoolingFactory is InitializableOwnable {
// ============ Settings =============
uint256 public _FREEZE_DURATION_ = 30 days;
uint256 public _CALM_DURATION_ = 0;
uint256 public _CALM_DURATION_ = 600;
uint256 public _VEST_DURATION_ = 0;
uint256 public _CLIFF_RATE_ = 10**18;