更新一些发布脚本
This commit is contained in:
parent
b6b309aac2
commit
6353d0e8d2
17595
build/contracts/FT.json
Normal file
17595
build/contracts/FT.json
Normal file
File diff suppressed because one or more lines are too long
@ -3235,7 +3235,7 @@
|
||||
}
|
||||
},
|
||||
"schemaVersion": "3.4.11",
|
||||
"updatedAt": "2023-04-26T07:39:54.133Z",
|
||||
"updatedAt": "2023-06-06T08:20:35.317Z",
|
||||
"networkType": "ethereum",
|
||||
"devdoc": {
|
||||
"kind": "dev",
|
||||
|
34084
build/contracts/NFT.json
34084
build/contracts/NFT.json
File diff suppressed because one or more lines are too long
@ -28619,6 +28619,12 @@
|
||||
"address": "0xb60c7312F56da4303CE3bf27124f1850dBe1D0E5",
|
||||
"transactionHash": "0x8d5a979aff70a022f1535af09ab3677ec00f224d0b879139af03c53de62f7e7d"
|
||||
},
|
||||
"421613": {
|
||||
"events": {},
|
||||
"links": {},
|
||||
"address": "0x0155eA97330aFF0a9d26bd37C6D967D50c41B4e7",
|
||||
"transactionHash": "0xfa37c913e9971fe86910b7fd3d6170a953bdb6c574e0f6b0ba18811e846b8317"
|
||||
},
|
||||
"1660724532588": {
|
||||
"events": {},
|
||||
"links": {},
|
||||
@ -28698,8 +28704,8 @@
|
||||
"transactionHash": "0x43c6ee315018205de90fb5becb6f6c2aac66597f3686f365dc240c833600a423"
|
||||
}
|
||||
},
|
||||
"schemaVersion": "3.4.4",
|
||||
"updatedAt": "2023-03-07T05:51:01.844Z",
|
||||
"schemaVersion": "3.4.11",
|
||||
"updatedAt": "2023-06-06T08:20:35.312Z",
|
||||
"networkType": "ethereum",
|
||||
"devdoc": {
|
||||
"kind": "dev",
|
||||
|
17
contracts/interfaces/IAsset.sol
Normal file
17
contracts/interfaces/IAsset.sol
Normal file
@ -0,0 +1,17 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.10;
|
||||
|
||||
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
|
||||
|
||||
interface IAsset is IERC721 {
|
||||
function batchMint(
|
||||
address to,
|
||||
uint256[] memory tokenIds
|
||||
) external returns (uint256[] memory);
|
||||
|
||||
function burn(address owner, uint256[] memory ids) external;
|
||||
|
||||
function ownerOf(uint256 tokenId) external view returns (address owner);
|
||||
|
||||
function isLocked(uint256 tokenId) external view returns (bool);
|
||||
}
|
@ -25,8 +25,7 @@ contract MinterFactory is
|
||||
// NFT contract
|
||||
IBEERC721 public hero;
|
||||
IBEERC721 public equip;
|
||||
IBEERC1155 public chip;
|
||||
IBEERC1155 public shard;
|
||||
IBEERC721 public chip;
|
||||
|
||||
address public feeToAddress;
|
||||
|
||||
@ -50,8 +49,7 @@ contract MinterFactory is
|
||||
function init(address[4] calldata _erc721s) external initializer onlyOwner {
|
||||
hero = IBEERC721(_erc721s[0]);
|
||||
equip = IBEERC721(_erc721s[1]);
|
||||
chip = IBEERC1155(_erc721s[2]);
|
||||
shard = IBEERC1155(_erc721s[3]);
|
||||
chip = IBEERC721(_erc721s[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,67 +71,34 @@ contract MinterFactory is
|
||||
/**
|
||||
* @dev mint function to distribute Hero NFT to user
|
||||
*/
|
||||
function mintHeroTo(address to, uint256 tokenId, uint256 nonce) external onlyOwner {
|
||||
function mintHeroTo(
|
||||
address to,
|
||||
uint256 tokenId,
|
||||
uint256 nonce
|
||||
) external onlyOwner {
|
||||
mint721NFT(to, tokenId, nonce, hero);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev mint function to distribute Equipment NFT to user
|
||||
*/
|
||||
function mintEquipTo(address to, uint256 tokenId, uint256 nonce) external onlyOwner {
|
||||
function mintEquipTo(
|
||||
address to,
|
||||
uint256 tokenId,
|
||||
uint256 nonce
|
||||
) external onlyOwner {
|
||||
mint721NFT(to, tokenId, nonce, equip);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev mint function to distribute Chip NFT to user
|
||||
*/
|
||||
function mintChipTo(address to, uint256 tokenId, uint256 nonce) external onlyOwner {
|
||||
mint1155NFT(to, tokenId, nonce, 1, chip);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev mint function to distribute Shard NFT to user
|
||||
*/
|
||||
function mintShardTo(address to, uint256 tokenId, uint256 nonce) external onlyOwner {
|
||||
mint1155NFT(to, tokenId, nonce, 1, shard);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev batch mint 1155 Chip to user
|
||||
*/
|
||||
function mintChipBatch(address to, uint256[] memory ids, uint256 nonce) external onlyOwner {
|
||||
require(
|
||||
to != address(0),
|
||||
"MinterFactory::mintChipBatch: to address can not be zero"
|
||||
);
|
||||
require(
|
||||
ids.length > 0,
|
||||
"MinterFactory::mintChipBatch: ids cannot be empty"
|
||||
);
|
||||
uint256[] memory amounts = new uint256[](ids.length);
|
||||
uint256 len = ids.length;
|
||||
for (uint256 i = 0; i < len; ++i) {
|
||||
amounts[i] = 1;
|
||||
}
|
||||
mint1155NFTBatch(to, nonce, ids, amounts, chip);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev batch mint 1155 Shard to user
|
||||
*/
|
||||
function mintShardBatch(
|
||||
function mintChipTo(
|
||||
address to,
|
||||
uint256 nonce,
|
||||
uint256[] memory ids,
|
||||
uint256[] memory amounts
|
||||
uint256 tokenId,
|
||||
uint256 nonce
|
||||
) external onlyOwner {
|
||||
require(to != address(0), "MinterFactory: to address can not be zero");
|
||||
require(ids.length > 0, "MinterFactory: ids cannot be empty");
|
||||
require(
|
||||
ids.length == amounts.length,
|
||||
"MinterFactory: ids and amounts length mismatch"
|
||||
);
|
||||
mint1155NFTBatch(to, nonce, ids, amounts, shard);
|
||||
mint721NFT(to, tokenId, nonce, chip);
|
||||
}
|
||||
|
||||
function mint721ByUser(
|
||||
@ -158,87 +123,6 @@ contract MinterFactory is
|
||||
_useSignature(signature);
|
||||
}
|
||||
|
||||
function mint1155BatchByUser(
|
||||
address to,
|
||||
uint256[] memory ids,
|
||||
uint256[] memory amounts,
|
||||
uint256 startTime,
|
||||
uint256 saltNonce,
|
||||
bytes calldata signature,
|
||||
IBEERC1155 nft
|
||||
) external signatureValid(signature) timeValid(startTime) {
|
||||
uint256 len = ids.length;
|
||||
require(len > 0, "MinterFactory: ids cannot be empty");
|
||||
require(
|
||||
len == amounts.length,
|
||||
"MinterFactory: ids and amounts length mismatch"
|
||||
);
|
||||
uint256[] memory signArray = new uint256[](len * 2);
|
||||
for (uint256 i = 0; i < len; ++i) {
|
||||
require(
|
||||
nft.canMint(ids[i]),
|
||||
"MinterFactory: can not mint for current nft rule setting"
|
||||
);
|
||||
signArray[i * 2] = ids[i];
|
||||
signArray[i * 2 + 1] = amounts[i];
|
||||
}
|
||||
bytes32 criteriaMessageHash = getMessageHash(
|
||||
to,
|
||||
address(nft),
|
||||
startTime,
|
||||
saltNonce,
|
||||
signArray
|
||||
);
|
||||
checkSigner(executor, criteriaMessageHash, signature);
|
||||
mint1155NFTBatch(to, saltNonce, ids, amounts, nft);
|
||||
_useSignature(signature);
|
||||
}
|
||||
|
||||
function shardMixByUser(
|
||||
ShardParam memory param,
|
||||
uint256[] memory ids,
|
||||
uint256[] memory amounts,
|
||||
bytes calldata signature,
|
||||
IBEERC721 nft
|
||||
) external signatureValid(signature) timeValid(param.startTime) {
|
||||
require(ids.length > 0, "MinterFactory: ids cannot be empty");
|
||||
require(
|
||||
ids.length == amounts.length,
|
||||
"MinterFactory: ids and amounts length mismatch"
|
||||
);
|
||||
|
||||
uint256[] memory signArray = new uint256[](ids.length * 2);
|
||||
for (uint256 i = 0; i < ids.length; ++i) {
|
||||
require(
|
||||
shard.balanceOf(param.to, ids[i]) > 0,
|
||||
"MinterFactory: not enough shard"
|
||||
);
|
||||
signArray[i * 2] = ids[i];
|
||||
signArray[i * 2 + 1] = amounts[i];
|
||||
}
|
||||
bytes32 criteriaMessageHash = getShardMixHash(
|
||||
param,
|
||||
address(nft),
|
||||
signArray
|
||||
);
|
||||
checkSigner(executor, criteriaMessageHash, signature);
|
||||
// Check payment approval and buyer balance
|
||||
IERC20 paymentContract = IERC20(param.payToken);
|
||||
require(
|
||||
paymentContract.balanceOf(param.to) >= param.payAmount,
|
||||
"MinterFactory: doesn't have enough token to mix shard"
|
||||
);
|
||||
require(
|
||||
paymentContract.allowance(param.to, address(this)) >= param.payAmount,
|
||||
"MinterFactory: doesn't approve MinterFactory to spend payment amount"
|
||||
);
|
||||
// transfer money to address
|
||||
paymentContract.safeTransferFrom(param.to, feeToAddress, param.payAmount);
|
||||
shard.burnBatch(param.to, ids, amounts);
|
||||
mint721NFT(param.to, param.nftId, param.saltNonce, nft);
|
||||
_useSignature(signature);
|
||||
}
|
||||
|
||||
function mint721NFT(
|
||||
address to,
|
||||
uint256 tokenId,
|
||||
|
@ -2,204 +2,79 @@
|
||||
pragma solidity 0.8.10;
|
||||
import "@openzeppelin/contracts/access/Ownable.sol";
|
||||
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
|
||||
import "../interfaces/IBEERC721.sol";
|
||||
import "../interfaces/IBEERC1155.sol";
|
||||
import "./FactoryBase.sol";
|
||||
import "./MinterFactory.sol";
|
||||
import "../interfaces/IAsset.sol";
|
||||
import "../utils/TimeChecker.sol";
|
||||
import "../core/HasSignature.sol";
|
||||
|
||||
contract UserMinterFactory is Ownable, FactoryBase, Initializable {
|
||||
MinterFactory factory;
|
||||
IBEERC721 public hero;
|
||||
IBEERC721 public equip;
|
||||
IBEERC1155 public chip;
|
||||
IBEERC1155 public shard;
|
||||
contract UserMinterFactory is
|
||||
Ownable,
|
||||
TimeChecker,
|
||||
HasSignature,
|
||||
Initializable
|
||||
{
|
||||
mapping(address => bool) public tokenSupported;
|
||||
|
||||
event TokenMintFail(
|
||||
address indexed to,
|
||||
uint256 indexed nonce,
|
||||
bytes signature,
|
||||
string reason,
|
||||
bytes byteReason
|
||||
);
|
||||
address public executor;
|
||||
|
||||
function init(address[5] calldata addressArr) external initializer onlyOwner {
|
||||
hero = IBEERC721(addressArr[0]);
|
||||
equip = IBEERC721(addressArr[1]);
|
||||
chip = IBEERC1155(addressArr[2]);
|
||||
shard = IBEERC1155(addressArr[3]);
|
||||
factory = MinterFactory(addressArr[4]);
|
||||
}
|
||||
constructor() HasSignature("UserMinterFactory", "1") {}
|
||||
|
||||
/**
|
||||
* @dev mint hero by user
|
||||
*/
|
||||
function mintHeroUser(
|
||||
uint256 tokenId,
|
||||
function mintNft(
|
||||
address nftAddress,
|
||||
uint256[] memory tokenIds,
|
||||
uint256 startTime,
|
||||
uint256 saltNonce,
|
||||
bytes calldata signature
|
||||
) external returns (bool success) {
|
||||
) external signatureValid(signature) timeValid(startTime) {
|
||||
require(tokenSupported[nftAddress], "UserMinterFactory: Unsupported NFT");
|
||||
address to = _msgSender();
|
||||
try
|
||||
factory.mint721ByUser(to, tokenId, startTime, saltNonce, signature, hero)
|
||||
{
|
||||
return true;
|
||||
} catch Error(string memory reason) {
|
||||
bytes memory by;
|
||||
factory.useSignature(signature);
|
||||
emit TokenMintFail(to, saltNonce, signature, reason, by);
|
||||
return false;
|
||||
} catch (bytes memory lowLevelData) {
|
||||
factory.useSignature(signature);
|
||||
string memory reason;
|
||||
emit TokenMintFail(to, saltNonce, signature, reason, lowLevelData);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev user mint equip
|
||||
*/
|
||||
function mintEquipUser(
|
||||
uint256 tokenId,
|
||||
uint256 startTime,
|
||||
uint256 saltNonce,
|
||||
bytes calldata signature
|
||||
) external returns (bool success) {
|
||||
address to = _msgSender();
|
||||
try
|
||||
factory.mint721ByUser(to, tokenId, startTime, saltNonce, signature, equip)
|
||||
{
|
||||
return true;
|
||||
} catch Error(string memory reason) {
|
||||
bytes memory by;
|
||||
factory.useSignature(signature);
|
||||
emit TokenMintFail(to, saltNonce, signature, reason, by);
|
||||
return false;
|
||||
} catch (bytes memory lowLevelData) {
|
||||
factory.useSignature(signature);
|
||||
string memory reason;
|
||||
emit TokenMintFail(to, saltNonce, signature, reason, lowLevelData);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev user batch mint 1155 chip
|
||||
*/
|
||||
function mintChipBatchUser(
|
||||
uint256[] memory ids,
|
||||
uint256 startTime,
|
||||
uint256 saltNonce,
|
||||
bytes calldata signature
|
||||
) external returns (bool success) {
|
||||
uint256 len = ids.length;
|
||||
uint256[] memory amounts = new uint256[](len);
|
||||
for (uint256 i = 0; i < len; ++i) {
|
||||
amounts[i] = 1;
|
||||
}
|
||||
address to = _msgSender();
|
||||
try
|
||||
factory.mint1155BatchByUser(
|
||||
to,
|
||||
ids,
|
||||
amounts,
|
||||
startTime,
|
||||
saltNonce,
|
||||
signature,
|
||||
chip
|
||||
)
|
||||
{
|
||||
return true;
|
||||
} catch Error(string memory reason) {
|
||||
bytes memory by;
|
||||
factory.useSignature(signature);
|
||||
emit TokenMintFail(to, saltNonce, signature, reason, by);
|
||||
return false;
|
||||
} catch (bytes memory lowLevelData) {
|
||||
factory.useSignature(signature);
|
||||
string memory reason;
|
||||
emit TokenMintFail(to, saltNonce, signature, reason, lowLevelData);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev user batch mint 1155 shard
|
||||
*/
|
||||
function mintShardBatchUser(
|
||||
uint256[] memory ids,
|
||||
uint256[] memory amounts,
|
||||
uint256 startTime,
|
||||
uint256 saltNonce,
|
||||
bytes calldata signature
|
||||
) external returns (bool success) {
|
||||
address to = _msgSender();
|
||||
try
|
||||
factory.mint1155BatchByUser(
|
||||
to,
|
||||
ids,
|
||||
amounts,
|
||||
startTime,
|
||||
saltNonce,
|
||||
signature,
|
||||
shard
|
||||
)
|
||||
{
|
||||
return true;
|
||||
} catch Error(string memory reason) {
|
||||
bytes memory by;
|
||||
factory.useSignature(signature);
|
||||
emit TokenMintFail(to, saltNonce, signature, reason, by);
|
||||
return false;
|
||||
} catch (bytes memory lowLevelData) {
|
||||
factory.useSignature(signature);
|
||||
string memory reason;
|
||||
emit TokenMintFail(to, saltNonce, signature, reason, lowLevelData);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev mint hero or equip with shard
|
||||
*/
|
||||
function shardMixByUser(
|
||||
uint256 nftId,
|
||||
uint8 nftType,
|
||||
address payToken,
|
||||
uint256 payAmount,
|
||||
uint256[] memory ids,
|
||||
uint256[] memory amounts,
|
||||
uint256 startTime,
|
||||
uint256 saltNonce,
|
||||
bytes calldata signature
|
||||
) external returns (bool success) {
|
||||
address to = _msgSender();
|
||||
IBEERC721 nft;
|
||||
if (nftType == 0) {
|
||||
nft = hero;
|
||||
} else {
|
||||
nft = equip;
|
||||
}
|
||||
ShardParam memory param = ShardParam(
|
||||
bytes32 criteriaMessageHash = getMessageHash(
|
||||
to,
|
||||
nftId,
|
||||
payToken,
|
||||
payAmount,
|
||||
nftAddress,
|
||||
startTime,
|
||||
saltNonce
|
||||
saltNonce,
|
||||
tokenIds
|
||||
);
|
||||
try factory.shardMixByUser(param, ids, amounts, signature, nft) {
|
||||
return true;
|
||||
} catch Error(string memory reason) {
|
||||
bytes memory by;
|
||||
factory.useSignature(signature);
|
||||
emit TokenMintFail(to, saltNonce, signature, reason, by);
|
||||
return false;
|
||||
} catch (bytes memory lowLevelData) {
|
||||
factory.useSignature(signature);
|
||||
string memory reason;
|
||||
emit TokenMintFail(to, saltNonce, signature, reason, lowLevelData);
|
||||
checkSigner(executor, criteriaMessageHash, signature);
|
||||
IAsset(nftAddress).batchMint(to, tokenIds);
|
||||
_useSignature(signature);
|
||||
}
|
||||
|
||||
function addTokenSupport(address nftToken) external onlyOwner {
|
||||
tokenSupported[nftToken] = true;
|
||||
}
|
||||
|
||||
function removeTokenSupport(address nftToken) external onlyOwner {
|
||||
tokenSupported[nftToken] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev update executor
|
||||
*/
|
||||
function updateExecutor(address account) external onlyOwner {
|
||||
require(account != address(0), "address can not be zero");
|
||||
executor = account;
|
||||
}
|
||||
|
||||
function getMessageHash(
|
||||
address _to,
|
||||
address _nftAddress,
|
||||
uint256 _startTime,
|
||||
uint256 _saltNonce,
|
||||
uint256[] memory _ids
|
||||
) public pure returns (bytes32) {
|
||||
bytes memory encoded = abi.encodePacked(
|
||||
_to,
|
||||
_nftAddress,
|
||||
_startTime,
|
||||
_saltNonce
|
||||
);
|
||||
uint256 len = _ids.length;
|
||||
for (uint256 i = 0; i < len; ++i) {
|
||||
encoded = bytes.concat(encoded, abi.encodePacked(_ids[i]));
|
||||
}
|
||||
return keccak256(encoded);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.10;
|
||||
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
|
||||
|
||||
contract BECoin is ERC20Burnable {
|
||||
uint256 public constant INITIALIZED_CAP = 100000000 * 1e18;
|
||||
|
||||
constructor() ERC20("CRYPTO ELITE'S COIN", "CEC") {
|
||||
_mint(_msgSender(), INITIALIZED_CAP);
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.10;
|
||||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
||||
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
|
||||
import "@openzeppelin/contracts/security/Pausable.sol";
|
||||
import "@openzeppelin/contracts/access/Ownable.sol";
|
||||
|
||||
/**
|
||||
* this contract will transfer ownership to BETimelockController after deployed
|
||||
* all onlyowner method would add timelock
|
||||
*/
|
||||
contract BEGold is ERC20, ERC20Burnable, Pausable, Ownable {
|
||||
constructor() ERC20("CRYPTO ELITE'S GOLD", "CEG") {}
|
||||
|
||||
function pause() external onlyOwner {
|
||||
_pause();
|
||||
}
|
||||
|
||||
function unpause() external onlyOwner {
|
||||
_unpause();
|
||||
}
|
||||
|
||||
function mint(address to, uint256 amount) external onlyOwner {
|
||||
_mint(to, amount);
|
||||
}
|
||||
|
||||
function _beforeTokenTransfer(
|
||||
address from,
|
||||
address to,
|
||||
uint256 amount
|
||||
) internal override whenNotPaused {
|
||||
super._beforeTokenTransfer(from, to, amount);
|
||||
}
|
||||
}
|
@ -5,20 +5,20 @@ import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
|
||||
import "@openzeppelin/contracts/security/Pausable.sol";
|
||||
import "@openzeppelin/contracts/access/AccessControl.sol";
|
||||
|
||||
/**
|
||||
* only for test
|
||||
*/
|
||||
contract BEUSDT is ERC20, ERC20Burnable, Pausable, AccessControl {
|
||||
contract FT is ERC20, ERC20Burnable, Pausable, AccessControl {
|
||||
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
|
||||
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
|
||||
uint256 public immutable supplyLimit;
|
||||
|
||||
constructor(
|
||||
string memory name_,
|
||||
string memory symbol_
|
||||
string memory symbol_,
|
||||
uint256 _supplyLimt
|
||||
) ERC20(name_, symbol_) {
|
||||
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
|
||||
_setupRole(PAUSER_ROLE, msg.sender);
|
||||
_setupRole(MINTER_ROLE, msg.sender);
|
||||
supplyLimit = _supplyLimt;
|
||||
}
|
||||
|
||||
// constructor() ERC20("BE test USDT", "USDT") {}
|
||||
@ -32,6 +32,12 @@ contract BEUSDT is ERC20, ERC20Burnable, Pausable, AccessControl {
|
||||
}
|
||||
|
||||
function mint(address to, uint256 amount) external onlyRole(MINTER_ROLE) {
|
||||
if (supplyLimit > 0) {
|
||||
require(
|
||||
(totalSupply() + amount) <= supplyLimit,
|
||||
"Exceed the total supply"
|
||||
);
|
||||
}
|
||||
_mint(to, amount);
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.10;
|
||||
import "./BEBase.sol";
|
||||
|
||||
// this contract will transfer ownership to BETimelockController after deployed
|
||||
// all onlyowner method would add timelock
|
||||
contract BEChip is BEBase {
|
||||
constructor() ERC721("CRYPTO ELITE'S CHIP", "CHIP") {}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.10;
|
||||
import "./BEBase.sol";
|
||||
|
||||
// this contract will transfer ownership to BETimelockController after deployed
|
||||
// all onlyowner method would add timelock
|
||||
contract BEEquipment is BEBase {
|
||||
constructor() ERC721("CRYPTO ELITE'S WEAPON", "WEAPON") {}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.10;
|
||||
import "./BEBase.sol";
|
||||
|
||||
// this contract will transfer ownership to BETimelockController after deployed
|
||||
// all onlyowner method would add timelock
|
||||
contract BEHero is BEBase {
|
||||
constructor() ERC721("CRYPTO ELITE'S HERO", "HERO") {}
|
||||
}
|
165
contracts/tokens/erc721/NFT.sol
Normal file
165
contracts/tokens/erc721/NFT.sol
Normal file
@ -0,0 +1,165 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.10;
|
||||
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
|
||||
import "@openzeppelin/contracts/access/AccessControl.sol";
|
||||
|
||||
contract NFT is AccessControl, ERC721Enumerable {
|
||||
mapping(uint256 => bool) public lockedTokens;
|
||||
string private _baseTokenURI = "https://market.cebg.games/api/nft/info/";
|
||||
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
|
||||
bytes32 public constant LOCK_ROLE = keccak256("LOCK_ROLE");
|
||||
uint256 public immutable supplyLimit;
|
||||
uint256 tokenIndex;
|
||||
|
||||
event Lock(uint256 indexed tokenId);
|
||||
event UnLock(uint256 indexed tokenId);
|
||||
event BatchMint(address indexed to, uint256[] tokenIds);
|
||||
|
||||
constructor(
|
||||
string memory _name,
|
||||
string memory _symbol,
|
||||
uint256 _supplyLimt
|
||||
) ERC721(_name, _symbol) {
|
||||
_setRoleAdmin(MINTER_ROLE, DEFAULT_ADMIN_ROLE);
|
||||
_setRoleAdmin(LOCK_ROLE, DEFAULT_ADMIN_ROLE);
|
||||
|
||||
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
|
||||
_setupRole(MINTER_ROLE, msg.sender);
|
||||
_setupRole(LOCK_ROLE, msg.sender);
|
||||
supplyLimit = _supplyLimt;
|
||||
}
|
||||
|
||||
function _baseURI() internal view virtual override returns (string memory) {
|
||||
return _baseTokenURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Batch mint tokens and transfer to specified address.
|
||||
*
|
||||
* Requirements:
|
||||
* - Caller must have `MINTER_ROLE`.
|
||||
* - The total supply limit should not be exceeded.
|
||||
* - The number of tokenIds offered for minting should not exceed 100.
|
||||
*/
|
||||
|
||||
function batchMint(
|
||||
address to,
|
||||
uint256[] memory tokenIds
|
||||
) external onlyRole(MINTER_ROLE) returns (uint256[] memory) {
|
||||
uint256 count = tokenIds.length;
|
||||
require(count <= 100, "tokenIds too many");
|
||||
if (supplyLimit > 0) {
|
||||
require(
|
||||
(totalSupply() + count) <= supplyLimit,
|
||||
"Exceed the total supply"
|
||||
);
|
||||
}
|
||||
for (uint256 i = 0; i < count; i++) {
|
||||
tokenIndex += 1;
|
||||
uint256 tokenId = tokenIndex;
|
||||
_safeMint(to, tokenId);
|
||||
tokenIds[i] = tokenId;
|
||||
}
|
||||
emit BatchMint(to, tokenIds);
|
||||
return tokenIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Grant mint role to address
|
||||
*/
|
||||
function setMintRole(address to) external {
|
||||
grantRole(MINTER_ROLE, to);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Remove mint role to address
|
||||
*/
|
||||
function removeMintRole(address to) external {
|
||||
revokeRole(MINTER_ROLE, to);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Add address for lock item
|
||||
*/
|
||||
function grantLockRole(address to) external {
|
||||
grantRole(LOCK_ROLE, to);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Remove address for lock item
|
||||
*/
|
||||
function removeLockRole(address account) external {
|
||||
revokeRole(LOCK_ROLE, account);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Lock token to use in game or for rental
|
||||
*/
|
||||
function lock(uint256 tokenId) external onlyRole(LOCK_ROLE) {
|
||||
require(_exists(tokenId), "Must be valid tokenId");
|
||||
require(!lockedTokens[tokenId], "Token has already locked");
|
||||
lockedTokens[tokenId] = true;
|
||||
emit Lock(tokenId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Unlock token to use blockchain or sale on marketplace
|
||||
*/
|
||||
function unlock(uint256 tokenId) external onlyRole(LOCK_ROLE) {
|
||||
require(_exists(tokenId), "Must be valid tokenId");
|
||||
require(lockedTokens[tokenId], "Token has already unlocked");
|
||||
lockedTokens[tokenId] = false;
|
||||
emit UnLock(tokenId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Get lock status
|
||||
*/
|
||||
function isLocked(uint256 tokenId) external view returns (bool) {
|
||||
return lockedTokens[tokenId];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Set token URI
|
||||
*/
|
||||
function updateBaseURI(
|
||||
string calldata baseTokenURI
|
||||
) external onlyRole(DEFAULT_ADMIN_ROLE) {
|
||||
_baseTokenURI = baseTokenURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev See {IERC165-_beforeTokenTransfer}.
|
||||
*/
|
||||
function _beforeTokenTransfer(
|
||||
address from,
|
||||
address to,
|
||||
uint256 tokenId
|
||||
) internal virtual override(ERC721Enumerable) {
|
||||
require(!lockedTokens[tokenId], "Can not transfer locked token");
|
||||
super._beforeTokenTransfer(from, to, tokenId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev See {IERC165-supportsInterface}.
|
||||
*/
|
||||
function supportsInterface(
|
||||
bytes4 interfaceId
|
||||
)
|
||||
public
|
||||
view
|
||||
virtual
|
||||
override(AccessControl, ERC721Enumerable)
|
||||
returns (bool)
|
||||
{
|
||||
return super.supportsInterface(interfaceId);
|
||||
}
|
||||
|
||||
function burn(uint256 tokenId) public virtual {
|
||||
require(
|
||||
_isApprovedOrOwner(_msgSender(), tokenId),
|
||||
"caller is not owner nor approved"
|
||||
);
|
||||
_burn(tokenId);
|
||||
}
|
||||
}
|
@ -1,47 +1,54 @@
|
||||
const BEHero = artifacts.require("tokens/erc721/BEHero");
|
||||
const BEEquipment = artifacts.require("tokens/erc721/BEEquipment");
|
||||
const BECoin = artifacts.require("tokens/erc20/BECoin");
|
||||
const BEGold = artifacts.require("tokens/erc20/BEGold");
|
||||
const BEUsdt = artifacts.require("tokens/erc20/BEUSDT");
|
||||
const BEChip1155 = artifacts.require("tokens/erc1155/BEChip1155");
|
||||
const BEShard = artifacts.require("tokens/erc1155/BEShard");
|
||||
const FT = artifacts.require("tokens/erc20/FT");
|
||||
const NFT = artifacts.require("tokens/erc20/NFT");
|
||||
const MarketPlace = artifacts.require("market/BENFTMarket");
|
||||
// const BEBoxMall = artifacts.require('market/BEBoxMall')
|
||||
const MinterFactory = artifacts.require("logic/MinterFactory");
|
||||
const UserMinterFactory = artifacts.require("logic/UserMinterFactory");
|
||||
const EvolveFactory = artifacts.require("logic/EvolveFactory");
|
||||
const UserEvolveFactory = artifacts.require("logic/UserEvolveFactory");
|
||||
const BENftMall = artifacts.require("market/BENftMall");
|
||||
const NftChipLocker = artifacts.require("logic/NftChipLocker");
|
||||
|
||||
const config = require("../config/config");
|
||||
const base = require("../scripts/base");
|
||||
|
||||
module.exports = async function main(callback) {
|
||||
try {
|
||||
// Our code will go here
|
||||
const network = "arbitrum_testnet";
|
||||
let cfgs = base.loadData({ network });
|
||||
const accounts = await web3.eth.getAccounts();
|
||||
console.log(accounts);
|
||||
|
||||
const heroInstance = await BEHero.deployed();
|
||||
const equipInstance = await BEEquipment.deployed();
|
||||
const chipInstance = await BEChip1155.deployed();
|
||||
const shardInstance = await BEShard.deployed();
|
||||
const coinInstance = await BECoin.deployed();
|
||||
const goldInstance = await BEGold.deployed();
|
||||
const usdtInstance = await BEUsdt.deployed();
|
||||
const heroInstance = await NFT.at(
|
||||
cfgs.find((c) => c.name === "HERO").address
|
||||
);
|
||||
const equipInstance = await NFT.at(
|
||||
cfgs.find((c) => c.name === "WEAPON").address
|
||||
);
|
||||
const chipInstance = await NFT.at(
|
||||
cfgs.find((c) => c.name === "CHIP").address
|
||||
);
|
||||
|
||||
const coinInstance = await FT.at(
|
||||
cfgs.find((c) => c.name === "CEC").address
|
||||
);
|
||||
const goldInstance = await FT.at(
|
||||
cfgs.find((c) => c.name === "CEG").address
|
||||
);
|
||||
|
||||
const usdtInstance = await await FT.at(
|
||||
cfgs.find((c) => c.name === "BEUSDT").address
|
||||
);
|
||||
config.market.paymentTokens.push(coinInstance.address);
|
||||
config.market.paymentTokens.push(goldInstance.address);
|
||||
config.market.paymentTokens.push(usdtInstance.address);
|
||||
|
||||
await heroInstance.updateBaseURI(config.token.baseTokenURI);
|
||||
console.log("BEHero baseURI update success.");
|
||||
// await heroInstance.updateBaseURI(config.token.baseTokenURI);
|
||||
// console.log("BEHero baseURI update success.");
|
||||
|
||||
await equipInstance.updateBaseURI(config.token.baseTokenURI);
|
||||
console.log("Equip baseURI update success.");
|
||||
// await equipInstance.updateBaseURI(config.token.baseTokenURI);
|
||||
// console.log("Equip baseURI update success.");
|
||||
|
||||
const marketInstance = await MarketPlace.deployed();
|
||||
const marketInstance = await MarketPlace.at(
|
||||
cfgs.find((c) => c.name === "BENftMarket").address
|
||||
);
|
||||
const ROUND = 1000000;
|
||||
const DECIMALS = 1000000000000000000
|
||||
const DECIMALS = 1000000000000000000;
|
||||
if (marketInstance) {
|
||||
await marketInstance.setFeeToAddress(config.market.feeToAddress);
|
||||
console.log(
|
||||
@ -50,45 +57,19 @@ module.exports = async function main(callback) {
|
||||
await marketInstance.setTransactionFee((4 * ROUND) / 100);
|
||||
await marketInstance.addERC721Support(heroInstance.address);
|
||||
await marketInstance.addERC721Support(equipInstance.address);
|
||||
await marketInstance.addERC1155Support(chipInstance.address);
|
||||
await marketInstance.addERC1155Support(shardInstance.address);
|
||||
const maxPrice = web3.utils.toWei('99990000')
|
||||
const minPrice = web3.utils.toWei('0.01')
|
||||
await marketInstance.setNFTPriceMaxLimit(
|
||||
heroInstance.address,
|
||||
maxPrice
|
||||
);
|
||||
await marketInstance.setNFTPriceMinLimit(
|
||||
heroInstance.address,
|
||||
minPrice
|
||||
);
|
||||
await marketInstance.setNFTPriceMaxLimit(
|
||||
equipInstance.address,
|
||||
maxPrice
|
||||
);
|
||||
await marketInstance.setNFTPriceMinLimit(
|
||||
equipInstance.address,
|
||||
minPrice
|
||||
);
|
||||
await marketInstance.setNFTPriceMaxLimit(
|
||||
chipInstance.address,
|
||||
maxPrice
|
||||
);
|
||||
await marketInstance.setNFTPriceMinLimit(
|
||||
chipInstance.address,
|
||||
minPrice
|
||||
);
|
||||
await marketInstance.setNFTPriceMaxLimit(
|
||||
shardInstance.address,
|
||||
maxPrice
|
||||
);
|
||||
await marketInstance.setNFTPriceMinLimit(
|
||||
shardInstance.address,
|
||||
minPrice
|
||||
);
|
||||
await marketInstance.addERC721Support(chipInstance.address);
|
||||
|
||||
const maxPrice = web3.utils.toWei("99990000");
|
||||
const minPrice = web3.utils.toWei("0.01");
|
||||
await marketInstance.setNFTPriceMaxLimit(heroInstance.address, maxPrice);
|
||||
await marketInstance.setNFTPriceMinLimit(heroInstance.address, minPrice);
|
||||
await marketInstance.setNFTPriceMaxLimit(equipInstance.address, maxPrice);
|
||||
await marketInstance.setNFTPriceMinLimit(equipInstance.address, minPrice);
|
||||
await marketInstance.setNFTPriceMaxLimit(chipInstance.address, maxPrice);
|
||||
await marketInstance.setNFTPriceMinLimit(chipInstance.address, minPrice);
|
||||
for (let token of config.market.paymentTokens) {
|
||||
await marketInstance.addERC20Support(token);
|
||||
console.log(`add token for market payment: ${token}`)
|
||||
console.log(`add token for market payment: ${token}`);
|
||||
}
|
||||
|
||||
console.log(`finish update market config`);
|
||||
@ -106,107 +87,26 @@ module.exports = async function main(callback) {
|
||||
await heroInstance.grantLockRole(config.admins.admin);
|
||||
await equipInstance.grantLockRole(config.admins.admin);
|
||||
await chipInstance.grantLockRole(config.admins.admin);
|
||||
await shardInstance.grantLockRole(config.admins.admin);
|
||||
console.log(
|
||||
`Allow operation ${marketInstance.address} to reduce gas fee`
|
||||
);
|
||||
}
|
||||
|
||||
const factoryInstance = await MinterFactory.deployed();
|
||||
const factoryInstance = await UserMinterFactory.deployed();
|
||||
if (!factoryInstance) {
|
||||
console.error("no factoryInstance");
|
||||
return;
|
||||
}
|
||||
await factoryInstance.init([
|
||||
heroInstance.address,
|
||||
equipInstance.address,
|
||||
chipInstance.address,
|
||||
shardInstance.address,
|
||||
]);
|
||||
await factoryInstance.setFeeToAddress(config.market.feeToAddress);
|
||||
|
||||
await factoryInstance.updateExecutor(config.admins.admin);
|
||||
await heroInstance.setMintFactory(factoryInstance.address);
|
||||
await equipInstance.setMintFactory(factoryInstance.address);
|
||||
await chipInstance.setMintFactory(factoryInstance.address);
|
||||
await shardInstance.setMintFactory(factoryInstance.address);
|
||||
|
||||
console.log(
|
||||
`Allow factory ${factoryInstance.address} to mint contract \n hero: ${heroInstance.address}, \n equip: ${equipInstance.address}, \n chip: ${chipInstance.address}`
|
||||
);
|
||||
await heroInstance.grantBurnRole(factoryInstance.address);
|
||||
await equipInstance.grantBurnRole(factoryInstance.address);
|
||||
await chipInstance.grantBurnRole(factoryInstance.address);
|
||||
await shardInstance.grantBurnRole(factoryInstance.address);
|
||||
|
||||
console.log(
|
||||
`Allow factory ${factoryInstance.address} to burn contract \n hero: ${heroInstance.address}, \n equip: ${equipInstance.address}, \n chip: ${chipInstance.address}`
|
||||
);
|
||||
|
||||
const userFactoryInstance = await UserMinterFactory.deployed();
|
||||
if (!userFactoryInstance) {
|
||||
console.error("no userFactoryInstance");
|
||||
return;
|
||||
}
|
||||
await factoryInstance.addApprovalList(userFactoryInstance.address);
|
||||
await userFactoryInstance.init([
|
||||
heroInstance.address,
|
||||
equipInstance.address,
|
||||
chipInstance.address,
|
||||
shardInstance.address,
|
||||
factoryInstance.address,
|
||||
]);
|
||||
const proxyInstance = await EvolveFactory.deployed();
|
||||
if (!proxyInstance) {
|
||||
console.error("no proxyInstance");
|
||||
return;
|
||||
}
|
||||
await proxyInstance.init(chipInstance.address);
|
||||
await proxyInstance.addNFTTokenSupport(heroInstance.address);
|
||||
await proxyInstance.addNFTTokenSupport(equipInstance.address);
|
||||
await proxyInstance.updateExecutor(config.admins.admin);
|
||||
await heroInstance.grantBurnRole(proxyInstance.address);
|
||||
await equipInstance.grantBurnRole(proxyInstance.address);
|
||||
await chipInstance.grantBurnRole(proxyInstance.address);
|
||||
console.log(
|
||||
`Allow proxy ${proxyInstance.address} to burn contract \n hero: ${heroInstance.address}, \n equip: ${equipInstance.address}, \n chip: ${chipInstance.address}`
|
||||
);
|
||||
const userProxyInstance = await UserEvolveFactory.deployed();
|
||||
if (!userProxyInstance) {
|
||||
console.error("no userProxyInstance");
|
||||
return;
|
||||
}
|
||||
await proxyInstance.addApprovalList(userProxyInstance.address);
|
||||
await userProxyInstance.init(proxyInstance.address);
|
||||
|
||||
// const boxInstance = await BEBoxMall.deployed();
|
||||
// if (!boxInstance) {
|
||||
// console.error("no boxInstance");
|
||||
// return;
|
||||
// }
|
||||
// await boxInstance.setPaymentReceivedAddress(config.market.mallFeeAddress);
|
||||
// console.log(
|
||||
// `update payment received address: ${config.market.mallFeeAddress}`
|
||||
// );
|
||||
|
||||
const nftMallInstance = await BENftMall.deployed();
|
||||
if (nftMallInstance) {
|
||||
await nftMallInstance.setFeeToAddress(config.market.feeToAddress);
|
||||
await nftMallInstance.setPaymentTokens(config.market.paymentTokens);
|
||||
await nftMallInstance.addNFTTokenSupport(heroInstance.address);
|
||||
await nftMallInstance.addNFTTokenSupport(equipInstance.address);
|
||||
await nftMallInstance.addNFTTokenSupport(chipInstance.address);
|
||||
await heroInstance.setMintFactory(nftMallInstance.address);
|
||||
await equipInstance.setMintFactory(nftMallInstance.address);
|
||||
await chipInstance.setMintFactory(nftMallInstance.address);
|
||||
console.log("update nftMallInstance settings success");
|
||||
}
|
||||
const lockerInstance = await NftChipLocker.deployed();
|
||||
if (lockerInstance) {
|
||||
await lockerInstance.addNFTTokenSupport(heroInstance.address);
|
||||
await lockerInstance.addNFTTokenSupport(equipInstance.address);
|
||||
await lockerInstance.addNFTTokenSupport(chipInstance.address);
|
||||
console.log("update NftChipLocker addNFTTokenSupport success");
|
||||
}
|
||||
callback(0);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
@ -3,6 +3,7 @@ const Coin = artifacts.require("tokens/erc20/BEUSDT");
|
||||
const Wallet = artifacts.require("core/BEMultiSigWallet");
|
||||
const Distributor = artifacts.require("logic/NftDistributor");
|
||||
const config = require("../config/config");
|
||||
const base = require("../scripts/base");
|
||||
|
||||
module.exports = async function (deployer, network, accounts) {
|
||||
await deployer.deploy(Badge, "BE Badge", "Badge", "4000");
|
||||
@ -11,6 +12,13 @@ module.exports = async function (deployer, network, accounts) {
|
||||
console.log("BEBadge successfully deployed. ");
|
||||
console.log("address: " + badgeInstance.address);
|
||||
}
|
||||
base.updateArray({
|
||||
name: "BEBadge",
|
||||
type: "erc721",
|
||||
json: "assets/contracts/BEBadge.json",
|
||||
address: badgeInstance.address,
|
||||
network,
|
||||
});
|
||||
await badgeInstance.updateBaseURI(config.token.baseTokenURI);
|
||||
await deployer.deploy(Coin, "BE test USDT", "USDT");
|
||||
const coinInstance = await Coin.deployed();
|
||||
@ -18,6 +26,13 @@ module.exports = async function (deployer, network, accounts) {
|
||||
console.log("BEUSDT successfully deployed. ");
|
||||
console.log("address: " + coinInstance.address);
|
||||
}
|
||||
base.updateArray({
|
||||
name: "BEUSDT",
|
||||
type: "erc20",
|
||||
json: "assets/contracts/BEUSDT.json",
|
||||
address: coinInstance.address,
|
||||
network,
|
||||
});
|
||||
await deployer.deploy(
|
||||
Wallet,
|
||||
60,
|
||||
@ -31,6 +46,13 @@ module.exports = async function (deployer, network, accounts) {
|
||||
console.log("BEMultiSigWallet successfully deployed.");
|
||||
console.log("address: " + walletInstance.address);
|
||||
}
|
||||
base.updateArray({
|
||||
name: "BEMultiSigWallet",
|
||||
type: "logic",
|
||||
json: "assets/contracts/BEMultiSigWallet.json",
|
||||
address: walletInstance.address,
|
||||
network,
|
||||
});
|
||||
await badgeInstance.setMintRole(walletInstance.address);
|
||||
console.log("success add wallet to badge's mint role");
|
||||
await coinInstance.setMintRole(walletInstance.address);
|
||||
@ -46,10 +68,18 @@ module.exports = async function (deployer, network, accounts) {
|
||||
console.log("NftDistributor successfully deployed.");
|
||||
console.log("address: " + distributorInstance.address);
|
||||
}
|
||||
base.updateArray({
|
||||
name: "NftDistributor",
|
||||
type: "logic",
|
||||
json: "assets/contracts/NftDistributor.json",
|
||||
address: distributorInstance.address,
|
||||
network,
|
||||
});
|
||||
await badgeInstance.setMintRole(distributorInstance.address);
|
||||
await distributorInstance.grantRole(
|
||||
"0xa076a07f65bcd51bcb15a0f01a65bc18f2d922acb81bcfd8af4caf5adb557091",
|
||||
walletInstance.address
|
||||
);
|
||||
console.log("success add distributor to badge's mint role");
|
||||
jetpack.write("./out.json", cfgs);
|
||||
};
|
||||
|
@ -1,11 +1,31 @@
|
||||
const Coin = artifacts.require('tokens/erc20/BECoin');
|
||||
const base = require("../scripts/base");
|
||||
|
||||
module.exports = async function (deployer, network, accounts) {
|
||||
const tokens = [
|
||||
{
|
||||
name: "CEC",
|
||||
desc: "CRYPTO ELITE'S COIN",
|
||||
limit: "10000000000000000000000000",
|
||||
},
|
||||
{ name: "CEG", desc: "CRYPTO ELITE'S GOLD", limit: 0 },
|
||||
];
|
||||
for (let i = 0, l = tokens.length; i < l; i++) {
|
||||
const Coin = artifacts.require("tokens/erc20/FT");
|
||||
const { name, desc, limit } = tokens[i];
|
||||
await deployer.deploy(Coin, desc, name, limit);
|
||||
|
||||
await deployer.deploy(Coin);
|
||||
const coinInstance = await Coin.deployed();
|
||||
if(coinInstance) {
|
||||
// tmpData.writeKeyVal('coin', coinInstance.address);
|
||||
console.log("BECoin successfully deployed.")
|
||||
const coinInstance = await Coin.deployed();
|
||||
if (coinInstance) {
|
||||
console.log(
|
||||
`${name} successfully deployed. address: ${coinInstance.address}`
|
||||
);
|
||||
}
|
||||
base.updateArray({
|
||||
name: name,
|
||||
type: "erc20",
|
||||
json: "assets/contracts/FT.json",
|
||||
address: coinInstance.address,
|
||||
network,
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -1,11 +0,0 @@
|
||||
const Coin = artifacts.require('tokens/erc20/BEGold');
|
||||
// const Coin = artifacts.require('tokens/erc20/BEUSDT');
|
||||
|
||||
module.exports = async function (deployer, network, accounts) {
|
||||
await deployer.deploy(Coin);
|
||||
const coinInstance = await Coin.deployed();
|
||||
if(coinInstance) {
|
||||
// tmpData.writeKeyVal('coin', coinInstance.address);
|
||||
console.log("BEGold successfully deployed.")
|
||||
}
|
||||
};
|
@ -1,10 +0,0 @@
|
||||
const Hero = artifacts.require("tokens/erc721/BEHero");
|
||||
const config = require("../config/config");
|
||||
|
||||
module.exports = async function (deployer, network, accounts) {
|
||||
await deployer.deploy(Hero);
|
||||
const heroInstance = await Hero.deployed();
|
||||
if (heroInstance) {
|
||||
console.log("BEHero successfully deployed.");
|
||||
}
|
||||
};
|
28
migrations/5_deploy_nft.js
Normal file
28
migrations/5_deploy_nft.js
Normal file
@ -0,0 +1,28 @@
|
||||
const config = require("../config/config");
|
||||
const base = require("../scripts/base");
|
||||
|
||||
module.exports = async function (deployer, network, accounts) {
|
||||
const tokens = [
|
||||
{ name: "HERO", desc: "CRYPTO ELITE'S HERO", limit: 0 },
|
||||
{ name: "WEAPON", desc: "CRYPTO ELITE'S WEAPON", limit: 0 },
|
||||
{ name: "CHIP", desc: "CRYPTO ELITE'S CHIP", limit: 0 },
|
||||
];
|
||||
for (let i = 0, l = tokens.length; i < l; i++) {
|
||||
const { name, desc, limit } = tokens[i];
|
||||
let Nft = artifacts.require("tokens/erc721/NFT");
|
||||
await deployer.deploy(Nft, desc, name, limit);
|
||||
const nftInstance = await Nft.deployed();
|
||||
if (nftInstance) {
|
||||
console.log(
|
||||
`${name} successfully deployed. address: ${nftInstance.address}`
|
||||
);
|
||||
}
|
||||
base.updateArray({
|
||||
name: name,
|
||||
type: "erc721",
|
||||
json: "assets/contracts/NFT.json",
|
||||
address: nftInstance.address,
|
||||
network,
|
||||
});
|
||||
}
|
||||
};
|
@ -1,10 +0,0 @@
|
||||
const Equip = artifacts.require("tokens/erc20/BEEquipment");
|
||||
const config = require("../config/config");
|
||||
|
||||
module.exports = async function (deployer, network, accounts) {
|
||||
await deployer.deploy(Equip);
|
||||
const equipInstance = await Equip.deployed();
|
||||
if (equipInstance) {
|
||||
console.log("Equip successfully deployed.");
|
||||
}
|
||||
};
|
22
migrations/6_deploy_factory.js
Normal file
22
migrations/6_deploy_factory.js
Normal file
@ -0,0 +1,22 @@
|
||||
const UserFactory = artifacts.require("logic/UserMinterFactory");
|
||||
const base = require("../scripts/base");
|
||||
|
||||
module.exports = async function (deployer, network, accounts) {
|
||||
await deployer.deploy(UserFactory);
|
||||
const userFactoryInstance = await UserFactory.deployed();
|
||||
if (userFactoryInstance) {
|
||||
console.log("User Mint Factory successfully deployed.");
|
||||
}
|
||||
|
||||
let cfgs = base.updateArray({
|
||||
name: "UserMinterFactory",
|
||||
type: "logic",
|
||||
json: "assets/contracts/UserMinterFactory.json",
|
||||
address: userFactoryInstance.address,
|
||||
network,
|
||||
});
|
||||
|
||||
// // update settings
|
||||
// for (let cfg of cfgs) {
|
||||
// }
|
||||
};
|
@ -1,10 +0,0 @@
|
||||
const Chip = artifacts.require("tokens/erc1155/BEChip1155");
|
||||
const config = require("../config/config");
|
||||
|
||||
module.exports = async function (deployer, network, accounts) {
|
||||
await deployer.deploy(Chip);
|
||||
const chipInstance = await Chip.deployed();
|
||||
if (chipInstance) {
|
||||
console.log("Chip successfully deployed.");
|
||||
}
|
||||
};
|
@ -1,4 +1,5 @@
|
||||
const MarketPlace = artifacts.require("market/BENftMarket");
|
||||
const base = require("../scripts/base");
|
||||
|
||||
module.exports = async function (deployer, network, accounts) {
|
||||
await deployer.deploy(MarketPlace);
|
||||
@ -6,4 +7,11 @@ module.exports = async function (deployer, network, accounts) {
|
||||
if (marketInstance) {
|
||||
console.log("MarketPlace successfully deployed.");
|
||||
}
|
||||
base.updateArray({
|
||||
name: "BENftMarket",
|
||||
type: "logic",
|
||||
json: "assets/contracts/BENftMarket.json",
|
||||
address: marketInstance.address,
|
||||
network,
|
||||
});
|
||||
};
|
@ -1,9 +0,0 @@
|
||||
const Shard = artifacts.require("chip1155/BEShard");
|
||||
|
||||
module.exports = async function (deployer, network, accounts) {
|
||||
await deployer.deploy(Shard);
|
||||
const shardInstance = await Shard.deployed();
|
||||
if (shardInstance) {
|
||||
console.log("Shard 1155 successfully deployed.");
|
||||
}
|
||||
};
|
@ -1,16 +0,0 @@
|
||||
const Factory = artifacts.require('logic/MinterFactory');
|
||||
const UserFactory = artifacts.require('logic/UserMinterFactory');
|
||||
|
||||
module.exports = async function (deployer, network, accounts) {
|
||||
await deployer.deploy(Factory);
|
||||
const factoryInstance = await Factory.deployed();
|
||||
if(factoryInstance) {
|
||||
console.log("Mint Factory successfully deployed.")
|
||||
}
|
||||
await deployer.deploy(UserFactory);
|
||||
const userFactoryInstance = await UserFactory.deployed();
|
||||
if(userFactoryInstance) {
|
||||
console.log("User Mint Factory successfully deployed.")
|
||||
}
|
||||
|
||||
}
|
56
out_arbitrum_testnet_dev.json
Normal file
56
out_arbitrum_testnet_dev.json
Normal file
@ -0,0 +1,56 @@
|
||||
[
|
||||
{
|
||||
"name": "CEC",
|
||||
"type": "erc20",
|
||||
"json": "assets/contracts/FT.json",
|
||||
"address": "0x8dd1439E0C3254b4543d6D68b3C0C891E5Bd2eCE"
|
||||
},
|
||||
{
|
||||
"name": "CEG",
|
||||
"type": "erc20",
|
||||
"json": "assets/contracts/FT.json",
|
||||
"address": "0x2C7221588D4FBac2585D71618CD540e74c7413B8"
|
||||
},
|
||||
{
|
||||
"name": "HERO",
|
||||
"type": "erc721",
|
||||
"json": "assets/contracts/NFT.json",
|
||||
"address": "0x376076491F4fa4139f6FFec8D4abdE92f186f312"
|
||||
},
|
||||
{
|
||||
"name": "WEAPON",
|
||||
"type": "erc721",
|
||||
"json": "assets/contracts/NFT.json",
|
||||
"address": "0xA89327d3ca77c1f3982a426fe5fB06bAEA7E383F"
|
||||
},
|
||||
{
|
||||
"name": "CHIP",
|
||||
"type": "erc721",
|
||||
"json": "assets/contracts/NFT.json",
|
||||
"address": "0x07Bad070e403a4Bad2Eec3BA3894c4524d3d2674"
|
||||
},
|
||||
{
|
||||
"name": "UserMinterFactory",
|
||||
"type": "logic",
|
||||
"json": "assets/contracts/UserMinterFactory.json",
|
||||
"address": "0x0155eA97330aFF0a9d26bd37C6D967D50c41B4e7"
|
||||
},
|
||||
{
|
||||
"name": "BEUSDT",
|
||||
"type": "erc20",
|
||||
"json": "assets/contracts/FT.json",
|
||||
"address": "0xaa34B79A0Ab433eaC900fB3CB9f191F5Cd27501D"
|
||||
},
|
||||
{
|
||||
"name": "BADGE",
|
||||
"type": "erc721",
|
||||
"json": "assets/contracts/BEBadge.json",
|
||||
"address": "0xB469331cEC98E52b7Eab07dFB586253bE232BBF7"
|
||||
},
|
||||
{
|
||||
"name": "BENftMarket",
|
||||
"type": "logic",
|
||||
"json": "assets/contracts/BENftMarket.json",
|
||||
"address": "0xb80E19c50747972E735c68C0BA5651AD952d70BC"
|
||||
}
|
||||
]
|
1407
package-lock.json
generated
1407
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -14,8 +14,9 @@
|
||||
"deploy:bsctest": "truffle migrate --network bsc_testnet --compile-none",
|
||||
"deploy:kcctest": "truffle migrate --network kcc_testnet --compile-none",
|
||||
"deploy:polygon_testnet": "truffle migrate --network polygon_testnet --compile-none",
|
||||
"deploy:arbitrum_testnet": "truffle migrate --network arbitrum_testnet --compile-none",
|
||||
"update:nft_sample": "npx truffle exec --network lan20 ./init_scripts/update_nft_setting.js",
|
||||
"deploy:dev:arbitrum_testnet": "DEPLOY_ENV=dev truffle migrate --network arbitrum_testnet --compile-none",
|
||||
"deploy:release:arbitrum_testnet": "DEPLOY_ENV=release truffle migrate --network arbitrum_testnet --compile-none",
|
||||
"update:nft_setting": "npx truffle exec --network arbitrum_testnet ./init_scripts/update_nft_setting.js",
|
||||
"mint_presale:dev": "npx truffle exec --network development ./init_scripts/generate_presalebox.js",
|
||||
"size": "truffle run contract-size"
|
||||
},
|
||||
@ -32,6 +33,7 @@
|
||||
"truffle-plugin-verify": "^0.5.25"
|
||||
},
|
||||
"dependencies": {
|
||||
"@openzeppelin/contracts": "^4.5.0"
|
||||
"@openzeppelin/contracts": "^4.5.0",
|
||||
"fs-jetpack": "^5.1.0"
|
||||
}
|
||||
}
|
||||
|
30
scripts/base.js
Normal file
30
scripts/base.js
Normal file
@ -0,0 +1,30 @@
|
||||
const jetpack = require("fs-jetpack");
|
||||
|
||||
module.exports = {
|
||||
updateArray: function ({ name, type, json, address, network }) {
|
||||
let env = process.env.NODE_ENV || "dev";
|
||||
const filename = `./out_${network}_${env}.json`;
|
||||
let cfgs = jetpack.read(filename, "json");
|
||||
cfgs = cfgs || [];
|
||||
if (cfgs.find((item) => item.name === name)) {
|
||||
cfgs.slice(
|
||||
cfgs.findIndex((item) => item.name === name),
|
||||
1
|
||||
);
|
||||
}
|
||||
cfgs.push({
|
||||
name,
|
||||
type,
|
||||
json,
|
||||
address,
|
||||
});
|
||||
jetpack.write(filename, cfgs);
|
||||
return cfgs;
|
||||
},
|
||||
|
||||
loadData: function ({ network }) {
|
||||
let env = process.env.NODE_ENV || "dev";
|
||||
const filename = `./out_${network}_${env}.json`;
|
||||
return jetpack.read(filename, "json");
|
||||
},
|
||||
};
|
@ -123,7 +123,8 @@ module.exports = {
|
||||
provider: () =>
|
||||
new HDWalletProvider({
|
||||
privateKeys: [kccTestnetKey],
|
||||
providerOrUrl: `https://arbitrum-goerli.public.blastapi.io`,
|
||||
// providerOrUrl: `https://arbitrum-goerli.public.blastapi.io`,
|
||||
providerOrUrl: "https://arbitrum-goerli.publicnode.com",
|
||||
pollingInterval: 8000,
|
||||
}),
|
||||
gasPrice: 28000000000,
|
||||
|
Loading…
x
Reference in New Issue
Block a user