根据审计报告修改合约
This commit is contained in:
parent
fb0c3a2093
commit
7453ceeef4
@ -24,6 +24,8 @@ contract BENftMarket is Ownable, ReentrancyGuard, ERC1155Holder, ERC721Holder {
|
||||
}
|
||||
mapping(address => bool) public erc721Supported;
|
||||
mapping(address => bool) public erc1155Supported;
|
||||
mapping(address => bool) public erc721SupportedHistory;
|
||||
mapping(address => bool) public erc1155SupportedHistory;
|
||||
mapping(address => bool) public erc20Supported;
|
||||
mapping(uint256 => OrderInfo) public orderInfos;
|
||||
mapping(address => uint256) public nftPriceMaxLimit;
|
||||
@ -145,9 +147,10 @@ contract BENftMarket is Ownable, ReentrancyGuard, ERC1155Holder, ERC721Holder {
|
||||
);
|
||||
}
|
||||
|
||||
function buy(uint256 orderId) external nonReentrant {
|
||||
function buy(uint256 orderId, uint256 price) external nonReentrant {
|
||||
OrderInfo memory orderInfo = orderInfos[orderId];
|
||||
require(orderInfo.tokenId != 0, "NFTMarket: NFT does not exist");
|
||||
require(orderInfo.orderId != 0, "NFTMarket: order info does not exist");
|
||||
require(orderInfo.price == price, "NFTMarket: Price error");
|
||||
uint256 _transactionFee = (orderInfo.price * transactionFee) / ROUND;
|
||||
tranFeeTotal = tranFeeTotal + _transactionFee;
|
||||
uint256 _transactionTax = (orderInfo.price * transactionTax) / ROUND;
|
||||
@ -178,13 +181,19 @@ contract BENftMarket is Ownable, ReentrancyGuard, ERC1155Holder, ERC721Holder {
|
||||
);
|
||||
}
|
||||
|
||||
if (erc721Supported[orderInfo.nftToken]) {
|
||||
if (
|
||||
erc721Supported[orderInfo.nftToken] ||
|
||||
erc721SupportedHistory[orderInfo.nftToken]
|
||||
) {
|
||||
IERC721(orderInfo.nftToken).safeTransferFrom(
|
||||
address(this),
|
||||
_msgSender(),
|
||||
orderInfo.tokenId
|
||||
);
|
||||
} else if (erc1155Supported[orderInfo.nftToken]) {
|
||||
} else if (
|
||||
erc1155Supported[orderInfo.nftToken] ||
|
||||
erc1155SupportedHistory[orderInfo.nftToken]
|
||||
) {
|
||||
IERC1155(orderInfo.nftToken).safeTransferFrom(
|
||||
address(this),
|
||||
_msgSender(),
|
||||
@ -213,13 +222,19 @@ contract BENftMarket is Ownable, ReentrancyGuard, ERC1155Holder, ERC721Holder {
|
||||
"NFTMarket: cancel caller is not owner"
|
||||
);
|
||||
OrderInfo memory orderInfo = orderInfos[orderId];
|
||||
if (erc721Supported[orderInfo.nftToken]) {
|
||||
if (
|
||||
erc721Supported[orderInfo.nftToken] ||
|
||||
erc721SupportedHistory[orderInfo.nftToken]
|
||||
) {
|
||||
IERC721(orderInfo.nftToken).safeTransferFrom(
|
||||
address(this),
|
||||
_msgSender(),
|
||||
orderInfo.tokenId
|
||||
);
|
||||
} else if (erc1155Supported[orderInfo.nftToken]) {
|
||||
} else if (
|
||||
erc1155Supported[orderInfo.nftToken] ||
|
||||
erc1155SupportedHistory[orderInfo.nftToken]
|
||||
) {
|
||||
IERC1155(orderInfo.nftToken).safeTransferFrom(
|
||||
address(this),
|
||||
_msgSender(),
|
||||
@ -270,6 +285,7 @@ contract BENftMarket is Ownable, ReentrancyGuard, ERC1155Holder, ERC721Holder {
|
||||
*/
|
||||
function removeERC721Support(address nftToken) external onlyOwner {
|
||||
erc721Supported[nftToken] = false;
|
||||
erc1155SupportedHistory[nftToken] = true;
|
||||
emit RemoveNFTSuppout(nftToken);
|
||||
}
|
||||
|
||||
@ -286,6 +302,7 @@ contract BENftMarket is Ownable, ReentrancyGuard, ERC1155Holder, ERC721Holder {
|
||||
*/
|
||||
function removeERC1155Support(address nftToken) external onlyOwner {
|
||||
erc1155Supported[nftToken] = false;
|
||||
erc1155SupportedHistory[nftToken] = true;
|
||||
emit RemoveNFTSuppout(nftToken);
|
||||
}
|
||||
|
||||
|
@ -108,13 +108,6 @@ contract NFT is AccessControl, ERC721Enumerable {
|
||||
emit UnLock(tokenId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Get lock status
|
||||
*/
|
||||
function isLocked(uint256 tokenId) external view returns (bool) {
|
||||
return lockedTokens[tokenId];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Set token URI
|
||||
*/
|
||||
|
@ -4,9 +4,11 @@ import "@openzeppelin/contracts/access/Ownable.sol";
|
||||
|
||||
contract TimeChecker is Ownable {
|
||||
uint256 private _duration;
|
||||
uint256 private minDuration;
|
||||
|
||||
constructor() {
|
||||
_duration = 1 days;
|
||||
minDuration = 30 minutes;
|
||||
}
|
||||
|
||||
modifier timeValid(uint256 time) {
|
||||
@ -28,6 +30,7 @@ contract TimeChecker is Ownable {
|
||||
* @dev Change duration value
|
||||
*/
|
||||
function updateDuation(uint256 valNew) external onlyOwner {
|
||||
require(valNew > minDuration, "duration too short");
|
||||
_duration = valNew;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user