opensea-js 6.1.5 → 6.1.6
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/api.d.ts +139 -88
- package/lib/api/api.js +132 -69
- package/lib/api/api.js.map +1 -1
- package/lib/api/types.d.ts +94 -2
- package/lib/bundle.js +593 -442
- package/lib/constants.d.ts +1 -1
- package/lib/constants.js +2 -3
- package/lib/constants.js.map +1 -1
- package/lib/index.d.ts +7 -4
- package/lib/index.js +15 -0
- package/lib/index.js.map +1 -1
- package/lib/orders/types.d.ts +24 -0
- package/lib/sdk.d.ts +104 -61
- package/lib/sdk.js +100 -66
- package/lib/sdk.js.map +1 -1
- package/lib/types.d.ts +142 -39
- package/lib/types.js +59 -32
- package/lib/types.js.map +1 -1
- package/lib/utils/utils.js +4 -0
- package/lib/utils/utils.js.map +1 -1
- package/package.json +5 -3
- package/src/api/api.ts +145 -87
- package/src/api/types.ts +103 -2
- package/src/constants.ts +1 -2
- package/src/index.ts +21 -4
- package/src/orders/types.ts +24 -0
- package/src/sdk.ts +103 -74
- package/src/types.ts +142 -90
- package/src/utils/utils.ts +4 -0
package/lib/api/api.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
|
-
import { BuildOfferResponse, Offer, ListNFTsResponse, GetNFTResponse, ListCollectionOffersResponse } from "./types";
|
|
3
|
-
import { FulfillmentDataResponse, OrderAPIOptions, OrderSide, OrdersQueryOptions, OrderV2, ProtocolData
|
|
4
|
-
import { Chain, OpenSeaAPIConfig, OpenSeaAsset, OpenSeaAssetBundle, OpenSeaAssetBundleQuery, OpenSeaAssetQuery, OpenSeaCollection,
|
|
2
|
+
import { BuildOfferResponse, Offer, ListNFTsResponse, GetNFTResponse, ListCollectionOffersResponse, GetAssetsResponse, GetOrdersResponse, GetPaymentTokensResponse, GetBundlesResponse } from "./types";
|
|
3
|
+
import { FulfillmentDataResponse, OrderAPIOptions, OrderSide, OrdersQueryOptions, OrderV2, ProtocolData } from "../orders/types";
|
|
4
|
+
import { Chain, OpenSeaAPIConfig, OpenSeaAsset, OpenSeaAssetBundle, OpenSeaAssetBundleQuery, OpenSeaAssetQuery, OpenSeaCollection, OpenSeaFungibleTokenQuery } from "../types";
|
|
5
|
+
/**
|
|
6
|
+
* The API class for the OpenSea SDK.
|
|
7
|
+
* @category Main Classes
|
|
8
|
+
*/
|
|
5
9
|
export declare class OpenSeaAPI {
|
|
6
10
|
/**
|
|
7
11
|
* Base url for the API
|
|
8
12
|
*/
|
|
9
13
|
readonly apiBaseUrl: string;
|
|
10
14
|
/**
|
|
11
|
-
*
|
|
15
|
+
* Default size to use for fetching orders
|
|
12
16
|
*/
|
|
13
17
|
pageSize: number;
|
|
14
18
|
/**
|
|
@@ -25,150 +29,197 @@ export declare class OpenSeaAPI {
|
|
|
25
29
|
*/
|
|
26
30
|
constructor(config: OpenSeaAPIConfig, logger?: (arg: string) => void);
|
|
27
31
|
/**
|
|
28
|
-
* Gets an order from API based on query options.
|
|
32
|
+
* Gets an order from API based on query options.
|
|
33
|
+
* @param options
|
|
34
|
+
* @param options.side The side of the order (buy or sell
|
|
35
|
+
* @param options.protocol The protocol, typically seaport, to query orders for
|
|
36
|
+
* @param options.orderDirection The direction to sort the orders
|
|
37
|
+
* @param options.orderBy The field to sort the orders by
|
|
38
|
+
* @param options.limit The number of orders to retrieve
|
|
39
|
+
* @param options.makerAddress Fitler by the wallet addres of the order maker
|
|
40
|
+
* @param options.takerAddress Filter by wallet address of the order taker
|
|
41
|
+
* @param options.asset_contract_address Address of the NFT's contract
|
|
42
|
+
* @param options.token_ids String array of token IDs to filter by.
|
|
43
|
+
* @param options.listed_after Filter by orders listed after the Unix epoch timestamp in seconds
|
|
44
|
+
* @param options.listed_before Filter by orders listed before the Unix epoch timestamp in seconds
|
|
45
|
+
* @returns The first {@link OrderV2} returned by the API
|
|
46
|
+
*
|
|
47
|
+
* @throws An error if there are no matching orders.
|
|
29
48
|
*/
|
|
30
49
|
getOrder({ side, protocol, orderDirection, orderBy, ...restOptions }: Omit<OrdersQueryOptions, "limit">): Promise<OrderV2>;
|
|
31
50
|
/**
|
|
32
|
-
* Gets a list of orders from API based on query options
|
|
33
|
-
*
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
*
|
|
51
|
+
* Gets a list of orders from API based on query options.
|
|
52
|
+
* @param options
|
|
53
|
+
* @param options.side The side of the order (buy or sell)
|
|
54
|
+
* @param options.protocol The protocol, typically seaport, to query orders for
|
|
55
|
+
* @param options.orderDirection The direction to sort the orders
|
|
56
|
+
* @param options.orderBy The field to sort the orders by
|
|
57
|
+
* @param options.limit The number of orders to retrieve
|
|
58
|
+
* @param options.makerAddress Fitler by the wallet addres of the order maker
|
|
59
|
+
* @param options.takerAddress Filter by wallet address of the order taker
|
|
60
|
+
* @param options.asset_contract_address Address of the NFT's contract
|
|
61
|
+
* @param options.token_ids String array of token IDs to filter by.
|
|
62
|
+
* @param options.listed_after Filter by orders listed after the Unix epoch timestamp in seconds
|
|
63
|
+
* @param options.listed_before Filter by orders listed before the Unix epoch timestamp in seconds
|
|
64
|
+
* @returns The {@link GetOrdersResponse} returned by the API.
|
|
65
|
+
*/
|
|
66
|
+
getOrders({ side, protocol, orderDirection, orderBy, ...restOptions }: Omit<OrdersQueryOptions, "limit">): Promise<GetOrdersResponse>;
|
|
67
|
+
/**
|
|
68
|
+
* Generate the data needed to fulfill a listing or an offer onchain.
|
|
69
|
+
* @param fulfillerAddress The wallet address which will be used to fulfill the order
|
|
70
|
+
* @param orderHash The hash of the order to fulfill
|
|
71
|
+
* @param protocolAddress The address of the seaport contract
|
|
72
|
+
* @side The side of the order (buy or sell)
|
|
73
|
+
* @returns The {@link FulfillmentDataResponse}
|
|
40
74
|
*/
|
|
41
75
|
generateFulfillmentData(fulfillerAddress: string, orderHash: string, protocolAddress: string, side: OrderSide): Promise<FulfillmentDataResponse>;
|
|
42
76
|
/**
|
|
43
|
-
*
|
|
77
|
+
* Post an order to OpenSea.
|
|
78
|
+
* @param order The order to post
|
|
79
|
+
* @param apiOptions
|
|
80
|
+
* @param apiOptions.protocol The protocol, typically seaport, to post the order to.
|
|
81
|
+
* @param apiOptions.side The side of the order (buy or sell).
|
|
82
|
+
* @param apiOptions.protocolAddress The address of the seaport contract.
|
|
83
|
+
* @param options
|
|
84
|
+
* @param options.retries Number of times to retry if the service is unavailable for any reason.
|
|
85
|
+
* @returns The {@link OrderV2} posted to the API.
|
|
44
86
|
*/
|
|
45
87
|
postOrder(order: ProtocolData, apiOptions: OrderAPIOptions, { retries }?: {
|
|
46
88
|
retries?: number;
|
|
47
89
|
}): Promise<OrderV2>;
|
|
48
90
|
/**
|
|
49
|
-
* Build
|
|
91
|
+
* Build a OpenSea collection offer.
|
|
92
|
+
* @param offererAddress The wallet address which is creating the offer.
|
|
93
|
+
* @param quantity The number of NFTs requested in the offer.
|
|
94
|
+
* @param collectionSlug The slug (identifier) of the collection to build the offer for.
|
|
95
|
+
* @returns The {@link BuildOfferResponse} returned by the API.
|
|
50
96
|
*/
|
|
51
97
|
buildOffer(offererAddress: string, quantity: number, collectionSlug: string): Promise<BuildOfferResponse>;
|
|
52
98
|
/**
|
|
53
|
-
* Get collection offers for a given slug
|
|
54
|
-
*
|
|
55
|
-
* @param
|
|
56
|
-
* @
|
|
57
|
-
*
|
|
58
|
-
* @returns {@link ListCollectionOffersResponse}
|
|
99
|
+
* Get a list collection offers for a given slug.
|
|
100
|
+
* @param slug The slug (identifier) of the collection to list offers for
|
|
101
|
+
* @param retries Number of times to retry if the service is unavailable for any reason.
|
|
102
|
+
* @returns The {@link ListCollectionOffersResponse} returned by the API.
|
|
59
103
|
*/
|
|
60
104
|
getCollectionOffers(slug: string, retries?: number): Promise<ListCollectionOffersResponse | null>;
|
|
61
105
|
/**
|
|
62
|
-
* Post a collection offer to
|
|
63
|
-
*
|
|
64
|
-
* @param
|
|
65
|
-
* @param
|
|
66
|
-
* @
|
|
67
|
-
*
|
|
68
|
-
* @returns {@link Offer}
|
|
106
|
+
* Post a collection offer to OpenSea.
|
|
107
|
+
* @param order The collection offer to post.
|
|
108
|
+
* @param slug The slug (identifier) of the collection to post the offer for.
|
|
109
|
+
* @param retries Number of times to retry if the service is unavailable for any reason.
|
|
110
|
+
* @returns The {@link Offer} returned to the API.
|
|
69
111
|
*/
|
|
70
112
|
postCollectionOffer(order: ProtocolData, slug: string, retries?: number): Promise<Offer | null>;
|
|
71
113
|
/**
|
|
72
|
-
* Fetch an asset
|
|
73
|
-
*
|
|
74
|
-
* @
|
|
75
|
-
*
|
|
76
|
-
* @param
|
|
77
|
-
* @param tokenId The asset's token ID, or null if ERC-20
|
|
114
|
+
* Fetch an asset.
|
|
115
|
+
* @deprecated Use {@link getNFT} for multichain capabilities.
|
|
116
|
+
* @param options
|
|
117
|
+
* @param options.tokenAddress The asset's contract address.
|
|
118
|
+
* @param options.tokenId The asset's token ID, or null if ERC-20
|
|
78
119
|
* @param retries Number of times to retry if the service is unavailable for any reason
|
|
120
|
+
* @returns The {@link OpenSeaAsset} returned by the API.
|
|
121
|
+
* @throws An error if the function is called on an unsupported chain.
|
|
79
122
|
*/
|
|
80
123
|
getAsset({ tokenAddress, tokenId, }: {
|
|
81
124
|
tokenAddress: string;
|
|
82
125
|
tokenId: string | number | null;
|
|
83
126
|
}, retries?: number): Promise<OpenSeaAsset>;
|
|
84
127
|
/**
|
|
85
|
-
* Fetch multiple NFTs for a collection
|
|
86
|
-
* @param slug The
|
|
128
|
+
* Fetch multiple NFTs for a collection.
|
|
129
|
+
* @param slug The slug (identifier) of the collection
|
|
87
130
|
* @param limit The number of NFTs to retrieve. Must be greater than 0 and less than 51.
|
|
88
131
|
* @param next Cursor to retrieve the next page of NFTs
|
|
89
|
-
* @param retries Number of times to retry if the service is unavailable for any reason
|
|
132
|
+
* @param retries Number of times to retry if the service is unavailable for any reason.
|
|
133
|
+
* @returns The {@link ListNFTsResponse} returned by the API.
|
|
90
134
|
*/
|
|
91
135
|
getNFTsByCollection(slug: string, limit?: number | undefined, next?: string | undefined, retries?: number): Promise<ListNFTsResponse>;
|
|
92
136
|
/**
|
|
93
|
-
* Fetch multiple NFTs for a contract
|
|
94
|
-
* @param chain
|
|
95
|
-
* @param address
|
|
137
|
+
* Fetch multiple NFTs for a contract.
|
|
138
|
+
* @param chain The NFT's chain.
|
|
139
|
+
* @param address The NFT's contract address.
|
|
96
140
|
* @param limit The number of NFTs to retrieve. Must be greater than 0 and less than 51.
|
|
97
|
-
* @param next Cursor to retrieve the next page of NFTs
|
|
98
|
-
* @param retries Number of times to retry if the service is unavailable for any reason
|
|
141
|
+
* @param next Cursor to retrieve the next page of NFTs.
|
|
142
|
+
* @param retries Number of times to retry if the service is unavailable for any reason.
|
|
143
|
+
* @returns The {@link ListNFTsResponse} returned by the API.
|
|
99
144
|
*/
|
|
100
145
|
getNFTsByContract(chain: Chain, address: string, limit?: number | undefined, next?: string | undefined, retries?: number): Promise<ListNFTsResponse>;
|
|
101
146
|
/**
|
|
102
|
-
* Fetch metadata, traits, ownership information, and rarity for
|
|
103
|
-
* @param chain
|
|
104
|
-
* @param address
|
|
105
|
-
* @param
|
|
147
|
+
* Fetch metadata, traits, ownership information, and rarity for a single NFT.
|
|
148
|
+
* @param chain The NFT's chain.
|
|
149
|
+
* @param address The NFT's contract address.
|
|
150
|
+
* @param identifier the identifier of the NFT (i.e. Token ID)
|
|
106
151
|
* @param retries Number of times to retry if the service is unavailable for any reason
|
|
152
|
+
* @returns The {@link GetNFTResponse} returned by the API.
|
|
107
153
|
*/
|
|
108
154
|
getNFT(chain: Chain, address: string, identifier: string, retries?: number): Promise<GetNFTResponse>;
|
|
109
155
|
/**
|
|
110
|
-
* Fetch list of assets
|
|
111
|
-
*
|
|
112
|
-
* @
|
|
113
|
-
*
|
|
114
|
-
* @param query
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
156
|
+
* Fetch a list of assets.
|
|
157
|
+
* @deprecated Use {@link getNFTsByContract} or {@link getNFTsByCollection} for multichain capabilities.
|
|
158
|
+
* @param query Options to filter the list returned.
|
|
159
|
+
* @param query.owner The wallet address of the owner of the assets.
|
|
160
|
+
* @param query.asset_contract_address The Asset's contract address.
|
|
161
|
+
* @param query.token_ids String array of token IDs to filter by.
|
|
162
|
+
* @param query.order_by The field to order the list by.
|
|
163
|
+
* @param query.order_direction The direction to order the list.
|
|
164
|
+
* @param query.limit The number of assets to retrieve. Must be greater than 0 and less than 201.
|
|
165
|
+
* @param query.cursor Cursor to retrieve the next page of assets.
|
|
166
|
+
* @throws An error if the function is called on an unsupported chain.
|
|
167
|
+
* @returns The {@link GetAssetsResponse} returned by the API.
|
|
168
|
+
*/
|
|
169
|
+
getAssets(query?: OpenSeaAssetQuery): Promise<GetAssetsResponse>;
|
|
170
|
+
/**
|
|
171
|
+
* Fetch an OpenSea collection.
|
|
172
|
+
* @param slug The slug (identifier) of the collection.
|
|
173
|
+
* @returns The {@link OpenSeaCollection} returned by the API.
|
|
124
174
|
*/
|
|
125
175
|
getCollection(slug: string): Promise<OpenSeaCollection>;
|
|
126
176
|
/**
|
|
127
|
-
* Fetch list of fungible tokens
|
|
128
|
-
* @param query Query to use for getting
|
|
129
|
-
* @param page Page number
|
|
130
|
-
*
|
|
131
|
-
* @
|
|
177
|
+
* Fetch list of fungible tokens.
|
|
178
|
+
* @param query Query to use for getting tokens. See {@link OpenSeaFungibleTokenQuery}.
|
|
179
|
+
* @param page Page number to fetch. Defaults to 1.
|
|
180
|
+
* @param retries Number of times to retry if the service is unavailable for any reason.
|
|
181
|
+
* @throws An error if the function is called on an unsupported chain.
|
|
182
|
+
* @returns The {@link GetPaymentTokensResponse} returned by the API.
|
|
132
183
|
*/
|
|
133
|
-
getPaymentTokens(query?: OpenSeaFungibleTokenQuery, page?: number, retries?: number): Promise<
|
|
134
|
-
tokens: OpenSeaFungibleToken[];
|
|
135
|
-
}>;
|
|
184
|
+
getPaymentTokens(query?: OpenSeaFungibleTokenQuery, page?: number, retries?: number): Promise<GetPaymentTokensResponse>;
|
|
136
185
|
/**
|
|
137
|
-
* Fetch a bundle from the API
|
|
138
|
-
* @param
|
|
186
|
+
* Fetch a bundle from the API.
|
|
187
|
+
* @param options
|
|
188
|
+
* @param options.slug The bundle's identifier
|
|
189
|
+
* @returns The {@link OpenSeaAssetBundle} returned by the API. If not found, returns null.
|
|
139
190
|
*/
|
|
140
191
|
getBundle({ slug, }: {
|
|
141
192
|
slug: string;
|
|
142
193
|
}): Promise<OpenSeaAssetBundle | null>;
|
|
143
194
|
/**
|
|
144
|
-
* Fetch list of bundles from the API
|
|
145
|
-
* @param query Query to use for getting
|
|
146
|
-
* @param page Page number
|
|
147
|
-
*
|
|
195
|
+
* Fetch list of bundles from the API.
|
|
196
|
+
* @param query Query to use for getting bunldes. See {@link OpenSeaAssetBundleQuery}.
|
|
197
|
+
* @param page Page number to fetch. Defaults to 1.
|
|
198
|
+
* @returns The {@link GetBundlesResponse} returned by the API.
|
|
148
199
|
*/
|
|
149
|
-
getBundles(query?: OpenSeaAssetBundleQuery, page?: number): Promise<
|
|
150
|
-
bundles: OpenSeaAssetBundle[];
|
|
151
|
-
estimatedCount: number;
|
|
152
|
-
}>;
|
|
200
|
+
getBundles(query?: OpenSeaAssetBundleQuery, page?: number): Promise<GetBundlesResponse>;
|
|
153
201
|
/**
|
|
154
|
-
*
|
|
155
|
-
* @param chain chain the
|
|
156
|
-
* @param address address of the
|
|
157
|
-
* @param
|
|
158
|
-
* @param retries Number of times to retry if the service is unavailable for any reason
|
|
202
|
+
* Force refresh the metadata for an NFT.
|
|
203
|
+
* @param chain The chain where the NFT is located.
|
|
204
|
+
* @param address The address of the NFT's contract.
|
|
205
|
+
* @param identifier The identifier of the NFT.
|
|
206
|
+
* @param retries Number of times to retry if the service is unavailable for any reason.
|
|
207
|
+
* @returns The response from the API.
|
|
159
208
|
*/
|
|
160
|
-
refreshNFTMetadata(chain: Chain, address: string, identifier: string, retries?: number): Promise<
|
|
209
|
+
refreshNFTMetadata(chain: Chain, address: string, identifier: string, retries?: number): Promise<Response>;
|
|
161
210
|
/**
|
|
162
|
-
*
|
|
211
|
+
* Generic fetch method for any API endpoint
|
|
163
212
|
* @param apiPath Path to URL endpoint under API
|
|
164
|
-
* @param query
|
|
213
|
+
* @param query URL query params. Will be used to create a URLSearchParams object.
|
|
214
|
+
* @returns @typeParam T The response from the API.
|
|
165
215
|
*/
|
|
166
216
|
get<T>(apiPath: string, query?: object): Promise<T>;
|
|
167
217
|
/**
|
|
168
|
-
*
|
|
218
|
+
* Generic post methd for any API endpoint.
|
|
169
219
|
* @param apiPath Path to URL endpoint under API
|
|
170
|
-
* @param body Data to send.
|
|
220
|
+
* @param body Data to send.
|
|
171
221
|
* @param opts ethers ConnectionInfo, similar to Fetch API.
|
|
222
|
+
* @returns @typeParam T The response from the API.
|
|
172
223
|
*/
|
|
173
224
|
post<T>(apiPath: string, body?: object, opts?: ethers.utils.ConnectionInfo): Promise<T>;
|
|
174
225
|
private objectToSearchParams;
|