将evolveproxy改为evolvefactory

This commit is contained in:
cebgcontract 2022-08-16 11:49:28 +08:00
parent f656b07923
commit 92876d4160
23 changed files with 83155 additions and 60930 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -45146,10 +45146,22 @@
"links": {},
"address": "0x6eD79Aa1c71FD7BdBC515EfdA3Bd4e26394435cC",
"transactionHash": "0xffd4e86f44fe11afca22cd992f1a67bf548d52f55afd486f86e94969d5da07da"
},
"1660614931290": {
"events": {},
"links": {},
"address": "0x6eD79Aa1c71FD7BdBC515EfdA3Bd4e26394435cC",
"transactionHash": "0x821abb31a58e7a4f4294c40f40bb994635c3d85a88ec500ba79a589eb9fe4518"
},
"1660621703807": {
"events": {},
"links": {},
"address": "0x6eD79Aa1c71FD7BdBC515EfdA3Bd4e26394435cC",
"transactionHash": "0x821abb31a58e7a4f4294c40f40bb994635c3d85a88ec500ba79a589eb9fe4518"
}
},
"schemaVersion": "3.4.4",
"updatedAt": "2022-08-15T06:52:20.254Z",
"updatedAt": "2022-08-16T03:48:47.906Z",
"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

View File

@ -9670,10 +9670,22 @@
"links": {},
"address": "0xCfEB869F69431e42cdB54A4F4f105C19C080A601",
"transactionHash": "0x2204250d687161b0ca7a13205946e84000a26e776b23eb5e859e510b524829f3"
},
"1660614931290": {
"events": {},
"links": {},
"address": "0xCfEB869F69431e42cdB54A4F4f105C19C080A601",
"transactionHash": "0x2204250d687161b0ca7a13205946e84000a26e776b23eb5e859e510b524829f3"
},
"1660621703807": {
"events": {},
"links": {},
"address": "0xCfEB869F69431e42cdB54A4F4f105C19C080A601",
"transactionHash": "0x2204250d687161b0ca7a13205946e84000a26e776b23eb5e859e510b524829f3"
}
},
"schemaVersion": "3.4.4",
"updatedAt": "2022-08-15T06:52:13.226Z",
"updatedAt": "2022-08-16T03:48:38.680Z",
"networkType": "ethereum",
"devdoc": {
"kind": "dev",

File diff suppressed because one or more lines are too long

View File

@ -11718,10 +11718,22 @@
"links": {},
"address": "0xC89Ce4735882C9F0f0FE26686c53074E09B0D550",
"transactionHash": "0x6d2a8e99df9adb00dfa3fda55853cddf2f206987a4c80cb8f0062fa451cb8224"
},
"1660614931290": {
"events": {},
"links": {},
"address": "0xC89Ce4735882C9F0f0FE26686c53074E09B0D550",
"transactionHash": "0x6d2a8e99df9adb00dfa3fda55853cddf2f206987a4c80cb8f0062fa451cb8224"
},
"1660621703807": {
"events": {},
"links": {},
"address": "0xC89Ce4735882C9F0f0FE26686c53074E09B0D550",
"transactionHash": "0x6d2a8e99df9adb00dfa3fda55853cddf2f206987a4c80cb8f0062fa451cb8224"
}
},
"schemaVersion": "3.4.4",
"updatedAt": "2022-08-15T06:52:13.989Z",
"updatedAt": "2022-08-16T03:48:39.500Z",
"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

File diff suppressed because one or more lines are too long

View File

@ -25192,10 +25192,16 @@
"links": {},
"address": "0x21a59654176f2689d12E828B77a783072CD26680",
"transactionHash": "0x4af14eefca13fef07b442e1a04e222abd8def1354259739e7323a6b0cdf1d5f7"
},
"1660621703807": {
"events": {},
"links": {},
"address": "0x21a59654176f2689d12E828B77a783072CD26680",
"transactionHash": "0x45778432273c4bb8707e0cca1fd0e3b7391316c3406994399edba6dd6b801b87"
}
},
"schemaVersion": "3.4.4",
"updatedAt": "2022-08-15T06:52:21.916Z",
"updatedAt": "2022-08-16T03:48:49.556Z",
"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

View File

