Skip to content

Commit 03c7c43

Browse files
authored
fix passing next cursor for getAllListings/getAllOffers (#1302)
1 parent 4475b61 commit 03c7c43

4 files changed

Lines changed: 34 additions & 7 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "opensea-js",
3-
"version": "6.1.14",
3+
"version": "6.1.15",
44
"description": "JavaScript SDK for the OpenSea marketplace helps developers build new experiences using NFTs and our marketplace data!",
55
"license": "MIT",
66
"author": "OpenSea Developers",

src/api/api.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,10 @@ export class OpenSeaAPI {
199199
): Promise<GetOffersResponse> {
200200
const response = await this.get<GetOffersResponse>(
201201
getAllOffersAPIPath(collectionSlug),
202-
serializeOrdersQueryOptions({
202+
{
203203
limit,
204204
next,
205-
}),
205+
},
206206
);
207207
return response;
208208
}
@@ -221,10 +221,10 @@ export class OpenSeaAPI {
221221
): Promise<GetListingsResponse> {
222222
const response = await this.get<GetListingsResponse>(
223223
getAllListingsAPIPath(collectionSlug),
224-
serializeOrdersQueryOptions({
224+
{
225225
limit,
226226
next,
227-
}),
227+
},
228228
);
229229
return response;
230230
}

src/api/types.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,19 +156,27 @@ export type GetOrdersResponse = QueryCursors & {
156156
orders: OrderV2[];
157157
};
158158

159+
/**
160+
* Base query cursors response from OpenSea API.
161+
* @category API Response Types
162+
*/
163+
export type QueryCursorsV2 = {
164+
next?: string;
165+
};
166+
159167
/**
160168
* Response from OpenSea API for fetching offers.
161169
* @category API Response Types
162170
*/
163-
export type GetOffersResponse = QueryCursors & {
171+
export type GetOffersResponse = QueryCursorsV2 & {
164172
offers: Offer[];
165173
};
166174

167175
/**
168176
* Response from OpenSea API for fetching listings.
169177
* @category API Response Types
170178
*/
171-
export type GetListingsResponse = QueryCursors & {
179+
export type GetListingsResponse = QueryCursorsV2 & {
172180
listings: Listing[];
173181
};
174182

test/integration/getListingsAndOffers.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,25 @@ suite("SDK: getAllListings", () => {
3737
response.listings[0].protocol_data,
3838
"Protocol data should not be null",
3939
);
40+
assert(response.next, "Cursor for next page should not be null");
41+
42+
// Should get the next page of listings
43+
const responsePage2 = await sdk.api.getAllListings(
44+
slug,
45+
undefined,
46+
response.next,
47+
);
48+
assert(responsePage2, "Response should not be null");
49+
assert.notDeepEqual(
50+
response.listings,
51+
responsePage2.listings,
52+
"Response of second page should not equal the response of first page",
53+
);
54+
assert.notEqual(
55+
response.next,
56+
responsePage2.next,
57+
"Next cursor should change",
58+
);
4059
});
4160
});
4261

0 commit comments

Comments
 (0)