becrypto/migrations/8_deploy_timelock.js
2022-02-10 15:35:32 +08:00

58 lines
3.1 KiB
JavaScript

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');
const config = require("../config/config");
module.exports = async function (deployer, network, accounts) {
await deployer.deploy(
TimelockController,
config.admins.proposers,
config.admins.executors
);
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();
await heroInstance.transferOwnership(timelockInstance.address);
console.log('Hero onwer has change to: ', timelockInstance.address);
const equipInstance = await Equip.deployed();
await equipInstance.transferOwnership(timelockInstance.address);
console.log('Equip onwer has change to: ', timelockInstance.address);
const chipInstance = await Chip.deployed();
await chipInstance.transferOwnership(timelockInstance.address);
console.log('Chip onwer has change to: ', timelockInstance.address);
console.log('============= begin generate config ==============')
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('generate config with error: ', err);
}
}