From 0a2a4c97dea53e608bc2210f653180db5b61da37 Mon Sep 17 00:00:00 2001 From: cebgcontract <99630598+cebgcontract@users.noreply.github.com> Date: Wed, 10 Aug 2022 11:57:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E4=BA=9B=E5=BC=95?= =?UTF-8?q?=E7=94=A8=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contracts/interfaces/IBEERC721.sol | 1 + contracts/logic/EvolveProxy.sol | 16 +++++++--------- contracts/logic/MinterFactory.sol | 16 +++++++--------- contracts/logic/MysteryBoxProxy.sol | 22 +++++++++------------- contracts/logic/NFTActivateProxy.sol | 24 ++++++++++-------------- 5 files changed, 34 insertions(+), 45 deletions(-) diff --git a/contracts/interfaces/IBEERC721.sol b/contracts/interfaces/IBEERC721.sol index 944788d..ab9fbf7 100644 --- a/contracts/interfaces/IBEERC721.sol +++ b/contracts/interfaces/IBEERC721.sol @@ -6,5 +6,6 @@ import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; interface IBEERC721 is IERC721 { + function mint(address to, uint256 tokenId) external; function burn(address owner, uint256 tokenId) external; } \ No newline at end of file diff --git a/contracts/logic/EvolveProxy.sol b/contracts/logic/EvolveProxy.sol index b637e9b..83a3615 100644 --- a/contracts/logic/EvolveProxy.sol +++ b/contracts/logic/EvolveProxy.sol @@ -3,19 +3,17 @@ 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"; +import "../interfaces/IBEERC721.sol"; import "../core/HasSignature.sol"; // this contract will transfer ownership to BETimelockController after deployed // all onlyowner method would add timelock -interface IBurnableERC721 is IERC721 { - function burn(address owner, uint256 tokenId) external; -} contract EvolveProxy is Ownable, Initializable, HasSignature { - IBurnableERC721 public hero; - IBurnableERC721 public equip; - IBurnableERC721 public chip; + IBEERC721 public hero; + IBEERC721 public equip; + IBEERC721 public chip; mapping(bytes => bool) public usedSignatures; @@ -34,9 +32,9 @@ contract EvolveProxy is Ownable, Initializable, HasSignature { } function init(address[3] calldata _erc721s) external initializer onlyOwner { - hero = IBurnableERC721(_erc721s[0]); - equip = IBurnableERC721(_erc721s[1]); - chip = IBurnableERC721(_erc721s[2]); + hero = IBEERC721(_erc721s[0]); + equip = IBEERC721(_erc721s[1]); + chip = IBEERC721(_erc721s[2]); } /** diff --git a/contracts/logic/MinterFactory.sol b/contracts/logic/MinterFactory.sol index e3cbddb..593f2f7 100644 --- a/contracts/logic/MinterFactory.sol +++ b/contracts/logic/MinterFactory.sol @@ -3,16 +3,14 @@ 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"; +import "../interfaces/IBEERC721.sol"; -interface IMintableERC721 is IERC721 { - function mint(address to, uint256 tokenId) external; -} contract MinterFactory is Ownable, Initializable { // NFT contract - IMintableERC721 public hero; - IMintableERC721 public equip; - IMintableERC721 public chip; + IBEERC721 public hero; + IBEERC721 public equip; + IBEERC721 public chip; event TokenMinted( @@ -22,9 +20,9 @@ contract MinterFactory is Ownable, Initializable { ); function init(address[3] calldata _erc721s) external initializer onlyOwner { - hero = IMintableERC721(_erc721s[0]); - equip = IMintableERC721(_erc721s[1]); - chip = IMintableERC721(_erc721s[2]); + hero = IBEERC721(_erc721s[0]); + equip = IBEERC721(_erc721s[1]); + chip = IBEERC721(_erc721s[2]); } /** diff --git a/contracts/logic/MysteryBoxProxy.sol b/contracts/logic/MysteryBoxProxy.sol index bd72376..619a692 100644 --- a/contracts/logic/MysteryBoxProxy.sol +++ b/contracts/logic/MysteryBoxProxy.sol @@ -4,18 +4,14 @@ 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"; +import "../interfaces/IBEERC721.sol"; import "../core/HasSignature.sol"; -interface IMintableERC721 is IERC721 { - function mint(address to, uint256 tokenId) external; - function burn(address owner, uint256 tokenId) external; -} - contract MysteryBoxProxy is Ownable, Initializable, HasSignature { - IMintableERC721 public box; - IMintableERC721 public hero; - IMintableERC721 public equip; - IMintableERC721 public chip; + IBEERC721 public box; + IBEERC721 public hero; + IBEERC721 public equip; + IBEERC721 public chip; uint8 public constant TYPE_NONE = 0; uint8 public constant TYPE_HERO = 1; @@ -47,10 +43,10 @@ contract MysteryBoxProxy is Ownable, Initializable, HasSignature { initializer onlyOwner { - hero = IMintableERC721(_erc721s[0]); - equip = IMintableERC721(_erc721s[1]); - chip = IMintableERC721(_erc721s[2]); - box = IMintableERC721(_erc721s[3]); + hero = IBEERC721(_erc721s[0]); + equip = IBEERC721(_erc721s[1]); + chip = IBEERC721(_erc721s[2]); + box = IBEERC721(_erc721s[3]); } /** diff --git a/contracts/logic/NFTActivateProxy.sol b/contracts/logic/NFTActivateProxy.sol index a23d88d..0a142cc 100644 --- a/contracts/logic/NFTActivateProxy.sol +++ b/contracts/logic/NFTActivateProxy.sol @@ -4,21 +4,17 @@ 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"; +import "../interfaces/IBEERC721.sol"; import "../core/HasSignature.sol"; -interface IMintableERC721 is IERC721 { - function mint(address to, uint256 tokenId) external; - - function burn(address owner, uint256 tokenId) external; -} contract NFTActivateProxy is Ownable, Initializable, HasSignature { uint256 private constant MINI_GEN_NFT_ID = 1e17; uint256 private constant MAX_GAME_NFT_ID = 9 * 1e15; - IMintableERC721 public hero; - IMintableERC721 public equip; - IMintableERC721 public chip; + IBEERC721 public hero; + IBEERC721 public equip; + IBEERC721 public chip; uint256 public constant TYPE_NONE = 0; uint256 public constant TYPE_HERO = 1; @@ -39,9 +35,9 @@ contract NFTActivateProxy is Ownable, Initializable, HasSignature { constructor() HasSignature("NFTActivateProxy", "1") {} function init(address[3] calldata _erc721s) external initializer onlyOwner { - hero = IMintableERC721(_erc721s[0]); - equip = IMintableERC721(_erc721s[1]); - chip = IMintableERC721(_erc721s[2]); + hero = IBEERC721(_erc721s[0]); + equip = IBEERC721(_erc721s[1]); + chip = IBEERC721(_erc721s[2]); } /** @@ -74,7 +70,7 @@ contract NFTActivateProxy is Ownable, Initializable, HasSignature { "NFTActivateProxy: signature used. please send another transaction with new signature" ); address owner = msg.sender; - IMintableERC721 nft721 = getIMintableERC721ByType(nftType); + IBEERC721 nft721 = getIBEERC721ByType(nftType); require( nft721.ownerOf(nftOld) == owner, "NFTActivateProxy: only owner can activate this nft" @@ -95,10 +91,10 @@ contract NFTActivateProxy is Ownable, Initializable, HasSignature { emit LogNFTActivate(owner, nftOld, nftNew, nftType); } - function getIMintableERC721ByType(uint256 nftType) + function getIBEERC721ByType(uint256 nftType) private view - returns (IMintableERC721) + returns (IBEERC721) { if (nftType == TYPE_HERO) { return hero;