一些onlyowner的方法增加timelock
This commit is contained in:
parent
424bf3435d
commit
a3d2c4b970
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
24241
build/contracts/BETimelockController.json
Normal file
24241
build/contracts/BETimelockController.json
Normal file
File diff suppressed because one or more lines are too long
@ -23041,12 +23041,12 @@
|
||||
}
|
||||
},
|
||||
"links": {},
|
||||
"address": "0xED7dfD0332e81Ba6eAF50a9500EfE34C5Cd5Ca2A",
|
||||
"transactionHash": "0x225c8225646cef00529fd1992b0b8ef14d4a82c95187ac97c7781977d22f3b6d"
|
||||
"address": "0x21601e485c3EaeaF3973C2d7e0379267C9c31cc6",
|
||||
"transactionHash": "0xde1847d5018eaa7dbe1a6ac278595735925aabbcbf59dd6b3b515d78780b7ffd"
|
||||
}
|
||||
},
|
||||
"schemaVersion": "3.4.3",
|
||||
"updatedAt": "2022-02-09T05:50:54.749Z",
|
||||
"updatedAt": "2022-02-09T11:02:22.823Z",
|
||||
"networkType": "ethereum",
|
||||
"devdoc": {
|
||||
"kind": "dev",
|
||||
|
File diff suppressed because one or more lines are too long
@ -3158,12 +3158,12 @@
|
||||
"1338": {
|
||||
"events": {},
|
||||
"links": {},
|
||||
"address": "0xc280be234Cba6d1062b7995b6a59c967B0ce7cBF",
|
||||
"transactionHash": "0x8007536c99a3804c1a860b7345fbd3e9cc98c17c576937828ca9025a8537e9b9"
|
||||
"address": "0x57a26552eaad5aDb4BcC4715A631Dcd23725abe6",
|
||||
"transactionHash": "0x939d77413b159507b7e1a79b4c5c354ae0f0b3241a83944f115d3f51612ef27e"
|
||||
}
|
||||
},
|
||||
"schemaVersion": "3.4.3",
|
||||
"updatedAt": "2022-02-09T05:50:54.759Z",
|
||||
"updatedAt": "2022-02-09T11:02:22.835Z",
|
||||
"networkType": "ethereum",
|
||||
"devdoc": {
|
||||
"kind": "dev",
|
||||
|
@ -8865,12 +8865,12 @@
|
||||
}
|
||||
},
|
||||
"links": {},
|
||||
"address": "0xd2E79E14739a883B89D593F97a22B76d7496DE08",
|
||||
"transactionHash": "0xe828175849da124a45ba059cea7b4d29c0951ef2d777675d09f757fadd2566ea"
|
||||
"address": "0xfDAED787615c30c95b34df9Dc7Aa8349aA6530E4",
|
||||
"transactionHash": "0x52713f721812544f9773158de322f503f9a2a0eeb5dbd51b0130b57d3b8bdcb8"
|
||||
}
|
||||
},
|
||||
"schemaVersion": "3.4.3",
|
||||
"updatedAt": "2022-02-09T05:50:54.738Z",
|
||||
"updatedAt": "2022-02-09T11:02:22.813Z",
|
||||
"networkType": "ethereum",
|
||||
"devdoc": {
|
||||
"kind": "dev",
|
||||
|
@ -14,9 +14,6 @@ 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) {
|
||||
return _baseTokenURI;
|
||||
@ -57,7 +54,6 @@ abstract contract BEBase is ERC721, AccessControlEnumerable, ERC721Enumerable, O
|
||||
*/
|
||||
function addApprovalWhitelist(address proxy) external onlyOwner {
|
||||
require(!approvalWhitelists[proxy], "Invalid proxy address");
|
||||
|
||||
approvalWhitelists[proxy] = true;
|
||||
}
|
||||
|
||||
@ -72,9 +68,14 @@ 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);
|
||||
minter_factory_initialized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Remove factory
|
||||
*/
|
||||
function removeMintFactory(address factory) external onlyOwner {
|
||||
revokeRole(MINTER_ROLE, factory);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -168,8 +169,13 @@ 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);
|
||||
burn_proxy_initialized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Remove proxy
|
||||
*/
|
||||
function removeBurnProxy(address proxy) external onlyOwner {
|
||||
revokeRole(BURN_ROLE, proxy);
|
||||
}
|
||||
}
|
43
contracts/BETimelockController.sol
Normal file
43
contracts/BETimelockController.sol
Normal file
@ -0,0 +1,43 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.10;
|
||||
import "@openzeppelin/contracts/governance/TimelockController.sol";
|
||||
|
||||
contract BETimelockController is TimelockController {
|
||||
uint256 public constant MIN_DELAY = 2 minutes;
|
||||
uint256 private _minDelay;
|
||||
|
||||
constructor(
|
||||
address[] memory proposers,
|
||||
address[] memory executors)
|
||||
TimelockController(MIN_DELAY, proposers, executors){
|
||||
_minDelay = MIN_DELAY;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @dev Returns the minimum delay for an operation to become valid.
|
||||
*
|
||||
* This value can be changed by executing an operation that calls `updateDelay`.
|
||||
*/
|
||||
function getMinDelay() public view virtual override returns (uint256 duration) {
|
||||
return _minDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Changes the minimum timelock duration for future operations.
|
||||
*
|
||||
* Emits a {MinDelayChange} event.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - the caller must be the timelock itself. This can only be achieved by scheduling and later executing
|
||||
* an operation where the timelock is the target and the data is the ABI-encoded call to this function.
|
||||
*/
|
||||
function updateDelay(uint256 newDelay) external virtual override {
|
||||
require(msg.sender == address(this), "BETimelockController: caller must be timelock");
|
||||
require(newDelay >= MIN_DELAY);
|
||||
emit MinDelayChange(_minDelay, newDelay);
|
||||
_minDelay = newDelay;
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,8 @@ contract MarketPlace is Ownable, HasSignature {
|
||||
address public feeToAddress;
|
||||
uint256 public transactionFee;
|
||||
|
||||
uint256 private constant MIN_TRANSACTION_FEE = 50;
|
||||
uint256 private constant MAX_TRANSACTION_FEE = 1000;
|
||||
uint256 public constant MIN_TRANSACTION_FEE = 50;
|
||||
uint256 public constant MAX_TRANSACTION_FEE = 1000;
|
||||
|
||||
// Events
|
||||
event MatchTransaction(
|
||||
|
@ -10,21 +10,4 @@ module.exports = async function (deployer, network, accounts) {
|
||||
// tmpData.writeKeyVal('coin', coinInstance.address);
|
||||
console.log("BECoin successfully deployed.")
|
||||
}
|
||||
|
||||
// if (network == "lan22" || network == "development") {
|
||||
// let jsons = []
|
||||
// jsons.push({name: 'coin', json: 'assets/contracts/BECoin.json', address: coinInstance.address})
|
||||
// jsons.push({name: 'hero', json: 'assets/contracts/BEHero.json', address: heroInstance.address})
|
||||
// jsons.push({name: 'equip', json: 'assets/contracts/BEEquipment.json', address: equipInstance.address})
|
||||
// jsons.push({name: 'chip', json: 'assets/contracts/BEChip.json', address: chipInstance.address})
|
||||
// jsons.push({name: 'factory', json: 'assets/contracts/MinterFactory.json', address: factoryInstance.address})
|
||||
// jsons.push({name: 'market', json: 'assets/contracts/MarketPlace.json', address: marketInstance.address})
|
||||
// jsons.push({name: 'mall', json: 'assets/contracts/BEBoxMall.json', address: boxInstance.address})
|
||||
// jsons.push({name: 'proxy', json: 'assets/contracts/EvolveProxy.json', address: proxyInstance.address})
|
||||
// console.log(jsons);
|
||||
// console.log(`export const userAddress = '${accounts[0]}';`)
|
||||
// console.log(`export const privateKey = '';`)
|
||||
// console.log(`export const userBuyAddress = '${accounts[1]}';`)
|
||||
// }
|
||||
|
||||
};
|
@ -1,11 +1,4 @@
|
||||
const Box = artifacts.require('BEBoxMall');
|
||||
const Coin = artifacts.require('BECoin');
|
||||
const Hero = artifacts.require('BEHero');
|
||||
const Equip = artifacts.require('BEEquipment');
|
||||
const Chip = artifacts.require('BEChip');
|
||||
const MarketPlace = artifacts.require('MarketPlace');
|
||||
const Factory = artifacts.require('MinterFactory');
|
||||
const EvolveProxy = artifacts.require('EvolveProxy');
|
||||
|
||||
const config = require("../config/config");
|
||||
|
||||
@ -23,27 +16,4 @@ module.exports = async function (deployer, network, accounts) {
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
try{
|
||||
const heroInstance = await Hero.deployed();
|
||||
const equipInstance = await Equip.deployed();
|
||||
const chipInstance = await Chip.deployed();
|
||||
const coinInstance = await Coin.deployed();
|
||||
const marketInstance = await MarketPlace.deployed();
|
||||
const factoryInstance = await Factory.deployed();
|
||||
const proxyInstance = await EvolveProxy.deployed();
|
||||
let jsons = []
|
||||
jsons.push({name: 'coin', json: 'assets/contracts/BECoin.json', address: coinInstance.address})
|
||||
jsons.push({name: 'hero', json: 'assets/contracts/BEHero.json', address: heroInstance.address})
|
||||
jsons.push({name: 'equip', json: 'assets/contracts/BEEquipment.json', address: equipInstance.address})
|
||||
jsons.push({name: 'chip', json: 'assets/contracts/BEChip.json', address: chipInstance.address})
|
||||
jsons.push({name: 'factory', json: 'assets/contracts/MinterFactory.json', address: factoryInstance.address})
|
||||
jsons.push({name: 'market', json: 'assets/contracts/MarketPlace.json', address: marketInstance.address})
|
||||
jsons.push({name: 'mall', json: 'assets/contracts/BEBoxMall.json', address: boxInstance.address})
|
||||
jsons.push({name: 'proxy', json: 'assets/contracts/EvolveProxy.json', address: proxyInstance.address})
|
||||
console.log(jsons);
|
||||
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
50
migrations/8_deploy_timelock.js
Normal file
50
migrations/8_deploy_timelock.js
Normal file
@ -0,0 +1,50 @@
|
||||
const TimelockController = artifacts.require('BETimelockController');
|
||||
const Box = artifacts.require('BEBoxMall');
|
||||
const Coin = artifacts.require('BECoin');
|
||||
const Hero = artifacts.require('BEHero');
|
||||
const Equip = artifacts.require('BEEquipment');
|
||||
const Chip = artifacts.require('BEChip');
|
||||
const MarketPlace = artifacts.require('MarketPlace');
|
||||
const Factory = artifacts.require('MinterFactory');
|
||||
const EvolveProxy = artifacts.require('EvolveProxy');
|
||||
|
||||
|
||||
module.exports = async function (deployer, network, accounts) {
|
||||
await deployer.deploy(
|
||||
TimelockController,
|
||||
[accounts[0]],
|
||||
[accounts[0]]
|
||||
);
|
||||
const timelockInstance = await TimelockController.deployed();
|
||||
if(timelockInstance) {
|
||||
console.log("TimelockController successfully deployed.")
|
||||
}
|
||||
try {
|
||||
const marketInstance = await MarketPlace.deployed();
|
||||
await marketInstance.transferOwnership(timelockInstance.address);
|
||||
console.log('MarketPlace onwer has change to: ', timelockInstance.address);
|
||||
const heroInstance = await Hero.deployed();
|
||||
const equipInstance = await Equip.deployed();
|
||||
const chipInstance = await Chip.deployed();
|
||||
const coinInstance = await Coin.deployed();
|
||||
const factoryInstance = await Factory.deployed();
|
||||
const proxyInstance = await EvolveProxy.deployed();
|
||||
const boxInstance = await Box.deployed();
|
||||
let jsons = []
|
||||
jsons.push({name: 'coin', json: 'assets/contracts/BECoin.json', address: coinInstance.address})
|
||||
jsons.push({name: 'hero', json: 'assets/contracts/BEHero.json', address: heroInstance.address})
|
||||
jsons.push({name: 'equip', json: 'assets/contracts/BEEquipment.json', address: equipInstance.address})
|
||||
jsons.push({name: 'chip', json: 'assets/contracts/BEChip.json', address: chipInstance.address})
|
||||
jsons.push({name: 'factory', json: 'assets/contracts/MinterFactory.json', address: factoryInstance.address})
|
||||
jsons.push({name: 'market', json: 'assets/contracts/MarketPlace.json', address: marketInstance.address})
|
||||
jsons.push({name: 'mall', json: 'assets/contracts/BEBoxMall.json', address: boxInstance.address})
|
||||
jsons.push({name: 'proxy', json: 'assets/contracts/EvolveProxy.json', address: proxyInstance.address})
|
||||
jsons.push({name: 'timelock', json: 'assets/contracts/BETimelockController.json', address: timelockInstance.address})
|
||||
console.log(jsons);
|
||||
console.log(`export const userAddress = '${accounts[0]}';`)
|
||||
console.log(`export const privateKey = '';`)
|
||||
console.log(`export const userBuyAddress = '${accounts[1]}';`)
|
||||
} catch(err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user