// SPDX-License-Identifier: MIT pragma solidity 0.8.10; 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 to, uint256[3] calldata tokenIds) external { require((publicEvolveAllowed && _msgSender() == to) || _msgSender() == owner()); require(hero.ownerOf(tokenIds[0]) == to, "current address is not owner of this hero now"); hero.burn(to, tokenIds[1]); if (tokenIds[2] > 0) { chip.burn(to, tokenIds[2]); } emit TokenEvolved(address(hero), to, tokenIds[0], tokenIds[1], tokenIds[2]); } /** * @dev evolve function to Blissful Elites Equip NFT * tokenIds: [equip_to_evolve, equip_for_burn, chip] */ function evolveEquip(address to, uint256[3] calldata tokenIds) external{ require((publicEvolveAllowed && _msgSender() == to) || _msgSender() == owner()); require(equip.ownerOf(tokenIds[0]) == to, "current address is not owner of this equipment now"); equip.burn(to, tokenIds[1]); if (tokenIds[2] > 0) { chip.burn(to, tokenIds[2]); } emit TokenEvolved(address(equip), to, tokenIds[0], tokenIds[1], tokenIds[2]); } /** * @dev function to update allow user evolve items */ function updatePublicEvolve(bool val) external onlyOwner { publicEvolveAllowed = val; } }