更新market相关地址, 增加官方商城的配置脚本

This commit is contained in:
CounterFire2023 2023-06-15 16:13:02 +08:00
parent 80244a77d7
commit 81d2a11c2f
4 changed files with 166 additions and 10 deletions

View File

@ -10,7 +10,7 @@ import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol"; import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
contract BENFTMarket is Ownable, ReentrancyGuard, ERC1155Holder, ERC721Holder { contract BENftMarket is Ownable, ReentrancyGuard, ERC1155Holder, ERC721Holder {
using SafeERC20 for IERC20; using SafeERC20 for IERC20;
struct OrderInfo { struct OrderInfo {

View File

@ -0,0 +1,96 @@
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.setFeeToAddress(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}`);
}
}
callback(0);
} catch (error) {
console.error(error);
callback(1);
}
};

View File

@ -1,9 +1,12 @@
const MarketPlace = artifacts.require("market/BENftMarket"); 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 base = require("../scripts/base"); const base = require("../scripts/base");
module.exports = async function (deployer, network, accounts) { module.exports = async function (deployer, network, accounts) {
await deployer.deploy(MarketPlace); await deployer.deploy(BENftMarket);
const marketInstance = await MarketPlace.deployed(); const marketInstance = await BENftMarket.deployed();
if (marketInstance) { if (marketInstance) {
console.log("MarketPlace successfully deployed."); console.log("MarketPlace successfully deployed.");
} }
@ -14,4 +17,43 @@ module.exports = async function (deployer, network, accounts) {
address: marketInstance.address, address: marketInstance.address,
network, network,
}); });
await deployer.deploy(BENftMall);
const nftMallInstance = await BENftMall.deployed();
if (nftMallInstance) {
console.log("BENftMall successfully deployed.");
}
base.updateArray({
name: "BENftMall",
type: "logic",
json: "assets/contracts/BENftMall.json",
address: nftMallInstance.address,
network,
});
await deployer.deploy(GameItemMarket);
const gameMarketInstance = await GameItemMarket.deployed();
if (gameMarketInstance) {
console.log("GameItemMarket successfully deployed.");
}
base.updateArray({
name: "GameItemMarket",
type: "logic",
json: "assets/contracts/GameItemMarket.json",
address: gameMarketInstance.address,
network,
});
await deployer.deploy(GameItemMall);
const gameMallInstance = await GameItemMall.deployed();
if (gameMallInstance) {
console.log("GameItemMall successfully deployed.");
}
base.updateArray({
name: "GameItemMall",
type: "logic",
json: "assets/contracts/GameItemMall.json",
address: gameMallInstance.address,
network,
});
}; };

View File

@ -41,12 +41,6 @@
"json": "assets/contracts/BEBadge.json", "json": "assets/contracts/BEBadge.json",
"address": "0xB469331cEC98E52b7Eab07dFB586253bE232BBF7" "address": "0xB469331cEC98E52b7Eab07dFB586253bE232BBF7"
}, },
{
"name": "BENFTMarket",
"type": "logic",
"json": "assets/contracts/BENFTMarket.json",
"address": "0xb80E19c50747972E735c68C0BA5651AD952d70BC"
},
{ {
"name": "UserMinterFactory", "name": "UserMinterFactory",
"type": "logic", "type": "logic",
@ -64,5 +58,29 @@
"type": "logic", "type": "logic",
"json": "assets/contracts/ClaimBoxFactory.json", "json": "assets/contracts/ClaimBoxFactory.json",
"address": "0x41a7f94f0B3b615F84c7084F45556FEf1bd18A18" "address": "0x41a7f94f0B3b615F84c7084F45556FEf1bd18A18"
},
{
"name": "BENFTMarket",
"type": "logic",
"json": "assets/contracts/BENFTMarket.json",
"address": "0x1d33b4E045ce595B6346C3D0e334814dd4Af5418"
},
{
"name": "BENftMall",
"type": "logic",
"json": "assets/contracts/BENftMall.json",
"address": "0x38Bf9f3C29D8384B6A79435745AE796cd2465545"
},
{
"name": "GameItemMarket",
"type": "logic",
"json": "assets/contracts/GameItemMarket.json",
"address": "0x19a13Da2E7EB33210c98B589888EA68267ee61d6"
},
{
"name": "GameItemMall",
"type": "logic",
"json": "assets/contracts/GameItemMall.json",
"address": "0x52e3Eb12A2e7f6F9BEAcEd3C2122eD508091A2F1"
} }
] ]