@opensea/sdk 10.3.1 → 10.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/lib/api/accounts.d.ts +29 -1
  2. package/lib/api/accounts.js +63 -0
  3. package/lib/api/accounts.js.map +1 -1
  4. package/lib/api/api.d.ts +129 -41
  5. package/lib/api/api.js +180 -48
  6. package/lib/api/api.js.map +1 -1
  7. package/lib/api/apiPaths.d.ts +29 -2
  8. package/lib/api/apiPaths.js +121 -6
  9. package/lib/api/apiPaths.js.map +1 -1
  10. package/lib/api/assets.d.ts +18 -0
  11. package/lib/api/assets.js +26 -0
  12. package/lib/api/assets.js.map +1 -0
  13. package/lib/api/collections.d.ts +19 -1
  14. package/lib/api/collections.js +26 -0
  15. package/lib/api/collections.js.map +1 -1
  16. package/lib/api/drops.d.ts +12 -1
  17. package/lib/api/drops.js +14 -0
  18. package/lib/api/drops.js.map +1 -1
  19. package/lib/api/listings.d.ts +16 -14
  20. package/lib/api/listings.js +21 -30
  21. package/lib/api/listings.js.map +1 -1
  22. package/lib/api/nfts.d.ts +14 -1
  23. package/lib/api/nfts.js +19 -0
  24. package/lib/api/nfts.js.map +1 -1
  25. package/lib/api/offers.d.ts +2 -2
  26. package/lib/api/offers.js +2 -9
  27. package/lib/api/offers.js.map +1 -1
  28. package/lib/api/orders.d.ts +4 -21
  29. package/lib/api/orders.js +15 -96
  30. package/lib/api/orders.js.map +1 -1
  31. package/lib/api/tokens.d.ts +27 -1
  32. package/lib/api/tokens.js +33 -0
  33. package/lib/api/tokens.js.map +1 -1
  34. package/lib/api/transactions.d.ts +16 -0
  35. package/lib/api/transactions.js +24 -0
  36. package/lib/api/transactions.js.map +1 -0
  37. package/lib/api/types.d.ts +147 -10
  38. package/lib/api/types.js.map +1 -1
  39. package/lib/orders/types.d.ts +0 -67
  40. package/lib/orders/types.js.map +1 -1
  41. package/lib/orders/utils.d.ts +1 -19
  42. package/lib/orders/utils.js +1 -62
  43. package/lib/orders/utils.js.map +1 -1
  44. package/lib/sdk/base.d.ts +6 -6
  45. package/lib/sdk/base.js +2 -2
  46. package/lib/sdk/orders.d.ts +13 -10
  47. package/lib/sdk/orders.js +6 -22
  48. package/lib/sdk/orders.js.map +1 -1
  49. package/lib/types.d.ts +0 -6
  50. package/package.json +2 -2
  51. package/src/api/accounts.ts +130 -0
  52. package/src/api/api.ts +324 -86
  53. package/src/api/apiPaths.ts +138 -8
  54. package/src/api/assets.ts +22 -0
  55. package/src/api/collections.ts +65 -0
  56. package/src/api/drops.ts +34 -1
  57. package/src/api/listings.ts +37 -41
  58. package/src/api/nfts.ts +44 -0
  59. package/src/api/offers.ts +8 -16
  60. package/src/api/orders.ts +40 -177
  61. package/src/api/tokens.ts +76 -0
  62. package/src/api/transactions.ts +28 -0
  63. package/src/api/types.ts +205 -15
  64. package/src/orders/types.ts +0 -74
  65. package/src/orders/utils.ts +2 -73
  66. package/src/sdk/base.ts +6 -6
  67. package/src/sdk/orders.ts +31 -32
  68. package/src/types.ts +0 -6
@@ -1,6 +1,10 @@
1
1
  import type { Chain, OpenSeaCollection, OpenSeaCollectionStats } from "../types"
2
2
  import { collectionFromJSON } from "../utils/converters"
