From c41b4cd029a1a7310226e74b04a3c1a55443f192 Mon Sep 17 00:00:00 2001 From: Mnigos Date: Mon, 19 Sep 2022 17:04:14 +0200 Subject: [PATCH] fix(Marketplace): requires --- contracts/Marketplace.sol | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/contracts/Marketplace.sol b/contracts/Marketplace.sol index 8407b29..747a06b 100644 --- a/contracts/Marketplace.sol +++ b/contracts/Marketplace.sol @@ -48,18 +48,11 @@ contract Marketplace is ReentrancyGuard { uint256 _price ) external nonReentrant { require(_price > 0, "Price must be greater than 0"); - require( - _nft.ownerOf(_tokenId) == msg.sender, - "You are not the owner of this NFT" - ); - require( - _nft.getApproved(_tokenId) == address(this), - "You must approve this contract to sell this NFT" - ); + + itemCount++; _nft.transferFrom(msg.sender, address(this), _tokenId); - itemCount++; items[itemCount] = Item( itemCount, _tokenId, @@ -77,8 +70,11 @@ contract Marketplace is ReentrancyGuard { Item storage item = items[_id]; require(item.id > 0 && item.id <= itemCount, "Item does not exist"); - require(item.sold == false, "Item is already sold"); - require(item.price == msg.value, "Price is not correct"); + require(!item.sold, "Item is already sold"); + require( + msg.value >= totalPrice, + "not enough ether to cover item price and market fee" + ); payable(item.seller).transfer(item.price); chairPerson.transfer(totalPrice - item.price);