const Hero = artifacts.require('BEHero'); const Equip = artifacts.require('BEEquipment'); const Chip = artifacts.require('BEChip'); const Factory = artifacts.require('MinterFactory'); const MarketPlace = artifacts.require('MarketPlace'); const Coin = artifacts.require('BECoin'); module.exports = async function (deployer) { await deployer.deploy(Coin); const coinInstance = await Coin.deployed(); if(coinInstance) { console.log("BECoin successfully deployed.") } await deployer.deploy(Hero); const heroInstance = await Hero.deployed(); if(heroInstance) { console.log("BEHero successfully deployed.") } await deployer.deploy(Equip); const equipInstance = await Equip.deployed(); if(equipInstance) { console.log("Equip successfully deployed.") } await deployer.deploy(Chip); const chipInstance = await Chip.deployed(); if(chipInstance) { console.log("Chip successfully deployed.") } await deployer.deploy(Factory); const factoryInstance = await Factory.deployed(); if(factoryInstance) { console.log("Mint Factory successfully deployed.") } try { factoryInstance.init([ heroInstance.address, equipInstance.address, chipInstance.address ]) heroInstance.setMintFactory(factoryInstance.address); equipInstance.setMintFactory(factoryInstance.address); 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}` ); } catch(err) { console.log(err); } await deployer.deploy(MarketPlace); const marketInstance = await MarketPlace.deployed(); if(marketInstance) { console.log("MarketPlace successfully deployed.") } try { marketInstance.setFeeToAddress('0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1'); marketInstance.setPaymentTokens([coinInstance.address]); } catch(err) { console.log(err); } // add marketplace to whitelist try { await heroInstance.addApprovalWhitelist(marketInstance.address); await equipInstance.addApprovalWhitelist(marketInstance.address); await chipInstance.addApprovalWhitelist(marketInstance.address); console.log( `Allow operation ${marketInstance.address} to reduce gas fee` ); } catch (err) { console.log(err); } 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}) console.log(jsons); };