增加nft销毁proxy, 重构代码
This commit is contained in:
parent
723c679676
commit
dd9d251cba
10497
build/contracts/BEBase.json
Normal file
10497
build/contracts/BEBase.json
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -18080,12 +18080,12 @@
|
||||
}
|
||||
},
|
||||
"links": {},
|
||||
"address": "0x95B4b95B8EbCcaBe87ad6D9D899257863ed01B50",
|
||||
"transactionHash": "0xc2b0ed20a0465dbeeaabdd904fce2031c988505843df5d985d0a96e968fc7811"
|
||||
"address": "0xAD5D74570Ad4ce647FB3a46426aA33bDAD614E55",
|
||||
"transactionHash": "0xc713f2402f6c9ac9475f92fc06f817a40e58e682e72d12f91f97ed791efa740c"
|
||||
}
|
||||
},
|
||||
"schemaVersion": "3.4.4",
|
||||
"updatedAt": "2022-01-12T06:52:32.682Z",
|
||||
"updatedAt": "2022-01-12T09:15:06.378Z",
|
||||
"networkType": "ethereum",
|
||||
"devdoc": {
|
||||
"kind": "dev",
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
9110
build/contracts/EvolveProxy.json
Normal file
9110
build/contracts/EvolveProxy.json
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -30651,12 +30651,12 @@
|
||||
}
|
||||
},
|
||||
"links": {},
|
||||
"address": "0x7a2039467d583d76F8378e493Df2C773581a2992",
|
||||
"transactionHash": "0x35e8d2407d93658539882e004aa3a31b7c4c4e6c2c3baa83b7361fce67e01adf"
|
||||
"address": "0x63D79b997de9B7a3A6E06E79b1DC017658d0DEeE",
|
||||
"transactionHash": "0x383624bf213c52af24b13a8dd4261d1615aef48f29add06a9bce2c8fc529be5c"
|
||||
}
|
||||
},
|
||||
"schemaVersion": "3.4.4",
|
||||
"updatedAt": "2022-01-12T06:52:32.666Z",
|
||||
"updatedAt": "2022-01-12T09:15:06.361Z",
|
||||
"networkType": "ethereum",
|
||||
"devdoc": {
|
||||
"kind": "dev",
|
||||
|
@ -2323,12 +2323,12 @@
|
||||
"1338": {
|
||||
"events": {},
|
||||
"links": {},
|
||||
"address": "0xc2976420A0654F22566e70c576a7F550F2Ae5C6A",
|
||||
"transactionHash": "0xa0c8cff94132f9bd0e386edc88811015987e96817f6ab22391bf074b46f994b5"
|
||||
"address": "0x6078d24213D93A12d8e315b799c8c60E0EeE0490",
|
||||
"transactionHash": "0xb242b36c10edf8000a85589ca4c8cbf7296a2f0feac00e4fff4524910b006aed"
|
||||
}
|
||||
},
|
||||
"schemaVersion": "3.4.4",
|
||||
"updatedAt": "2022-01-12T06:52:32.700Z",
|
||||
"updatedAt": "2022-01-12T09:15:06.407Z",
|
||||
"networkType": "ethereum",
|
||||
"devdoc": {
|
||||
"kind": "dev",
|
||||
|
File diff suppressed because one or more lines are too long
187
contracts/BEBase.sol
Normal file
187
contracts/BEBase.sol
Normal file
@ -0,0 +1,187 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.0;
|
||||
import "@openzeppelin/contracts/access/Ownable.sol";
|
||||
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
|
||||
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
|
||||
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
|
||||
|
||||
abstract contract BEBase is ERC721, AccessControlEnumerable, ERC721Enumerable, Ownable {
|
||||
mapping(address => bool) public approvalWhitelists;
|
||||
mapping(uint256 => bool) public lockedTokens;
|
||||
string private _baseTokenURI;
|
||||
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
|
||||
bytes32 public constant BURN_ROLE = keccak256("BURN_ROLE");
|
||||
|
||||
|
||||
function _baseURI() internal view virtual override returns (string memory) {
|
||||
return _baseTokenURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Creates a new token for `to`. Its token ID will be automatically
|
||||
* assigned (and available on the emitted {IERC721-Transfer} event), and the token
|
||||
* URI autogenerated based on the base URI passed at construction.
|
||||
*
|
||||
* See {ERC721-_mint}.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - the caller must have the `MINTER_ROLE`.
|
||||
*/
|
||||
function mint(address to, uint256 tokenId) public virtual {
|
||||
require(
|
||||
hasRole(MINTER_ROLE, _msgSender()),
|
||||
"Must have minter role to mint"
|
||||
);
|
||||
require(!_exists(tokenId), "Must have unique tokenId");
|
||||
// We cannot just use balanceOf to create the new tokenId because tokens
|
||||
// can be burned (destroyed), so we need a separate counter.
|
||||
_mint(to, tokenId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev See {IERC721-isApprovedForAll}.
|
||||
*/
|
||||
function isApprovedForAll(address owner, address operator)
|
||||
public
|
||||
view
|
||||
override
|
||||
returns (bool)
|
||||
{
|
||||
if (approvalWhitelists[operator] == true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.isApprovedForAll(owner, operator);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Allow operation to reduce gas fee.
|
||||
*/
|
||||
function addApprovalWhitelist(address proxy) public onlyOwner {
|
||||
require(approvalWhitelists[proxy] == false, "Invalid proxy address");
|
||||
|
||||
approvalWhitelists[proxy] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Remove operation from approval list.
|
||||
*/
|
||||
function removeApprovalWhitelist(address proxy) public onlyOwner {
|
||||
approvalWhitelists[proxy] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Add factory to mint item
|
||||
*/
|
||||
function setMintFactory(address factory) public onlyOwner {
|
||||
_setupRole(MINTER_ROLE, factory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Remove factory
|
||||
*/
|
||||
function removeMintFactory(address factory) public onlyOwner {
|
||||
revokeRole(MINTER_ROLE, factory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Lock token to use in game or for rental
|
||||
*/
|
||||
function lock(uint256 tokenId) public {
|
||||
require(
|
||||
approvalWhitelists[_msgSender()],
|
||||
"Must be valid approval whitelist"
|
||||
);
|
||||
require(_exists(tokenId), "Must be valid tokenId");
|
||||
require(!lockedTokens[tokenId], "Token has already locked");
|
||||
lockedTokens[tokenId] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Unlock token to use blockchain or sale on marketplace
|
||||
*/
|
||||
function unlock(uint256 tokenId) public {
|
||||
require(
|
||||
approvalWhitelists[_msgSender()],
|
||||
"Must be valid approval whitelist"
|
||||
);
|
||||
require(_exists(tokenId), "Must be valid tokenId");
|
||||
require(lockedTokens[tokenId], "Token has already unlocked");
|
||||
lockedTokens[tokenId] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Get lock status
|
||||
*/
|
||||
function isLocked(uint256 tokenId) public view returns (bool) {
|
||||
return lockedTokens[tokenId];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Set token URI
|
||||
*/
|
||||
function updateBaseURI(string calldata baseTokenURI) public onlyOwner {
|
||||
_baseTokenURI = baseTokenURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev See {IERC165-_beforeTokenTransfer}.
|
||||
*/
|
||||
function _beforeTokenTransfer(
|
||||
address from,
|
||||
address to,
|
||||
uint256 tokenId
|
||||
) internal virtual override(ERC721, 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(AccessControlEnumerable, ERC721, ERC721Enumerable)
|
||||
returns (bool)
|
||||
{
|
||||
return super.supportsInterface(interfaceId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @dev Burns `tokenId`.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - The caller must own `tokenId` or be an approved operator.
|
||||
*/
|
||||
function burn(address owner, uint256 tokenId) public virtual {
|
||||
require(
|
||||
hasRole(BURN_ROLE, _msgSender()),
|
||||
"Must have burn role to burn"
|
||||
);
|
||||
require(_exists(tokenId), "TokenId not exists");
|
||||
require(
|
||||
ownerOf(tokenId) == owner,
|
||||
"current address is not owner of this item now"
|
||||
);
|
||||
_burn(tokenId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Add factory to burn item
|
||||
*/
|
||||
function setBurnProxy(address proxy) public onlyOwner {
|
||||
_setupRole(BURN_ROLE, proxy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Remove proxy
|
||||
*/
|
||||
function removeBurnProxy(address proxy) public onlyOwner {
|
||||
revokeRole(BURN_ROLE, proxy);
|
||||
}
|
||||
}
|
@ -1,152 +1,8 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.0;
|
||||
import "@openzeppelin/contracts/access/Ownable.sol";
|
||||
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
|
||||
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
|
||||
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
|
||||
|
||||
contract BEChip is ERC721, AccessControlEnumerable, ERC721Enumerable, Ownable {
|
||||
mapping(address => bool) public approvalWhitelists;
|
||||
mapping(uint256 => bool) public lockedTokens;
|
||||
string private _baseTokenURI;
|
||||
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
|
||||
import "./BEBase.sol";
|
||||
|
||||
contract BEChip is BEBase{
|
||||
constructor() ERC721("Blissful Elites Chip", "BECP") {}
|
||||
|
||||
function _baseURI() internal view virtual override returns (string memory) {
|
||||
return _baseTokenURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Creates a new token for `to`. Its token ID will be automatically
|
||||
* assigned (and available on the emitted {IERC721-Transfer} event), and the token
|
||||
* URI autogenerated based on the base URI passed at construction.
|
||||
*
|
||||
* See {ERC721-_mint}.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - the caller must have the `MINTER_ROLE`.
|
||||
*/
|
||||
function mint(address to, uint256 tokenId) public virtual {
|
||||
require(
|
||||
hasRole(MINTER_ROLE, _msgSender()),
|
||||
"Must have minter role to mint"
|
||||
);
|
||||
require(!_exists(tokenId), "Must have unique tokenId");
|
||||
// We cannot just use balanceOf to create the new tokenId because tokens
|
||||
// can be burned (destroyed), so we need a separate counter.
|
||||
_mint(to, tokenId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev See {IERC721-isApprovedForAll}.
|
||||
*/
|
||||
function isApprovedForAll(address owner, address operator)
|
||||
public
|
||||
view
|
||||
override
|
||||
returns (bool)
|
||||
{
|
||||
if (approvalWhitelists[operator] == true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.isApprovedForAll(owner, operator);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Allow operation to reduce gas fee.
|
||||
*/
|
||||
function addApprovalWhitelist(address proxy) public onlyOwner {
|
||||
require(approvalWhitelists[proxy] == false, "Invalid proxy address");
|
||||
|
||||
approvalWhitelists[proxy] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Remove operation from approval list.
|
||||
*/
|
||||
function removeApprovalWhitelist(address proxy) public onlyOwner {
|
||||
approvalWhitelists[proxy] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Add factory to mint item
|
||||
*/
|
||||
function setMintFactory(address factory) public onlyOwner {
|
||||
_setupRole(MINTER_ROLE, factory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Remove factory
|
||||
*/
|
||||
function removeMintFactory(address factory) public onlyOwner {
|
||||
revokeRole(MINTER_ROLE, factory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Lock token to use in game or for rental
|
||||
*/
|
||||
function lock(uint256 tokenId) public {
|
||||
require(
|
||||
approvalWhitelists[_msgSender()],
|
||||
"Must be valid approval whitelist"
|
||||
);
|
||||
require(_exists(tokenId), "Must be valid tokenId");
|
||||
require(!lockedTokens[tokenId], "Token has already locked");
|
||||
lockedTokens[tokenId] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Unlock token to use blockchain or sale on marketplace
|
||||
*/
|
||||
function unlock(uint256 tokenId) public {
|
||||
require(
|
||||
approvalWhitelists[_msgSender()],
|
||||
"Must be valid approval whitelist"
|
||||
);
|
||||
require(_exists(tokenId), "Must be valid tokenId");
|
||||
require(lockedTokens[tokenId], "Token has already unlocked");
|
||||
lockedTokens[tokenId] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Get lock status
|
||||
*/
|
||||
function isLocked(uint256 tokenId) public view returns (bool) {
|
||||
return lockedTokens[tokenId];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Set token URI
|
||||
*/
|
||||
function updateBaseURI(string calldata baseTokenURI) public onlyOwner {
|
||||
_baseTokenURI = baseTokenURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev See {IERC165-_beforeTokenTransfer}.
|
||||
*/
|
||||
function _beforeTokenTransfer(
|
||||
address from,
|
||||
address to,
|
||||
uint256 tokenId
|
||||
) internal virtual override(ERC721, 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(AccessControlEnumerable, ERC721, ERC721Enumerable)
|
||||
returns (bool)
|
||||
{
|
||||
return super.supportsInterface(interfaceId);
|
||||
}
|
||||
}
|
||||
|
@ -1,152 +1,8 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.0;
|
||||
import "@openzeppelin/contracts/access/Ownable.sol";
|
||||
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
|
||||
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
|
||||
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
|
||||
|
||||
contract BEEquipment is ERC721, AccessControlEnumerable, ERC721Enumerable, Ownable {
|
||||
mapping(address => bool) public approvalWhitelists;
|
||||
mapping(uint256 => bool) public lockedTokens;
|
||||
string private _baseTokenURI;
|
||||
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
|
||||
import "./BEBase.sol";
|
||||
|
||||
contract BEEquipment is BEBase{
|
||||
constructor() ERC721("Blissful Elites Equipment", "BEE") {}
|
||||
|
||||
function _baseURI() internal view virtual override returns (string memory) {
|
||||
return _baseTokenURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Creates a new token for `to`. Its token ID will be automatically
|
||||
* assigned (and available on the emitted {IERC721-Transfer} event), and the token
|
||||
* URI autogenerated based on the base URI passed at construction.
|
||||
*
|
||||
* See {ERC721-_mint}.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - the caller must have the `MINTER_ROLE`.
|
||||
*/
|
||||
function mint(address to, uint256 tokenId) public virtual {
|
||||
require(
|
||||
hasRole(MINTER_ROLE, _msgSender()),
|
||||
"Must have minter role to mint"
|
||||
);
|
||||
require(!_exists(tokenId), "Must have unique tokenId");
|
||||
// We cannot just use balanceOf to create the new tokenId because tokens
|
||||
// can be burned (destroyed), so we need a separate counter.
|
||||
_mint(to, tokenId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev See {IERC721-isApprovedForAll}.
|
||||
*/
|
||||
function isApprovedForAll(address owner, address operator)
|
||||
public
|
||||
view
|
||||
override
|
||||
returns (bool)
|
||||
{
|
||||
if (approvalWhitelists[operator] == true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.isApprovedForAll(owner, operator);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Allow operation to reduce gas fee.
|
||||
*/
|
||||
function addApprovalWhitelist(address proxy) public onlyOwner {
|
||||
require(approvalWhitelists[proxy] == false, "Invalid proxy address");
|
||||
|
||||
approvalWhitelists[proxy] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Remove operation from approval list.
|
||||
*/
|
||||
function removeApprovalWhitelist(address proxy) public onlyOwner {
|
||||
approvalWhitelists[proxy] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Add factory to mint item
|
||||
*/
|
||||
function setMintFactory(address factory) public onlyOwner {
|
||||
_setupRole(MINTER_ROLE, factory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Remove factory
|
||||
*/
|
||||
function removeMintFactory(address factory) public onlyOwner {
|
||||
revokeRole(MINTER_ROLE, factory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Lock token to use in game or for rental
|
||||
*/
|
||||
function lock(uint256 tokenId) public {
|
||||
require(
|
||||
approvalWhitelists[_msgSender()],
|
||||
"Must be valid approval whitelist"
|
||||
);
|
||||
require(_exists(tokenId), "Must be valid tokenId");
|
||||
require(!lockedTokens[tokenId], "Token has already locked");
|
||||
lockedTokens[tokenId] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Unlock token to use blockchain or sale on marketplace
|
||||
*/
|
||||
function unlock(uint256 tokenId) public {
|
||||
require(
|
||||
approvalWhitelists[_msgSender()],
|
||||
"Must be valid approval whitelist"
|
||||
);
|
||||
require(_exists(tokenId), "Must be valid tokenId");
|
||||
require(lockedTokens[tokenId], "Token has already unlocked");
|
||||
lockedTokens[tokenId] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Get lock status
|
||||
*/
|
||||
function isLocked(uint256 tokenId) public view returns (bool) {
|
||||
return lockedTokens[tokenId];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Set token URI
|
||||
*/
|
||||
function updateBaseURI(string calldata baseTokenURI) public onlyOwner {
|
||||
_baseTokenURI = baseTokenURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev See {IERC165-_beforeTokenTransfer}.
|
||||
*/
|
||||
function _beforeTokenTransfer(
|
||||
address from,
|
||||
address to,
|
||||
uint256 tokenId
|
||||
) internal virtual override(ERC721, 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(AccessControlEnumerable, ERC721, ERC721Enumerable)
|
||||
returns (bool)
|
||||
{
|
||||
return super.supportsInterface(interfaceId);
|
||||
}
|
||||
}
|
||||
|
@ -1,152 +1,8 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.0;
|
||||
import "@openzeppelin/contracts/access/Ownable.sol";
|
||||
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
|
||||
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
|
||||
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
|
||||
|
||||
contract BEHero is ERC721, AccessControlEnumerable, ERC721Enumerable, Ownable {
|
||||
mapping(address => bool) public approvalWhitelists;
|
||||
mapping(uint256 => bool) public lockedTokens;
|
||||
string private _baseTokenURI;
|
||||
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
|
||||
import "./BEBase.sol";
|
||||
|
||||
contract BEHero is BEBase{
|
||||
constructor() ERC721("Blissful Elites Hero", "BEH") {}
|
||||
|
||||
function _baseURI() internal view virtual override returns (string memory) {
|
||||
return _baseTokenURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Creates a new token for `to`. Its token ID will be automatically
|
||||
* assigned (and available on the emitted {IERC721-Transfer} event), and the token
|
||||
* URI autogenerated based on the base URI passed at construction.
|
||||
*
|
||||
* See {ERC721-_mint}.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - the caller must have the `MINTER_ROLE`.
|
||||
*/
|
||||
function mint(address to, uint256 tokenId) public virtual {
|
||||
require(
|
||||
hasRole(MINTER_ROLE, _msgSender()),
|
||||
"Must have minter role to mint"
|
||||
);
|
||||
require(!_exists(tokenId), "Must have unique tokenId");
|
||||
// We cannot just use balanceOf to create the new tokenId because tokens
|
||||
// can be burned (destroyed), so we need a separate counter.
|
||||
_mint(to, tokenId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev See {IERC721-isApprovedForAll}.
|
||||
*/
|
||||
function isApprovedForAll(address owner, address operator)
|
||||
public
|
||||
view
|
||||
override
|
||||
returns (bool)
|
||||
{
|
||||
if (approvalWhitelists[operator] == true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.isApprovedForAll(owner, operator);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Allow operation to reduce gas fee.
|
||||
*/
|
||||
function addApprovalWhitelist(address proxy) public onlyOwner {
|
||||
require(approvalWhitelists[proxy] == false, "Invalid proxy address");
|
||||
|
||||
approvalWhitelists[proxy] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Remove operation from approval list.
|
||||
*/
|
||||
function removeApprovalWhitelist(address proxy) public onlyOwner {
|
||||
approvalWhitelists[proxy] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Add factory to mint item
|
||||
*/
|
||||
function setMintFactory(address factory) public onlyOwner {
|
||||
_setupRole(MINTER_ROLE, factory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Remove factory
|
||||
*/
|
||||
function removeMintFactory(address factory) public onlyOwner {
|
||||
revokeRole(MINTER_ROLE, factory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Lock token to use in game or for rental
|
||||
*/
|
||||
function lock(uint256 tokenId) public {
|
||||
require(
|
||||
approvalWhitelists[_msgSender()],
|
||||
"Must be valid approval whitelist"
|
||||
);
|
||||
require(_exists(tokenId), "Must be valid tokenId");
|
||||
require(!lockedTokens[tokenId], "Token has already locked");
|
||||
lockedTokens[tokenId] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Unlock token to use blockchain or sale on marketplace
|
||||
*/
|
||||
function unlock(uint256 tokenId) public {
|
||||
require(
|
||||
approvalWhitelists[_msgSender()],
|
||||
"Must be valid approval whitelist"
|
||||
);
|
||||
require(_exists(tokenId), "Must be valid tokenId");
|
||||
require(lockedTokens[tokenId], "Token has already unlocked");
|
||||
lockedTokens[tokenId] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Get lock status
|
||||
*/
|
||||
function isLocked(uint256 tokenId) public view returns (bool) {
|
||||
return lockedTokens[tokenId];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Set token URI
|
||||
*/
|
||||
function updateBaseURI(string calldata baseTokenURI) public onlyOwner {
|
||||
_baseTokenURI = baseTokenURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev See {IERC165-_beforeTokenTransfer}.
|
||||
*/
|
||||
function _beforeTokenTransfer(
|
||||
address from,
|
||||
address to,
|
||||
uint256 tokenId
|
||||
) internal virtual override(ERC721, 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(AccessControlEnumerable, ERC721, ERC721Enumerable)
|
||||
returns (bool)
|
||||
{
|
||||
return super.supportsInterface(interfaceId);
|
||||
}
|
||||
}
|
||||
}
|
66
contracts/EvolveProxy.sol
Normal file
66
contracts/EvolveProxy.sol
Normal file
@ -0,0 +1,66 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.0;
|
||||
import "@openzeppelin/contracts/access/Ownable.sol";
|
||||
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
|
||||
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
|
||||
|
||||
interface IBurnableERC721 is IERC721 {
|
||||
function burn(address owner, uint256 tokenId) external;
|
||||
}
|
||||
contract EvolveProxy is Ownable, Initializable {
|
||||
|
||||
IBurnableERC721 public hero;
|
||||
IBurnableERC721 public equip;
|
||||
IBurnableERC721 public chip;
|
||||
|
||||
bool public publicEvolveAllowed;
|
||||
event TokenEvolved(
|
||||
address contractAddress,
|
||||
address owner,
|
||||
uint256[3] tokenIds
|
||||
);
|
||||
|
||||
|
||||
function init(address[3] calldata _erc721s) external initializer onlyOwner {
|
||||
hero = IBurnableERC721(_erc721s[0]);
|
||||
equip = IBurnableERC721(_erc721s[1]);
|
||||
chip = IBurnableERC721(_erc721s[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev evolve function to Blissful Elites Hero NFT
|
||||
* tokenIds: [hero_to_evolve, hero_for_food, chip]
|
||||
*/
|
||||
function evolveHero(address owner, uint256[3] calldata tokenIds) public onlyOwner returns (bool){
|
||||
require(publicEvolveAllowed);
|
||||
hero.burn(owner, tokenIds[1]);
|
||||
if (tokenIds[2] > 0) {
|
||||
chip.burn(owner, tokenIds[1]);
|
||||
}
|
||||
emit TokenEvolved(address(hero), owner, tokenIds);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev evolve function to Blissful Elites Equip NFT
|
||||
* tokenIds: [equip_to_evolve, equip_for_food, chip]
|
||||
*/
|
||||
function evolveEquip(address owner, uint256[3] calldata tokenIds) public onlyOwner returns (bool){
|
||||
require(publicEvolveAllowed);
|
||||
equip.burn(owner, tokenIds[1]);
|
||||
if (tokenIds[2] > 0) {
|
||||
chip.burn(owner, tokenIds[1]);
|
||||
}
|
||||
emit TokenEvolved(address(equip), owner, tokenIds);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @dev function to allow user mint items
|
||||
*/
|
||||
function allowPublicEvolve() public onlyOwner {
|
||||
publicEvolveAllowed = true;
|
||||
}
|
||||
|
||||
}
|
@ -21,7 +21,7 @@ contract MinterFactory is Ownable, Initializable {
|
||||
uint256 indexed tokenId
|
||||
);
|
||||
|
||||
function init(address[] calldata _erc721s) external initializer onlyOwner {
|
||||
function init(address[3] calldata _erc721s) external initializer onlyOwner {
|
||||
hero = IMintableERC721(_erc721s[0]);
|
||||
equip = IMintableERC721(_erc721s[1]);
|
||||
chip = IMintableERC721(_erc721s[2]);
|
||||
|
@ -5,6 +5,7 @@ const Factory = artifacts.require('MinterFactory');
|
||||
const MarketPlace = artifacts.require('MarketPlace');
|
||||
const Coin = artifacts.require('BECoin');
|
||||
const Box = artifacts.require('BEBoxMall');
|
||||
const EvolveProxy = artifacts.require('EvolveProxy');
|
||||
|
||||
module.exports = async function (deployer, network, accounts) {
|
||||
const account = accounts[0];
|
||||
@ -55,6 +56,27 @@ module.exports = async function (deployer, network, accounts) {
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
await deployer.deploy(EvolveProxy);
|
||||
const proxyInstance = await EvolveProxy.deployed();
|
||||
if(proxyInstance) {
|
||||
console.log("EvolveProxy successfully deployed.")
|
||||
}
|
||||
try {
|
||||
proxyInstance.init([
|
||||
heroInstance.address,
|
||||
equipInstance.address,
|
||||
chipInstance.address
|
||||
])
|
||||
heroInstance.setBurnProxy(proxyInstance.address);
|
||||
equipInstance.setBurnProxy(proxyInstance.address);
|
||||
chipInstance.setBurnProxy(proxyInstance.address);
|
||||
console.log(
|
||||
`Allow proxy ${proxyInstance.address} to burn contract \n hero: ${heroInstance.address}, \n equip: ${equipInstance.address}, \n chip: ${chipInstance.address}`
|
||||
);
|
||||
} catch(err) {
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
|
||||
|
||||
await deployer.deploy(MarketPlace);
|
||||
@ -104,6 +126,7 @@ module.exports = async function (deployer, network, accounts) {
|
||||
jsons.push({name: 'factory', json: 'assets/contracts/MinterFactory.json', address: factoryInstance.address})
|
||||
jsons.push({name: 'market', json: 'assets/contracts/MarketPlace.json', address: marketInstance.address})
|
||||
jsons.push({name: 'mall', json: 'assets/contracts/BEBoxMall.json', address: boxInstance.address})
|
||||
jsons.push({name: 'proxy', json: 'assets/contracts/EvolveProxy.json', address: proxyInstance.address})
|
||||
console.log(jsons);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user