修改market购买中心化物品的方法

This commit is contained in:
CounterFire2023 2023-06-15 20:03:56 +08:00
parent b0eea9601b
commit f37fc2f087
5 changed files with 4991 additions and 5185 deletions

File diff suppressed because one or more lines are too long

View File

@ -65,18 +65,17 @@ contract GameItemMarket is
orderId,
currency,
price,
feeToAddress,
startTime,
saltNonce
);
checkSigner(executor, criteriaMessageHash, signature);
require(
IERC20(currency).balanceOf(_msgSender()) >= price,
"GameItemMall: buyer doesn't have enough token to buy this item"
"GameItemMarket: buyer doesn't have enough token to buy this item"
);
require(
IERC20(currency).allowance(_msgSender(), address(this)) >= price,
"GameItemMall: buyer doesn't approve marketplace to spend payment amount"
"GameItemMarket: buyer doesn't approve marketplace to spend payment amount"
);
uint256 _transactionFee = (price * transactionFee) / ROUND;
if (_transactionFee > 0) {
@ -112,7 +111,6 @@ contract GameItemMarket is
uint256 _orderId,
address _currency,
uint256 _price,
address _feeToAddress,
uint256 _startTime,
uint256 _saltNonce
) public pure returns (bytes32) {
@ -122,7 +120,6 @@ contract GameItemMarket is
_orderId,
_currency,
_price,
_feeToAddress,
_startTime,
_saltNonce
);

View File

@ -36,54 +36,72 @@ module.exports = async function main(callback) {
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 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
// 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 (gameMallInstance) {
await gameMallInstance.setFeeToAddress(config.market.feeToAddress);
if (gameMarketInstance) {
await gameMarketInstance.setFeeToAddress(config.market.feeToAddress);
console.log(
`mall receive fee address set to : ${config.market.feeToAddress}`
);
await gameMallInstance.updateExecutor(config.admins.admin);
await gameMarketInstance.updateExecutor(config.admins.admin);
console.log(`mall executor set to : ${config.admins.admin}`);
for (let token of config.market.paymentTokens) {
await gameMallInstance.addERC20Support(token);
await gameMarketInstance.addERC20Support(token);
console.log(`add token for mall payment: ${token}`);
}
}

View File

@ -31,29 +31,29 @@ module.exports = async function (deployer, network, accounts) {
// 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.");
await deployer.deploy(GameItemMarket);
const gameMarketInstance = await GameItemMarket.deployed();
if (gameMarketInstance) {
console.log("GameItemMarket successfully deployed.");
}
base.updateArray({
name: "GameItemMall",
name: "GameItemMarket",
type: "logic",
json: "assets/contracts/GameItemMall.json",
address: gameMallInstance.address,
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

@ -75,7 +75,7 @@
"name": "GameItemMarket",
"type": "logic",
"json": "assets/contracts/GameItemMarket.json",
"address": "0x19a13Da2E7EB33210c98B589888EA68267ee61d6"
"address": "0x46e2C612756b702b3d68d89F97c88FFa725F6fab"
},
{
"name": "GameItemMall",