From 4d078f62cc60028a0ddd345216ec842f461d98e9 Mon Sep 17 00:00:00 2001 From: CounterFire2023 <136581895+CounterFire2023@users.noreply.github.com> Date: Wed, 28 Jun 2023 15:57:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0market=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contracts/market/BENftMarket.sol | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/contracts/market/BENftMarket.sol b/contracts/market/BENftMarket.sol index f943182..2d28b4b 100644 --- a/contracts/market/BENftMarket.sol +++ b/contracts/market/BENftMarket.sol @@ -111,7 +111,7 @@ contract BENftMarket is Ownable, ReentrancyGuard, ERC1155Holder, ERC721Holder { "NFTMarket: Maximum price limit exceeded" ); require( - price >= nftPriceMinLimit[nftToken] && price != 0, + price >= nftPriceMinLimit[nftToken], "NFTMarket: Below the minimum price limit" ); incrId += 1; @@ -148,6 +148,7 @@ contract BENftMarket is Ownable, ReentrancyGuard, ERC1155Holder, ERC721Holder { } function buy(uint256 orderId, uint256 price) external nonReentrant { + require(orderId > 0 && orderId <= incrId, "NFTMarket: orderId error"); OrderInfo memory orderInfo = orderInfos[orderId]; require(orderInfo.orderId != 0, "NFTMarket: order info does not exist"); require(orderInfo.price == price, "NFTMarket: Price error"); @@ -217,11 +218,10 @@ contract BENftMarket is Ownable, ReentrancyGuard, ERC1155Holder, ERC721Holder { } function cancelOrder(uint256 orderId) external nonReentrant { - require( - orderInfos[orderId].owner == _msgSender(), - "NFTMarket: cancel caller is not owner" - ); + require(orderId > 0 && orderId <= incrId, "NFTMarket: orderId error"); OrderInfo memory orderInfo = orderInfos[orderId]; + require(orderInfo.orderId != 0, "NFTMarket: NFT does not exist"); + require(orderInfo.owner == _msgSender(), "NFTMarket: caller is not owner"); if ( erc721Supported[orderInfo.nftToken] || erc721SupportedHistory[orderInfo.nftToken] @@ -249,8 +249,9 @@ contract BENftMarket is Ownable, ReentrancyGuard, ERC1155Holder, ERC721Holder { } function updatePrice(uint256 orderId, uint256 price) external { + require(orderId > 0 && orderId <= incrId, "NFTMarket: orderId error"); OrderInfo storage orderInfo = orderInfos[orderId]; - require(orderInfo.tokenId != 0, "NFTMarket: NFT does not exist"); + require(orderInfo.orderId != 0, "NFTMarket: NFT does not exist"); require(orderInfo.owner == _msgSender(), "NFTMarket: caller is not owner"); require( price <= nftPriceMaxLimit[orderInfo.nftToken] || @@ -258,7 +259,7 @@ contract BENftMarket is Ownable, ReentrancyGuard, ERC1155Holder, ERC721Holder { "NFTMarket: Maximum price limit exceeded" ); require( - price >= nftPriceMinLimit[orderInfo.nftToken] && price != 0, + price >= nftPriceMinLimit[orderInfo.nftToken], "NFTMarket: Below the minimum price limit" ); uint256 priceOld = orderInfo.price;