fix: correct getCollectionOffers return type and add pagination support #1818
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a type mismatch in the
getCollectionOffersmethod, corrects invalidAssetEventTypeenum values, and bumps the package version:getCollectionOffersreturn type fromListCollectionOffersResponse | nulltoGetOffersResponselimit,next) togetCollectionOffersmethodAssetEventTypeenum values (CANCEL,REDEMPTION)Background
During an audit of OpenSea API v2 endpoints against the opensea-js implementation, I discovered:
getCollectionOffers type mismatch: Testing with the actual API endpoint confirmed it returns
{ "offers": [...], "next": "..." }which matchesGetOffersResponse(with pagination cursor), notListCollectionOffersResponse(which lacks pagination).Invalid AssetEventType values: API testing revealed that
CANCELandREDEMPTIONare not valid event types. The API only accepts:order- New listings and offerssale- NFT salestransfer- NFT transfers (including mints from 0x0 address)cancel- Returns API errorredemption- Returns API errorChanges
API Implementation
src/api/offers.ts: Changed return type toGetOffersResponseand addedlimit/nextparameterssrc/api/api.ts: Updated wrapper method signature and removed unusedListCollectionOffersResponseimportsrc/api/types.ts: RemovedCANCELandREDEMPTIONfromAssetEventTypeenumTests
test/api/offers.spec.ts: Updated all 5 unit tests to useGetOffersResponseand added pagination teststest/integration/getCollectionOffers.spec.ts: Added proper null check foroffer.criteriaDocumentation
developerDocs/api-reference.md: Updated event types list, removed invalid typesdeveloperDocs/getting-started.md: Updated event types list, removed invalid typesVersion
package.json: Bumped version from 8.0.5 to 8.0.6Testing
npm test)npm run check-types)npm run lint)npm run prettier:check)npm run build)API Verification
Tested all event types with live API:
🤖 Generated with Claude Code