@opensea/sdk 9.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/LICENSE +7 -0
- package/README.md +70 -0
- package/lib/api/accounts.d.ts +27 -0
- package/lib/api/accounts.js +46 -0
- package/lib/api/accounts.js.map +1 -0
- package/lib/api/api.d.ts +489 -0
- package/lib/api/api.js +754 -0
- package/lib/api/api.js.map +1 -0
- package/lib/api/apiPaths.d.ts +46 -0
- package/lib/api/apiPaths.js +176 -0
- package/lib/api/apiPaths.js.map +1 -0
- package/lib/api/chains.d.ts +13 -0
- package/lib/api/chains.js +22 -0
- package/lib/api/chains.js.map +1 -0
- package/lib/api/collections.d.ts +34 -0
- package/lib/api/collections.js +80 -0
- package/lib/api/collections.js.map +1 -0
- package/lib/api/drops.d.ts +21 -0
- package/lib/api/drops.js +39 -0
- package/lib/api/drops.js.map +1 -0
- package/lib/api/events.d.ts +26 -0
- package/lib/api/events.js +43 -0
- package/lib/api/events.js.map +1 -0
- package/lib/api/fetcher.d.ts +24 -0
- package/lib/api/fetcher.js +3 -0
- package/lib/api/fetcher.js.map +1 -0
- package/lib/api/index.d.ts +2 -0
- package/lib/api/index.js +19 -0
- package/lib/api/index.js.map +1 -0
- package/lib/api/listings.d.ts +44 -0
- package/lib/api/listings.js +88 -0
- package/lib/api/listings.js.map +1 -0
- package/lib/api/nfts.d.ts +39 -0
- package/lib/api/nfts.js +79 -0
- package/lib/api/nfts.js.map +1 -0
- package/lib/api/offers.d.ts +54 -0
- package/lib/api/offers.js +124 -0
- package/lib/api/offers.js.map +1 -0
- package/lib/api/orders.d.ts +50 -0
- package/lib/api/orders.js +153 -0
- package/lib/api/orders.js.map +1 -0
- package/lib/api/search.d.ts +13 -0
- package/lib/api/search.js +22 -0
- package/lib/api/search.js.map +1 -0
- package/lib/api/tokens.d.ts +25 -0
- package/lib/api/tokens.js +43 -0
- package/lib/api/tokens.js.map +1 -0
- package/lib/api/types.d.ts +1113 -0
- package/lib/api/types.js +65 -0
- package/lib/api/types.js.map +1 -0
- package/lib/constants.d.ts +22 -0
- package/lib/constants.js +52 -0
- package/lib/constants.js.map +1 -0
- package/lib/index.d.ts +18 -0
- package/lib/index.js +24 -0
- package/lib/index.js.map +1 -0
- package/lib/orders/privateListings.d.ts +12 -0
- package/lib/orders/privateListings.js +130 -0
- package/lib/orders/privateListings.js.map +1 -0
- package/lib/orders/types.d.ts +160 -0
- package/lib/orders/types.js +10 -0
- package/lib/orders/types.js.map +1 -0
- package/lib/orders/utils.d.ts +89 -0
- package/lib/orders/utils.js +177 -0
- package/lib/orders/utils.js.map +1 -0
- package/lib/sdk/assets.d.ts +104 -0
- package/lib/sdk/assets.js +398 -0
- package/lib/sdk/assets.js.map +1 -0
- package/lib/sdk/cancellation.d.ts +97 -0
- package/lib/sdk/cancellation.js +235 -0
- package/lib/sdk/cancellation.js.map +1 -0
- package/lib/sdk/context.d.ts +28 -0
- package/lib/sdk/context.js +3 -0
- package/lib/sdk/context.js.map +1 -0
- package/lib/sdk/fulfillment.d.ts +153 -0
- package/lib/sdk/fulfillment.js +298 -0
- package/lib/sdk/fulfillment.js.map +1 -0
- package/lib/sdk/orders.d.ts +253 -0
- package/lib/sdk/orders.js +679 -0
- package/lib/sdk/orders.js.map +1 -0
- package/lib/sdk/tokens.d.ts +31 -0
- package/lib/sdk/tokens.js +65 -0
- package/lib/sdk/tokens.js.map +1 -0
- package/lib/sdk.d.ts +560 -0
- package/lib/sdk.js +693 -0
- package/lib/sdk.js.map +1 -0
- package/lib/src/api/accounts.d.ts +18 -0
- package/lib/src/api/accounts.js +30 -0
- package/lib/src/api/accounts.js.map +1 -0
- package/lib/src/api/api.d.ts +429 -0
- package/lib/src/api/api.js +652 -0
- package/lib/src/api/api.js.map +1 -0
- package/lib/src/api/apiPaths.d.ts +37 -0
- package/lib/src/api/apiPaths.js +140 -0
- package/lib/src/api/apiPaths.js.map +1 -0
- package/lib/src/api/collections.d.ts +26 -0
- package/lib/src/api/collections.js +57 -0
- package/lib/src/api/collections.js.map +1 -0
- package/lib/src/api/events.d.ts +26 -0
- package/lib/src/api/events.js +42 -0
- package/lib/src/api/events.js.map +1 -0
- package/lib/src/api/fetcher.d.ts +24 -0
- package/lib/src/api/fetcher.js +3 -0
- package/lib/src/api/fetcher.js.map +1 -0
- package/lib/src/api/index.d.ts +2 -0
- package/lib/src/api/index.js +19 -0
- package/lib/src/api/index.js.map +1 -0
- package/lib/src/api/listings.d.ts +44 -0
- package/lib/src/api/listings.js +86 -0
- package/lib/src/api/listings.js.map +1 -0
- package/lib/src/api/nfts.d.ts +35 -0
- package/lib/src/api/nfts.js +66 -0
- package/lib/src/api/nfts.js.map +1 -0
- package/lib/src/api/offers.d.ts +54 -0
- package/lib/src/api/offers.js +122 -0
- package/lib/src/api/offers.js.map +1 -0
- package/lib/src/api/orders.d.ts +50 -0
- package/lib/src/api/orders.js +151 -0
- package/lib/src/api/orders.js.map +1 -0
- package/lib/src/api/search.d.ts +13 -0
- package/lib/src/api/search.js +21 -0
- package/lib/src/api/search.js.map +1 -0
- package/lib/src/api/tokens.d.ts +25 -0
- package/lib/src/api/tokens.js +42 -0
- package/lib/src/api/tokens.js.map +1 -0
- package/lib/src/api/types.d.ts +840 -0
- package/lib/src/api/types.js +65 -0
- package/lib/src/api/types.js.map +1 -0
- package/lib/src/constants.d.ts +22 -0
- package/lib/src/constants.js +52 -0
- package/lib/src/constants.js.map +1 -0
- package/lib/src/index.d.ts +18 -0
- package/lib/src/index.js +24 -0
- package/lib/src/index.js.map +1 -0
- package/lib/src/orders/privateListings.d.ts +12 -0
- package/lib/src/orders/privateListings.js +130 -0
- package/lib/src/orders/privateListings.js.map +1 -0
- package/lib/src/orders/types.d.ts +160 -0
- package/lib/src/orders/types.js +10 -0
- package/lib/src/orders/types.js.map +1 -0
- package/lib/src/orders/utils.d.ts +89 -0
- package/lib/src/orders/utils.js +177 -0
- package/lib/src/orders/utils.js.map +1 -0
- package/lib/src/sdk/assets.d.ts +104 -0
- package/lib/src/sdk/assets.js +397 -0
- package/lib/src/sdk/assets.js.map +1 -0
- package/lib/src/sdk/cancellation.d.ts +97 -0
- package/lib/src/sdk/cancellation.js +234 -0
- package/lib/src/sdk/cancellation.js.map +1 -0
- package/lib/src/sdk/context.d.ts +28 -0
- package/lib/src/sdk/context.js +3 -0
- package/lib/src/sdk/context.js.map +1 -0
- package/lib/src/sdk/fulfillment.d.ts +153 -0
- package/lib/src/sdk/fulfillment.js +296 -0
- package/lib/src/sdk/fulfillment.js.map +1 -0
- package/lib/src/sdk/orders.d.ts +253 -0
- package/lib/src/sdk/orders.js +677 -0
- package/lib/src/sdk/orders.js.map +1 -0
- package/lib/src/sdk/tokens.d.ts +31 -0
- package/lib/src/sdk/tokens.js +64 -0
- package/lib/src/sdk/tokens.js.map +1 -0
- package/lib/src/sdk.d.ts +560 -0
- package/lib/src/sdk.js +675 -0
- package/lib/src/sdk.js.map +1 -0
- package/lib/src/typechain/contracts/ERC1155.d.ts +236 -0
- package/lib/src/typechain/contracts/ERC1155.js +3 -0
- package/lib/src/typechain/contracts/ERC1155.js.map +1 -0
- package/lib/src/typechain/contracts/ERC20.d.ts +141 -0
- package/lib/src/typechain/contracts/ERC20.js +3 -0
- package/lib/src/typechain/contracts/ERC20.js.map +1 -0
- package/lib/src/typechain/contracts/ERC721.d.ts +213 -0
- package/lib/src/typechain/contracts/ERC721.js +3 -0
- package/lib/src/typechain/contracts/ERC721.js.map +1 -0
- package/lib/src/typechain/contracts/Multicall3.d.ts +57 -0
- package/lib/src/typechain/contracts/Multicall3.js +3 -0
- package/lib/src/typechain/contracts/Multicall3.js.map +1 -0
- package/lib/src/typechain/contracts/TransferHelper.d.ts +55 -0
- package/lib/src/typechain/contracts/TransferHelper.js +3 -0
- package/lib/src/typechain/contracts/TransferHelper.js.map +1 -0
- package/lib/src/typechain/contracts/common.d.ts +50 -0
- package/lib/src/typechain/contracts/common.js +3 -0
- package/lib/src/typechain/contracts/common.js.map +1 -0
- package/lib/src/typechain/contracts/factories/ERC1155__factory.d.ts +250 -0
- package/lib/src/typechain/contracts/factories/ERC1155__factory.js +332 -0
- package/lib/src/typechain/contracts/factories/ERC1155__factory.js.map +1 -0
- package/lib/src/typechain/contracts/factories/ERC20__factory.d.ts +174 -0
- package/lib/src/typechain/contracts/factories/ERC20__factory.js +240 -0
- package/lib/src/typechain/contracts/factories/ERC20__factory.js.map +1 -0
- package/lib/src/typechain/contracts/factories/ERC721__factory.d.ts +268 -0
- package/lib/src/typechain/contracts/factories/ERC721__factory.js +351 -0
- package/lib/src/typechain/contracts/factories/ERC721__factory.js.map +1 -0
- package/lib/src/typechain/contracts/factories/Multicall3__factory.d.ts +43 -0
- package/lib/src/typechain/contracts/factories/Multicall3__factory.js +68 -0
- package/lib/src/typechain/contracts/factories/Multicall3__factory.js.map +1 -0
- package/lib/src/typechain/contracts/factories/TransferHelper__factory.d.ts +46 -0
- package/lib/src/typechain/contracts/factories/TransferHelper__factory.js +71 -0
- package/lib/src/typechain/contracts/factories/TransferHelper__factory.js.map +1 -0
- package/lib/src/typechain/contracts/factories/index.d.ts +5 -0
- package/lib/src/typechain/contracts/factories/index.js +17 -0
- package/lib/src/typechain/contracts/factories/index.js.map +1 -0
- package/lib/src/typechain/contracts/index.d.ts +11 -0
- package/lib/src/typechain/contracts/index.js +48 -0
- package/lib/src/typechain/contracts/index.js.map +1 -0
- package/lib/src/types.d.ts +387 -0
- package/lib/src/types.js +127 -0
- package/lib/src/types.js.map +1 -0
- package/lib/src/utils/chain.d.ts +60 -0
- package/lib/src/utils/chain.js +248 -0
- package/lib/src/utils/chain.js.map +1 -0
- package/lib/src/utils/converters.d.ts +37 -0
- package/lib/src/utils/converters.js +137 -0
- package/lib/src/utils/converters.js.map +1 -0
- package/lib/src/utils/dateHelper.d.ts +38 -0
- package/lib/src/utils/dateHelper.js +52 -0
- package/lib/src/utils/dateHelper.js.map +1 -0
- package/lib/src/utils/fees.d.ts +13 -0
- package/lib/src/utils/fees.js +29 -0
- package/lib/src/utils/fees.js.map +1 -0
- package/lib/src/utils/index.d.ts +2 -0
- package/lib/src/utils/index.js +19 -0
- package/lib/src/utils/index.js.map +1 -0
- package/lib/src/utils/protocol.d.ts +75 -0
- package/lib/src/utils/protocol.js +161 -0
- package/lib/src/utils/protocol.js.map +1 -0
- package/lib/src/utils/rateLimit.d.ts +34 -0
- package/lib/src/utils/rateLimit.js +97 -0
- package/lib/src/utils/rateLimit.js.map +1 -0
- package/lib/src/utils/stringHelper.d.ts +18 -0
- package/lib/src/utils/stringHelper.js +24 -0
- package/lib/src/utils/stringHelper.js.map +1 -0
- package/lib/src/utils/utils.d.ts +18 -0
- package/lib/src/utils/utils.js +45 -0
- package/lib/src/utils/utils.js.map +1 -0
- package/lib/typechain/contracts/ERC1155.d.ts +236 -0
- package/lib/typechain/contracts/ERC1155.js +3 -0
- package/lib/typechain/contracts/ERC1155.js.map +1 -0
- package/lib/typechain/contracts/ERC20.d.ts +141 -0
- package/lib/typechain/contracts/ERC20.js +3 -0
- package/lib/typechain/contracts/ERC20.js.map +1 -0
- package/lib/typechain/contracts/ERC721.d.ts +213 -0
- package/lib/typechain/contracts/ERC721.js +3 -0
- package/lib/typechain/contracts/ERC721.js.map +1 -0
- package/lib/typechain/contracts/Multicall3.d.ts +57 -0
- package/lib/typechain/contracts/Multicall3.js +3 -0
- package/lib/typechain/contracts/Multicall3.js.map +1 -0
- package/lib/typechain/contracts/TransferHelper.d.ts +55 -0
- package/lib/typechain/contracts/TransferHelper.js +3 -0
- package/lib/typechain/contracts/TransferHelper.js.map +1 -0
- package/lib/typechain/contracts/common.d.ts +50 -0
- package/lib/typechain/contracts/common.js +3 -0
- package/lib/typechain/contracts/common.js.map +1 -0
- package/lib/typechain/contracts/factories/ERC1155__factory.d.ts +250 -0
- package/lib/typechain/contracts/factories/ERC1155__factory.js +332 -0
- package/lib/typechain/contracts/factories/ERC1155__factory.js.map +1 -0
- package/lib/typechain/contracts/factories/ERC20__factory.d.ts +174 -0
- package/lib/typechain/contracts/factories/ERC20__factory.js +240 -0
- package/lib/typechain/contracts/factories/ERC20__factory.js.map +1 -0
- package/lib/typechain/contracts/factories/ERC721__factory.d.ts +268 -0
- package/lib/typechain/contracts/factories/ERC721__factory.js +351 -0
- package/lib/typechain/contracts/factories/ERC721__factory.js.map +1 -0
- package/lib/typechain/contracts/factories/Multicall3__factory.d.ts +43 -0
- package/lib/typechain/contracts/factories/Multicall3__factory.js +68 -0
- package/lib/typechain/contracts/factories/Multicall3__factory.js.map +1 -0
- package/lib/typechain/contracts/factories/TransferHelper__factory.d.ts +46 -0
- package/lib/typechain/contracts/factories/TransferHelper__factory.js +71 -0
- package/lib/typechain/contracts/factories/TransferHelper__factory.js.map +1 -0
- package/lib/typechain/contracts/factories/index.d.ts +5 -0
- package/lib/typechain/contracts/factories/index.js +17 -0
- package/lib/typechain/contracts/factories/index.js.map +1 -0
- package/lib/typechain/contracts/index.d.ts +11 -0
- package/lib/typechain/contracts/index.js +48 -0
- package/lib/typechain/contracts/index.js.map +1 -0
- package/lib/types.d.ts +389 -0
- package/lib/types.js +129 -0
- package/lib/types.js.map +1 -0
- package/lib/utils/chain.d.ts +64 -0
- package/lib/utils/chain.js +211 -0
- package/lib/utils/chain.js.map +1 -0
- package/lib/utils/chainIds.generated.d.ts +7 -0
- package/lib/utils/chainIds.generated.js +37 -0
- package/lib/utils/chainIds.generated.js.map +1 -0
- package/lib/utils/converters.d.ts +37 -0
- package/lib/utils/converters.js +137 -0
- package/lib/utils/converters.js.map +1 -0
- package/lib/utils/dateHelper.d.ts +38 -0
- package/lib/utils/dateHelper.js +52 -0
- package/lib/utils/dateHelper.js.map +1 -0
- package/lib/utils/fees.d.ts +13 -0
- package/lib/utils/fees.js +29 -0
- package/lib/utils/fees.js.map +1 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +19 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/protocol.d.ts +75 -0
- package/lib/utils/protocol.js +161 -0
- package/lib/utils/protocol.js.map +1 -0
- package/lib/utils/rateLimit.d.ts +34 -0
- package/lib/utils/rateLimit.js +97 -0
- package/lib/utils/rateLimit.js.map +1 -0
- package/lib/utils/stringHelper.d.ts +18 -0
- package/lib/utils/stringHelper.js +24 -0
- package/lib/utils/stringHelper.js.map +1 -0
- package/lib/utils/utils.d.ts +18 -0
- package/lib/utils/utils.js +45 -0
- package/lib/utils/utils.js.map +1 -0
- package/package.json +72 -0
- package/src/abi/ERC1155.json +314 -0
- package/src/abi/ERC20.json +222 -0
- package/src/abi/ERC721.json +333 -0
- package/src/abi/Multicall3.json +50 -0
- package/src/abi/TransferHelper.json +53 -0
- package/src/api/accounts.ts +69 -0
- package/src/api/api.ts +1152 -0
- package/src/api/apiPaths.ts +208 -0
- package/src/api/chains.ts +18 -0
- package/src/api/collections.ts +120 -0
- package/src/api/drops.ts +49 -0
- package/src/api/events.ts +71 -0
- package/src/api/fetcher.ts +31 -0
- package/src/api/index.ts +2 -0
- package/src/api/listings.ts +126 -0
- package/src/api/nfts.ts +144 -0
- package/src/api/offers.ts +242 -0
- package/src/api/orders.ts +283 -0
- package/src/api/search.ts +21 -0
- package/src/api/tokens.ts +67 -0
- package/src/api/types.ts +1210 -0
- package/src/constants.ts +90 -0
- package/src/index.ts +22 -0
- package/src/orders/privateListings.ts +173 -0
- package/src/orders/types.ts +191 -0
- package/src/orders/utils.ts +253 -0
- package/src/sdk/assets.ts +591 -0
- package/src/sdk/cancellation.ts +346 -0
- package/src/sdk/context.ts +33 -0
- package/src/sdk/fulfillment.ts +478 -0
- package/src/sdk/orders.ts +1149 -0
- package/src/sdk/tokens.ts +95 -0
- package/src/sdk.ts +1051 -0
- package/src/typechain/contracts/ERC1155.ts +440 -0
- package/src/typechain/contracts/ERC20.ts +286 -0
- package/src/typechain/contracts/ERC721.ts +412 -0
- package/src/typechain/contracts/Multicall3.ts +117 -0
- package/src/typechain/contracts/TransferHelper.ts +122 -0
- package/src/typechain/contracts/common.ts +131 -0
- package/src/typechain/contracts/factories/ERC1155__factory.ts +331 -0
- package/src/typechain/contracts/factories/ERC20__factory.ts +239 -0
- package/src/typechain/contracts/factories/ERC721__factory.ts +350 -0
- package/src/typechain/contracts/factories/Multicall3__factory.ts +67 -0
- package/src/typechain/contracts/factories/TransferHelper__factory.ts +76 -0
- package/src/typechain/contracts/factories/index.ts +8 -0
- package/src/typechain/contracts/index.ts +14 -0
- package/src/types.ts +413 -0
- package/src/utils/chain.ts +224 -0
- package/src/utils/chainIds.generated.ts +34 -0
- package/src/utils/converters.ts +145 -0
- package/src/utils/dateHelper.ts +48 -0
- package/src/utils/fees.ts +31 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/protocol.ts +185 -0
- package/src/utils/rateLimit.ts +147 -0
- package/src/utils/stringHelper.ts +25 -0
- package/src/utils/utils.ts +36 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import type { OrderProtocol } from "../orders/types"
|
|
2
|
+
import { type Chain, OrderSide } from "../types"
|
|
3
|
+
|
|
4
|
+
/** Base path prefix for all OpenSea API v2 endpoints. */
|
|
5
|
+
export const API_V2_PREFIX = "/api/v2"
|
|
6
|
+
|
|
7
|
+
export const getOrdersAPIPath = (
|
|
8
|
+
chain: Chain,
|
|
9
|
+
protocol: OrderProtocol,
|
|
10
|
+
side: OrderSide,
|
|
11
|
+
) => {
|
|
12
|
+
const sidePath = side === OrderSide.LISTING ? "listings" : "offers"
|
|
13
|
+
return `${API_V2_PREFIX}/orders/${chain}/${protocol}/${sidePath}`
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const getAllOffersAPIPath = (collectionSlug: string) => {
|
|
17
|
+
return `${API_V2_PREFIX}/offers/collection/${collectionSlug}/all`
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const getAllListingsAPIPath = (collectionSlug: string) => {
|
|
21
|
+
return `${API_V2_PREFIX}/listings/collection/${collectionSlug}/all`
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const getBestOfferAPIPath = (
|
|
25
|
+
collectionSlug: string,
|
|
26
|
+
tokenId: string | number,
|
|
27
|
+
) => {
|
|
28
|
+
return `${API_V2_PREFIX}/offers/collection/${collectionSlug}/nfts/${tokenId}/best`
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const getBestListingAPIPath = (
|
|
32
|
+
collectionSlug: string,
|
|
33
|
+
tokenId: string | number,
|
|
34
|
+
) => {
|
|
35
|
+
return `${API_V2_PREFIX}/listings/collection/${collectionSlug}/nfts/${tokenId}/best`
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const getBestListingsAPIPath = (collectionSlug: string) => {
|
|
39
|
+
return `${API_V2_PREFIX}/listings/collection/${collectionSlug}/best`
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const getCollectionPath = (slug: string) => {
|
|
43
|
+
return `${API_V2_PREFIX}/collections/${slug}`
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const getCollectionsPath = () => {
|
|
47
|
+
return `${API_V2_PREFIX}/collections`
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const getCollectionStatsPath = (slug: string) => {
|
|
51
|
+
return `${API_V2_PREFIX}/collections/${slug}/stats`
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const getPaymentTokenPath = (chain: Chain, address: string) => {
|
|
55
|
+
return `${API_V2_PREFIX}/chain/${chain}/payment_token/${address}`
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const getAccountPath = (address: string) => {
|
|
59
|
+
return `${API_V2_PREFIX}/accounts/${address}`
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const getBuildOfferPath = () => {
|
|
63
|
+
return `${API_V2_PREFIX}/offers/build`
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const getPostCollectionOfferPath = () => {
|
|
67
|
+
return `${API_V2_PREFIX}/offers`
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export const getCollectionOffersPath = (slug: string) => {
|
|
71
|
+
return `${API_V2_PREFIX}/offers/collection/${slug}`
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const getListNFTsByCollectionPath = (slug: string) => {
|
|
75
|
+
return `${API_V2_PREFIX}/collection/${slug}/nfts`
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const getListNFTsByContractPath = (chain: Chain, address: string) => {
|
|
79
|
+
return `${API_V2_PREFIX}/chain/${chain}/contract/${address}/nfts`
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export const getListNFTsByAccountPath = (chain: Chain, address: string) => {
|
|
83
|
+
return `${API_V2_PREFIX}/chain/${chain}/account/${address}/nfts`
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export const getNFTPath = (
|
|
87
|
+
chain: Chain,
|
|
88
|
+
address: string,
|
|
89
|
+
identifier: string,
|
|
90
|
+
) => {
|
|
91
|
+
return `${API_V2_PREFIX}/chain/${chain}/contract/${address}/nfts/${identifier}`
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export const getRefreshMetadataPath = (
|
|
95
|
+
chain: Chain,
|
|
96
|
+
address: string,
|
|
97
|
+
identifier: string,
|
|
98
|
+
) => {
|
|
99
|
+
return `${API_V2_PREFIX}/chain/${chain}/contract/${address}/nfts/${identifier}/refresh`
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export const getOrderByHashPath = (
|
|
103
|
+
chain: Chain,
|
|
104
|
+
protocolAddress: string,
|
|
105
|
+
orderHash: string,
|
|
106
|
+
) => {
|
|
107
|
+
return `${API_V2_PREFIX}/orders/chain/${chain}/protocol/${protocolAddress}/${orderHash}`
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export const getCancelOrderPath = (
|
|
111
|
+
chain: Chain,
|
|
112
|
+
protocolAddress: string,
|
|
113
|
+
orderHash: string,
|
|
114
|
+
) => {
|
|
115
|
+
return `${API_V2_PREFIX}/orders/chain/${chain}/protocol/${protocolAddress}/${orderHash}/cancel`
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export const getTraitOffersPath = (collectionSlug: string) => {
|
|
119
|
+
return `${API_V2_PREFIX}/offers/collection/${collectionSlug}/traits`
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export const getEventsAPIPath = () => {
|
|
123
|
+
return `${API_V2_PREFIX}/events`
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export const getEventsByAccountAPIPath = (address: string) => {
|
|
127
|
+
return `${API_V2_PREFIX}/events/accounts/${address}`
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export const getEventsByCollectionAPIPath = (collectionSlug: string) => {
|
|
131
|
+
return `${API_V2_PREFIX}/events/collection/${collectionSlug}`
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export const getEventsByNFTAPIPath = (
|
|
135
|
+
chain: Chain,
|
|
136
|
+
address: string,
|
|
137
|
+
identifier: string,
|
|
138
|
+
) => {
|
|
139
|
+
return `${API_V2_PREFIX}/events/chain/${chain}/contract/${address}/nfts/${identifier}`
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export const getContractPath = (chain: Chain, address: string) => {
|
|
143
|
+
return `${API_V2_PREFIX}/chain/${chain}/contract/${address}`
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export const getTraitsPath = (collectionSlug: string) => {
|
|
147
|
+
return `${API_V2_PREFIX}/traits/${collectionSlug}`
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export const getTrendingTokensPath = () => {
|
|
151
|
+
return `${API_V2_PREFIX}/tokens/trending`
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export const getTopTokensPath = () => {
|
|
155
|
+
return `${API_V2_PREFIX}/tokens/top`
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export const getSwapQuotePath = () => {
|
|
159
|
+
return `${API_V2_PREFIX}/swap/quote`
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export const getTokenPath = (chain: string, address: string) => {
|
|
163
|
+
return `${API_V2_PREFIX}/chain/${chain}/token/${address}`
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export const getSearchPath = () => {
|
|
167
|
+
return `${API_V2_PREFIX}/search`
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export const getChainsPath = () => {
|
|
171
|
+
return `${API_V2_PREFIX}/chains`
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export const getAccountTokensPath = (address: string) => {
|
|
175
|
+
return `${API_V2_PREFIX}/account/${address}/tokens`
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export const getValidateMetadataPath = (
|
|
179
|
+
chain: Chain,
|
|
180
|
+
address: string,
|
|
181
|
+
identifier: string,
|
|
182
|
+
) => {
|
|
183
|
+
return `${API_V2_PREFIX}/chain/${chain}/contract/${address}/nfts/${identifier}/validate-metadata`
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export const getDropsPath = () => {
|
|
187
|
+
return `${API_V2_PREFIX}/drops`
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export const getDropPath = (slug: string) => {
|
|
191
|
+
return `${API_V2_PREFIX}/drops/${slug}`
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export const getDropMintPath = (slug: string) => {
|
|
195
|
+
return `${API_V2_PREFIX}/drops/${slug}/mint`
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export const getTrendingCollectionsPath = () => {
|
|
199
|
+
return `${API_V2_PREFIX}/collections/trending`
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export const getTopCollectionsPath = () => {
|
|
203
|
+
return `${API_V2_PREFIX}/collections/top`
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export const getResolveAccountPath = (identifier: string) => {
|
|
207
|
+
return `${API_V2_PREFIX}/accounts/resolve/${identifier}`
|
|
208
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { getChainsPath } from "./apiPaths"
|
|
2
|
+
import type { Fetcher } from "./fetcher"
|
|
3
|
+
import type { GetChainsResponse } from "./types"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Chain-related API operations
|
|
7
|
+
*/
|
|
8
|
+
export class ChainsAPI {
|
|
9
|
+
constructor(private fetcher: Fetcher) {}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Gets the list of supported chains.
|
|
13
|
+
*/
|
|
14
|
+
async getChains(): Promise<GetChainsResponse> {
|
|
15
|
+
const response = await this.fetcher.get<GetChainsResponse>(getChainsPath())
|
|
16
|
+
return response
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { Chain, OpenSeaCollection, OpenSeaCollectionStats } from "../types"
|
|
2
|
+
import { collectionFromJSON } from "../utils/converters"
|
|
3
|
+
import {
|
|
4
|
+
getCollectionPath,
|
|
5
|
+
getCollectionStatsPath,
|
|
6
|
+
getCollectionsPath,
|
|
7
|
+
getTopCollectionsPath,
|
|
8
|
+
getTraitsPath,
|
|
9
|
+
getTrendingCollectionsPath,
|
|
10
|
+
} from "./apiPaths"
|
|
11
|
+
import type { Fetcher } from "./fetcher"
|
|
12
|
+
import {
|
|
13
|
+
CollectionOrderByOption,
|
|
14
|
+
type GetCollectionResponse,
|
|
15
|
+
type GetCollectionsArgs,
|
|
16
|
+
type GetCollectionsPaginatedResponse,
|
|
17
|
+
type GetCollectionsResponse,
|
|
18
|
+
type GetTopCollectionsArgs,
|
|
19
|
+
type GetTraitsResponse,
|
|
20
|
+
type GetTrendingCollectionsArgs,
|
|
21
|
+
} from "./types"
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Collection-related API operations
|
|
25
|
+
*/
|
|
26
|
+
export class CollectionsAPI {
|
|
27
|
+
constructor(private fetcher: Fetcher) {}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Fetch an OpenSea collection.
|
|
31
|
+
*/
|
|
32
|
+
async getCollection(slug: string): Promise<OpenSeaCollection> {
|
|
33
|
+
const path = getCollectionPath(slug)
|
|
34
|
+
const response = await this.fetcher.get<GetCollectionResponse>(path)
|
|
35
|
+
return collectionFromJSON(response)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Fetch a list of OpenSea collections.
|
|
40
|
+
*/
|
|
41
|
+
async getCollections(
|
|
42
|
+
orderBy: CollectionOrderByOption = CollectionOrderByOption.CREATED_DATE,
|
|
43
|
+
chain?: Chain,
|
|
44
|
+
creatorUsername?: string,
|
|
45
|
+
includeHidden: boolean = false,
|
|
46
|
+
limit?: number,
|
|
47
|
+
next?: string,
|
|
48
|
+
): Promise<GetCollectionsResponse> {
|
|
49
|
+
const path = getCollectionsPath()
|
|
50
|
+
const args: GetCollectionsArgs = {
|
|
51
|
+
order_by: orderBy,
|
|
52
|
+
chain,
|
|
53
|
+
creator_username: creatorUsername,
|
|
54
|
+
include_hidden: includeHidden,
|
|
55
|
+
limit,
|
|
56
|
+
next,
|
|
57
|
+
}
|
|
58
|
+
const response = await this.fetcher.get<GetCollectionsResponse>(path, args)
|
|
59
|
+
response.collections = response.collections.map(collection =>
|
|
60
|
+
collectionFromJSON(collection),
|
|
61
|
+
)
|
|
62
|
+
return response
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Fetch stats for an OpenSea collection.
|
|
67
|
+
*/
|
|
68
|
+
async getCollectionStats(slug: string): Promise<OpenSeaCollectionStats> {
|
|
69
|
+
const path = getCollectionStatsPath(slug)
|
|
70
|
+
const response = await this.fetcher.get<OpenSeaCollectionStats>(path)
|
|
71
|
+
return response as OpenSeaCollectionStats
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Fetch all traits for a collection with their possible values and counts.
|
|
76
|
+
*/
|
|
77
|
+
async getTraits(collectionSlug: string): Promise<GetTraitsResponse> {
|
|
78
|
+
const path = getTraitsPath(collectionSlug)
|
|
79
|
+
const response = await this.fetcher.get<GetTraitsResponse>(path)
|
|
80
|
+
return response
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Fetch trending collections sorted by sales activity.
|
|
85
|
+
*/
|
|
86
|
+
async getTrendingCollections(
|
|
87
|
+
args?: GetTrendingCollectionsArgs,
|
|
88
|
+
): Promise<GetCollectionsPaginatedResponse> {
|
|
89
|
+
const response = await this.fetcher.get<GetCollectionsPaginatedResponse>(
|
|
90
|
+
getTrendingCollectionsPath(),
|
|
91
|
+
{
|
|
92
|
+
...args,
|
|
93
|
+
chains: args?.chains?.join(","),
|
|
94
|
+
},
|
|
95
|
+
)
|
|
96
|
+
response.collections = response.collections.map(collection =>
|
|
97
|
+
collectionFromJSON(collection),
|
|
98
|
+
)
|
|
99
|
+
return response
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Fetch top collections ranked by various stats.
|
|
104
|
+
*/
|
|
105
|
+
async getTopCollections(
|
|
106
|
+
args?: GetTopCollectionsArgs,
|
|
107
|
+
): Promise<GetCollectionsPaginatedResponse> {
|
|
108
|
+
const response = await this.fetcher.get<GetCollectionsPaginatedResponse>(
|
|
109
|
+
getTopCollectionsPath(),
|
|
110
|
+
{
|
|
111
|
+
...args,
|
|
112
|
+
chains: args?.chains?.join(","),
|
|
113
|
+
},
|
|
114
|
+
)
|
|
115
|
+
response.collections = response.collections.map(collection =>
|
|
116
|
+
collectionFromJSON(collection),
|
|
117
|
+
)
|
|
118
|
+
return response
|
|
119
|
+
}
|
|
120
|
+
}
|
package/src/api/drops.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { getDropMintPath, getDropPath, getDropsPath } from "./apiPaths"
|
|
2
|
+
import type { Fetcher } from "./fetcher"
|
|
3
|
+
import type {
|
|
4
|
+
DropMintRequest,
|
|
5
|
+
DropMintResponse,
|
|
6
|
+
GetDropResponse,
|
|
7
|
+
GetDropsArgs,
|
|
8
|
+
GetDropsResponse,
|
|
9
|
+
} from "./types"
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Drop-related API operations
|
|
13
|
+
*/
|
|
14
|
+
export class DropsAPI {
|
|
15
|
+
constructor(private fetcher: Fetcher) {}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Gets a list of drops (mints).
|
|
19
|
+
*/
|
|
20
|
+
async getDrops(args?: GetDropsArgs): Promise<GetDropsResponse> {
|
|
21
|
+
const response = await this.fetcher.get<GetDropsResponse>(getDropsPath(), {
|
|
22
|
+
...args,
|
|
23
|
+
chains: args?.chains?.join(","),
|
|
24
|
+
})
|
|
25
|
+
return response
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Gets detailed drop information for a collection.
|
|
30
|
+
*/
|
|
31
|
+
async getDrop(slug: string): Promise<GetDropResponse> {
|
|
32
|
+
const response = await this.fetcher.get<GetDropResponse>(getDropPath(slug))
|
|
33
|
+
return response
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Builds a mint transaction for a drop.
|
|
38
|
+
*/
|
|
39
|
+
async buildMintTransaction(
|
|
40
|
+
slug: string,
|
|
41
|
+
request: DropMintRequest,
|
|
42
|
+
): Promise<DropMintResponse> {
|
|
43
|
+
const response = await this.fetcher.post<DropMintResponse>(
|
|
44
|
+
getDropMintPath(slug),
|
|
45
|
+
request,
|
|
46
|
+
)
|
|
47
|
+
return response
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { Chain } from "../types"
|
|
2
|
+
import {
|
|
3
|
+
getEventsAPIPath,
|
|
4
|
+
getEventsByAccountAPIPath,
|
|
5
|
+
getEventsByCollectionAPIPath,
|
|
6
|
+
getEventsByNFTAPIPath,
|
|
7
|
+
} from "./apiPaths"
|
|
8
|
+
import type { Fetcher } from "./fetcher"
|
|
9
|
+
import type { GetEventsArgs, GetEventsResponse } from "./types"
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Events-related API operations
|
|
13
|
+
*/
|
|
14
|
+
export class EventsAPI {
|
|
15
|
+
constructor(private fetcher: Fetcher) {}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Gets a list of events based on query parameters.
|
|
19
|
+
*/
|
|
20
|
+
async getEvents(args?: GetEventsArgs): Promise<GetEventsResponse> {
|
|
21
|
+
const response = await this.fetcher.get<GetEventsResponse>(
|
|
22
|
+
getEventsAPIPath(),
|
|
23
|
+
args,
|
|
24
|
+
)
|
|
25
|
+
return response
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Gets a list of events for a specific account.
|
|
30
|
+
*/
|
|
31
|
+
async getEventsByAccount(
|
|
32
|
+
address: string,
|
|
33
|
+
args?: GetEventsArgs,
|
|
34
|
+
): Promise<GetEventsResponse> {
|
|
35
|
+
const response = await this.fetcher.get<GetEventsResponse>(
|
|
36
|
+
getEventsByAccountAPIPath(address),
|
|
37
|
+
args,
|
|
38
|
+
)
|
|
39
|
+
return response
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Gets a list of events for a specific collection.
|
|
44
|
+
*/
|
|
45
|
+
async getEventsByCollection(
|
|
46
|
+
collectionSlug: string,
|
|
47
|
+
args?: GetEventsArgs,
|
|
48
|
+
): Promise<GetEventsResponse> {
|
|
49
|
+
const response = await this.fetcher.get<GetEventsResponse>(
|
|
50
|
+
getEventsByCollectionAPIPath(collectionSlug),
|
|
51
|
+
args,
|
|
52
|
+
)
|
|
53
|
+
return response
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Gets a list of events for a specific NFT.
|
|
58
|
+
*/
|
|
59
|
+
async getEventsByNFT(
|
|
60
|
+
chain: Chain,
|
|
61
|
+
address: string,
|
|
62
|
+
identifier: string,
|
|
63
|
+
args?: GetEventsArgs,
|
|
64
|
+
): Promise<GetEventsResponse> {
|
|
65
|
+
const response = await this.fetcher.get<GetEventsResponse>(
|
|
66
|
+
getEventsByNFTAPIPath(chain, address, identifier),
|
|
67
|
+
args,
|
|
68
|
+
)
|
|
69
|
+
return response
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { RequestOptions } from "../types"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Fetcher context interface for making HTTP requests to the OpenSea API.
|
|
5
|
+
* This interface abstracts the HTTP methods used by specialized API clients.
|
|
6
|
+
*/
|
|
7
|
+
export interface Fetcher {
|
|
8
|
+
/**
|
|
9
|
+
* Generic fetch method for GET requests with automatic rate limit retry
|
|
10
|
+
* @param apiPath Path to URL endpoint under API
|
|
11
|
+
* @param query URL query params. Will be used to create a URLSearchParams object.
|
|
12
|
+
* @param options Request options like timeout and abort signal.
|
|
13
|
+
* @returns The response from the API.
|
|
14
|
+
*/
|
|
15
|
+
get<T>(apiPath: string, query?: object, options?: RequestOptions): Promise<T>
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Generic post method for POST requests with automatic rate limit retry
|
|
19
|
+
* @param apiPath Path to URL endpoint under API
|
|
20
|
+
* @param body Data to send.
|
|
21
|
+
* @param headers Additional headers to send with the request.
|
|
22
|
+
* @param options Request options like timeout and abort signal.
|
|
23
|
+
* @returns The response from the API.
|
|
24
|
+
*/
|
|
25
|
+
post<T>(
|
|
26
|
+
apiPath: string,
|
|
27
|
+
body?: object,
|
|
28
|
+
headers?: object,
|
|
29
|
+
options?: RequestOptions,
|
|
30
|
+
): Promise<T>
|
|
31
|
+
}
|
package/src/api/index.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { serializeOrdersQueryOptions } from "../orders/utils"
|
|
2
|
+
import { type Chain, OrderSide } from "../types"
|
|
3
|
+
import {
|
|
4
|
+
getAllListingsAPIPath,
|
|
5
|
+
getBestListingAPIPath,
|
|
6
|
+
getBestListingsAPIPath,
|
|
7
|
+
getOrdersAPIPath,
|
|
8
|
+
} from "./apiPaths"
|
|
9
|
+
import type { Fetcher } from "./fetcher"
|
|
10
|
+
import type { GetBestListingResponse, GetListingsResponse } from "./types"
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Listing-related API operations
|
|
14
|
+
*/
|
|
15
|
+
export class ListingsAPI {
|
|
16
|
+
constructor(
|
|
17
|
+
private fetcher: Fetcher,
|
|
18
|
+
private chain: Chain,
|
|
19
|
+
) {}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Gets all listings for a given collection.
|
|
23
|
+
* @param collectionSlug The collection slug
|
|
24
|
+
* @param limit The number of listings to return
|
|
25
|
+
* @param next The cursor for pagination
|
|
26
|
+
* @param includePrivateListings Whether to include private listings (default: false)
|
|
27
|
+
*/
|
|
28
|
+
async getAllListings(
|
|
29
|
+
collectionSlug: string,
|
|
30
|
+
limit?: number,
|
|
31
|
+
next?: string,
|
|
32
|
+
includePrivateListings?: boolean,
|
|
33
|
+
): Promise<GetListingsResponse> {
|
|
34
|
+
const response = await this.fetcher.get<GetListingsResponse>(
|
|
35
|
+
getAllListingsAPIPath(collectionSlug),
|
|
36
|
+
{
|
|
37
|
+
limit,
|
|
38
|
+
next,
|
|
39
|
+
...(includePrivateListings !== undefined && {
|
|
40
|
+
include_private_listings: includePrivateListings,
|
|
41
|
+
}),
|
|
42
|
+
},
|
|
43
|
+
)
|
|
44
|
+
return response
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Gets the best listing for a given token.
|
|
49
|
+
* @param collectionSlug The collection slug
|
|
50
|
+
* @param tokenId The token ID
|
|
51
|
+
* @param includePrivateListings Whether to include private listings (default: false)
|
|
52
|
+
*/
|
|
53
|
+
async getBestListing(
|
|
54
|
+
collectionSlug: string,
|
|
55
|
+
tokenId: string | number,
|
|
56
|
+
includePrivateListings?: boolean,
|
|
57
|
+
): Promise<GetBestListingResponse> {
|
|
58
|
+
const response = await this.fetcher.get<GetBestListingResponse>(
|
|
59
|
+
getBestListingAPIPath(collectionSlug, tokenId),
|
|
60
|
+
includePrivateListings !== undefined
|
|
61
|
+
? { include_private_listings: includePrivateListings }
|
|
62
|
+
: undefined,
|
|
63
|
+
)
|
|
64
|
+
return response
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Gets the best listings for a given collection.
|
|
69
|
+
* @param collectionSlug The collection slug
|
|
70
|
+
* @param limit The number of listings to return
|
|
71
|
+
* @param next The cursor for pagination
|
|
72
|
+
* @param includePrivateListings Whether to include private listings (default: false)
|
|
73
|
+
*/
|
|
74
|
+
async getBestListings(
|
|
75
|
+
collectionSlug: string,
|
|
76
|
+
limit?: number,
|
|
77
|
+
next?: string,
|
|
78
|
+
includePrivateListings?: boolean,
|
|
79
|
+
): Promise<GetListingsResponse> {
|
|
80
|
+
const response = await this.fetcher.get<GetListingsResponse>(
|
|
81
|
+
getBestListingsAPIPath(collectionSlug),
|
|
82
|
+
{
|
|
83
|
+
limit,
|
|
84
|
+
next,
|
|
85
|
+
...(includePrivateListings !== undefined && {
|
|
86
|
+
include_private_listings: includePrivateListings,
|
|
87
|
+
}),
|
|
88
|
+
},
|
|
89
|
+
)
|
|
90
|
+
return response
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Gets all active listings for a specific NFT.
|
|
95
|
+
* @param assetContractAddress The NFT contract address
|
|
96
|
+
* @param tokenId The token ID
|
|
97
|
+
* @param limit The number of listings to return
|
|
98
|
+
* @param next The cursor for pagination
|
|
99
|
+
* @param chain The blockchain chain
|
|
100
|
+
* @param includePrivateListings Whether to include private listings (default: false)
|
|
101
|
+
*/
|
|
102
|
+
async getNFTListings(
|
|
103
|
+
assetContractAddress: string,
|
|
104
|
+
tokenId: string,
|
|
105
|
+
limit?: number,
|
|
106
|
+
next?: string,
|
|
107
|
+
chain: Chain = this.chain,
|
|
108
|
+
includePrivateListings?: boolean,
|
|
109
|
+
): Promise<GetListingsResponse> {
|
|
110
|
+
const response = await this.fetcher.get<GetListingsResponse>(
|
|
111
|
+
getOrdersAPIPath(chain, "seaport", OrderSide.LISTING),
|
|
112
|
+
{
|
|
113
|
+
...serializeOrdersQueryOptions({
|
|
114
|
+
assetContractAddress,
|
|
115
|
+
tokenIds: [tokenId],
|
|
116
|
+
limit,
|
|
117
|
+
next,
|
|
118
|
+
}),
|
|
119
|
+
...(includePrivateListings !== undefined && {
|
|
120
|
+
include_private_listings: includePrivateListings,
|
|
121
|
+
}),
|
|
122
|
+
},
|
|
123
|
+
)
|
|
124
|
+
return response
|
|
125
|
+
}
|
|
126
|
+
}
|