From a1460cd004468befe65b8283d0f66336567f1ec0 Mon Sep 17 00:00:00 2001 From: ogarciarevett Date: Wed, 15 May 2024 21:32:31 -0400 Subject: [PATCH] Fix: Fixing loop cancelling --- .../direct-listings/DirectListingsLogic.sol | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/contracts/upgradeables/marketplace/direct-listings/DirectListingsLogic.sol b/contracts/upgradeables/marketplace/direct-listings/DirectListingsLogic.sol index e84028b..1e06cce 100644 --- a/contracts/upgradeables/marketplace/direct-listings/DirectListingsLogic.sol +++ b/contracts/upgradeables/marketplace/direct-listings/DirectListingsLogic.sol @@ -235,6 +235,13 @@ contract DirectListingsLogic is IDirectListings, ReentrancyGuard, ERC2771Context /// @notice Cancel a listing. function cancelListing(uint256 _listingId) external onlyExistingListing(_listingId) onlyListingCreator(_msgSender(), _listingId) { + if(_directListingsStorage().listings[_listingId].status == IDirectListings.Status.COMPLETED) { + revert("Marketplace: cannot cancel a completed listing."); + } + + if(_directListingsStorage().listings[_listingId].status == IDirectListings.Status.CANCELLED) { + revert("Marketplace: listing already cancelled."); + } _directListingsStorage().listings[_listingId].status = IDirectListings.Status.CANCELLED; _transferListingTokensToCreator(_directListingsStorage().listings[_listingId]); emit CancelledListing(_msgSender(), _listingId); @@ -242,6 +249,12 @@ contract DirectListingsLogic is IDirectListings, ReentrancyGuard, ERC2771Context /// @notice Cancel a listing. function adminCancelListing(address listingCreator, uint256 _listingId) external onlyManagerRole { + if(_directListingsStorage().listings[_listingId].status == IDirectListings.Status.COMPLETED) { + revert("Marketplace: cannot cancel a completed listing."); + } + if(_directListingsStorage().listings[_listingId].status == IDirectListings.Status.CANCELLED) { + revert("Marketplace: listing already cancelled."); + } _directListingsStorage().listings[_listingId].status = IDirectListings.Status.CANCELLED; _transferListingTokensToCreator(_directListingsStorage().listings[_listingId]); emit CancelledListing(listingCreator, _listingId);