Skip to content

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

Open
joshuahannan wants to merge 2 commits intojosh/report-fixesfrom
josh/is-ghost-listing
Open

add isGhostListing() with correct semantics; deprecate hasListingBecomeGhosted()#114
joshuahannan wants to merge 2 commits intojosh/report-fixesfrom
josh/is-ghost-listing

Conversation

@joshuahannan
Copy link
Member

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>
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.

1 participant