68 lines
2.0 KiB
Solidity
68 lines
2.0 KiB
Solidity
// 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 indexed tokenEvolved,
|
|
uint256 tokenBurned,
|
|
uint256 chip
|
|
);
|
|
|
|
|
|
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_burn, 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[2]);
|
|
}
|
|
emit TokenEvolved(address(hero), owner, tokenIds[0], tokenIds[1], tokenIds[2]);
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* @dev evolve function to Blissful Elites Equip NFT
|
|
* tokenIds: [equip_to_evolve, equip_for_burn, 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[2]);
|
|
}
|
|
emit TokenEvolved(address(equip), owner, tokenIds[0], tokenIds[1], tokenIds[2]);
|
|
return true;
|
|
}
|
|
|
|
|
|
/**
|
|
* @dev function to allow user mint items
|
|
*/
|
|
function allowPublicEvolve() public onlyOwner {
|
|
publicEvolveAllowed = true;
|
|
}
|
|
|
|
} |