Skip to content

add isGhostListing() with correct semantics; deprecate hasListingBecomeGhosted()#114

Merged
joshuahannan merged 4 commits into
josh/report-fixesfrom
josh/is-ghost-listing
Apr 6, 2026
Merged

add isGhostListing() with correct semantics; deprecate hasListingBecomeGhosted()#114
joshuahannan merged 4 commits into
josh/report-fixesfrom
josh/is-ghost-listing

Conversation

@joshuahannan
Copy link
Copy Markdown
Contributor

Summary

hasListingBecomeGhosted() has inverted return semantics relative to its name: it returns true when the NFT is still present (not ghosted) and false when the NFT is absent (ghosted). A GitHub code search shows that every public integrator that calls the function already compensates for this by negating the result with !. Fixing the semantics in place would silently break all of them.

This PR takes the additive approach:

  • Adds isGhostListing(): Bool to ListingPublic and Listing with correct semantics (true = ghosted)
  • Updates cleanupGhostListings to use isGhostListing() directly instead of !hasListingBecomeGhosted()
  • Adds deprecation notices to hasListingBecomeGhosted() in the interface, implementation, and both scripts that call it — without changing their behaviour
  • Adds scripts/is_ghost_listing.cdc and scripts/read_all_unique_ghost_listings_v2.cdc using the new function
  • Adds testIsGhostListing covering both new scripts
  • Updates docs/documentation.md to document isGhostListing() as the primary API and clearly mark hasListingBecomeGhosted() as deprecated with an explanation of the inversion

Test plan

  • make ci passes
  • testIsGhostListing confirms isGhostListing() returns false before the NFT is burned and true after
  • testCleanupGhostListings still passes (exercises cleanupGhostListings which now calls isGhostListing())
  • Existing scripts (has_listing_become_ghosted.cdc, read_all_unique_ghost_listings.cdc) are unchanged in behaviour

🤖 Generated with Claude Code

joshuahannan and others added 2 commits March 24, 2026 14:35
…meGhosted()

hasListingBecomeGhosted() returns true when the NFT is still present and false
when absent — the opposite of what its name implies. Existing callers in the wild
already compensate with !, so fixing the semantics in place would silently break
them. Instead, add isGhostListing() with correct semantics and deprecate the old
function without changing its behaviour.

Changes:
- Add isGhostListing() to ListingPublic interface and Listing resource
- Update cleanupGhostListings to use isGhostListing() directly
- Add deprecation notices to hasListingBecomeGhosted() in interface, impl, and scripts
- Add is_ghost_listing.cdc and read_all_unique_ghost_listings_v2.cdc scripts
- Add testIsGhostListing covering both new scripts
- Update documentation to clearly mark hasListingBecomeGhosted() as deprecated

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
testIsGhostListing emits one additional ListingCompleted event (on ghost
listing cleanup), shifting the cumulative event count seen by testRemoveItem
from 5 to 6.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@joshuahannan joshuahannan requested a review from nvdtf March 25, 2026 16:13
joshuahannan and others added 2 commits April 6, 2026 14:50
After removing the ghost listing from self.listings, the function fetched
duplicate listing IDs and cleaned each one up — but never called
removeDuplicateListing for the ghost listing itself. Every other removal
path (removeListing, cleanupPurchasedListings, cleanup) correctly removes
the primary listing from listedNFTs before processing duplicates.

The fix calls removeDuplicateListing for the ghost listing immediately after
removing it from self.listings, and before getDuplicateListingIDs is called.
This ensures getDuplicateListingIDs sees the correct state and the listedNFTs
entry is fully cleared.

Also adds:
- scripts/get_existing_listing_ids.cdc to expose getExistingListingIDs for tests
- testCleanupGhostListingsRemovesListedNFTsEntry to regression-test the fix

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The previous commit called removeDuplicateListing on the primary listing
before getDuplicateListingIDs, but getDuplicateListingIDs uses
contains(listingID) as a guard — once the primary is removed from
listedNFTs, it returns [] and duplicates are never cleaned up.

Correct order: fetch duplicates first (while the primary is still in
listedNFTs), then call removeDuplicateListing for the primary, then
clean up each duplicate.

Also bumps testRemoveItem's accumulated ListingCompleted event count
from 6 to 8: testCleanupGhostListingsRemovesListedNFTsEntry emits two
additional events (one for the primary ghost, one for its duplicate).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@joshuahannan joshuahannan requested a review from j1010001 April 6, 2026 19:50
@joshuahannan joshuahannan merged commit ce97807 into josh/report-fixes Apr 6, 2026
2 checks passed
@joshuahannan joshuahannan deleted the josh/is-ghost-listing branch April 6, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants