boxmall的setPaymentReceivedAddress增加timelock
This commit is contained in:
parent
a3d2c4b970
commit
c27f6db714
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
@ -10246,12 +10246,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"links": {},
|
"links": {},
|
||||||
"address": "0xcCcB7e38669894e319ab1Ba1a424d7f14C153C69",
|
"address": "0x24FCAF072dc88166076bEC67AF8dBb56C5AA86A3",
|
||||||
"transactionHash": "0xcce928be67951196c39a1616909dbea441740422b80e3d59fcfcca22d032138f"
|
"transactionHash": "0xb99e3a5a3c340863aa110e09327df04840984099a3bf8e80b93b92d843c5e5ba"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schemaVersion": "3.4.3",
|
"schemaVersion": "3.4.3",
|
||||||
"updatedAt": "2022-02-09T11:02:22.720Z",
|
"updatedAt": "2022-02-10T02:01:49.892Z",
|
||||||
"networkType": "ethereum",
|
"networkType": "ethereum",
|
||||||
"devdoc": {
|
"devdoc": {
|
||||||
"kind": "dev",
|
"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
@ -23041,12 +23041,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"links": {},
|
"links": {},
|
||||||
"address": "0x21601e485c3EaeaF3973C2d7e0379267C9c31cc6",
|
"address": "0xAFf2AC52D3203B8D8A7A1AA0E8883e15449b28c8",
|
||||||
"transactionHash": "0xde1847d5018eaa7dbe1a6ac278595735925aabbcbf59dd6b3b515d78780b7ffd"
|
"transactionHash": "0xc183e44e50a2cfd6c816c87c2ea5f7779286735521636b4db6943f68850ce7fa"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schemaVersion": "3.4.3",
|
"schemaVersion": "3.4.3",
|
||||||
"updatedAt": "2022-02-09T11:02:22.823Z",
|
"updatedAt": "2022-02-10T02:01:49.968Z",
|
||||||
"networkType": "ethereum",
|
"networkType": "ethereum",
|
||||||
"devdoc": {
|
"devdoc": {
|
||||||
"kind": "dev",
|
"kind": "dev",
|
||||||
|
@ -32109,12 +32109,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"links": {},
|
"links": {},
|
||||||
"address": "0x07b84822e814A68b057E9E09e616da43B38B9171",
|
"address": "0xEef66A9e478861a4a101c85ba1E7CD506a04e925",
|
||||||
"transactionHash": "0xd5e4d1c4d093a097bda41d6b7d7cd60e9985e8fd6bb4bd7aa563652c4a243737"
|
"transactionHash": "0x6b5e201eda17e315d1513e8c55de99623aa1696d610e717c37abcf39bed9279e"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schemaVersion": "3.4.3",
|
"schemaVersion": "3.4.3",
|
||||||
"updatedAt": "2022-02-09T11:02:22.797Z",
|
"updatedAt": "2022-02-10T02:01:49.949Z",
|
||||||
"networkType": "ethereum",
|
"networkType": "ethereum",
|
||||||
"devdoc": {
|
"devdoc": {
|
||||||
"kind": "dev",
|
"kind": "dev",
|
||||||
|
@ -3158,12 +3158,12 @@
|
|||||||
"1338": {
|
"1338": {
|
||||||
"events": {},
|
"events": {},
|
||||||
"links": {},
|
"links": {},
|
||||||
"address": "0x57a26552eaad5aDb4BcC4715A631Dcd23725abe6",
|
"address": "0xFe2146D1e7a03218d033368613452d9282Df5183",
|
||||||
"transactionHash": "0x939d77413b159507b7e1a79b4c5c354ae0f0b3241a83944f115d3f51612ef27e"
|
"transactionHash": "0x057b27bd0682c604c9bdf9d8132eefcdb5a6a40d1557ffd870e2900a986971b8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schemaVersion": "3.4.3",
|
"schemaVersion": "3.4.3",
|
||||||
"updatedAt": "2022-02-09T11:02:22.835Z",
|
"updatedAt": "2022-02-10T02:01:49.975Z",
|
||||||
"networkType": "ethereum",
|
"networkType": "ethereum",
|
||||||
"devdoc": {
|
"devdoc": {
|
||||||
"kind": "dev",
|
"kind": "dev",
|
||||||
|
@ -8865,12 +8865,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"links": {},
|
"links": {},
|
||||||
"address": "0xfDAED787615c30c95b34df9Dc7Aa8349aA6530E4",
|
"address": "0xaD7ac1341fa8c23ed3C5B381B39AE8B8F96d76de",
|
||||||
"transactionHash": "0x52713f721812544f9773158de322f503f9a2a0eeb5dbd51b0130b57d3b8bdcb8"
|
"transactionHash": "0x6e479a40de89089c5764ddefb7150da93893f24af54af21c0edea502e337e52e"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schemaVersion": "3.4.3",
|
"schemaVersion": "3.4.3",
|
||||||
"updatedAt": "2022-02-09T11:02:22.813Z",
|
"updatedAt": "2022-02-10T02:01:49.960Z",
|
||||||
"networkType": "ethereum",
|
"networkType": "ethereum",
|
||||||
"devdoc": {
|
"devdoc": {
|
||||||
"kind": "dev",
|
"kind": "dev",
|
||||||
|
@ -5,12 +5,18 @@ const market = {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const admins = {
|
||||||
|
proposers: ["0x50A8e60041A206AcaA5F844a1104896224be6F39"],
|
||||||
|
executors: ["0x50A8e60041A206AcaA5F844a1104896224be6F39"]
|
||||||
|
}
|
||||||
|
|
||||||
const token = {
|
const token = {
|
||||||
baseTokenURI: '',
|
baseTokenURI: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
market,
|
market,
|
||||||
|
admins,
|
||||||
token
|
token
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,12 +5,27 @@ import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|||||||
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
||||||
import "@openzeppelin/contracts/access/Ownable.sol";
|
import "@openzeppelin/contracts/access/Ownable.sol";
|
||||||
import "@openzeppelin/contracts/utils/Address.sol";
|
import "@openzeppelin/contracts/utils/Address.sol";
|
||||||
|
import "@openzeppelin/contracts/governance/TimelockController.sol";
|
||||||
import "./HasSignature.sol";
|
import "./HasSignature.sol";
|
||||||
|
|
||||||
contract BEBoxMall is Ownable, HasSignature {
|
contract BEBoxMall is Ownable, HasSignature, TimelockController{
|
||||||
using SafeERC20 for IERC20;
|
using SafeERC20 for IERC20;
|
||||||
using Address for address;
|
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(
|
event BEBoxPaid(
|
||||||
uint256 indexed boxId,
|
uint256 indexed boxId,
|
||||||
address indexed buyer,
|
address indexed buyer,
|
||||||
@ -23,10 +38,15 @@ contract BEBoxMall is Ownable, HasSignature {
|
|||||||
mapping(bytes => bool) public usedSignatures;
|
mapping(bytes => bool) public usedSignatures;
|
||||||
|
|
||||||
function setPaymentReceivedAddress(address _paymentReceivedAddress)
|
function setPaymentReceivedAddress(address _paymentReceivedAddress)
|
||||||
external
|
public
|
||||||
onlyOwner
|
|
||||||
{
|
{
|
||||||
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;
|
paymentReceivedAddress = _paymentReceivedAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,4 +112,31 @@ contract BEBoxMall is Ownable, HasSignature {
|
|||||||
abi.encodePacked(_boxType, _paymentErc20, _price, _saltNonce)
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import "@openzeppelin/contracts/governance/TimelockController.sol";
|
|||||||
|
|
||||||
contract BETimelockController is TimelockController {
|
contract BETimelockController is TimelockController {
|
||||||
uint256 public constant MIN_DELAY = 2 minutes;
|
uint256 public constant MIN_DELAY = 2 minutes;
|
||||||
|
uint256 public constant MAX_DELAY = 16 days;
|
||||||
uint256 private _minDelay;
|
uint256 private _minDelay;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ -36,6 +37,7 @@ contract BETimelockController is TimelockController {
|
|||||||
function updateDelay(uint256 newDelay) external virtual override {
|
function updateDelay(uint256 newDelay) external virtual override {
|
||||||
require(msg.sender == address(this), "BETimelockController: caller must be timelock");
|
require(msg.sender == address(this), "BETimelockController: caller must be timelock");
|
||||||
require(newDelay >= MIN_DELAY);
|
require(newDelay >= MIN_DELAY);
|
||||||
|
require(newDelay <= MAX_DELAY);
|
||||||
emit MinDelayChange(_minDelay, newDelay);
|
emit MinDelayChange(_minDelay, newDelay);
|
||||||
_minDelay = newDelay;
|
_minDelay = newDelay;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,11 @@ const Box = artifacts.require('BEBoxMall');
|
|||||||
const config = require("../config/config");
|
const config = require("../config/config");
|
||||||
|
|
||||||
module.exports = async function (deployer, network, accounts) {
|
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();
|
const boxInstance = await Box.deployed();
|
||||||
if(boxInstance) {
|
if(boxInstance) {
|
||||||
console.log("BEBoxMall successfully deployed.")
|
console.log("BEBoxMall successfully deployed.")
|
||||||
|
@ -12,8 +12,8 @@ const EvolveProxy = artifacts.require('EvolveProxy');
|
|||||||
module.exports = async function (deployer, network, accounts) {
|
module.exports = async function (deployer, network, accounts) {
|
||||||
await deployer.deploy(
|
await deployer.deploy(
|
||||||
TimelockController,
|
TimelockController,
|
||||||
[accounts[0]],
|
config.admins.proposers,
|
||||||
[accounts[0]]
|
config.admins.executors
|
||||||
);
|
);
|
||||||
const timelockInstance = await TimelockController.deployed();
|
const timelockInstance = await TimelockController.deployed();
|
||||||
if(timelockInstance) {
|
if(timelockInstance) {
|
||||||
@ -23,6 +23,7 @@ module.exports = async function (deployer, network, accounts) {
|
|||||||
const marketInstance = await MarketPlace.deployed();
|
const marketInstance = await MarketPlace.deployed();
|
||||||
await marketInstance.transferOwnership(timelockInstance.address);
|
await marketInstance.transferOwnership(timelockInstance.address);
|
||||||
console.log('MarketPlace onwer has change to: ', timelockInstance.address);
|
console.log('MarketPlace onwer has change to: ', timelockInstance.address);
|
||||||
|
console.log('============= begin generate config ==============')
|
||||||
const heroInstance = await Hero.deployed();
|
const heroInstance = await Hero.deployed();
|
||||||
const equipInstance = await Equip.deployed();
|
const equipInstance = await Equip.deployed();
|
||||||
const chipInstance = await Chip.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 privateKey = '';`)
|
||||||
console.log(`export const userBuyAddress = '${accounts[1]}';`)
|
console.log(`export const userBuyAddress = '${accounts[1]}';`)
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
console.log(err);
|
console.log('generate config with error: ', err);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user