3
3
  import {
4
+ getBatchCollectionsPath,
5
+ getCollectionFloorPricesPath,
6
+ getCollectionHoldersPath,
7
+ getCollectionOfferAggregatesPath,
4
8
  getCollectionPath,
5
9
  getCollectionStatsPath,
6
10
  getCollectionsPath,
@@ -10,7 +14,14 @@ import {
10
14
  } from "./apiPaths"
11
15
  import type { Fetcher } from "./fetcher"
12
16
  import {
17
+ type BatchCollectionsRequest,
18
+ type CollectionBatchResponse,
19
+ type CollectionFloorPricesArgs,
20
+ type CollectionHoldersArgs,
21
+ type CollectionHoldersPaginatedResponse,
22
+ type CollectionOfferAggregatesPaginatedResponse,
13
23
  CollectionOrderByOption,
24
+ type FloorPriceHistoryResponse,
14
25
  type GetCollectionResponse,
15
26
  type GetCollectionsArgs,
16
27
  type GetCollectionsPaginatedResponse,
@@ -18,6 +29,7 @@ import {
18
29
  type GetTopCollectionsArgs,
19
30
  type GetTraitsResponse,
20
31
  type GetTrendingCollectionsArgs,
32
+ type PaginatedAnalyticsArgs,
21
33
  } from "./types"
22
34
 
23
35
  /**
@@ -117,4 +129,57 @@ export class CollectionsAPI {
117
129
  )
118
130
  return response
119
131
  }
132
+
133
+ /**
134
+ * Fetch multiple collections in a single request by slug.
135
+ */
136
+ async getCollectionsBatch(
137
+ request: BatchCollectionsRequest,
138
+ ): Promise<CollectionBatchResponse> {
139
+ return this.fetcher.post<CollectionBatchResponse>(
140
+ getBatchCollectionsPath(),
141
+ request,
142
+ )
143
+ }
144
+
145
+ /**
146
+ * Fetch aggregated offer information for a collection — top offers grouped
147
+ * by price level. Useful for displaying offer-book depth.
148
+ */
149
+ async getCollectionOfferAggregates(
150
+ slug: string,
151
+ args?: PaginatedAnalyticsArgs,
152
+ ): Promise<CollectionOfferAggregatesPaginatedResponse> {
153
+ return this.fetcher.get<CollectionOfferAggregatesPaginatedResponse>(
154
+ getCollectionOfferAggregatesPath(slug),
155
+ args,
156
+ )
157
+ }
158
+
159
+ /**
160
+ * Fetch holders of a collection, ranked by quantity owned. Optionally
161
+ * filter to a single owner via `args.owned_by`.
162
+ */
163
+ async getCollectionHolders(
164
+ slug: string,
165
+ args?: CollectionHoldersArgs,
166
+ ): Promise<CollectionHoldersPaginatedResponse> {
167
+ return this.fetcher.get<CollectionHoldersPaginatedResponse>(
168
+ getCollectionHoldersPath(slug),
169
+ args,
170
+ )
171
+ }
172
+
173
+ /**
174
+ * Fetch the floor-price history of a collection.
175
+ */
176
+ async getCollectionFloorPrices(
177
+ slug: string,
178
+ args?: CollectionFloorPricesArgs,
179
+ ): Promise<FloorPriceHistoryResponse> {
180
+ return this.fetcher.get<FloorPriceHistoryResponse>(
181
+ getCollectionFloorPricesPath(slug),
182
+ args,
183
+ )
184
+ }
120
185
  }
package/src/api/drops.ts CHANGED
@@ -1,6 +1,16 @@
1
- import { getDropMintPath, getDropPath, getDropsPath } from "./apiPaths"
1
+ import type { Chain } from "../types"
2
+ import {
3
+ getDeployDropPath,
4
+ getDeployDropReceiptPath,
5
+ getDropMintPath,
6
+ getDropPath,
7
+ getDropsPath,
8
+ } from "./apiPaths"
2
9
  import type { Fetcher } from "./fetcher"
3
10
  import type {
11
+ DropDeployReceiptResponse,
12
+ DropDeployRequest,
13
+ DropDeployResponse,
4
14
  DropMintRequest,
5
15
  DropMintResponse,
6
16
  GetDropResponse,
@@ -46,4 +56,27 @@ export class DropsAPI {
46
56
  )
47
57
  return response
48
58
  }
59
+
60
+ /**
61
+ * Builds a deploy-contract transaction for a new drop. Returns
62
+ * ready-to-sign transaction data — caller submits onchain and then polls
63
+ * `getDeployReceipt` until the contract address is available.
64
+ */
65
+ async deployDropContract(
66
+ request: DropDeployRequest,
67
+ ): Promise<DropDeployResponse> {
68
+ return this.fetcher.post<DropDeployResponse>(getDeployDropPath(), request)
69
+ }
70
+
71
+ /**
72
+ * Get the receipt of a previously submitted drop-deploy transaction.
73
+ */
74
+ async getDeployReceipt(
75
+ chain: Chain,
76
+ txHash: string,
77
+ ): Promise<DropDeployReceiptResponse> {
78
+ return this.fetcher.get<DropDeployReceiptResponse>(
79
+ getDeployDropReceiptPath(chain, txHash),
80
+ )
81
+ }
49
82
  }
