修改英雄和装备升级流程
This commit is contained in:
parent
fab4f5c5e9
commit
7be19c26d1
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
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
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
@ -2315,12 +2315,12 @@
|
||||
"1338": {
|
||||
"events": {},
|
||||
"links": {},
|
||||
"address": "0xE7836E33447935f9B623CafB10f79781C364632c",
|
||||
"transactionHash": "0x74b5d45e68c3c222ebe5a5921ca04021734fe7eb8a8fcbf61fe0de1db3900d95"
|
||||
"address": "0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab",
|
||||
"transactionHash": "0x14a74e2720fd2450d915b87a0b8db4202de3d5726d7e83ce2a2c67bf9dd050e4"
|
||||
}
|
||||
},
|
||||
"schemaVersion": "3.4.4",
|
||||
"updatedAt": "2022-01-27T10:57:00.728Z",
|
||||
"updatedAt": "2022-01-28T05:54:43.823Z",
|
||||
"networkType": "ethereum",
|
||||
"devdoc": {
|
||||
"kind": "dev",
|
||||
|
@ -8859,12 +8859,12 @@
|
||||
}
|
||||
},
|
||||
"links": {},
|
||||
"address": "0x26a2377a79d3AcdFf599E2DeDce44A5E982300d2",
|
||||
"transactionHash": "0xd4caa01124fa38ddb27228fe9b4d61d66f700a2b492f8abcf35e28c84e6dd8ed"
|
||||
"address": "0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7",
|
||||
"transactionHash": "0xffc6e7fcd0fdfe16a56c20b57e3639c8d89f3bcdb05e933865475a2a2f118003"
|
||||
}
|
||||
},
|
||||
"schemaVersion": "3.4.4",
|
||||
"updatedAt": "2022-01-27T10:57:00.657Z",
|
||||
"updatedAt": "2022-01-28T05:54:43.776Z",
|
||||
"networkType": "ethereum",
|
||||
"devdoc": {
|
||||
"kind": "dev",
|
||||
|
@ -11,6 +11,8 @@ abstract contract BEBase is ERC721, AccessControlEnumerable, ERC721Enumerable, O
|
||||
string private _baseTokenURI;
|
||||
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
|
||||
bytes32 public constant BURN_ROLE = keccak256("BURN_ROLE");
|
||||
bool public minter_factory_initialized = false;
|
||||
bool public burn_proxy_initialized = false;
|
||||
|
||||
|
||||
function _baseURI() internal view virtual override returns (string memory) {
|
||||
@ -75,14 +77,9 @@ abstract contract BEBase is ERC721, AccessControlEnumerable, ERC721Enumerable, O
|
||||
* @dev Add factory to mint item
|
||||
*/
|
||||
function setMintFactory(address factory) external onlyOwner {
|
||||
require(!minter_factory_initialized, "BEBase::setMintFactory: can not change minter factory");
|
||||
_setupRole(MINTER_ROLE, factory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Remove factory
|
||||
*/
|
||||
function removeMintFactory(address factory) external onlyOwner {
|
||||
revokeRole(MINTER_ROLE, factory);
|
||||
minter_factory_initialized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -175,13 +172,8 @@ abstract contract BEBase is ERC721, AccessControlEnumerable, ERC721Enumerable, O
|
||||
* @dev Add factory to burn item
|
||||
*/
|
||||
function setBurnProxy(address proxy) external onlyOwner {
|
||||
require(!burn_proxy_initialized, "BEBase::setBurnProxy: can not change burn proxy");
|
||||
_setupRole(BURN_ROLE, proxy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Remove proxy
|
||||
*/
|
||||
function removeBurnProxy(address proxy) external onlyOwner {
|
||||
revokeRole(BURN_ROLE, proxy);
|
||||
burn_proxy_initialized = true;
|
||||
}
|
||||
}
|
@ -3,21 +3,23 @@ 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 "./HasSignature.sol";
|
||||
|
||||
interface IBurnableERC721 is IERC721 {
|
||||
function burn(address owner, uint256 tokenId) external;
|
||||
}
|
||||
contract EvolveProxy is Ownable, Initializable {
|
||||
contract EvolveProxy is Ownable, Initializable, HasSignature {
|
||||
|
||||
IBurnableERC721 public hero;
|
||||
IBurnableERC721 public equip;
|
||||
IBurnableERC721 public chip;
|
||||
|
||||
bool public publicEvolveAllowed;
|
||||
mapping(bytes => bool) public usedSignatures;
|
||||
|
||||
event TokenEvolved(
|
||||
address contractAddress,
|
||||
address owner,
|
||||
uint256 indexed tokenEvolved,
|
||||
uint256 indexed evolveEventId,
|
||||
address indexed owner,
|
||||
uint256 tokenEvolved,
|
||||
uint256 tokenBurned,
|
||||
uint256 chip
|
||||
);
|
||||
@ -33,36 +35,96 @@ contract EvolveProxy is Ownable, Initializable {
|
||||
* @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]);
|
||||
function evolveHero(
|
||||
uint256 evolveEventId,
|
||||
uint256[3] calldata tokenIds,
|
||||
uint256 saltNonce,
|
||||
bytes calldata signature
|
||||
) external {
|
||||
require(
|
||||
tokenIds[0] > 0 && tokenIds[1] > 0,
|
||||
"EvolveProxy: hero to evolve and burn can not be 0"
|
||||
);
|
||||
require(
|
||||
hero.ownerOf(tokenIds[0]) == msg.sender,
|
||||
"EvolveProxy: not owner of this hero now"
|
||||
);
|
||||
|
||||
require(
|
||||
!usedSignatures[signature],
|
||||
"EvolveProxy: signature used. please send another transaction with new signature"
|
||||
);
|
||||
bytes32 criteriaMessageHash = getMessageHash(
|
||||
evolveEventId,
|
||||
tokenIds[0],
|
||||
tokenIds[1],
|
||||
tokenIds[2],
|
||||
saltNonce
|
||||
);
|
||||
checkSigner(msg.sender, criteriaMessageHash, signature);
|
||||
hero.burn(msg.sender, tokenIds[1]);
|
||||
if (tokenIds[2] > 0) {
|
||||
chip.burn(to, tokenIds[2]);
|
||||
chip.burn(msg.sender, tokenIds[2]);
|
||||
}
|
||||
emit TokenEvolved(address(hero), to, tokenIds[0], tokenIds[1], tokenIds[2]);
|
||||
emit TokenEvolved(evolveEventId, msg.sender, 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]);
|
||||
function evolveEquip(
|
||||
uint256 evolveEventId,
|
||||
uint256[3] calldata tokenIds,
|
||||
uint256 saltNonce,
|
||||
bytes calldata signature
|
||||
) external{
|
||||
require(
|
||||
tokenIds[0] > 0 && tokenIds[1] > 0,
|
||||
"EvolveProxy: equip to evolve and burn can not be 0"
|
||||
);
|
||||
|
||||
require(
|
||||
equip.ownerOf(tokenIds[0]) == msg.sender,
|
||||
"EvolveProxy: current address is not owner of this equip now"
|
||||
);
|
||||
|
||||
require(
|
||||
!usedSignatures[signature],
|
||||
"EvolveProxy: signature used. please send another transaction with new signature"
|
||||
);
|
||||
bytes32 criteriaMessageHash = getMessageHash(
|
||||
evolveEventId,
|
||||
tokenIds[0],
|
||||
tokenIds[1],
|
||||
tokenIds[2],
|
||||
saltNonce
|
||||
);
|
||||
checkSigner(msg.sender, criteriaMessageHash, signature);
|
||||
equip.burn(msg.sender, tokenIds[1]);
|
||||
if (tokenIds[2] > 0) {
|
||||
chip.burn(to, tokenIds[2]);
|
||||
chip.burn(msg.sender, tokenIds[2]);
|
||||
}
|
||||
emit TokenEvolved(address(equip), to, tokenIds[0], tokenIds[1], tokenIds[2]);
|
||||
emit TokenEvolved(evolveEventId, msg.sender, tokenIds[0], tokenIds[1], tokenIds[2]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @dev function to update allow user evolve items
|
||||
*/
|
||||
function updatePublicEvolve(bool val) external onlyOwner {
|
||||
publicEvolveAllowed = val;
|
||||
function getMessageHash(
|
||||
uint256 _eventId,
|
||||
uint256 _mainToken,
|
||||
uint256 _burnToken,
|
||||
uint256 _chipToken,
|
||||
uint256 _saltNonce
|
||||
) public pure returns (bytes32) {
|
||||
return
|
||||
keccak256(
|
||||
abi.encodePacked(
|
||||
_eventId,
|
||||
_mainToken,
|
||||
_burnToken,
|
||||
_chipToken,
|
||||
_saltNonce
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user