diff --git a/migrations/10_deploy_box.js b/migrations/10_deploy_box.js new file mode 100644 index 0000000..1731830 --- /dev/null +++ b/migrations/10_deploy_box.js @@ -0,0 +1,15 @@ +const Box = artifacts.require('BEBoxMall'); + +const config = require("../config/config"); + +module.exports = async function (deployer, network, accounts) { + await deployer.deploy( + Box, + config.admins.proposers, + config.admins.executors + ); + const boxInstance = await Box.deployed(); + if(boxInstance) { + console.log("BEBoxMall successfully deployed.") + } +} \ No newline at end of file diff --git a/migrations/11_deploy_timelock.js b/migrations/11_deploy_timelock.js new file mode 100644 index 0000000..7ac9660 --- /dev/null +++ b/migrations/11_deploy_timelock.js @@ -0,0 +1,15 @@ +const TimelockController = artifacts.require('BETimelockController'); +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.") + } +} \ No newline at end of file diff --git a/migrations/12_update_nft_setting.js b/migrations/12_update_nft_setting.js new file mode 100644 index 0000000..69667cd --- /dev/null +++ b/migrations/12_update_nft_setting.js @@ -0,0 +1,88 @@ +const MarketPlace = artifacts.require('MarketPlace'); +const Factory = artifacts.require('MinterFactory'); +const EvolveProxy = artifacts.require('EvolveProxy'); +const Box = artifacts.require('BEBoxMall'); +const Hero = artifacts.require('BEHero'); +const Equip = artifacts.require('BEEquipment'); +const Chip = artifacts.require('BEChip'); +const Coin = artifacts.require('BECoin'); +const config = require("../config/config"); + + +module.exports = async function (deployer, network, accounts) { + + const heroInstance = await Hero.deployed(); + const equipInstance = await Equip.deployed(); + const chipInstance = await Chip.deployed(); + + await heroInstance.updateBaseURI(config.token.baseTokenURI) + console.log("BEHero baseURI update success.") + + + await equipInstance.updateBaseURI(config.token.baseTokenURI) + console.log("Equip baseURI update success.") + + await chipInstance.updateBaseURI(config.token.baseTokenURI) + console.log("Chip baseURI update success.") + + const marketInstance = await MarketPlace.deployed(); + if(marketInstance) { + await marketInstance.setFeeToAddress(config.market.feeToAddress); + await marketInstance.setTransactionFee(400); + const coinInstance = await Coin.deployed(); + config.market.paymentTokens.push(coinInstance.address); + await marketInstance.setPaymentTokens(config.market.paymentTokens); + + + await heroInstance.addApprovalWhitelist(marketInstance.address); + await heroInstance.setApprovalForAll(marketInstance.address); + await equipInstance.addApprovalWhitelist(marketInstance.address); + await equipInstance.setApprovalForAll(marketInstance.address); + await chipInstance.addApprovalWhitelist(marketInstance.address); + await chipInstance.setApprovalForAll(marketInstance.address); + console.log( + `Allow operation ${marketInstance.address} to reduce gas fee` + ); + } + + const factoryInstance = await Factory.deployed(); + if(factoryInstance) { + await factoryInstance.init([ + heroInstance.address, + equipInstance.address, + chipInstance.address + ]) + await heroInstance.setMintFactory(factoryInstance.address); + await equipInstance.setMintFactory(factoryInstance.address); + await chipInstance.setMintFactory(factoryInstance.address); + console.log( + `Allow factory ${factoryInstance.address} to mint contract \n hero: ${heroInstance.address}, \n equip: ${equipInstance.address}, \n chip: ${chipInstance.address}` + ); + } + + const proxyInstance = await EvolveProxy.deployed(); + if(proxyInstance) { + await proxyInstance.init([ + heroInstance.address, + equipInstance.address, + chipInstance.address + ]) + await heroInstance.setBurnProxy(proxyInstance.address); + await equipInstance.setBurnProxy(proxyInstance.address); + await chipInstance.setBurnProxy(proxyInstance.address); + console.log( + `Allow proxy ${proxyInstance.address} to burn contract \n hero: ${heroInstance.address}, \n equip: ${equipInstance.address}, \n chip: ${chipInstance.address}` + ); + } + + + const boxInstance = await Box.deployed(); + if(boxInstance) { + await boxInstance.setPaymentReceivedAddress(config.market.mallFeeAddress); + console.log( + `update payment received address: ${config.market.mallFeeAddress}` + ); + } + + +} \ No newline at end of file diff --git a/migrations/13_update_timelock.js b/migrations/13_update_timelock.js new file mode 100644 index 0000000..331063b --- /dev/null +++ b/migrations/13_update_timelock.js @@ -0,0 +1,53 @@ +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) { + + try { + const timelockInstance = await TimelockController.deployed(); + 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); + const proxyInstance = await EvolveProxy.deployed(); + await proxyInstance.transferOwnership(timelockInstance.address); + console.log('EvolveProxy onwer has change to: ', timelockInstance.address); + console.log('============= begin generate config ==============') + const coinInstance = await Coin.deployed(); + const factoryInstance = await Factory.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); + } +} \ No newline at end of file diff --git a/migrations/2_deploy_coin.js b/migrations/2_deploy_coin.js index 58a6533..c09128d 100644 --- a/migrations/2_deploy_coin.js +++ b/migrations/2_deploy_coin.js @@ -1,8 +1,6 @@ const Coin = artifacts.require('BECoin'); module.exports = async function (deployer, network, accounts) { - const account = accounts[0]; - console.log('current account: ', account); await deployer.deploy(Coin); const coinInstance = await Coin.deployed(); diff --git a/migrations/3_deploy_gold.js b/migrations/3_deploy_gold.js new file mode 100644 index 0000000..4307e48 --- /dev/null +++ b/migrations/3_deploy_gold.js @@ -0,0 +1,10 @@ +const Coin = artifacts.require('BEGold'); + +module.exports = async function (deployer, network, accounts) { + await deployer.deploy(Coin); + const coinInstance = await Coin.deployed(); + if(coinInstance) { + // tmpData.writeKeyVal('coin', coinInstance.address); + console.log("BEGold successfully deployed.") + } +}; \ No newline at end of file diff --git a/migrations/4_deploy_hero.js b/migrations/4_deploy_hero.js new file mode 100644 index 0000000..0340650 --- /dev/null +++ b/migrations/4_deploy_hero.js @@ -0,0 +1,10 @@ +const Hero = artifacts.require('BEHero'); +const config = require("../config/config"); + +module.exports = async function (deployer, network, accounts) { + await deployer.deploy(Hero); + const heroInstance = await Hero.deployed(); + if(heroInstance) { + console.log("BEHero successfully deployed.") + } +} \ No newline at end of file diff --git a/migrations/5_deploy_equip.js b/migrations/5_deploy_equip.js new file mode 100644 index 0000000..e54db3e --- /dev/null +++ b/migrations/5_deploy_equip.js @@ -0,0 +1,10 @@ +const Equip = artifacts.require('BEEquipment'); +const config = require("../config/config"); + +module.exports = async function (deployer, network, accounts) { + await deployer.deploy(Equip); + const equipInstance = await Equip.deployed(); + if(equipInstance) { + console.log("Equip successfully deployed.") + } +} \ No newline at end of file diff --git a/migrations/6_deploy_chip.js b/migrations/6_deploy_chip.js new file mode 100644 index 0000000..0db185f --- /dev/null +++ b/migrations/6_deploy_chip.js @@ -0,0 +1,10 @@ +const Chip = artifacts.require('BEChip'); +const config = require("../config/config"); + +module.exports = async function (deployer, network, accounts) { + await deployer.deploy(Chip); + const chipInstance = await Chip.deployed(); + if(chipInstance) { + console.log("Chip successfully deployed.") + } +} \ No newline at end of file diff --git a/migrations/7_deploy_market.js b/migrations/7_deploy_market.js new file mode 100644 index 0000000..40cc9fb --- /dev/null +++ b/migrations/7_deploy_market.js @@ -0,0 +1,9 @@ +const MarketPlace = artifacts.require('MarketPlace'); + +module.exports = async function (deployer, network, accounts) { + await deployer.deploy(MarketPlace); + const marketInstance = await MarketPlace.deployed(); + if(marketInstance) { + console.log("MarketPlace successfully deployed.") + } +} \ No newline at end of file diff --git a/migrations/8_deploy_factory.js b/migrations/8_deploy_factory.js new file mode 100644 index 0000000..428789c --- /dev/null +++ b/migrations/8_deploy_factory.js @@ -0,0 +1,10 @@ +const Factory = artifacts.require('MinterFactory'); + +module.exports = async function (deployer, network, accounts) { + await deployer.deploy(Factory); + const factoryInstance = await Factory.deployed(); + if(factoryInstance) { + console.log("Mint Factory successfully deployed.") + } + +} \ No newline at end of file diff --git a/migrations/9_deploy_proxy.js b/migrations/9_deploy_proxy.js new file mode 100644 index 0000000..cfce117 --- /dev/null +++ b/migrations/9_deploy_proxy.js @@ -0,0 +1,9 @@ +const EvolveProxy = artifacts.require('EvolveProxy'); + +module.exports = async function (deployer, network, accounts) { + await deployer.deploy(EvolveProxy); + const proxyInstance = await EvolveProxy.deployed(); + if(proxyInstance) { + console.log("EvolveProxy successfully deployed.") + } +} \ No newline at end of file