@opensea/sdk 10.4.0 → 11.0.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 +72 -5
- package/lib/api/accounts.js.map +1 -1
- package/lib/api/api.d.ts +116 -9
- package/lib/api/api.js +186 -17
- package/lib/api/api.js.map +1 -1
- package/lib/api/apiPaths.d.ts +22 -0
- package/lib/api/apiPaths.js +97 -1
- 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 +33 -15
- 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/fetcher.d.ts +35 -5
- package/lib/api/listings.d.ts +8 -1
- package/lib/api/listings.js +12 -3
- package/lib/api/listings.js.map +1 -1
- package/lib/api/nfts.d.ts +15 -2
- package/lib/api/nfts.js +21 -5
- package/lib/api/nfts.js.map +1 -1
- package/lib/api/offers.d.ts +11 -0
- package/lib/api/offers.js +14 -11
- package/lib/api/offers.js.map +1 -1
- package/lib/api/orders.d.ts +16 -1
- package/lib/api/orders.js +17 -3
- package/lib/api/orders.js.map +1 -1
- package/lib/api/tokens.d.ts +22 -1
- package/lib/api/tokens.js +26 -0
- package/lib/api/tokens.js.map +1 -1
- package/lib/api/types.d.ts +296 -341
- package/lib/api/types.js +2 -1
- package/lib/api/types.js.map +1 -1
- package/lib/orders/types.d.ts +2 -2
- package/lib/orders/utils.d.ts +53 -13
- package/lib/orders/utils.js +33 -50
- package/lib/orders/utils.js.map +1 -1
- package/lib/sdk/base.d.ts +11 -4
- package/lib/sdk/base.js +4 -4
- package/lib/sdk/base.js.map +1 -1
- package/lib/sdk/cancellation.d.ts +3 -1
- package/lib/sdk/cancellation.js +12 -6
- package/lib/sdk/cancellation.js.map +1 -1
- package/lib/sdk/fulfillment.js +7 -4
- package/lib/sdk/fulfillment.js.map +1 -1
- package/lib/sdk/orders.js +1 -1
- package/lib/sdk/orders.js.map +1 -1
- package/lib/types.d.ts +22 -122
- package/lib/types.js.map +1 -1
- package/lib/utils/case.d.ts +63 -0
- package/lib/utils/case.js +83 -0
- package/lib/utils/case.js.map +1 -0
- package/lib/utils/utils.d.ts +0 -1
- package/lib/utils/utils.js +0 -1
- package/lib/utils/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/api/accounts.ts +141 -5
- package/src/api/api.ts +328 -23
- package/src/api/apiPaths.ts +112 -0
- package/src/api/assets.ts +22 -0
- package/src/api/collections.ts +71 -20
- package/src/api/drops.ts +34 -1
- package/src/api/fetcher.ts +41 -6
- package/src/api/listings.ts +21 -3
- package/src/api/nfts.ts +47 -7
- package/src/api/offers.ts +17 -10
- package/src/api/orders.ts +29 -5
- package/src/api/tokens.ts +65 -0
- package/src/api/types.ts +382 -354
- package/src/orders/types.ts +2 -2
- package/src/orders/utils.ts +57 -79
- package/src/sdk/base.ts +4 -4
- package/src/sdk/cancellation.ts +16 -6
- package/src/sdk/fulfillment.ts +7 -6
- package/src/sdk/orders.ts +1 -1
- package/src/types.ts +33 -120
- package/src/utils/case.ts +150 -0
- package/src/utils/utils.ts +0 -1
- package/lib/utils/converters.d.ts +0 -37
- package/lib/utils/converters.js +0 -137
- package/lib/utils/converters.js.map +0 -1
- package/src/utils/converters.ts +0 -145
package/src/api/collections.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { Chain, OpenSeaCollection, OpenSeaCollectionStats } from "../types"
|
|
2
|
-
import { collectionFromJSON } from "../utils/converters"
|
|
3
2
|
import {
|
|
3
|
+
getBatchCollectionsPath,
|
|
4
|
+
getCollectionFloorPricesPath,
|
|
5
|
+
getCollectionHoldersPath,
|
|
6
|
+
getCollectionOfferAggregatesPath,
|
|
4
7
|
getCollectionPath,
|
|
5
8
|
getCollectionStatsPath,
|
|
6
9
|
getCollectionsPath,
|
|
@@ -10,7 +13,14 @@ import {
|
|
|
10
13
|
} from "./apiPaths"
|
|
11
14
|
import type { Fetcher } from "./fetcher"
|
|
12
15
|
import {
|
|
16
|
+
type BatchCollectionsRequest,
|
|
17
|
+
type CollectionBatchResponse,
|
|
18
|
+
type CollectionFloorPricesArgs,
|
|
19
|
+
type CollectionHoldersArgs,
|
|
20
|
+
type CollectionHoldersPaginatedResponse,
|
|
21
|
+
type CollectionOfferAggregatesPaginatedResponse,
|
|
13
22
|
CollectionOrderByOption,
|
|
23
|
+
type FloorPriceHistoryResponse,
|
|
14
24
|
type GetCollectionResponse,
|
|
15
25
|
type GetCollectionsArgs,
|
|
16
26
|
type GetCollectionsPaginatedResponse,
|
|
@@ -18,6 +28,7 @@ import {
|
|
|
18
28
|
type GetTopCollectionsArgs,
|
|
19
29
|
type GetTraitsResponse,
|
|
20
30
|
type GetTrendingCollectionsArgs,
|
|
31
|
+
type PaginatedAnalyticsArgs,
|
|
21
32
|
} from "./types"
|
|
22
33
|
|
|
23
34
|
/**
|
|
@@ -31,8 +42,7 @@ export class CollectionsAPI {
|
|
|
31
42
|
*/
|
|
32
43
|
async getCollection(slug: string): Promise<OpenSeaCollection> {
|
|
33
44
|
const path = getCollectionPath(slug)
|
|
34
|
-
|
|
35
|
-
return collectionFromJSON(response)
|
|
45
|
+
return this.fetcher.get<GetCollectionResponse>(path)
|
|
36
46
|
}
|
|
37
47
|
|
|
38
48
|
/**
|
|
@@ -48,18 +58,14 @@ export class CollectionsAPI {
|
|
|
48
58
|
): Promise<GetCollectionsResponse> {
|
|
49
59
|
const path = getCollectionsPath()
|
|
50
60
|
const args: GetCollectionsArgs = {
|
|
51
|
-
|
|
61
|
+
orderBy,
|
|
52
62
|
chain,
|
|
53
|
-
|
|
54
|
-
|
|
63
|
+
creatorUsername,
|
|
64
|
+
includeHidden,
|
|
55
65
|
limit,
|
|
56
66
|
next,
|
|
57
67
|
}
|
|
58
|
-
|
|
59
|
-
response.collections = response.collections.map(collection =>
|
|
60
|
-
collectionFromJSON(collection),
|
|
61
|
-
)
|
|
62
|
-
return response
|
|
68
|
+
return this.fetcher.get<GetCollectionsResponse>(path, args)
|
|
63
69
|
}
|
|
64
70
|
|
|
65
71
|
/**
|
|
@@ -86,17 +92,13 @@ export class CollectionsAPI {
|
|
|
86
92
|
async getTrendingCollections(
|
|
87
93
|
args?: GetTrendingCollectionsArgs,
|
|
88
94
|
): Promise<GetCollectionsPaginatedResponse> {
|
|
89
|
-
|
|
95
|
+
return this.fetcher.get<GetCollectionsPaginatedResponse>(
|
|
90
96
|
getTrendingCollectionsPath(),
|
|
91
97
|
{
|
|
92
98
|
...args,
|
|
93
99
|
chains: args?.chains?.join(","),
|
|
94
100
|
},
|
|
95
101
|
)
|
|
96
|
-
response.collections = response.collections.map(collection =>
|
|
97
|
-
collectionFromJSON(collection),
|
|
98
|
-
)
|
|
99
|
-
return response
|
|
100
102
|
}
|
|
101
103
|
|
|
102
104
|
/**
|
|
@@ -105,16 +107,65 @@ export class CollectionsAPI {
|
|
|
105
107
|
async getTopCollections(
|
|
106
108
|
args?: GetTopCollectionsArgs,
|
|
107
109
|
): Promise<GetCollectionsPaginatedResponse> {
|
|
108
|
-
|
|
110
|
+
return this.fetcher.get<GetCollectionsPaginatedResponse>(
|
|
109
111
|
getTopCollectionsPath(),
|
|
110
112
|
{
|
|
111
113
|
...args,
|
|
112
114
|
chains: args?.chains?.join(","),
|
|
113
115
|
},
|
|
114
116
|
)
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Fetch multiple collections in a single request by slug.
|
|
121
|
+
*/
|
|
122
|
+
async getCollectionsBatch(
|
|
123
|
+
request: BatchCollectionsRequest,
|
|
124
|
+
): Promise<CollectionBatchResponse> {
|
|
125
|
+
return this.fetcher.post<CollectionBatchResponse>(
|
|
126
|
+
getBatchCollectionsPath(),
|
|
127
|
+
request,
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Fetch aggregated offer information for a collection — top offers grouped
|
|
133
|
+
* by price level. Useful for displaying offer-book depth.
|
|
134
|
+
*/
|
|
135
|
+
async getCollectionOfferAggregates(
|
|
136
|
+
slug: string,
|
|
137
|
+
args?: PaginatedAnalyticsArgs,
|
|
138
|
+
): Promise<CollectionOfferAggregatesPaginatedResponse> {
|
|
139
|
+
return this.fetcher.get<CollectionOfferAggregatesPaginatedResponse>(
|
|
140
|
+
getCollectionOfferAggregatesPath(slug),
|
|
141
|
+
args,
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Fetch holders of a collection, ranked by quantity owned. Optionally
|
|
147
|
+
* filter to a single owner via `args.owned_by`.
|
|
148
|
+
*/
|
|
149
|
+
async getCollectionHolders(
|
|
150
|
+
slug: string,
|
|
151
|
+
args?: CollectionHoldersArgs,
|
|
152
|
+
): Promise<CollectionHoldersPaginatedResponse> {
|
|
153
|
+
return this.fetcher.get<CollectionHoldersPaginatedResponse>(
|
|
154
|
+
getCollectionHoldersPath(slug),
|
|
155
|
+
args,
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Fetch the floor-price history of a collection.
|
|
161
|
+
*/
|
|
162
|
+
async getCollectionFloorPrices(
|
|
163
|
+
slug: string,
|
|
164
|
+
args?: CollectionFloorPricesArgs,
|
|
165
|
+
): Promise<FloorPriceHistoryResponse> {
|
|
166
|
+
return this.fetcher.get<FloorPriceHistoryResponse>(
|
|
167
|
+
getCollectionFloorPricesPath(slug),
|
|
168
|
+
args,
|
|
117
169
|
)
|
|
118
|
-
return response
|
|
119
170
|
}
|
|
120
171
|
}
|
package/src/api/drops.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import {
|
|
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
|
}
|
package/src/api/fetcher.ts
CHANGED
|
@@ -1,8 +1,37 @@
|
|
|
1
1
|
import type { RequestOptions } from "../types"
|
|
2
|
+
import type { Camelize } from "../utils/case"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Options for the {@link Fetcher.post} method.
|
|
6
|
+
*
|
|
7
|
+
* Extends {@link RequestOptions} with a `snakeizeBody` opt-out so callers
|
|
8
|
+
* with mixed-casing wire bodies (e.g. Seaport order structs whose inner
|
|
9
|
+
* keys are camelCase on-wire) can disable the automatic camel→snake key
|
|
10
|
+
* rewrite and submit the body verbatim.
|
|
11
|
+
*
|
|
12
|
+
* @category API Models
|
|
13
|
+
*/
|
|
14
|
+
export interface PostOptions extends RequestOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Whether to recursively rewrite the body's keys from camelCase to
|
|
17
|
+
* snake_case before sending. Defaults to `true`.
|
|
18
|
+
*
|
|
19
|
+
* Set to `false` when the body contains Seaport-shaped structs or other
|
|
20
|
+
* mixed-casing payloads where some keys (`parameters.startTime`,
|
|
21
|
+
* `numericTraits`, `offererSignature`, …) must remain camelCase on the
|
|
22
|
+
* wire per the OpenSea OpenAPI spec. The caller is then responsible
|
|
23
|
+
* for emitting the body in exact wire shape.
|
|
24
|
+
*/
|
|
25
|
+
snakeizeBody?: boolean
|
|
26
|
+
}
|
|
2
27
|
|
|
3
28
|
/**
|
|
4
29
|
* Fetcher context interface for making HTTP requests to the OpenSea API.
|
|
5
30
|
* This interface abstracts the HTTP methods used by specialized API clients.
|
|
31
|
+
*
|
|
32
|
+
* Responses are camelized at this boundary — pass the API's snake_case shape
|
|
33
|
+
* (e.g. an api-types response type) as `T` and the return is the camelCase
|
|
34
|
+
* view. See `utils/case.ts`.
|
|
6
35
|
*/
|
|
7
36
|
export interface Fetcher {
|
|
8
37
|
/**
|
|
@@ -10,22 +39,28 @@ export interface Fetcher {
|
|
|
10
39
|
* @param apiPath Path to URL endpoint under API
|
|
11
40
|
* @param query URL query params. Will be used to create a URLSearchParams object.
|
|
12
41
|
* @param options Request options like timeout and abort signal.
|
|
13
|
-
* @returns The
|
|
42
|
+
* @returns The camelCase view of the API response.
|
|
14
43
|
*/
|
|
15
|
-
get<T>(
|
|
44
|
+
get<T>(
|
|
45
|
+
apiPath: string,
|
|
46
|
+
query?: object,
|
|
47
|
+
options?: RequestOptions,
|
|
48
|
+
): Promise<Camelize<T>>
|
|
16
49
|
|
|
17
50
|
/**
|
|
18
51
|
* Generic post method for POST requests with automatic rate limit retry
|
|
19
52
|
* @param apiPath Path to URL endpoint under API
|
|
20
53
|
* @param body Data to send.
|
|
21
54
|
* @param headers Additional headers to send with the request.
|
|
22
|
-
* @param options Request options
|
|
23
|
-
*
|
|
55
|
+
* @param options Request options. Includes the {@link PostOptions.snakeizeBody}
|
|
56
|
+
* opt-out for callers that need to emit the body in exact wire
|
|
57
|
+
* shape (e.g. Seaport-shaped POSTs).
|
|
58
|
+
* @returns The camelCase view of the API response.
|
|
24
59
|
*/
|
|
25
60
|
post<T>(
|
|
26
61
|
apiPath: string,
|
|
27
62
|
body?: object,
|
|
28
63
|
headers?: object,
|
|
29
|
-
options?:
|
|
30
|
-
): Promise<T
|
|
64
|
+
options?: PostOptions,
|
|
65
|
+
): Promise<Camelize<T>>
|
|
31
66
|
}
|
package/src/api/listings.ts
CHANGED
|
@@ -2,11 +2,14 @@ import {
|
|
|
2
2
|
getAllListingsAPIPath,
|
|
3
3
|
getBestListingAPIPath,
|
|
4
4
|
getBestListingsAPIPath,
|
|
5
|
+
getCreateListingActionsPath,
|
|
5
6
|
getCrossChainFulfillmentDataPath,
|
|
6
7
|
getSweepListingsPath,
|
|
7
8
|
} from "./apiPaths"
|
|
8
9
|
import type { Fetcher } from "./fetcher"
|
|
9
10
|
import {
|
|
11
|
+
type CreateListingActionsRequest,
|
|
12
|
+
type CreateListingActionsResponse,
|
|
10
13
|
type CrossChainFulfillmentRequest,
|
|
11
14
|
type CrossChainFulfillmentResponse,
|
|
12
15
|
encodeTraitsParam,
|
|
@@ -42,7 +45,7 @@ export class ListingsAPI {
|
|
|
42
45
|
limit,
|
|
43
46
|
next,
|
|
44
47
|
...(includePrivateListings !== undefined && {
|
|
45
|
-
|
|
48
|
+
includePrivateListings,
|
|
46
49
|
}),
|
|
47
50
|
},
|
|
48
51
|
)
|
|
@@ -63,7 +66,7 @@ export class ListingsAPI {
|
|
|
63
66
|
const response = await this.fetcher.get<GetBestListingResponse>(
|
|
64
67
|
getBestListingAPIPath(collectionSlug, tokenId),
|
|
65
68
|
includePrivateListings !== undefined
|
|
66
|
-
? {
|
|
69
|
+
? { includePrivateListings }
|
|
67
70
|
: undefined,
|
|
68
71
|
)
|
|
69
72
|
return response
|
|
@@ -86,7 +89,7 @@ export class ListingsAPI {
|
|
|
86
89
|
limit,
|
|
87
90
|
next,
|
|
88
91
|
...(includePrivateListings !== undefined && {
|
|
89
|
-
|
|
92
|
+
includePrivateListings,
|
|
90
93
|
}),
|
|
91
94
|
traits: encodeTraitsParam(traits),
|
|
92
95
|
},
|
|
@@ -122,4 +125,19 @@ export class ListingsAPI {
|
|
|
122
125
|
request,
|
|
123
126
|
)
|
|
124
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
|
+
}
|
|
125
143
|
}
|
package/src/api/nfts.ts
CHANGED
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
import type { Chain, OpenSeaCollection } from "../types"
|
|
2
|
-
import { collectionFromJSON } from "../utils/converters"
|
|
3
2
|
import {
|
|
3
|
+
getBatchNFTsPath,
|
|
4
4
|
getContractPath,
|
|
5
5
|
getListNFTsByAccountPath,
|
|
6
6
|
getListNFTsByCollectionPath,
|
|
7
7
|
getListNFTsByContractPath,
|
|
8
|
+
getNFTAnalyticsPath,
|
|
8
9
|
getNFTCollectionPath,
|
|
9
10
|
getNFTMetadataPath,
|
|
11
|
+
getNFTOwnersPath,
|
|
10
12
|
getNFTPath,
|
|
11
13
|
getRefreshMetadataPath,
|
|
12
14
|
getValidateMetadataPath,
|
|
13
15
|
} from "./apiPaths"
|
|
14
16
|
import type { Fetcher } from "./fetcher"
|
|
15
17
|
import {
|
|
18
|
+
type BatchNftsRequest,
|
|
16
19
|
encodeTraitsParam,
|
|
17
20
|
type GetCollectionResponse,
|
|
18
21
|
type GetContractResponse,
|
|
19
22
|
type GetNFTMetadataResponse,
|
|
20
23
|
type GetNFTResponse,
|
|
21
24
|
type ListNFTsResponse,
|
|
25
|
+
type NFTOwnersArgs,
|
|
26
|
+
type NftAnalyticsResponse,
|
|
27
|
+
type NftBatchResponse,
|
|
28
|
+
type OwnersPaginatedResponse,
|
|
22
29
|
type TraitFilter,
|
|
23
30
|
type ValidateMetadataResponse,
|
|
24
31
|
} from "./types"
|
|
@@ -109,13 +116,11 @@ export class NFTsAPI {
|
|
|
109
116
|
address: string,
|
|
110
117
|
identifier: string,
|
|
111
118
|
chain: Chain = this.chain,
|
|
112
|
-
): Promise<
|
|
113
|
-
|
|
119
|
+
): Promise<Record<string, unknown>> {
|
|
120
|
+
return this.fetcher.post<Record<string, unknown>>(
|
|
114
121
|
getRefreshMetadataPath(chain, address, identifier),
|
|
115
122
|
{},
|
|
116
123
|
)
|
|
117
|
-
|
|
118
|
-
return response
|
|
119
124
|
}
|
|
120
125
|
|
|
121
126
|
/**
|
|
@@ -158,10 +163,9 @@ export class NFTsAPI {
|
|
|
158
163
|
identifier: string,
|
|
159
164
|
chain: Chain = this.chain,
|
|
160
165
|
): Promise<OpenSeaCollection> {
|
|
161
|
-
|
|
166
|
+
return this.fetcher.get<GetCollectionResponse>(
|
|
162
167
|
getNFTCollectionPath(chain, address, identifier),
|
|
163
168
|
)
|
|
164
|
-
return collectionFromJSON(response)
|
|
165
169
|
}
|
|
166
170
|
|
|
167
171
|
/**
|
|
@@ -178,4 +182,40 @@ export class NFTsAPI {
|
|
|
178
182
|
)
|
|
179
183
|
return response
|
|
180
184
|
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Fetch multiple NFTs in a single request by chain + contract + token id.
|
|
188
|
+
*/
|
|
189
|
+
async getNFTsBatch(request: BatchNftsRequest): Promise<NftBatchResponse> {
|
|
190
|
+
return this.fetcher.post<NftBatchResponse>(getBatchNFTsPath(), request)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Fetch owners of an NFT. For ERC-721s this is a single owner; for
|
|
195
|
+
* ERC-1155s it can be a paginated list with per-owner quantities.
|
|
196
|
+
*/
|
|
197
|
+
async getNFTOwners(
|
|
198
|
+
address: string,
|
|
199
|
+
identifier: string,
|
|
200
|
+
chain: Chain = this.chain,
|
|
201
|
+
args?: NFTOwnersArgs,
|
|
202
|
+
): Promise<OwnersPaginatedResponse> {
|
|
203
|
+
return this.fetcher.get<OwnersPaginatedResponse>(
|
|
204
|
+
getNFTOwnersPath(chain, address, identifier),
|
|
205
|
+
args,
|
|
206
|
+
)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Fetch analytics for an NFT — historical sale points used for charting.
|
|
211
|
+
*/
|
|
212
|
+
async getNFTAnalytics(
|
|
213
|
+
address: string,
|
|
214
|
+
identifier: string,
|
|
215
|
+
chain: Chain = this.chain,
|
|
216
|
+
): Promise<NftAnalyticsResponse> {
|
|
217
|
+
return this.fetcher.get<NftAnalyticsResponse>(
|
|
218
|
+
getNFTAnalyticsPath(chain, address, identifier),
|
|
219
|
+
)
|
|
220
|
+
}
|
|
181
221
|
}
|
package/src/api/offers.ts
CHANGED
|
@@ -114,18 +114,10 @@ export class OffersAPI {
|
|
|
114
114
|
floatValue?: number,
|
|
115
115
|
intValue?: number,
|
|
116
116
|
): Promise<GetOffersResponse> {
|
|
117
|
-
|
|
117
|
+
return this.fetcher.get<GetOffersResponse>(
|
|
118
118
|
getTraitOffersPath(collectionSlug),
|
|
119
|
-
{
|
|
120
|
-
type,
|
|
121
|
-
value,
|
|
122
|
-
limit,
|
|
123
|
-
next,
|
|
124
|
-
float_value: floatValue,
|
|
125
|
-
int_value: intValue,
|
|
126
|
-
},
|
|
119
|
+
{ type, value, limit, next, floatValue, intValue },
|
|
127
120
|
)
|
|
128
|
-
return response
|
|
129
121
|
}
|
|
130
122
|
|
|
131
123
|
/**
|
|
@@ -143,6 +135,12 @@ export class OffersAPI {
|
|
|
143
135
|
|
|
144
136
|
/**
|
|
145
137
|
* Build a OpenSea collection offer.
|
|
138
|
+
*
|
|
139
|
+
* The body uses mixed casing per the OpenSea OpenAPI spec: the outer
|
|
140
|
+
* envelope (`protocol_address`, `offer_protection_enabled`) is snake_case,
|
|
141
|
+
* but `criteria.numericTraits` keeps its camelCase key on the wire per
|
|
142
|
+
* the {@link CriteriaObject} schema. Opt out of automatic snakeize and
|
|
143
|
+
* emit the body in exact wire shape.
|
|
146
144
|
*/
|
|
147
145
|
async buildOffer(
|
|
148
146
|
offererAddress: string,
|
|
@@ -169,6 +167,8 @@ export class OffersAPI {
|
|
|
169
167
|
const response = await this.fetcher.post<BuildOfferResponse>(
|
|
170
168
|
getBuildOfferPath(),
|
|
171
169
|
payload,
|
|
170
|
+
undefined,
|
|
171
|
+
{ snakeizeBody: false },
|
|
172
172
|
)
|
|
173
173
|
return response
|
|
174
174
|
}
|
|
@@ -192,6 +192,11 @@ export class OffersAPI {
|
|
|
192
192
|
|
|
193
193
|
/**
|
|
194
194
|
* Post a collection offer to OpenSea.
|
|
195
|
+
*
|
|
196
|
+
* Mixed-casing body: outer `protocol_address`, `protocol_data` are
|
|
197
|
+
* snake_case, but `protocol_data.parameters` (Seaport struct) and
|
|
198
|
+
* `criteria.numericTraits` keep their camelCase keys on the wire. Opt out
|
|
199
|
+
* of automatic snakeize and emit the body in exact wire shape.
|
|
195
200
|
*/
|
|
196
201
|
async postCollectionOffer(
|
|
197
202
|
order: ProtocolData,
|
|
@@ -214,6 +219,8 @@ export class OffersAPI {
|
|
|
214
219
|
return await this.fetcher.post<CollectionOffer>(
|
|
215
220
|
getPostCollectionOfferPath(),
|
|
216
221
|
payload,
|
|
222
|
+
undefined,
|
|
223
|
+
{ snakeizeBody: false },
|
|
217
224
|
)
|
|
218
225
|
}
|
|
219
226
|
|
package/src/api/orders.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
getFulfillOfferPayload,
|
|
6
6
|
} from "../orders/utils"
|
|
7
7
|
import { type Chain, OrderSide } from "../types"
|
|
8
|
+
import type { Camelize } from "../utils/case"
|
|
8
9
|
import {
|
|
9
10
|
getCancelOrderPath,
|
|
10
11
|
getOrderByHashPath,
|
|
@@ -56,7 +57,7 @@ export class OrdersAPI {
|
|
|
56
57
|
unitsToFill?: string,
|
|
57
58
|
recipientAddress?: string,
|
|
58
59
|
includeOptionalCreatorFees: boolean = false,
|
|
59
|
-
): Promise<FulfillmentDataResponse
|
|
60
|
+
): Promise<Camelize<FulfillmentDataResponse>> {
|
|
60
61
|
const payload =
|
|
61
62
|
side === OrderSide.LISTING
|
|
62
63
|
? getFulfillListingPayload(
|
|
@@ -88,6 +89,12 @@ export class OrdersAPI {
|
|
|
88
89
|
|
|
89
90
|
/**
|
|
90
91
|
* Post a listing to OpenSea.
|
|
92
|
+
*
|
|
93
|
+
* The body uses mixed casing per the OpenSea OpenAPI spec: the outer
|
|
94
|
+
* envelope (`protocol_address`) is snake_case, but the inner Seaport
|
|
95
|
+
* struct (`parameters.startTime`, `parameters.orderType`, `offer[].itemType`,
|
|
96
|
+
* etc.) mirrors the on-chain struct names and must stay camelCase on the
|
|
97
|
+
* wire. We pass `snakeizeBody: false` and emit the body in exact wire shape.
|
|
91
98
|
*/
|
|
92
99
|
async postListing(
|
|
93
100
|
order: ProtocolData,
|
|
@@ -106,11 +113,18 @@ export class OrdersAPI {
|
|
|
106
113
|
...order,
|
|
107
114
|
protocol_address: protocolAddress,
|
|
108
115
|
},
|
|
116
|
+
undefined,
|
|
117
|
+
{ snakeizeBody: false },
|
|
109
118
|
)
|
|
110
119
|
}
|
|
111
120
|
|
|
112
121
|
/**
|
|
113
122
|
* Post an offer to OpenSea.
|
|
123
|
+
*
|
|
124
|
+
* Same mixed-casing wire shape as {@link postListing}: outer
|
|
125
|
+
* `protocol_address` is snake_case but the inner Seaport struct stays
|
|
126
|
+
* camelCase. We opt out of automatic snakeize so `parameters` is sent
|
|
127
|
+
* verbatim.
|
|
114
128
|
*/
|
|
115
129
|
async postOffer(
|
|
116
130
|
order: ProtocolData,
|
|
@@ -123,14 +137,22 @@ export class OrdersAPI {
|
|
|
123
137
|
throw new Error("Invalid protocol address format")
|
|
124
138
|
}
|
|
125
139
|
|
|
126
|
-
return this.fetcher.post<Offer>(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
140
|
+
return this.fetcher.post<Offer>(
|
|
141
|
+
getPostOfferPath(this.chain, "seaport"),
|
|
142
|
+
{
|
|
143
|
+
...order,
|
|
144
|
+
protocol_address: protocolAddress,
|
|
145
|
+
},
|
|
146
|
+
undefined,
|
|
147
|
+
{ snakeizeBody: false },
|
|
148
|
+
)
|
|
130
149
|
}
|
|
131
150
|
|
|
132
151
|
/**
|
|
133
152
|
* Offchain cancel an order, offer or listing, by its order hash when protected by the SignedZone.
|
|
153
|
+
*
|
|
154
|
+
* The OpenSea OpenAPI `CancelRequest` schema uses camelCase
|
|
155
|
+
* `offererSignature`, so we opt out of automatic snakeize.
|
|
134
156
|
*/
|
|
135
157
|
async offchainCancelOrder(
|
|
136
158
|
protocolAddress: string,
|
|
@@ -141,6 +163,8 @@ export class OrdersAPI {
|
|
|
141
163
|
return this.fetcher.post<CancelOrderResponse>(
|
|
142
164
|
getCancelOrderPath(chain, protocolAddress, orderHash),
|
|
143
165
|
{ offererSignature },
|
|
166
|
+
undefined,
|
|
167
|
+
{ snakeizeBody: false },
|
|
144
168
|
)
|
|
145
169
|
}
|
|
146
170
|
}
|
package/src/api/tokens.ts
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
+
import type { Chain } from "../types"
|
|
1
2
|
import {
|
|
3
|
+
getBatchTokensPath,
|
|
2
4
|
getSwapExecutePath,
|
|
3
5
|
getSwapQuotePath,
|
|
6
|
+
getTokenActivityPath,
|
|
4
7
|
getTokenGroupPath,
|
|
5
8
|
getTokenGroupsPath,
|
|
9
|
+
getTokenOhlcvPath,
|
|
6
10
|
getTokenPath,
|
|
11
|
+
getTokenPriceHistoryPath,
|
|
7
12
|
getTopTokensPath,
|
|
8
13
|
getTrendingTokensPath,
|
|
9
14
|
} from "./apiPaths"
|
|
10
15
|
import type { Fetcher } from "./fetcher"
|
|
11
16
|
import type {
|
|
17
|
+
BatchTokensRequest,
|
|
12
18
|
GetSwapQuoteArgs,
|
|
13
19
|
GetSwapQuoteResponse,
|
|
14
20
|
GetTokenGroupResponse,
|
|
@@ -18,8 +24,14 @@ import type {
|
|
|
18
24
|
GetTokensArgs,
|
|
19
25
|
GetTopTokensResponse,
|
|
20
26
|
GetTrendingTokensResponse,
|
|
27
|
+
OhlcvResponse,
|
|
28
|
+
PriceHistoryResponse,
|
|
21
29
|
SwapExecuteRequest,
|
|
22
30
|
SwapExecuteResponse,
|
|
31
|
+
TokenActivityArgs,
|
|
32
|
+
TokenBatchResponse,
|
|
33
|
+
TokenSwapActivityPaginatedResponse,
|
|
34
|
+
TokenTimeSeriesArgs,
|
|
23
35
|
} from "./types"
|
|
24
36
|
|
|
25
37
|
/**
|
|
@@ -96,4 +108,57 @@ export class TokensAPI {
|
|
|
96
108
|
async getTokenGroup(slug: string): Promise<GetTokenGroupResponse> {
|
|
97
109
|
return this.fetcher.get<GetTokenGroupResponse>(getTokenGroupPath(slug))
|
|
98
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
|
+
* `startTime` and `bucketSize` are required.
|
|
139
|
+
*/
|
|
140
|
+
async getTokenOhlcv(
|
|
141
|
+
chain: Chain,
|
|
142
|
+
address: string,
|
|
143
|
+
args: TokenTimeSeriesArgs & { bucketSize: 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
|
+
}
|
|
99
164
|
}
|