@@ -1,19 +1,22 @@
1
- import { serializeOrdersQueryOptions } from "../orders/utils"
2
- import { type Chain, OrderSide } from "../types"
3
1
  import {
4
2
  getAllListingsAPIPath,
5
3
  getBestListingAPIPath,
6
4
  getBestListingsAPIPath,
5
+ getCreateListingActionsPath,
7
6
  getCrossChainFulfillmentDataPath,
8
- getOrdersAPIPath,
7
+ getSweepListingsPath,
9
8
  } from "./apiPaths"
10
9
  import type { Fetcher } from "./fetcher"
11
10
  import {
11
+ type CreateListingActionsRequest,
12
+ type CreateListingActionsResponse,
12
13
  type CrossChainFulfillmentRequest,
13
14
  type CrossChainFulfillmentResponse,
14
15
  encodeTraitsParam,
15
16
  type GetBestListingResponse,
16
17
  type GetListingsResponse,
18
+ type SweepCollectionRequest,
19
+ type SweepCollectionResponse,
17
20
  type TraitFilter,
18
21
  } from "./types"
19
22
 
@@ -21,10 +24,7 @@ import {
21
24
  * Listing-related API operations
22
25
  */
23
26
  export class ListingsAPI {
24
- constructor(
25
- private fetcher: Fetcher,
26
- private chain: Chain,
27
- ) {}
27
+ constructor(private fetcher: Fetcher) {}
28
28
 
29
29
  /**
30
30
  * Gets all listings for a given collection.
@@ -97,40 +97,6 @@ export class ListingsAPI {
97
97
  return response
98
98
  }
99
99
 
100
- /**
101
- * Gets all active listings for a specific NFT.
102
- * @param assetContractAddress The NFT contract address
103
- * @param tokenId The token ID
104
- * @param limit The number of listings to return
105
- * @param next The cursor for pagination
106
- * @param chain The blockchain chain
107
- * @param includePrivateListings Whether to include private listings (default: false)
108
- */
109
- async getNFTListings(
110
- assetContractAddress: string,
111
- tokenId: string,
112
- limit?: number,
113
- next?: string,
114
- chain: Chain = this.chain,
115
- includePrivateListings?: boolean,
116
- ): Promise<GetListingsResponse> {
117
- const response = await this.fetcher.get<GetListingsResponse>(
118
- getOrdersAPIPath(chain, "seaport", OrderSide.LISTING),
119
- {
120
- ...serializeOrdersQueryOptions({
121
- assetContractAddress,
122
- tokenIds: [tokenId],
123
- limit,
124
- next,
125
- }),
126
- ...(includePrivateListings !== undefined && {
127
- include_private_listings: includePrivateListings,
128
- }),
129
- },
130
- )
131
- return response
132
- }
133
-
134
100
  /**
135
101
  * Get cross-chain fulfillment data for one or more listings.
136
102
  * Supports same-chain, cross-token, and cross-chain purchases.
@@ -144,4 +110,34 @@ export class ListingsAPI {
144
110
  request,
145
111
  )
146
112
  }
113
+
114
+ /**
115
+ * Bulk-buy items from a collection.
116
+ * If a requested item becomes unavailable, the system can automatically
117
+ * substitute it with the next cheapest listing from the same collection
118
+ * (enabled by default). Returns an ordered list of transactions to execute.
119
+ */
120
+ async sweepCollection(
121
+ request: SweepCollectionRequest,
122
+ ): Promise<SweepCollectionResponse> {
123
+ return this.fetcher.post<SweepCollectionResponse>(
124
+ getSweepListingsPath(),
125
+ request,
126
+ )
127
+ }
128
+
129
+ /**
130
+ * Get an ordered list of blockchain actions required to create one or more
131
+ * listings — token approvals + a final action containing the Seaport order
132
+ * to sign. Useful for clients that prefer the server to compute the
133
+ * approval graph.
134
+ */
135
+ async createListingActions(
136
+ request: CreateListingActionsRequest,
137
+ ): Promise<CreateListingActionsResponse> {
138
+ return this.fetcher.post<CreateListingActionsResponse>(
139
+ getCreateListingActionsPath(),
140
+ request,
141
+ )
142
+ }
147
143
  }
package/src/api/nfts.ts CHANGED
@@ -1,24 +1,32 @@
1
1
  import type { Chain, OpenSeaCollection } from "../types"
2
2
  import { collectionFromJSON } from "../utils/converters"
3
3
  import {
4
+ getBatchNFTsPath,
4
5
  getContractPath,
5
6
  getListNFTsByAccountPath,
6
7
  getListNFTsByCollectionPath,
7
8
  getListNFTsByContractPath,
9
+ getNFTAnalyticsPath,
8
10
  getNFTCollectionPath,
9
11
  getNFTMetadataPath,
12
+ getNFTOwnersPath,
10
13
  getNFTPath,
11
14
  getRefreshMetadataPath,
12
15
  getValidateMetadataPath,
13
16
  } from "./apiPaths"
14
17
  import type { Fetcher } from "./fetcher"
15
18
  import {
19
+ type BatchNftsRequest,
16
20
  encodeTraitsParam,
17
21
  type GetCollectionResponse,
18
22
  type GetContractResponse,
19
23
  type GetNFTMetadataResponse,
20
24
  type GetNFTResponse,
21
25
  type ListNFTsResponse,
26
+ type NFTOwnersArgs,
27
+ type NftAnalyticsResponse,
28
+ type NftBatchResponse,
29
+ type OwnersPaginatedResponse,
22
30
  type TraitFilter,
23
31
  type ValidateMetadataResponse,
24
32
  } from "./types"
@@ -178,4 +186,40 @@ export class NFTsAPI {
178
186
  )
179
187
  return response
180
188
  }
