becrypto/init_scripts/update_market_setting.js
2023-06-21 11:14:48 +08:00

148 lines
5.9 KiB
JavaScript

const FT = artifacts.require("tokens/erc20/FT");
const NFT = artifacts.require("tokens/erc20/NFT");
const BENftMarket = artifacts.require("market/BENftMarket");
const BENftMall = artifacts.require("market/BENftMall");
const GameItemMarket = artifacts.require("market/GameItemMarket");
const GameItemMall = artifacts.require("market/GameItemMall");
const config = require("../config/config");
const base = require("../scripts/base");
module.exports = async function main(callback) {
try {
// Our code will go here
const network = "arbitrum_testnet";
let cfgs = base.loadData({ network });
const accounts = await web3.eth.getAccounts();
console.log(accounts);
const heroInstance = await NFT.at(
cfgs.find((c) => c.name === "HERO").address
);
const equipInstance = await NFT.at(
cfgs.find((c) => c.name === "WEAPON").address
);
const chipInstance = await NFT.at(
cfgs.find((c) => c.name === "CHIP").address
);
const coinInstance = await FT.at(
cfgs.find((c) => c.name === "CEC").address
);
const goldInstance = await FT.at(
cfgs.find((c) => c.name === "CEG").address
);
config.market.paymentTokens.push(coinInstance.address);
config.market.paymentTokens.push(goldInstance.address);
// const marketInstance = await BENftMarket.at(
// cfgs.find((c) => c.name === "BENftMarket").address
// );
// const ROUND = 1000000;
// const DECIMALS = 1000000000000000000;
// if (marketInstance) {
// await marketInstance.setFeeToAddress(config.market.feeToAddress);
// console.log(
// `market receive fee address set to : ${config.market.feeToAddress}`
// );
// await marketInstance.setTaxToAddress(config.market.feeToAddress);
// console.log(
// `market receive tax address set to : ${config.market.feeToAddress}`
// );
// await marketInstance.setTransactionFee((3 * ROUND) / 100);
// await marketInstance.setTransactionTax((1 * ROUND) / 100);
// await marketInstance.addERC721Support(heroInstance.address);
// await marketInstance.addERC721Support(equipInstance.address);
// await marketInstance.addERC721Support(chipInstance.address);
// const maxPrice = web3.utils.toWei("99990000");
// const minPrice = web3.utils.toWei("0.01");
// await marketInstance.setNFTPriceMaxLimit(heroInstance.address, maxPrice);
// await marketInstance.setNFTPriceMinLimit(heroInstance.address, minPrice);
// await marketInstance.setNFTPriceMaxLimit(equipInstance.address, maxPrice);
// await marketInstance.setNFTPriceMinLimit(equipInstance.address, minPrice);
// await marketInstance.setNFTPriceMaxLimit(chipInstance.address, maxPrice);
// await marketInstance.setNFTPriceMinLimit(chipInstance.address, minPrice);
// for (let token of config.market.paymentTokens) {
// await marketInstance.addERC20Support(token);
// console.log(`add token for market payment: ${token}`);
// }
// console.log(`finish update market config`);
// }
// const gameMallInstance = await GameItemMall.at(
// cfgs.find((c) => c.name === "GameItemMall").address
// );
// if (gameMallInstance) {
// await gameMallInstance.setFeeToAddress(config.market.feeToAddress);
// console.log(
// `mall receive fee address set to : ${config.market.feeToAddress}`
// );
// await gameMallInstance.updateExecutor(config.admins.admin);
// console.log(`mall executor set to : ${config.admins.admin}`);
// for (let token of config.market.paymentTokens) {
// await gameMallInstance.addERC20Support(token);
// console.log(`add token for mall payment: ${token}`);
// }
// }
// const gameMarketInstance = await GameItemMarket.at(
// cfgs.find((c) => c.name === "GameItemMarket").address
// );
// if (gameMarketInstance) {
// await gameMarketInstance.setFeeToAddress(config.market.feeToAddress);
// console.log(
// `mall receive fee address set to : ${config.market.feeToAddress}`
// );
// await gameMarketInstance.updateExecutor(config.admins.admin);
// console.log(`mall executor set to : ${config.admins.admin}`);
// for (let token of config.market.paymentTokens) {
// await gameMarketInstance.addERC20Support(token);
// console.log(`add token for mall payment: ${token}`);
// }
// }
const nftMallInstance = await BENftMall.at(
cfgs.find((c) => c.name === "BENftMall").address
);
if (nftMallInstance) {
await nftMallInstance.setFeeToAddress(config.market.feeToAddress);
console.log(
`nft mall receive fee address set to : ${config.market.feeToAddress}`
);
await nftMallInstance.updateExecutor(config.admins.admin);
console.log(`mall executor set to : ${config.admins.admin}`);
for (let token of config.market.paymentTokens) {
await nftMallInstance.addERC20Support(token);
console.log(`add token for mall payment: ${token}`);
}
await nftMallInstance.addERC721Support(heroInstance.address);
console.log(`add token for mall sell: ${heroInstance.address}`);
await nftMallInstance.addERC721Support(equipInstance.address);
console.log(`add token for mall sell: ${equipInstance.address}`);
await nftMallInstance.addERC721Support(chipInstance.address);
console.log(`add token for mall sell: ${chipInstance.address}`);
await heroInstance.setMintRole(nftMallInstance.address);
await equipInstance.setMintRole(nftMallInstance.address);
await chipInstance.setMintRole(nftMallInstance.address);
const testHeroInstance = await NFT.at(
cfgs.find((c) => c.name === "TestHERO").address
);
await nftMallInstance.addERC721Support(testHeroInstance.address);
await testHeroInstance.setMintRole(nftMallInstance.address);
}
callback(0);
} catch (error) {
console.error(error);
callback(1);
}
};