Skip to content

Conversation

@ryanio
Copy link
Collaborator

@ryanio ryanio commented Oct 30, 2025

Summary

This PR includes two main features:

  1. Changes the SDK to always default unitsToFill to "1" for both listings and offers
  2. Adds includePrivateListings parameter to all listing endpoints to match backend API changes

Changes

1. unitsToFill Default Behavior

Before

  • Listings: defaulted to remaining_quantity (API-side)
  • Offers: defaulted to 1 (API-side)
  • SDK sent undefined when unitsToFill was not specified

After

  • SDK always sends "1" when unitsToFill is not specified
  • Consistent default behavior for both listings and offers
  • Cleaner implementation with default parameters in utility functions

2. includePrivateListings Parameter

Added support for include_private_listings query parameter to all listing endpoints:

  • getBestListing - get best listing for a specific NFT
  • getBestListings - get best listings for a collection
  • getAllListings - get all listings for a collection
  • getNFTListings - get all listings for a specific NFT

This aligns the SDK with backend API changes that add include_private_listings support to:

  • GET /api/v2/listings/collection/{slug}/best
  • GET /api/v2/listings/collection/{slug}/nfts/{tokenId}/best
  • GET /api/v2/listings/collection/{slug}/all
  • GET /api/v2/chain/{chain}/protocol/{protocol}/orders

Modified Files

unitsToFill Changes:

  • JSDoc comments updated in src/sdk.ts, src/sdk/fulfillment.ts, and src/api/api.ts
    • Changed documentation to reflect new default behavior
  • src/sdk/fulfillment.ts
    • Modified to default unitsToFill to "1" instead of undefined
  • src/orders/utils.ts
    • Refactored getFulfillListingPayload and getFulfillOfferPayload to use default parameters
    • Changed units_to_fill from optional to required in payload types
    • Always include units_to_fill in payload (no conditional check)
  • test/sdk/fulfillmentManager.spec.ts and test/orders/utils.spec.ts
    • Updated tests to verify new default behavior
    • Changed expectations from undefined to "1"

includePrivateListings Changes:

  • src/api/listings.ts
    • Added includePrivateListings parameter to getAllListings, getBestListing, getBestListings, and getNFTListings
    • Updated JSDoc documentation
  • src/api/api.ts
    • Updated public API methods to pass through includePrivateListings parameter
    • Updated JSDoc documentation
  • test/integration/fulfillBestListing.spec.ts
    • Updated integration test to use include_private_listings=true

Version:

  • package.json
    • Bumped version to 8.0.5

Test Plan

  • ✅ All 237 existing tests pass
  • ✅ Build succeeds without errors
  • ✅ Updated tests verify that unitsToFill now defaults to "1"
  • ✅ Integration test updated to include private listings

Notes

  • The SDK accepts BigNumberish (number, BigInt, or string) for unitsToFill for developer convenience
  • Values are converted to strings for API transmission (JSON compatibility)
  • The OpenSea API can apply its own logic when it receives "1" (e.g., defaulting listings to remaining_quantity if needed)
  • includePrivateListings defaults to false for backward compatibility

ryanio and others added 4 commits October 30, 2025 16:08
Changes the SDK to always default `unitsToFill` to "1" for both listings and offers, providing consistent behavior across order types.

Previously:
- Listings: defaulted to remaining_quantity (API-side)
- Offers: defaulted to 1 (API-side)
- SDK sent undefined when not specified

Now:
- SDK always sends "1" when unitsToFill is not specified
- Consistent default behavior for both listings and offers
- Cleaner implementation with default parameters in utility functions

Changes:
- Updated JSDoc comments to reflect new behavior
- Modified fulfillment.ts to default to "1" instead of undefined
- Refactored getFulfillListingPayload and getFulfillOfferPayload to use default parameters and always include units_to_fill
- Updated tests to verify new default behavior
- Bumped version to 8.0.5

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Update test expectations to include units_to_fill: "1" in the expected payloads, reflecting the new default behavior.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add support for include_private_listings query parameter to getBestListing API method. This allows the integration test to fetch private listings when needed, fixing the "No listings found" error.

Changes:
- Added includePrivateListings optional parameter to getBestListing in ListingsAPI and OpenSeaAPI
- Updated integration test to use include_private_listings=true
- Updated JSDoc documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…and getNFTListings

Add support for include_private_listings query parameter to listing endpoints to match backend API changes.

Changes:
- Added includePrivateListings parameter to getAllListings, getBestListings, and getNFTListings in ListingsAPI
- Updated corresponding public API methods in OpenSeaAPI
- Updated JSDoc documentation for all affected methods
- All tests passing

Aligns SDK with backend PR that adds include_private_listings support to:
- GET /api/v2/listings/collection/{slug}/best
- GET /api/v2/listings/collection/{slug}/nfts/{tokenId}/best
- GET /api/v2/listings/collection/{slug}/all
- GET /api/v2/chain/{chain}/protocol/{protocol}/orders

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@ryanio ryanio changed the title feat: default unitsToFill to 1 for both listings and offers feat: default unitsToFill to 1 and add includePrivateListings parameter Oct 30, 2025
@ryanio ryanio changed the title feat: default unitsToFill to 1 and add includePrivateListings parameter feat: default unitsToFill to 1 for offers and listings, add includePrivateListings parameter Oct 30, 2025
@ryanio ryanio merged commit 66930ae into main Oct 30, 2025
8 checks passed
@ryanio ryanio deleted the units-to-fill-default-1 branch October 30, 2025 23:19
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