189
+
190
+ /**
191
+ * Fetch multiple NFTs in a single request by chain + contract + token id.
192
+ */
193
+ async getNFTsBatch(request: BatchNftsRequest): Promise<NftBatchResponse> {
194
+ return this.fetcher.post<NftBatchResponse>(getBatchNFTsPath(), request)
195
+ }
196
+
197
+ /**
198
+ * Fetch owners of an NFT. For ERC-721s this is a single owner; for
199
+ * ERC-1155s it can be a paginated list with per-owner quantities.
200
+ */
201
+ async getNFTOwners(
202
+ address: string,
203
+ identifier: string,
204
+ chain: Chain = this.chain,
205
+ args?: NFTOwnersArgs,
206
+ ): Promise<OwnersPaginatedResponse> {
207
+ return this.fetcher.get<OwnersPaginatedResponse>(
208
+ getNFTOwnersPath(chain, address, identifier),
209
+ args,
210
+ )
211
+ }
212
+
213
+ /**
214
+ * Fetch analytics for an NFT — historical sale points used for charting.
215
+ */
216
+ async getNFTAnalytics(
217
+ address: string,
218
+ identifier: string,
219
+ chain: Chain = this.chain,
220
+ ): Promise<NftAnalyticsResponse> {
221
+ return this.fetcher.get<NftAnalyticsResponse>(
222
+ getNFTAnalyticsPath(chain, address, identifier),
223
+ )
224
+ }
181
225
  }
