boxmall的setPaymentReceivedAddress增加timelock

This commit is contained in:
zhl 2022-02-10 10:14:23 +08:00
parent a3d2c4b970
commit c27f6db714
16 changed files with 44634 additions and 25025 deletions

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

@ -10246,12 +10246,12 @@
}
},
"links": {},
"address": "0xcCcB7e38669894e319ab1Ba1a424d7f14C153C69",
"transactionHash": "0xcce928be67951196c39a1616909dbea441740422b80e3d59fcfcca22d032138f"
"address": "0x24FCAF072dc88166076bEC67AF8dBb56C5AA86A3",
"transactionHash": "0xb99e3a5a3c340863aa110e09327df04840984099a3bf8e80b93b92d843c5e5ba"
}
},
"schemaVersion": "3.4.3",
"updatedAt": "2022-02-09T11:02:22.720Z",
"updatedAt": "2022-02-10T02:01:49.892Z",
"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

@ -23041,12 +23041,12 @@
}
},
"links": {},
"address": "0x21601e485c3EaeaF3973C2d7e0379267C9c31cc6",
"transactionHash": "0xde1847d5018eaa7dbe1a6ac278595735925aabbcbf59dd6b3b515d78780b7ffd"
"address": "0xAFf2AC52D3203B8D8A7A1AA0E8883e15449b28c8",
"transactionHash": "0xc183e44e50a2cfd6c816c87c2ea5f7779286735521636b4db6943f68850ce7fa"
}
},
"schemaVersion": "3.4.3",
"updatedAt": "2022-02-09T11:02:22.823Z",
"updatedAt": "2022-02-10T02:01:49.968Z",
"networkType": "ethereum",
"devdoc": {
"kind": "dev",

View File

@ -32109,12 +32109,12 @@
}
},
"links": {},
"address": "0x07b84822e814A68b057E9E09e616da43B38B9171",
"transactionHash": "0xd5e4d1c4d093a097bda41d6b7d7cd60e9985e8fd6bb4bd7aa563652c4a243737"
"address": "0xEef66A9e478861a4a101c85ba1E7CD506a04e925",
"transactionHash": "0x6b5e201eda17e315d1513e8c55de99623aa1696d610e717c37abcf39bed9279e"
}
},
"schemaVersion": "3.4.3",
"updatedAt": "2022-02-09T11:02:22.797Z",
"updatedAt": "2022-02-10T02:01:49.949Z",
"networkType": "ethereum",
"devdoc": {
"kind": "dev",

View File

@ -3158,12 +3158,12 @@
"1338": {
"events": {},
"links": {},
"address": "0x57a26552eaad5aDb4BcC4715A631Dcd23725abe6",
"transactionHash": "0x939d77413b159507b7e1a79b4c5c354ae0f0b3241a83944f115d3f51612ef27e"
"address": "0xFe2146D1e7a03218d033368613452d9282Df5183",
"transactionHash": "0x057b27bd0682c604c9bdf9d8132eefcdb5a6a40d1557ffd870e2900a986971b8"
}
},
"schemaVersion": "3.4.3",
"updatedAt": "2022-02-09T11:02:22.835Z",
"updatedAt": "2022-02-10T02:01:49.975Z",
"networkType": "ethereum",
"devdoc": {
"kind": "dev",

View File

@ -8865,12 +8865,12 @@
}
},
"links": {},
"address": "0xfDAED787615c30c95b34df9Dc7Aa8349aA6530E4",
"transactionHash": "0x52713f721812544f9773158de322f503f9a2a0eeb5dbd51b0130b57d3b8bdcb8"
"address": "0xaD7ac1341fa8c23ed3C5B381B39AE8B8F96d76de",
"transactionHash": "0x6e479a40de89089c5764ddefb7150da93893f24af54af21c0edea502e337e52e"
}
},
"schemaVersion": "3.4.3",
"updatedAt": "2022-02-09T11:02:22.813Z",
"updatedAt": "2022-02-10T02:01:49.960Z",
"networkType": "ethereum",
"devdoc": {
"kind": "dev",

View File

@ -5,12 +5,18 @@ const market = {
],
}
const admins = {
proposers: ["0x50A8e60041A206AcaA5F844a1104896224be6F39"],
executors: ["0x50A8e60041A206AcaA5F844a1104896224be6F39"]
}
const token = {
baseTokenURI: '',
}
var config = {
market,
admins,
token
}

