@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.
- package/lib/api/accounts.d.ts +29 -1
- package/lib/api/accounts.js +63 -0
- package/lib/api/accounts.js.map +1 -1
- package/lib/api/api.d.ts +129 -41
- package/lib/api/api.js +180 -48
- package/lib/api/api.js.map +1 -1
- package/lib/api/apiPaths.d.ts +29 -2
- package/lib/api/apiPaths.js +121 -6
- package/lib/api/apiPaths.js.map +1 -1
- package/lib/api/assets.d.ts +18 -0
- package/lib/api/assets.js +26 -0
- package/lib/api/assets.js.map +1 -0
- package/lib/api/collections.d.ts +19 -1
- package/lib/api/collections.js +26 -0
- package/lib/api/collections.js.map +1 -1
- package/lib/api/drops.d.ts +12 -1
- package/lib/api/drops.js +14 -0
- package/lib/api/drops.js.map +1 -1
- package/lib/api/listings.d.ts +16 -14
- package/lib/api/listings.js +21 -30
- package/lib/api/listings.js.map +1 -1
- package/lib/api/nfts.d.ts +14 -1
- package/lib/api/nfts.js +19 -0
- package/lib/api/nfts.js.map +1 -1
- package/lib/api/offers.d.ts +2 -2
- package/lib/api/offers.js +2 -9
- package/lib/api/offers.js.map +1 -1
- package/lib/api/orders.d.ts +4 -21
- package/lib/api/orders.js +15 -96
- package/lib/api/orders.js.map +1 -1
- package/lib/api/tokens.d.ts +27 -1
- package/lib/api/tokens.js +33 -0
- package/lib/api/tokens.js.map +1 -1
- package/lib/api/transactions.d.ts +16 -0
- package/lib/api/transactions.js +24 -0
- package/lib/api/transactions.js.map +1 -0
- package/lib/api/types.d.ts +147 -10
- package/lib/api/types.js.map +1 -1
- package/lib/orders/types.d.ts +0 -67
- package/lib/orders/types.js.map +1 -1
- package/lib/orders/utils.d.ts +1 -19
- package/lib/orders/utils.js +1 -62
- package/lib/orders/utils.js.map +1 -1
- package/lib/sdk/base.d.ts +6 -6
- package/lib/sdk/base.js +2 -2
- package/lib/sdk/orders.d.ts +13 -10
- package/lib/sdk/orders.js +6 -22
- package/lib/sdk/orders.js.map +1 -1
- package/lib/types.d.ts +0 -6
- package/package.json +2 -2
- package/src/api/accounts.ts +130 -0
- package/src/api/api.ts +324 -86
- package/src/api/apiPaths.ts +138 -8
- package/src/api/assets.ts +22 -0
- package/src/api/collections.ts +65 -0
- package/src/api/drops.ts +34 -1
- package/src/api/listings.ts +37 -41
- package/src/api/nfts.ts +44 -0
- package/src/api/offers.ts +8 -16
- package/src/api/orders.ts +40 -177
- package/src/api/tokens.ts +76 -0
- package/src/api/transactions.ts +28 -0
- package/src/api/types.ts +205 -15
- package/src/orders/types.ts +0 -74
- package/src/orders/utils.ts +2 -73
- package/src/sdk/base.ts +6 -6
- package/src/sdk/orders.ts +31 -32
- package/src/types.ts +0 -6
package/src/api/tokens.ts
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
|
+
import type { Chain } from "../types"
|
|
1
2
|
import {
|
|
3
|
+
getBatchTokensPath,
|
|
4
|
+
getSwapExecutePath,
|
|
2
5
|
getSwapQuotePath,
|
|
6
|
+
getTokenActivityPath,
|
|
3
7
|
getTokenGroupPath,
|
|
4
8
|
getTokenGroupsPath,
|
|
9
|
+
getTokenOhlcvPath,
|
|
5
10
|
getTokenPath,
|
|
11
|
+
getTokenPriceHistoryPath,
|
|
6
12
|
getTopTokensPath,
|
|
7
13
|
getTrendingTokensPath,
|
|
8
14
|
} from "./apiPaths"
|
|
9
15
|
import type { Fetcher } from "./fetcher"
|
|
10
16
|
import type {
|
|
17
|
+
BatchTokensRequest,
|
|
11
18
|
GetSwapQuoteArgs,
|
|
12
19
|
GetSwapQuoteResponse,
|
|
13
20
|
GetTokenGroupResponse,
|
|
@@ -17,6 +24,14 @@ import type {
|
|
|
17
24
|
GetTokensArgs,
|
|
18
25
|
GetTopTokensResponse,
|
|
19
26
|
GetTrendingTokensResponse,
|
|
27
|
+
OhlcvResponse,
|
|
28
|
+
PriceHistoryResponse,
|
|
29
|
+
SwapExecuteRequest,
|
|
30
|
+
SwapExecuteResponse,
|
|
31
|
+
TokenActivityArgs,
|
|
32
|
+
TokenBatchResponse,
|
|
33
|
+
TokenSwapActivityPaginatedResponse,
|
|
34
|
+
TokenTimeSeriesArgs,
|
|
20
35
|
} from "./types"
|
|
21
36
|
|
|
22
37
|
/**
|
|
@@ -60,6 +75,14 @@ export class TokensAPI {
|
|
|
60
75
|
return response
|
|
61
76
|
}
|
|
62
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Get executable transactions for a token swap.
|
|
80
|
+
* Supports same-chain and cross-chain swaps with multiple from/to assets.
|
|
81
|
+
*/
|
|
82
|
+
async executeSwap(request: SwapExecuteRequest): Promise<SwapExecuteResponse> {
|
|
83
|
+
return this.fetcher.post<SwapExecuteResponse>(getSwapExecutePath(), request)
|
|
84
|
+
}
|
|
85
|
+
|
|
63
86
|
/**
|
|
64
87
|
* Gets details for a specific token.
|
|
65
88
|
*/
|
|
@@ -85,4 +108,57 @@ export class TokensAPI {
|
|
|
85
108
|
async getTokenGroup(slug: string): Promise<GetTokenGroupResponse> {
|
|
86
109
|
return this.fetcher.get<GetTokenGroupResponse>(getTokenGroupPath(slug))
|
|
87
110
|
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Fetch multiple tokens in a single request by chain + contract address.
|
|
114
|
+
*/
|
|
115
|
+
async getTokensBatch(
|
|
116
|
+
request: BatchTokensRequest,
|
|
117
|
+
): Promise<TokenBatchResponse> {
|
|
118
|
+
return this.fetcher.post<TokenBatchResponse>(getBatchTokensPath(), request)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Fetch the price history of a token. `start_time` is required and the
|
|
123
|
+
* default `end_time` is "now".
|
|
124
|
+
*/
|
|
125
|
+
async getTokenPriceHistory(
|
|
126
|
+
chain: Chain,
|
|
127
|
+
address: string,
|
|
128
|
+
args: TokenTimeSeriesArgs,
|
|
129
|
+
): Promise<PriceHistoryResponse> {
|
|
130
|
+
return this.fetcher.get<PriceHistoryResponse>(
|
|
131
|
+
getTokenPriceHistoryPath(chain, address),
|
|
132
|
+
args,
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Fetch OHLCV (open / high / low / close / volume) candles for a token.
|
|
138
|
+
* `start_time` and `bucket_size` are required.
|
|
139
|
+
*/
|
|
140
|
+
async getTokenOhlcv(
|
|
141
|
+
chain: Chain,
|
|
142
|
+
address: string,
|
|
143
|
+
args: TokenTimeSeriesArgs & { bucket_size: string },
|
|
144
|
+
): Promise<OhlcvResponse> {
|
|
145
|
+
return this.fetcher.get<OhlcvResponse>(
|
|
146
|
+
getTokenOhlcvPath(chain, address),
|
|
147
|
+
args,
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Fetch recent swap activity for a token.
|
|
153
|
+
*/
|
|
154
|
+
async getTokenActivity(
|
|
155
|
+
chain: Chain,
|
|
156
|
+
address: string,
|
|
157
|
+
args?: TokenActivityArgs,
|
|
158
|
+
): Promise<TokenSwapActivityPaginatedResponse> {
|
|
159
|
+
return this.fetcher.get<TokenSwapActivityPaginatedResponse>(
|
|
160
|
+
getTokenActivityPath(chain, address),
|
|
161
|
+
args,
|
|
162
|
+
)
|
|
163
|
+
}
|
|
88
164
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getTransactionReceiptPath } from "./apiPaths"
|
|
2
|
+
import type { Fetcher } from "./fetcher"
|
|
3
|
+
import type {
|
|
4
|
+
TransactionReceiptRequest,
|
|
5
|
+
TransactionReceiptResponse,
|
|
6
|
+
} from "./types"
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Transaction-related API operations
|
|
10
|
+
*/
|
|
11
|
+
export class TransactionsAPI {
|
|
12
|
+
constructor(private fetcher: Fetcher) {}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Get the receipt/status for a submitted transaction.
|
|
16
|
+
* Works for all transaction types: listing fulfillments, cross-chain buys,
|
|
17
|
+
* sweeps, offer fulfillments, and token swaps. Poll this endpoint to check
|
|
18
|
+
* completion status.
|
|
19
|
+
*/
|
|
20
|
+
async getTransactionReceipt(
|
|
21
|
+
request: TransactionReceiptRequest,
|
|
22
|
+
): Promise<TransactionReceiptResponse> {
|
|
23
|
+
return this.fetcher.post<TransactionReceiptResponse>(
|
|
24
|
+
getTransactionReceiptPath(),
|
|
25
|
+
request,
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/api/types.ts
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
SwapExecuteRequest as ApiSwapExecuteRequest,
|
|
3
|
+
SwapExecuteResponse as ApiSwapExecuteResponse,
|
|
4
|
+
SweepCollectionRequest as ApiSweepCollectionRequest,
|
|
5
|
+
SweepCollectionResponse as ApiSweepCollectionResponse,
|
|
6
|
+
TransactionReceiptRequest as ApiTransactionReceiptRequest,
|
|
7
|
+
TransactionReceiptResponse as ApiTransactionReceiptResponse,
|
|
2
8
|
AssetMetadataResponse,
|
|
3
9
|
InstantApiKeyResponse,
|
|
10
|
+
ListingsResponse,
|
|
11
|
+
NftListResponse,
|
|
12
|
+
OffersResponse,
|
|
4
13
|
TokenGroupPaginatedResponse,
|
|
5
14
|
TokenGroupResponse,
|
|
6
15
|
} from "@opensea/api-types"
|
|
7
16
|
import type { ConsiderationItem } from "@opensea/seaport-js/lib/types"
|
|
8
|
-
import type {
|
|
9
|
-
OrderType,
|
|
10
|
-
OrderV2,
|
|
11
|
-
ProtocolData,
|
|
12
|
-
QueryCursors,
|
|
13
|
-
} from "../orders/types"
|
|
17
|
+
import type { OrderType, ProtocolData } from "../orders/types"
|
|
14
18
|
import type { OpenSeaCollection } from "../types"
|
|
15
19
|
|
|
16
20
|
/**
|
|
@@ -260,15 +264,6 @@ export type GetNFTResponse = {
|
|
|
260
264
|
nft: NFT
|
|
261
265
|
}
|
|
262
266
|
|
|
263
|
-
/**
|
|
264
|
-
* Response from OpenSea API for fetching Orders.
|
|
265
|
-
* @category API Response Types
|
|
266
|
-
*/
|
|
267
|
-
export type GetOrdersResponse = QueryCursors & {
|
|
268
|
-
/** List of {@link OrderV2} */
|
|
269
|
-
orders: OrderV2[]
|
|
270
|
-
}
|
|
271
|
-
|
|
272
267
|
/**
|
|
273
268
|
* Base query cursors response from OpenSea API.
|
|
274
269
|
* @category API Response Types
|
|
@@ -320,6 +315,42 @@ export type CancelOrderResponse = {
|
|
|
320
315
|
last_signature_issued_valid_until: string | null
|
|
321
316
|
}
|
|
322
317
|
|
|
318
|
+
/**
|
|
319
|
+
* Request body for sweeping (bulk-buying) items from a collection.
|
|
320
|
+
* @category API Query Args
|
|
321
|
+
*/
|
|
322
|
+
export type SweepCollectionRequest = ApiSweepCollectionRequest
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Response from sweeping a collection.
|
|
326
|
+
* @category API Response Types
|
|
327
|
+
*/
|
|
328
|
+
export type SweepCollectionResponse = ApiSweepCollectionResponse
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Request body for executing a token swap.
|
|
332
|
+
* @category API Query Args
|
|
333
|
+
*/
|
|
334
|
+
export type SwapExecuteRequest = ApiSwapExecuteRequest
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Response from executing a token swap.
|
|
338
|
+
* @category API Response Types
|
|
339
|
+
*/
|
|
340
|
+
export type SwapExecuteResponse = ApiSwapExecuteResponse
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Request body for fetching a transaction receipt.
|
|
344
|
+
* @category API Query Args
|
|
345
|
+
*/
|
|
346
|
+
export type TransactionReceiptRequest = ApiTransactionReceiptRequest
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Response from fetching a transaction receipt.
|
|
350
|
+
* @category API Response Types
|
|
351
|
+
*/
|
|
352
|
+
export type TransactionReceiptResponse = ApiTransactionReceiptResponse
|
|
353
|
+
|
|
323
354
|
/**
|
|
324
355
|
* NFT type returned by OpenSea API.
|
|
325
356
|
* @category API Models
|
|
@@ -1310,3 +1341,162 @@ export type {
|
|
|
1310
1341
|
ListingObject,
|
|
1311
1342
|
SwapTransactionResponse,
|
|
1312
1343
|
} from "@opensea/api-types"
|
|
1344
|
+
|
|
1345
|
+
// ─── New endpoint types (api-types 0.4.0) ───────────────────────────
|
|
1346
|
+
// Request bodies for POST endpoints and response shapes for analytics /
|
|
1347
|
+
// profile / batch / drops-deploy / transfer endpoints. All re-exported
|
|
1348
|
+
// from @opensea/api-types — see packages/api-types/src/index.ts.
|
|
1349
|
+
|
|
1350
|
+
export type {
|
|
1351
|
+
BatchCollectionsRequest,
|
|
1352
|
+
BatchNftsRequest,
|
|
1353
|
+
BatchTokensRequest,
|
|
1354
|
+
CollectionBatchResponse,
|
|
1355
|
+
CollectionHoldersPaginatedResponse,
|
|
1356
|
+
CollectionOfferAggregatesPaginatedResponse,
|
|
1357
|
+
CreateListingActionsRequest,
|
|
1358
|
+
CreateListingActionsResponse,
|
|
1359
|
+
DropDeployReceiptResponse,
|
|
1360
|
+
DropDeployRequest,
|
|
1361
|
+
DropDeployResponse,
|
|
1362
|
+
FloorPriceHistoryResponse,
|
|
1363
|
+
NftAnalyticsResponse,
|
|
1364
|
+
NftBatchResponse,
|
|
1365
|
+
OhlcvResponse,
|
|
1366
|
+
OwnersPaginatedResponse,
|
|
1367
|
+
PortfolioHistoryResponse,
|
|
1368
|
+
PortfolioStatsResponse,
|
|
1369
|
+
PriceHistoryResponse,
|
|
1370
|
+
ProfileCollectionsResponse,
|
|
1371
|
+
TokenBatchResponse,
|
|
1372
|
+
TokenSwapActivityPaginatedResponse,
|
|
1373
|
+
TransferRequest,
|
|
1374
|
+
TransferResponse,
|
|
1375
|
+
} from "@opensea/api-types"
|
|
1376
|
+
|
|
1377
|
+
/**
|
|
1378
|
+
* Query args for paginated collection-analytics endpoints (offer aggregates,
|
|
1379
|
+
* holders). All fields are optional; `cursor` paginates forward.
|
|
1380
|
+
* @category API Query Args
|
|
1381
|
+
*/
|
|
1382
|
+
export interface PaginatedAnalyticsArgs {
|
|
1383
|
+
limit?: number
|
|
1384
|
+
cursor?: string
|
|
1385
|
+
sort_direction?: "asc" | "desc"
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
/**
|
|
1389
|
+
* Query args for the collection holders endpoint — adds optional `owned_by`
|
|
1390
|
+
* filter on top of {@link PaginatedAnalyticsArgs}.
|
|
1391
|
+
* @category API Query Args
|
|
1392
|
+
*/
|
|
1393
|
+
export interface CollectionHoldersArgs extends PaginatedAnalyticsArgs {
|
|
1394
|
+
owned_by?: string
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
/**
|
|
1398
|
+
* Query args for the collection floor-price history endpoint.
|
|
1399
|
+
* @category API Query Args
|
|
1400
|
+
*/
|
|
1401
|
+
export interface CollectionFloorPricesArgs {
|
|
1402
|
+
/** Time window: one_minute, five_minutes, fifteen_minutes, one_hour, one_day, seven_days, thirty_days, one_year, all_time */
|
|
1403
|
+
timeframe?: string
|
|
1404
|
+
/** Number of data points to return */
|
|
1405
|
+
resolution?: number
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
/**
|
|
1409
|
+
* Query args for token price-history and OHLCV endpoints.
|
|
1410
|
+
* @category API Query Args
|
|
1411
|
+
*/
|
|
1412
|
+
export interface TokenTimeSeriesArgs {
|
|
1413
|
+
/** Start time (ISO 8601, required by the API). */
|
|
1414
|
+
start_time: string
|
|
1415
|
+
/** End time (ISO 8601, defaults to now). */
|
|
1416
|
+
end_time?: string
|
|
1417
|
+
/** Candle bucket size: 1s, 1m, 5m, 15m, 1h, 4h, 1d. */
|
|
1418
|
+
bucket_size?: string
|
|
1419
|
+
/** Whether to fill empty time windows with zero-volume candles (OHLCV only). */
|
|
1420
|
+
fill_time_window?: boolean
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
/**
|
|
1424
|
+
* Query args for the token swap-activity endpoint.
|
|
1425
|
+
* @category API Query Args
|
|
1426
|
+
*/
|
|
1427
|
+
export interface TokenActivityArgs {
|
|
1428
|
+
limit?: number
|
|
1429
|
+
cursor?: string
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
/**
|
|
1433
|
+
* Query args for the NFT owners endpoint (paginated with `next` cursor).
|
|
1434
|
+
* @category API Query Args
|
|
1435
|
+
*/
|
|
1436
|
+
export interface NFTOwnersArgs {
|
|
1437
|
+
limit?: number
|
|
1438
|
+
next?: string
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
/**
|
|
1442
|
+
* Query args for the account portfolio and portfolio history endpoints.
|
|
1443
|
+
* @category API Query Args
|
|
1444
|
+
*/
|
|
1445
|
+
export interface PortfolioArgs {
|
|
1446
|
+
/** Timeframe for P&L / net-worth history calculation. */
|
|
1447
|
+
timeframe?: "HOUR" | "DAY" | "WEEK" | "MONTH"
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
/**
|
|
1451
|
+
* Query args shared by the account profile listing-and-offer endpoints
|
|
1452
|
+
* (offers, offers_received, listings).
|
|
1453
|
+
* @category API Query Args
|
|
1454
|
+
*/
|
|
1455
|
+
export interface ProfileOrdersArgs {
|
|
1456
|
+
after?: string
|
|
1457
|
+
limit?: number
|
|
1458
|
+
collection_slugs?: string[]
|
|
1459
|
+
chains?: string[]
|
|
1460
|
+
sort_by?: string
|
|
1461
|
+
sort_direction?: "asc" | "desc"
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
/**
|
|
1465
|
+
* Query args for the account profile favorites endpoint.
|
|
1466
|
+
* @category API Query Args
|
|
1467
|
+
*/
|
|
1468
|
+
export interface ProfileFavoritesArgs {
|
|
1469
|
+
after?: string
|
|
1470
|
+
limit?: number
|
|
1471
|
+
sort_by?: string
|
|
1472
|
+
sort_direction?: "asc" | "desc"
|
|
1473
|
+
chains?: string[]
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
/**
|
|
1477
|
+
* Query args for the account profile collections endpoint.
|
|
1478
|
+
* @category API Query Args
|
|
1479
|
+
*/
|
|
1480
|
+
export interface ProfileCollectionsArgs {
|
|
1481
|
+
after?: string
|
|
1482
|
+
limit?: number
|
|
1483
|
+
chains?: string[]
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
/**
|
|
1487
|
+
* Response from the account favorites endpoint — favorited NFTs.
|
|
1488
|
+
* @category API Response Types
|
|
1489
|
+
*/
|
|
1490
|
+
export type ProfileFavoritesResponse = NftListResponse
|
|
1491
|
+
|
|
1492
|
+
/**
|
|
1493
|
+
* Response from the account profile listings endpoint.
|
|
1494
|
+
* @category API Response Types
|
|
1495
|
+
*/
|
|
1496
|
+
export type ProfileListingsResponse = ListingsResponse
|
|
1497
|
+
|
|
1498
|
+
/**
|
|
1499
|
+
* Response from the account profile offers / offers_received endpoints.
|
|
1500
|
+
* @category API Response Types
|
|
1501
|
+
*/
|
|
1502
|
+
export type ProfileOffersResponse = OffersResponse
|
package/src/orders/types.ts
CHANGED
|
@@ -3,7 +3,6 @@ import type {
|
|
|
3
3
|
AdvancedOrder,
|
|
4
4
|
OrderWithCounter,
|
|
5
5
|
} from "@opensea/seaport-js/lib/types"
|
|
6
|
-
import type { Listing, Offer } from "../api/types"
|
|
7
6
|
import type { OpenSeaAccount, OrderSide } from "../types"
|
|
8
7
|
|
|
9
8
|
// Protocol data
|
|
@@ -112,80 +111,7 @@ type Transaction = {
|
|
|
112
111
|
}
|
|
113
112
|
|
|
114
113
|
// API query types
|
|
115
|
-
type OpenOrderOrderingOption = "created_date" | "eth_price"
|
|
116
|
-
type OrderByDirection = "asc" | "desc"
|
|
117
|
-
|
|
118
|
-
export type OrderAPIOptions = {
|
|
119
|
-
protocol?: OrderProtocol
|
|
120
|
-
protocolAddress?: string
|
|
121
|
-
side: OrderSide
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export type OrdersQueryOptions = OrderAPIOptions & {
|
|
125
|
-
limit?: number
|
|
126
|
-
cursor?: string
|
|
127
|
-
next?: string
|
|
128
|
-
|
|
129
|
-
paymentTokenAddress?: string
|
|
130
|
-
maker?: string
|
|
131
|
-
taker?: string
|
|
132
|
-
owner?: string
|
|
133
|
-
listedAfter?: number | string
|
|
134
|
-
listedBefore?: number | string
|
|
135
|
-
tokenId?: string
|
|
136
|
-
tokenIds?: string[]
|
|
137
|
-
assetContractAddress?: string
|
|
138
|
-
orderBy?: OpenOrderOrderingOption
|
|
139
|
-
orderDirection?: OrderByDirection
|
|
140
|
-
onlyEnglish?: boolean
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export type SerializedOrderV2 = {
|
|
144
|
-
created_date: string
|
|
145
|
-
closing_date: string | null
|
|
146
|
-
listing_time: number
|
|
147
|
-
expiration_time: number
|
|
148
|
-
order_hash: string | null
|
|
149
|
-
maker: unknown
|
|
150
|
-
taker: unknown | null
|
|
151
|
-
protocol_data: ProtocolData
|
|
152
|
-
protocol_address: string
|
|
153
|
-
current_price: string
|
|
154
|
-
maker_fees: {
|
|
155
|
-
account: unknown
|
|
156
|
-
basis_points: string
|
|
157
|
-
}[]
|
|
158
|
-
taker_fees: {
|
|
159
|
-
account: unknown
|
|
160
|
-
basis_points: string
|
|
161
|
-
}[]
|
|
162
|
-
side: OrderSide
|
|
163
|
-
order_type: OrderType
|
|
164
|
-
cancelled: boolean
|
|
165
|
-
finalized: boolean
|
|
166
|
-
marked_invalid: boolean
|
|
167
|
-
client_signature: string | null
|
|
168
|
-
remaining_quantity: number
|
|
169
|
-
}
|
|
170
|
-
|
|
171
114
|
export type QueryCursors = {
|
|
172
115
|
next: string | null
|
|
173
116
|
previous: string | null
|
|
174
117
|
}
|
|
175
|
-
|
|
176
|
-
export type OrdersQueryResponse = QueryCursors & {
|
|
177
|
-
orders: SerializedOrderV2[]
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/** @deprecated Use ListingPostQueryResponse or OfferPostQueryResponse instead. */
|
|
181
|
-
export type OrdersPostQueryResponse = { order: SerializedOrderV2 }
|
|
182
|
-
|
|
183
|
-
export type ListingPostQueryResponse = {
|
|
184
|
-
order: SerializedOrderV2
|
|
185
|
-
listing: Listing
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export type OfferPostQueryResponse = {
|
|
189
|
-
order: SerializedOrderV2
|
|
190
|
-
offer: Offer
|
|
191
|
-
}
|
package/src/orders/utils.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { CROSS_CHAIN_SEAPORT_V1_6_ADDRESS } from "@opensea/seaport-js/lib/constants"
|
|
2
2
|
import { API_V2_PREFIX } from "../api/apiPaths"
|
|
3
3
|
import { type Chain, OrderSide } from "../types"
|
|
4
|
-
import {
|
|
5
|
-
import type {
|
|
6
|
-
OrdersQueryOptions,
|
|
7
|
-
OrderV2,
|
|
8
|
-
ProtocolData,
|
|
9
|
-
SerializedOrderV2,
|
|
10
|
-
} from "./types"
|
|
4
|
+
import { getSeaportAddress } from "../utils"
|
|
5
|
+
import type { ProtocolData } from "./types"
|
|
11
6
|
|
|
12
7
|
export const DEFAULT_SEAPORT_CONTRACT_ADDRESS = CROSS_CHAIN_SEAPORT_V1_6_ADDRESS
|
|
13
8
|
|
|
@@ -192,69 +187,3 @@ export const getFulfillOfferPayload = (
|
|
|
192
187
|
|
|
193
188
|
return payload
|
|
194
189
|
}
|
|
195
|
-
|
|
196
|
-
type OrdersQueryPathOptions = "protocol" | "side"
|
|
197
|
-
export const serializeOrdersQueryOptions = (
|
|
198
|
-
options: Omit<OrdersQueryOptions, OrdersQueryPathOptions>,
|
|
199
|
-
) => {
|
|
200
|
-
const tokenIds =
|
|
201
|
-
options.tokenIds && options.tokenIds.length > 0
|
|
202
|
-
? options.tokenIds
|
|
203
|
-
: options.tokenId !== undefined
|
|
204
|
-
? [options.tokenId]
|
|
205
|
-
: options.tokenIds
|
|
206
|
-
|
|
207
|
-
return {
|
|
208
|
-
limit: options.limit,
|
|
209
|
-
cursor: options.cursor ?? options.next,
|
|
210
|
-
|
|
211
|
-
payment_token_address: options.paymentTokenAddress,
|
|
212
|
-
maker: options.maker,
|
|
213
|
-
taker: options.taker,
|
|
214
|
-
owner: options.owner,
|
|
215
|
-
listed_after: options.listedAfter,
|
|
216
|
-
listed_before: options.listedBefore,
|
|
217
|
-
token_ids: tokenIds,
|
|
218
|
-
asset_contract_address: options.assetContractAddress,
|
|
219
|
-
order_by: options.orderBy,
|
|
220
|
-
order_direction: options.orderDirection,
|
|
221
|
-
only_english: options.onlyEnglish,
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/** Map API side values ("ask"/"bid") to SDK OrderSide enum values */
|
|
226
|
-
const mapApiSide = (side: string): OrderSide => {
|
|
227
|
-
if (side === "ask" || side === OrderSide.LISTING) return OrderSide.LISTING
|
|
228
|
-
if (side === "bid" || side === OrderSide.OFFER) return OrderSide.OFFER
|
|
229
|
-
return side as OrderSide
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export const deserializeOrder = (order: SerializedOrderV2): OrderV2 => {
|
|
233
|
-
return {
|
|
234
|
-
createdDate: order.created_date,
|
|
235
|
-
closingDate: order.closing_date,
|
|
236
|
-
listingTime: order.listing_time,
|
|
237
|
-
expirationTime: order.expiration_time,
|
|
238
|
-
orderHash: order.order_hash,
|
|
239
|
-
maker: accountFromJSON(order.maker),
|
|
240
|
-
taker: order.taker ? accountFromJSON(order.taker) : null,
|
|
241
|
-
protocolData: order.protocol_data,
|
|
242
|
-
protocolAddress: order.protocol_address,
|
|
243
|
-
currentPrice: BigInt(order.current_price),
|
|
244
|
-
makerFees: (order.maker_fees ?? []).map(({ account, basis_points }) => ({
|
|
245
|
-
account: accountFromJSON(account),
|
|
246
|
-
basisPoints: basis_points,
|
|
247
|
-
})),
|
|
248
|
-
takerFees: (order.taker_fees ?? []).map(({ account, basis_points }) => ({
|
|
249
|
-
account: accountFromJSON(account),
|
|
250
|
-
basisPoints: basis_points,
|
|
251
|
-
})),
|
|
252
|
-
side: mapApiSide(order.side as string),
|
|
253
|
-
orderType: order.order_type,
|
|
254
|
-
cancelled: order.cancelled,
|
|
255
|
-
finalized: order.finalized,
|
|
256
|
-
markedInvalid: order.marked_invalid,
|
|
257
|
-
clientSignature: order.client_signature,
|
|
258
|
-
remainingQuantity: order.remaining_quantity,
|
|
259
|
-
}
|
|
260
|
-
}
|
package/src/sdk/base.ts
CHANGED
|
@@ -207,7 +207,7 @@ export class BaseOpenSeaSDK {
|
|
|
207
207
|
* @param options.salt Arbitrary salt. Auto-generated if not provided.
|
|
208
208
|
* @param options.expirationTime Expiration time for the order, in UTC seconds
|
|
209
209
|
* @param options.zone Zone for order protection. Defaults to chain's signed zone.
|
|
210
|
-
* @returns The {@link
|
|
210
|
+
* @returns The {@link Offer} that was created.
|
|
211
211
|
*/
|
|
212
212
|
public async createOffer(options: {
|
|
213
213
|
asset: AssetWithTokenId
|
|
@@ -218,7 +218,7 @@ export class BaseOpenSeaSDK {
|
|
|
218
218
|
salt?: Amount
|
|
219
219
|
expirationTime?: Amount
|
|
220
220
|
zone?: string
|
|
221
|
-
}): Promise<
|
|
221
|
+
}): Promise<Offer> {
|
|
222
222
|
return this._ordersManager.createOffer(options)
|
|
223
223
|
}
|
|
224
224
|
|
|
@@ -236,7 +236,7 @@ export class BaseOpenSeaSDK {
|
|
|
236
236
|
* @param options.buyerAddress Optional address that's allowed to purchase this item.
|
|
237
237
|
* @param options.includeOptionalCreatorFees If true, optional creator fees will be included. Default: false.
|
|
238
238
|
* @param options.zone Zone for order protection. Defaults to no zone.
|
|
239
|
-
* @returns The {@link
|
|
239
|
+
* @returns The {@link Listing} that was created.
|
|
240
240
|
*/
|
|
241
241
|
public async createListing(options: {
|
|
242
242
|
asset: AssetWithTokenId
|
|
@@ -250,7 +250,7 @@ export class BaseOpenSeaSDK {
|
|
|
250
250
|
buyerAddress?: string
|
|
251
251
|
includeOptionalCreatorFees?: boolean
|
|
252
252
|
zone?: string
|
|
253
|
-
}): Promise<
|
|
253
|
+
}): Promise<Listing> {
|
|
254
254
|
return this._ordersManager.createListing(options)
|
|
255
255
|
}
|
|
256
256
|
|
|
@@ -271,7 +271,7 @@ export class BaseOpenSeaSDK {
|
|
|
271
271
|
accountAddress: string
|
|
272
272
|
continueOnError?: boolean
|
|
273
273
|
onProgress?: (completed: number, total: number) => void
|
|
274
|
-
}): Promise<BulkOrderResult
|
|
274
|
+
}): Promise<BulkOrderResult<Listing>> {
|
|
275
275
|
return this._ordersManager.createBulkListings(options)
|
|
276
276
|
}
|
|
277
277
|
|
|
@@ -289,7 +289,7 @@ export class BaseOpenSeaSDK {
|
|
|
289
289
|
accountAddress: string
|
|
290
290
|
continueOnError?: boolean
|
|
291
291
|
onProgress?: (completed: number, total: number) => void
|
|
292
|
-
}): Promise<BulkOrderResult
|
|
292
|
+
}): Promise<BulkOrderResult<Offer>> {
|
|
293
293
|
return this._ordersManager.createBulkOffers(options)
|
|
294
294
|
}
|
|
295
295
|
|