Skip to content

Commit 4139a02

Browse files
committed
Refactor / simplify OfferWithdrawn event emition.
1 parent 0624595 commit 4139a02

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

.changeset/fresh-candies-hang.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@1001-digital/erc721-extensions": minor
3+
---
4+
5+
Refactor / simplify OfferWithdrawn event emition. Fixes #16

contracts/OnlyOnGainsCreatorFeesMarket.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,13 @@ abstract contract OnlyOnGainsCreatorFeesMarket is ERC721, WithFees, ReentrancyGu
142142
emit OfferWithdrawn(tokenId);
143143
}
144144

145-
/// @dev Clear active offers on transfers.
146-
/// Emits an {OfferWithdrawn} event if an active offer exists.
145+
/// @dev Clear active offers on transfers without emitting OfferWithdrawn.
146+
/// The Sale or Transfer event is sufficient for off-chain indexers.
147147
function _update(address to, uint256 tokenId, address auth) internal virtual override(ERC721) returns (address) {
148148
address from = super._update(to, tokenId, auth);
149149
if (_offers[tokenId].price > 0) {
150-
_cancelOffer(tokenId);
150+
_offers[tokenId].price = 0;
151+
_offers[tokenId].specificBuyer = payable(address(0));
151152
}
152153
return from;
153154
}

contracts/WithMarketOffers.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ abstract contract WithMarketOffers is ERC721, WithFees, ReentrancyGuard {
130130
emit OfferWithdrawn(tokenId);
131131
}
132132

133-
/// @dev Clear active offers on transfers.
134-
/// Emits an {OfferWithdrawn} event if an active offer exists.
133+
/// @dev Clear active offers on transfers without emitting OfferWithdrawn.
134+
/// The Sale or Transfer event is sufficient for off-chain indexers.
135135
function _update(address to, uint256 tokenId, address auth) internal virtual override(ERC721) returns (address) {
136136
address from = super._update(to, tokenId, auth);
137137
if (_offers[tokenId].price > 0) {
138-
_cancelOffer(tokenId);
138+
delete _offers[tokenId];
139139
}
140140
return from;
141141
}

0 commit comments

Comments
 (0)