becrypto/migrations/10_deploy_shard.js

36 lines
1.8 KiB
JavaScript

let Shard = artifacts.require("tokens/erc1155/BEShard");
let ShardAssembler = artifacts.require("logic/ShardAssembler");
let Nft = artifacts.require("tokens/erc721/NFT");
let FT = artifacts.require("tokens/erc20/FT");
const base = require("../scripts/base");
module.exports = async function (deployer, network, accounts) {
const config = require(`../config/config_${network}`);
let cfgs = base.loadData({ network });
await deployer.deploy(Shard);
const shardInstance = await Shard.deployed();
if (shardInstance) {
console.log("BEShard successfully deployed: ", shardInstance.address);
}
const heroInstance = await Nft.at(cfgs.find((c) => c.name === "HERO").address);
await deployer.deploy(ShardAssembler, [heroInstance.address, shardInstance.address]);
const shardAssemblerInstance = await ShardAssembler.deployed();
if (shardAssemblerInstance) {
console.log("ShardAssembler successfully deployed: ", shardAssemblerInstance.address);
}
await shardInstance.setMintRole(config.admins.admin);
await heroInstance.setMintRole(shardAssemblerInstance.address);
console.log(`success set mint role for: ${heroInstance.address}`);
await shardInstance.setApprovalForAll(shardAssemblerInstance.address, true);
console.log(`success set approve for all for: ${shardInstance.address}`);
await shardAssemblerInstance.updateExecutor(config.admins.admin);
console.log(`success set executor for: ${shardAssemblerInstance.address}`);
const coinInstance = await FT.at(cfgs.find((c) => c.name === "CEC").address);
await shardAssemblerInstance.addERC20Support(coinInstance.address);
console.log(`success add erc20 support for: ${shardAssemblerInstance.address}`);
await shardAssemblerInstance.setFeeToAddress(config.admins.admin);
console.log(`success set fee to address for: ${shardAssemblerInstance.address}`);
};