136 lines
4.6 KiB
JavaScript
136 lines
4.6 KiB
JavaScript
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');
|
|
const Box = artifacts.require('BEBoxMall');
|
|
const EvolveProxy = artifacts.require('EvolveProxy');
|
|
|
|
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();
|
|
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(EvolveProxy);
|
|
const proxyInstance = await EvolveProxy.deployed();
|
|
if(proxyInstance) {
|
|
console.log("EvolveProxy successfully deployed.")
|
|
}
|
|
try {
|
|
proxyInstance.init([
|
|
heroInstance.address,
|
|
equipInstance.address,
|
|
chipInstance.address
|
|
])
|
|
heroInstance.setBurnProxy(proxyInstance.address);
|
|
equipInstance.setBurnProxy(proxyInstance.address);
|
|
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}`
|
|
);
|
|
} catch(err) {
|
|
console.log(err);
|
|
}
|
|
|
|
|
|
|
|
await deployer.deploy(MarketPlace);
|
|
const marketInstance = await MarketPlace.deployed();
|
|
if(marketInstance) {
|
|
console.log("MarketPlace successfully deployed.")
|
|
}
|
|
try {
|
|
marketInstance.setFeeToAddress(account);
|
|
marketInstance.setPaymentTokens([coinInstance.address]);
|
|
} catch(err) {
|
|
console.log(err);
|
|
}
|
|
|
|
await deployer.deploy(Box);
|
|
const boxInstance = await Box.deployed();
|
|
if(boxInstance) {
|
|
console.log("BEBoxMall successfully deployed.")
|
|
}
|
|
try {
|
|
await boxInstance.setPaymentReceivedAddress(account);
|
|
console.log(
|
|
`update payment received address: ${account}`
|
|
);
|
|
} 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);
|
|
}
|
|
if (network == "lan22" || network == "development") {
|
|
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})
|
|
console.log(jsons);
|
|
console.log(`export const userAddress = '${accounts[0]}';`)
|
|
console.log(`export const privateKey = '';`)
|
|
console.log(`export const userBuyAddress = '${accounts[1]}';`)
|
|
}
|
|
|
|
}; |