package/src/api/offers.ts CHANGED
@@ -2,15 +2,14 @@ import type { ProtocolData } from "../orders/types"
2
2
  import {
3
3
  getBuildCollectionOfferPayload,
4
4
  getPostCollectionOfferPayload,
5
- serializeOrdersQueryOptions,
6
5
  } from "../orders/utils"
7
- import { type Chain, OrderSide } from "../types"
6
+ import type { Chain } from "../types"
8
7
  import {
9
8
  getAllOffersAPIPath,
10
9
  getBestOfferAPIPath,
11
10
  getBuildOfferPath,
12
11
  getCollectionOffersPath,
13
- getOrdersAPIPath,
12
+ getOffersByNFTPath,
14
13
  getPostCollectionOfferPath,
15
14
  getTraitOffersPath,
16
15
  } from "./apiPaths"
@@ -221,22 +220,15 @@ export class OffersAPI {
221
220
  /**
222
221
  * Gets all active offers for a specific NFT.
223
222
  */
224
- async getNFTOffers(
225
- assetContractAddress: string,
226
- tokenId: string,
223
+ async getOffersByNFT(
224
+ collectionSlug: string,
225
+ identifier: string | number,
227
226
  limit?: number,
228
227
  next?: string,
229
- chain: Chain = this.chain,
230
228
  ): Promise<GetOffersResponse> {
231
- const response = await this.fetcher.get<GetOffersResponse>(
232
- getOrdersAPIPath(chain, "seaport", OrderSide.OFFER),
233
- serializeOrdersQueryOptions({
234
- assetContractAddress,
235
- tokenIds: [tokenId],
236
- limit,
237
- next,
238
- }),
229
+ return this.fetcher.get<GetOffersResponse>(
230
+ getOffersByNFTPath(collectionSlug, identifier),
231
+ { limit, next },
239
232
  )
240
- return response
241
233
  }
242
234
  }
package/src/api/orders.ts CHANGED
@@ -1,32 +1,20 @@
1
- import type {
2
- FulfillmentDataResponse,
3
- ListingPostQueryResponse,
4
- OfferPostQueryResponse,
5
- OrderAPIOptions,
6
- OrdersPostQueryResponse,
7
- OrdersQueryOptions,
8
- OrdersQueryResponse,
9
- OrderV2,
10
- ProtocolData,
11
- } from "../orders/types"
1
+ import type { FulfillmentDataResponse, ProtocolData } from "../orders/types"
12
2
  import {
13
- deserializeOrder,
14
3
  getFulfillListingPayload,
15
4
  getFulfillmentDataPath,
16
5
  getFulfillOfferPayload,
17
- serializeOrdersQueryOptions,
18
6
  } from "../orders/utils"
19
7
  import { type Chain, OrderSide } from "../types"
20
8
  import {
21
9
  getCancelOrderPath,
22
10
  getOrderByHashPath,
23
- getOrdersAPIPath,
11
+ getPostListingPath,
12
+ getPostOfferPath,
24
13
  } from "./apiPaths"
25
14
  import type { Fetcher } from "./fetcher"
26
15
  import type {
27
16
  CancelOrderResponse,
28
17
  GetOrderByHashResponse,
29
- GetOrdersResponse,
30
18
  Listing,
31
19
  Offer,
32
20
  } from "./types"
@@ -40,44 +28,6 @@ export class OrdersAPI {
40
28
  private chain: Chain,
41
29
  ) {}
42
30
 
43
- /**
44
- * Gets an order from API based on query options.
45
- * @deprecated Use collection-based endpoints instead: getAllOffers, getAllListings, getBestOffer, getBestListing.
46
- */
47
- async getOrder({
48
- side,
49
- protocol = "seaport",
50
- orderDirection = "desc",
51
- orderBy = "created_date",
52
- ...restOptions
53
- }: Omit<OrdersQueryOptions, "limit">): Promise<OrderV2> {
54
- // Validate eth_price orderBy requires additional parameters
55
- if (orderBy === "eth_price") {
56
- const hasTokenId =
57
- (restOptions.tokenIds?.length ?? 0) > 0 ||
58
- restOptions.tokenId !== undefined
59
- if (!restOptions.assetContractAddress || !hasTokenId) {
60
- throw new Error(
61
- 'When using orderBy: "eth_price", you must provide both assetContractAddress and tokenIds (or tokenId) parameters',
62
- )
63
- }
64
- }
65
-
66
- const { orders } = await this.fetcher.get<OrdersQueryResponse>(
67
- getOrdersAPIPath(this.chain, protocol, side),
68
- serializeOrdersQueryOptions({
69
- limit: 1,
70
- orderBy,
71
- orderDirection,
72
- ...restOptions,
73
- }),
74
- )
75
- if (orders.length === 0) {
76
- throw new Error("Not found: no matching order found")
77
- }
78
- return deserializeOrder(orders[0])
79
- }
80
-
81
31
  /**
82
32
  * Gets a single order by its order hash.
83
33
  * Returns the raw API response which can be either an Offer or Listing.
@@ -93,47 +43,6 @@ export class OrdersAPI {
93
43
  return response.order
94
44
  }
95
45
 
96
- /**
97
- * Gets a list of orders from API based on query options.
98
- * @deprecated Use collection-based endpoints instead: getAllOffers, getAllListings, getBestOffer, getBestListing.
99
- */
100
- async getOrders({
101
- side,
102
- protocol = "seaport",
103
- orderDirection = "desc",
104
- orderBy = "created_date",
105
- pageSize = 20,
106
- ...restOptions
107
- }: Omit<OrdersQueryOptions, "limit"> & {
108
- pageSize?: number
109
- }): Promise<GetOrdersResponse> {
110
- // Validate eth_price orderBy requires additional parameters
111
- if (orderBy === "eth_price") {
112
- const hasTokenId =
113
- (restOptions.tokenIds?.length ?? 0) > 0 ||
114
- restOptions.tokenId !== undefined
115
- if (!restOptions.assetContractAddress || !hasTokenId) {
116
- throw new Error(
117
- 'When using orderBy: "eth_price", you must provide both assetContractAddress and tokenIds (or tokenId) parameters',
118
- )
119
- }
120
- }
121
-
122
- const response = await this.fetcher.get<OrdersQueryResponse>(
123
- getOrdersAPIPath(this.chain, protocol, side),
124
- serializeOrdersQueryOptions({
125
- limit: pageSize,
126
- orderBy,
127
- orderDirection,
128
- ...restOptions,
129
- }),
130
- )
131
- return {
132
- ...response,
133
- orders: response.orders.map(deserializeOrder),
134
- }
135
- }
136
-
137
46
  /**
138
47
  * Generate the data needed to fulfill a listing or an offer onchain.
139
48
  */
@@ -148,83 +57,37 @@ export class OrdersAPI {
148
57
  recipientAddress?: string,
149
58
  includeOptionalCreatorFees: boolean = false,
150
59
  ): Promise<FulfillmentDataResponse> {
151
- let payload: object | null = null
152
- if (side === OrderSide.LISTING) {
153
- payload = getFulfillListingPayload(
154
- fulfillerAddress,
155
- orderHash,
156
- protocolAddress,
157
- this.chain,
158
- assetContractAddress,
159
- tokenId,
160
- unitsToFill,
161
- recipientAddress,
162
- includeOptionalCreatorFees,
163
- )
164
- } else {
165
- payload = getFulfillOfferPayload(
166
- fulfillerAddress,
167
- orderHash,
168
- protocolAddress,
169
- this.chain,
170
- assetContractAddress,
171
- tokenId,
172
- unitsToFill,
173
- includeOptionalCreatorFees,
174
- )
175
- }
176
- const response = await this.fetcher.post<FulfillmentDataResponse>(
60
+ const payload =
61
+ side === OrderSide.LISTING
62
+ ? getFulfillListingPayload(
63
+ fulfillerAddress,
64
+ orderHash,
65
+ protocolAddress,
66
+ this.chain,
67
+ assetContractAddress,
68
+ tokenId,
69
+ unitsToFill,
70
+ recipientAddress,
71
+ includeOptionalCreatorFees,
72
+ )
73
+ : getFulfillOfferPayload(
74
+ fulfillerAddress,
75
+ orderHash,
76
+ protocolAddress,
77
+ this.chain,
78
+ assetContractAddress,
79
+ tokenId,
80
+ unitsToFill,
81
+ includeOptionalCreatorFees,
82
+ )
83
+ return this.fetcher.post<FulfillmentDataResponse>(
177
84
  getFulfillmentDataPath(side),
178
85
  payload,
179
86
  )
180
- return response
181
87
  }
182
88
 
183
89
  /**
184
- * Post an order to OpenSea.
185
- * @deprecated Use postListing or postOffer instead.
186
- */
187
- async postOrder(
188
- order: ProtocolData,
189
- apiOptions: OrderAPIOptions,
190
- ): Promise<OrderV2> {
191
- const { protocol = "seaport", side, protocolAddress } = apiOptions
192
-
193
- // Validate required fields
194
- if (!side) {
195
- throw new Error("apiOptions.side is required")
196
- }
197
- if (!protocolAddress) {
198
- throw new Error("apiOptions.protocolAddress is required")
199
- }
200
- if (!order) {
201
- throw new Error("order data is required")
202
- }
203
-
204
- // Validate protocol value
205
- if (protocol !== "seaport") {
206
- throw new Error("Currently only 'seaport' protocol is supported")
207
- }
208
-
209
- // Validate side value
210
- if (side !== "listing" && side !== "offer") {
211
- throw new Error("side must be either 'listing' or 'offer'")
212
- }
213
-
214
- // Validate protocolAddress format
215
- if (!/^0x[a-fA-F0-9]{40}$/.test(protocolAddress)) {
216
- throw new Error("Invalid protocol address format")
217
- }
218
-
219
- const response = await this.fetcher.post<OrdersPostQueryResponse>(
220
- getOrdersAPIPath(this.chain, protocol, side),
221
- { ...order, protocol_address: protocolAddress },
222
- )
223
- return deserializeOrder(response.order)
224
- }
225
-
226
- /**
227
- * Post a listing to OpenSea. Returns the new Listing response format.
90
+ * Post a listing to OpenSea.
228
91
  */
229
92
  async postListing(
230
93
  order: ProtocolData,
@@ -237,15 +100,17 @@ export class OrdersAPI {
237
100
  throw new Error("Invalid protocol address format")
238
101
  }
239
102
 
240
- const response = await this.fetcher.post<ListingPostQueryResponse>(
241
- getOrdersAPIPath(this.chain, "seaport", OrderSide.LISTING),
242
- { ...order, protocol_address: protocolAddress },
103
+ return this.fetcher.post<Listing>(
104
+ getPostListingPath(this.chain, "seaport"),
105
+ {
106
+ ...order,
107
+ protocol_address: protocolAddress,
108
+ },
243
109
  )
244
- return response.listing
245
110
  }
246
111
 
247
112
  /**
248
- * Post an offer to OpenSea. Returns the new Offer response format.
113
+ * Post an offer to OpenSea.
249
114
  */
250
115
  async postOffer(
251
116
  order: ProtocolData,
@@ -258,11 +123,10 @@ export class OrdersAPI {
258
123
  throw new Error("Invalid protocol address format")
259
124
  }
260
125
 
261
- const response = await this.fetcher.post<OfferPostQueryResponse>(
262
- getOrdersAPIPath(this.chain, "seaport", OrderSide.OFFER),
263
- { ...order, protocol_address: protocolAddress },
264
- )
265
- return response.offer
126
+ return this.fetcher.post<Offer>(getPostOfferPath(this.chain, "seaport"), {
127
+ ...order,
128
+ protocol_address: protocolAddress,
129
+ })
266
130
  }
267
131
 
268
132
  /**
@@ -274,10 +138,9 @@ export class OrdersAPI {
274
138
  chain: Chain = this.chain,
275
139
  offererSignature?: string,
276
140
  ): Promise<CancelOrderResponse> {
277
- const response = await this.fetcher.post<CancelOrderResponse>(
141
+ return this.fetcher.post<CancelOrderResponse>(
278
142
  getCancelOrderPath(chain, protocolAddress, orderHash),
279
143
  { offererSignature },
280
144
  )
281
- return response
282
145
  }
283
146
  }