View File

@ -5,12 +5,27 @@ import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/governance/TimelockController.sol";
import "./HasSignature.sol";
contract BEBoxMall is Ownable, HasSignature {
contract BEBoxMall is Ownable, HasSignature, TimelockController{
using SafeERC20 for IERC20;
using Address for address;
uint256 public constant MIN_DELAY = 2 minutes;
uint256 public constant MAX_DELAY = 16 days;
uint256 private _minDelay;
bool public address_initialized;
constructor(
address[] memory proposers,
address[] memory executors)
TimelockController(MIN_DELAY, proposers, executors){
_minDelay = MIN_DELAY;
address_initialized = false;
}
event BEBoxPaid(
uint256 indexed boxId,
address indexed buyer,
@ -23,10 +38,15 @@ contract BEBoxMall is Ownable, HasSignature {
mapping(bytes => bool) public usedSignatures;
function setPaymentReceivedAddress(address _paymentReceivedAddress)
external
onlyOwner
public
{
require(_paymentReceivedAddress != address(0), 'payment received address can not be zero');
require(_paymentReceivedAddress != address(0), 'BEBoxMall::setPaymentReceivedAddress: payment received address can not be zero');
if (address_initialized) {
require(msg.sender == address(this), "BEBoxMall::setPaymentReceivedAddress: Call must come from BEBoxMall.");
} else {
require(msg.sender == owner(), "BEBoxMall::setPaymentReceivedAddress: First call must come from owner.");
address_initialized = true;
}
paymentReceivedAddress = _paymentReceivedAddress;
}
@ -92,4 +112,31 @@ contract BEBoxMall is Ownable, HasSignature {
abi.encodePacked(_boxType, _paymentErc20, _price, _saltNonce)
);
}
/**
* @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), "BEBoxMall: caller must be timelock");
require(newDelay >= MIN_DELAY);
require(newDelay <= MAX_DELAY);
emit MinDelayChange(_minDelay, newDelay);
_minDelay = newDelay;
}
}

View File

@ -4,6 +4,7 @@ import "@openzeppelin/contracts/governance/TimelockController.sol";
contract BETimelockController is TimelockController {
uint256 public constant MIN_DELAY = 2 minutes;
uint256 public constant MAX_DELAY = 16 days;
uint256 private _minDelay;
constructor(
@ -36,6 +37,7 @@ contract BETimelockController is TimelockController {
function updateDelay(uint256 newDelay) external virtual override {
require(msg.sender == address(this), "BETimelockController: caller must be timelock");
require(newDelay >= MIN_DELAY);
require(newDelay <= MAX_DELAY);
emit MinDelayChange(_minDelay, newDelay);
_minDelay = newDelay;
}

View File

@ -3,7 +3,11 @@ const Box = artifacts.require('BEBoxMall');
const config = require("../config/config");
module.exports = async function (deployer, network, accounts) {
await deployer.deploy(Box);
await deployer.deploy(
Box,
config.admins.proposers,
config.admins.executors
);
const boxInstance = await Box.deployed();
if(boxInstance) {
console.log("BEBoxMall successfully deployed.")

View File

@ -12,8 +12,8 @@ const EvolveProxy = artifacts.require('EvolveProxy');
module.exports = async function (deployer, network, accounts) {
await deployer.deploy(
TimelockController,
[accounts[0]],
[accounts[0]]
config.admins.proposers,
config.admins.executors
);
const timelockInstance = await TimelockController.deployed();
if(timelockInstance) {
@ -23,6 +23,7 @@ module.exports = async function (deployer, network, accounts) {
const marketInstance = await MarketPlace.deployed();
await marketInstance.transferOwnership(timelockInstance.address);
console.log('MarketPlace onwer has change to: ', timelockInstance.address);
console.log('============= begin generate config ==============')
const heroInstance = await Hero.deployed();
const equipInstance = await Equip.deployed();
const chipInstance = await Chip.deployed();
@ -45,6 +46,6 @@ module.exports = async function (deployer, network, accounts) {
console.log(`export const privateKey = '';`)
console.log(`export const userBuyAddress = '${accounts[1]}';`)
} catch(err) {
console.log(err);
console.log('generate config with error: ', err);
}
}