@ -33543,10 +33543,22 @@
"links": {},
"address": "0xDb56f2e9369E0D7bD191099125a3f6C370F8ed15",
"transactionHash": "0x11a77fbd90b6847b301866ec17d74825797dbaac44b9a9a5f4ed6a55821ae0e7"
},
"1660614931290": {
"events": {},
"links": {},
"address": "0xDb56f2e9369E0D7bD191099125a3f6C370F8ed15",
"transactionHash": "0x477545d3be1d9f2cc26900fc672cce04661a8ca276bd054bdbe5f31d7c7deb38"
},
"1660621703807": {
"events": {},
"links": {},
"address": "0xDb56f2e9369E0D7bD191099125a3f6C370F8ed15",
"transactionHash": "0x477545d3be1d9f2cc26900fc672cce04661a8ca276bd054bdbe5f31d7c7deb38"
}
},
"schemaVersion": "3.4.4",
"updatedAt": "2022-08-15T06:52:19.317Z",
"updatedAt": "2022-08-16T03:48:46.657Z",
"networkType": "ethereum",
"devdoc": {
"kind": "dev",

View File

@ -3172,10 +3172,22 @@
"links": {},
"address": "0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab",
"transactionHash": "0x48bdf23a40832e27b03488c07a3499446ea72de28dfc5da232f940822771f02d"
},
"1660614931290": {
"events": {},
"links": {},
"address": "0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab",
"transactionHash": "0x48bdf23a40832e27b03488c07a3499446ea72de28dfc5da232f940822771f02d"
},
"1660621703807": {
"events": {},
"links": {},
"address": "0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab",
"transactionHash": "0x48bdf23a40832e27b03488c07a3499446ea72de28dfc5da232f940822771f02d"
}
},
"schemaVersion": "3.4.4",
"updatedAt": "2022-08-15T06:52:21.925Z",
"updatedAt": "2022-08-16T03:48:49.569Z",
"networkType": "ethereum",
"devdoc": {
"kind": "dev",

File diff suppressed because one or more lines are too long

View File

@ -62,7 +62,8 @@
}
],
"stateMutability": "view",
"type": "function"
"type": "function",
"constant": true
},
{
"inputs": [],
@ -75,7 +76,8 @@
}
],
"stateMutability": "view",
"type": "function"
"type": "function",
"constant": true
},
{
"inputs": [],
@ -88,7 +90,8 @@
}
],
"stateMutability": "view",
"type": "function"
"type": "function",
"constant": true
},
{
"inputs": [],
@ -101,7 +104,8 @@
}
],
"stateMutability": "view",
"type": "function"
"type": "function",
"constant": true
},
{
"inputs": [],
@ -121,7 +125,8 @@
}
],
"stateMutability": "view",
"type": "function"
"type": "function",
"constant": true
},
{
"inputs": [
@ -22049,10 +22054,23 @@
"links": {},
"address": "0x630589690929E9cdEFDeF0734717a9eF3Ec7Fcfe",
"transactionHash": "0x85d262965b9191e853ce9f580e51b8ee3393636c7b6ee7c1a80ac0c81d550ae1"
},
"1660614931290": {
"events": {},
"links": {},
"address": "0x630589690929E9cdEFDeF0734717a9eF3Ec7Fcfe",
"transactionHash": "0xc2f23e7839d7caa2c8ce36873cbb4774f61b210057b79e8a82e093a612ab5e55"
},
"1660621703807": {
"events": {},
"links": {},
"address": "0x630589690929E9cdEFDeF0734717a9eF3Ec7Fcfe",
"transactionHash": "0xc2f23e7839d7caa2c8ce36873cbb4774f61b210057b79e8a82e093a612ab5e55"
}
},
"schemaVersion": "3.4.4",
"updatedAt": "2022-08-16T03:00:46.801Z",
"updatedAt": "2022-08-16T03:48:44.115Z",
"networkType": "ethereum",
"devdoc": {
"kind": "dev",
"methods": {

View File

@ -11,7 +11,7 @@ import "../core/HasSignature.sol";
// this contract will transfer ownership to BETimelockController after deployed
// all onlyowner method would add timelock
contract EvolveProxy is Ownable, Initializable, HasSignature {
contract EvolveFactory is Ownable, Initializable, HasSignature {
using UInt for uint256;
IBEERC721 public hero;
@ -31,7 +31,7 @@ contract EvolveProxy is Ownable, Initializable, HasSignature {
);
constructor()
HasSignature("EvolveProxy", "1"){
HasSignature("EvolveFactory", "1"){
}
function init(address[3] calldata _erc721s) external initializer onlyOwner {
@ -60,22 +60,22 @@ contract EvolveProxy is Ownable, Initializable, HasSignature {
) external {
require(
tokenIds[0] > 0 && tokenIds[1] > 0,
"EvolveProxy: hero to evolve and burn can not be 0"
"EvolveFactory: hero to evolve and burn can not be 0"
);
require(
tokenIds[0] != tokenIds[1],
"EvolveProxy: hero to evolve and burn can not be same"
"EvolveFactory: hero to evolve and burn can not be same"
);
require(
hero.ownerOf(tokenIds[0]) == msg.sender,
"EvolveProxy: not owner of this hero now"
"EvolveFactory: not owner of this hero now"
);
require(
!usedSignatures[signature],
"EvolveProxy: signature used. please send another transaction with new signature"
"EvolveFactory: signature used. please send another transaction with new signature"
);
bytes32 criteriaMessageHash = getMessageHash(
evolveEventId,
@ -93,7 +93,13 @@ contract EvolveProxy is Ownable, Initializable, HasSignature {
amount.asSingletonArray());
}
usedSignatures[signature] = true;
emit TokenEvolved(evolveEventId, msg.sender, tokenIds[0], tokenIds[1], tokenIds[2]);
emit TokenEvolved(
evolveEventId,
msg.sender,
tokenIds[0],
tokenIds[1],
tokenIds[2]
);
}
/**
@ -108,22 +114,22 @@ contract EvolveProxy is Ownable, Initializable, HasSignature {
) external{
require(
tokenIds[0] > 0 && tokenIds[1] > 0,
"EvolveProxy: equip to evolve and burn can not be 0"
"EvolveFactory: equip to evolve and burn can not be 0"
);
require(
tokenIds[0] != tokenIds[1],
"EvolveProxy: equip to evolve and burn can not be same"
"EvolveFactory: equip to evolve and burn can not be same"
);
require(
equip.ownerOf(tokenIds[0]) == msg.sender,
"EvolveProxy: current address is not owner of this equip now"
"EvolveFactory: current address is not owner of this equip now"
);
require(
!usedSignatures[signature],
"EvolveProxy: signature used. please send another transaction with new signature"
"EvolveFactory: signature used. please send another transaction with new signature"
);
bytes32 criteriaMessageHash = getMessageHash(
evolveEventId,
@ -141,7 +147,13 @@ contract EvolveProxy is Ownable, Initializable, HasSignature {
amount.asSingletonArray());
}
usedSignatures[signature] = true;
emit TokenEvolved(evolveEventId, msg.sender, tokenIds[0], tokenIds[1], tokenIds[2]);
emit TokenEvolved(
evolveEventId,
msg.sender,
tokenIds[0],
tokenIds[1],
tokenIds[2]
);
}
function getMessageHash(

View File

@ -75,7 +75,6 @@ abstract contract BEBase1155 is ERC1155, Ownable, AccessControl {
onlyOwner
{
_grantRole(MINTER_ROLE, factory);
_grantRole(BURN_ROLE, factory);
}
/**
@ -86,9 +85,37 @@ abstract contract BEBase1155 is ERC1155, Ownable, AccessControl {
onlyOwner
{
_revokeRole(MINTER_ROLE, factory);
_revokeRole(BURN_ROLE, factory);
}
function grantLockRole(address account)
external
onlyOwner
{
_grantRole(LOCK_ROLE, account);
}
function revokeLockRole(address account)
external
onlyOwner
{
_revokeRole(LOCK_ROLE, account);
}
/**
* @dev Add factory to burn item
*/
function setBurnProxy(address proxy) external onlyOwner {
_grantRole(BURN_ROLE, proxy);
}
/**
* @dev Remove proxy
*/
function removeBurnProxy(address proxy) external onlyOwner {
_revokeRole(BURN_ROLE, proxy);
}
/**
* @dev Total amount of tokens in with a given id.
*/
@ -108,19 +135,7 @@ abstract contract BEBase1155 is ERC1155, Ownable, AccessControl {
}
function grantLockRole(address account)
external
onlyOwner
{
_grantRole(LOCK_ROLE, account);
}
function revokeLockRole(address account)
external
onlyOwner
{
_revokeRole(LOCK_ROLE, account);
}
/**
* @dev Lock token to use in game or for rental

View File

@ -4,16 +4,16 @@ import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
abstract contract BEBase is ERC721, AccessControlEnumerable, ERC721Enumerable, Ownable {
abstract contract BEBase is ERC721, AccessControl, ERC721Enumerable, Ownable {
using Strings for uint256;
mapping(address => bool) public approvalWhitelists;
mapping(uint256 => bool) public lockedTokens;
string private _baseTokenURI = "https://market.cebg.games/api/nft/info/";
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
bytes32 public constant BURN_ROLE = keccak256("BURN_ROLE");
bytes32 public constant LOCK_ROLE = keccak256("LOCK_ROLE");
function _baseURI() internal view virtual override returns (string memory) {
return _baseTokenURI;
@ -30,54 +30,67 @@ abstract contract BEBase is ERC721, AccessControlEnumerable, ERC721Enumerable, O
*
* - the caller must have the `MINTER_ROLE`.
*/
function mint(address to, uint256 tokenId) external virtual {
require(
hasRole(MINTER_ROLE, _msgSender()),
"Must have minter role to mint"
);
function mint(address to, uint256 tokenId)
external
onlyRole(MINTER_ROLE)
virtual {
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 Allow operation to approval list.
*/
function addApprovalWhitelist(address proxy) external onlyOwner {
require(!approvalWhitelists[proxy], "Invalid proxy address");
approvalWhitelists[proxy] = true;
}
/**
* @dev Remove operation from approval list.
*/
function removeApprovalWhitelist(address proxy) external onlyOwner {
approvalWhitelists[proxy] = false;
}
/**
* @dev Add factory to mint item
*/
function setMintFactory(address factory) external onlyOwner {
_setupRole(MINTER_ROLE, factory);
_grantRole(MINTER_ROLE, factory);
}
/**
* @dev Remove factory
*/
function removeMintFactory(address factory) external onlyOwner {
revokeRole(MINTER_ROLE, factory);
_revokeRole(MINTER_ROLE, factory);
}
/**
* @dev Add factory to burn item
*/
function grantBurnRole(address proxy) external onlyOwner {
_grantRole(BURN_ROLE, proxy);
}
/**
* @dev Remove proxy
*/
function revokeBurnProxy(address proxy) external onlyOwner {
_revokeRole(BURN_ROLE, proxy);
}
/**
* @dev Add address to lock item
*/
function grantLockRole(address account)
external
onlyOwner
{
_grantRole(LOCK_ROLE, account);
}
/**
* @dev Remove address for lock item
*/
function revokeLockRole(address account)
external
onlyOwner
{
_revokeRole(LOCK_ROLE, account);
}
/**
* @dev Lock token to use in game or for rental
*/
function lock(uint256 tokenId) external {
require(
approvalWhitelists[_msgSender()],
"Must be valid approval whitelist"
);
function lock(uint256 tokenId) external onlyRole(LOCK_ROLE) {
require(_exists(tokenId), "Must be valid tokenId");
require(!lockedTokens[tokenId], "Token has already locked");
lockedTokens[tokenId] = true;
@ -86,11 +99,7 @@ abstract contract BEBase is ERC721, AccessControlEnumerable, ERC721Enumerable, O
/**
* @dev Unlock token to use blockchain or sale on marketplace
*/
function unlock(uint256 tokenId) external {
require(
approvalWhitelists[_msgSender()],
"Must be valid approval whitelist"
);
function unlock(uint256 tokenId) external onlyRole(LOCK_ROLE){
require(_exists(tokenId), "Must be valid tokenId");
require(lockedTokens[tokenId], "Token has already unlocked");
lockedTokens[tokenId] = false;
@ -129,7 +138,7 @@ abstract contract BEBase is ERC721, AccessControlEnumerable, ERC721Enumerable, O
public
view
virtual
override(AccessControlEnumerable, ERC721, ERC721Enumerable)
override(AccessControl, ERC721, ERC721Enumerable)
returns (bool)
{
return super.supportsInterface(interfaceId);
@ -143,11 +152,11 @@ abstract contract BEBase is ERC721, AccessControlEnumerable, ERC721Enumerable, O
*
* - The caller must own `tokenId` or be an approved operator.
*/
function burn(address owner, uint256 tokenId) external virtual {
require(
hasRole(BURN_ROLE, _msgSender()),
"Must have burn role to burn"
);
function burn(address owner, uint256 tokenId)
external
onlyRole(BURN_ROLE)
virtual
{
require(_exists(tokenId), "TokenId not exists");
require(!lockedTokens[tokenId], "Can not burn locked token");
require(
@ -157,17 +166,5 @@ abstract contract BEBase is ERC721, AccessControlEnumerable, ERC721Enumerable, O
_burn(tokenId);
}
/**
* @dev Add factory to burn item
*/
function setBurnProxy(address proxy) external onlyOwner {
_setupRole(BURN_ROLE, proxy);
}
/**
* @dev Remove proxy
*/
function removeBurnProxy(address proxy) external onlyOwner {
revokeRole(BURN_ROLE, proxy);
}
}
}

View File

@ -8,7 +8,7 @@ const MarketPlace = artifacts.require('market/MarketPlace')
// const BEBoxMall = artifacts.require('market/BEBoxMall')
const MinterFactory = artifacts.require('logic/MinterFactory')
const UserMinterFactory = artifacts.require('logic/UserMinterFactory')
// const EvolveProxy = artifacts.require('logic/EvolveProxy')
// const EvolveFactory = artifacts.require('logic/EvolveFactory')
const config = require('../config/config')
@ -39,18 +39,18 @@ module.exports = async function main(callback) {
await marketInstance.setPaymentTokens(config.market.paymentTokens)
console.log(`finish update market config`)
await heroInstance.addApprovalWhitelist(marketInstance.address)
await heroInstance.grantLockRole(marketInstance.address)
await heroInstance.setApprovalForAll(marketInstance.address, true)
console.log('finish heroInstance.addApprovalWhitelist')
await equipInstance.addApprovalWhitelist(marketInstance.address)
await equipInstance.grantLockRole(marketInstance.address)
await equipInstance.setApprovalForAll(marketInstance.address, true)
console.log('finish equipInstance.addApprovalWhitelist')
await chipInstance.grantLockRole(marketInstance.address)
await chipInstance.setApprovalForAll(marketInstance.address, true)
console.log('finish chipInstance.addApprovalWhitelist')
await heroInstance.addApprovalWhitelist(config.admins.admin)
await equipInstance.addApprovalWhitelist(config.admins.admin)
await heroInstance.grantLockRole(config.admins.admin)
await equipInstance.grantLockRole(config.admins.admin)
await chipInstance.grantLockRole(config.admins.admin)
await shardInstance.grantLockRole(config.admins.admin)
console.log(`Allow operation ${marketInstance.address} to reduce gas fee`)
@ -89,7 +89,7 @@ module.exports = async function main(callback) {
shardInstance.address,
factoryInstance.address
])
// const proxyInstance = await EvolveProxy.deployed()
// const proxyInstance = await EvolveFactory.deployed()
// if (!proxyInstance) {
// console.error('no proxyInstance')
// return
@ -99,9 +99,9 @@ module.exports = async function main(callback) {
// equipInstance.address,
// chipInstance.address,
// ])
// await heroInstance.setBurnProxy(proxyInstance.address)
// await equipInstance.setBurnProxy(proxyInstance.address)
// await chipInstance.setBurnProxy(proxyInstance.address)
// await heroInstance.grantBurnRole(proxyInstance.address)
// await equipInstance.grantBurnRole(proxyInstance.address)
// await chipInstance.grantBurnRole(proxyInstance.address)
// console.log(
// `Allow proxy ${proxyInstance.address} to burn contract \n hero: ${heroInstance.address}, \n equip: ${equipInstance.address}, \n chip: ${chipInstance.address}`,
// )

View File

@ -1,9 +1,9 @@
const EvolveProxy = artifacts.require('logic/EvolveProxy');
const EvolveFactory = artifacts.require('logic/EvolveFactory');
module.exports = async function (deployer, network, accounts) {
await deployer.deploy(EvolveProxy);
const proxyInstance = await EvolveProxy.deployed();
await deployer.deploy(EvolveFactory);
const proxyInstance = await EvolveFactory.deployed();
if(proxyInstance) {
console.log("EvolveProxy successfully deployed.")
console.log("EvolveFactory successfully deployed.")
}
}
}