@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,44 @@
|
|
|
1
|
+
import { type Chain } from "../types";
|
|
2
|
+
import type { Fetcher } from "./fetcher";
|
|
3
|
+
import type { GetBestListingResponse, GetListingsResponse } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* Listing-related API operations
|
|
6
|
+
*/
|
|
7
|
+
export declare class ListingsAPI {
|
|
8
|
+
private fetcher;
|
|
9
|
+
private chain;
|
|
10
|
+
constructor(fetcher: Fetcher, chain: Chain);
|
|
11
|
+
/**
|
|
12
|
+
* Gets all listings for a given collection.
|
|
13
|
+
* @param collectionSlug The collection slug
|
|
14
|
+
* @param limit The number of listings to return
|
|
15
|
+
* @param next The cursor for pagination
|
|
16
|
+
* @param includePrivateListings Whether to include private listings (default: false)
|
|
17
|
+
*/
|
|
18
|
+
getAllListings(collectionSlug: string, limit?: number, next?: string, includePrivateListings?: boolean): Promise<GetListingsResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* Gets the best listing for a given token.
|
|
21
|
+
* @param collectionSlug The collection slug
|
|
22
|
+
* @param tokenId The token ID
|
|
23
|
+
* @param includePrivateListings Whether to include private listings (default: false)
|
|
24
|
+
*/
|
|
25
|
+
getBestListing(collectionSlug: string, tokenId: string | number, includePrivateListings?: boolean): Promise<GetBestListingResponse>;
|
|
26
|
+
/**
|
|
27
|
+
* Gets the best listings for a given collection.
|
|
28
|
+
* @param collectionSlug The collection slug
|
|
29
|
+
* @param limit The number of listings to return
|
|
30
|
+
* @param next The cursor for pagination
|
|
31
|
+
* @param includePrivateListings Whether to include private listings (default: false)
|
|
32
|
+
*/
|
|
33
|
+
getBestListings(collectionSlug: string, limit?: number, next?: string, includePrivateListings?: boolean): Promise<GetListingsResponse>;
|
|
34
|
+
/**
|
|
35
|
+
* Gets all active listings for a specific NFT.
|
|
36
|
+
* @param assetContractAddress The NFT contract address
|
|
37
|
+
* @param tokenId The token ID
|
|
38
|
+
* @param limit The number of listings to return
|
|
39
|
+
* @param next The cursor for pagination
|
|
40
|
+
* @param chain The blockchain chain
|
|
41
|
+
* @param includePrivateListings Whether to include private listings (default: false)
|
|
42
|
+
*/
|
|
43
|
+
getNFTListings(assetContractAddress: string, tokenId: string, limit?: number, next?: string, chain?: Chain, includePrivateListings?: boolean): Promise<GetListingsResponse>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ListingsAPI = void 0;
|
|
4
|
+
const utils_1 = require("../orders/utils");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
const apiPaths_1 = require("./apiPaths");
|
|
7
|
+
/**
|
|
8
|
+
* Listing-related API operations
|
|
9
|
+
*/
|
|
10
|
+
class ListingsAPI {
|
|
11
|
+
fetcher;
|
|
12
|
+
chain;
|
|
13
|
+
constructor(fetcher, chain) {
|
|
14
|
+
this.fetcher = fetcher;
|
|
15
|
+
this.chain = chain;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Gets all listings for a given collection.
|
|
19
|
+
* @param collectionSlug The collection slug
|
|
20
|
+
* @param limit The number of listings to return
|
|
21
|
+
* @param next The cursor for pagination
|
|
22
|
+
* @param includePrivateListings Whether to include private listings (default: false)
|
|
23
|
+
*/
|
|
24
|
+
async getAllListings(collectionSlug, limit, next, includePrivateListings) {
|
|
25
|
+
const response = await this.fetcher.get((0, apiPaths_1.getAllListingsAPIPath)(collectionSlug), {
|
|
26
|
+
limit,
|
|
27
|
+
next,
|
|
28
|
+
...(includePrivateListings !== undefined && {
|
|
29
|
+
include_private_listings: includePrivateListings,
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
32
|
+
return response;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Gets the best listing for a given token.
|
|
36
|
+
* @param collectionSlug The collection slug
|
|
37
|
+
* @param tokenId The token ID
|
|
38
|
+
* @param includePrivateListings Whether to include private listings (default: false)
|
|
39
|
+
*/
|
|
40
|
+
async getBestListing(collectionSlug, tokenId, includePrivateListings) {
|
|
41
|
+
const response = await this.fetcher.get((0, apiPaths_1.getBestListingAPIPath)(collectionSlug, tokenId), includePrivateListings !== undefined
|
|
42
|
+
? { include_private_listings: includePrivateListings }
|
|
43
|
+
: undefined);
|
|
44
|
+
return response;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Gets the best listings for a given collection.
|
|
48
|
+
* @param collectionSlug The collection slug
|
|
49
|
+
* @param limit The number of listings to return
|
|
50
|
+
* @param next The cursor for pagination
|
|
51
|
+
* @param includePrivateListings Whether to include private listings (default: false)
|
|
52
|
+
*/
|
|
53
|
+
async getBestListings(collectionSlug, limit, next, includePrivateListings) {
|
|
54
|
+
const response = await this.fetcher.get((0, apiPaths_1.getBestListingsAPIPath)(collectionSlug), {
|
|
55
|
+
limit,
|
|
56
|
+
next,
|
|
57
|
+
...(includePrivateListings !== undefined && {
|
|
58
|
+
include_private_listings: includePrivateListings,
|
|
59
|
+
}),
|
|
60
|
+
});
|
|
61
|
+
return response;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Gets all active listings for a specific NFT.
|
|
65
|
+
* @param assetContractAddress The NFT contract address
|
|
66
|
+
* @param tokenId The token ID
|
|
67
|
+
* @param limit The number of listings to return
|
|
68
|
+
* @param next The cursor for pagination
|
|
69
|
+
* @param chain The blockchain chain
|
|
70
|
+
* @param includePrivateListings Whether to include private listings (default: false)
|
|
71
|
+
*/
|
|
72
|
+
async getNFTListings(assetContractAddress, tokenId, limit, next, chain = this.chain, includePrivateListings) {
|
|
73
|
+
const response = await this.fetcher.get((0, apiPaths_1.getOrdersAPIPath)(chain, "seaport", types_1.OrderSide.LISTING), {
|
|
74
|
+
...(0, utils_1.serializeOrdersQueryOptions)({
|
|
75
|
+
assetContractAddress,
|
|
76
|
+
tokenIds: [tokenId],
|
|
77
|
+
limit,
|
|
78
|
+
next,
|
|
79
|
+
}),
|
|
80
|
+
...(includePrivateListings !== undefined && {
|
|
81
|
+
include_private_listings: includePrivateListings,
|
|
82
|
+
}),
|
|
83
|
+
});
|
|
84
|
+
return response;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.ListingsAPI = ListingsAPI;
|
|
88
|
+
//# sourceMappingURL=listings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listings.js","sourceRoot":"","sources":["../../src/api/listings.ts"],"names":[],"mappings":";;;AAAA,2CAA6D;AAC7D,oCAAgD;AAChD,yCAKmB;AAInB;;GAEG;AACH,MAAa,WAAW;IAEZ;IACA;IAFV,YACU,OAAgB,EAChB,KAAY;QADZ,YAAO,GAAP,OAAO,CAAS;QAChB,UAAK,GAAL,KAAK,CAAO;IACnB,CAAC;IAEJ;;;;;;OAMG;IACH,KAAK,CAAC,cAAc,CAClB,cAAsB,EACtB,KAAc,EACd,IAAa,EACb,sBAAgC;QAEhC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CACrC,IAAA,gCAAqB,EAAC,cAAc,CAAC,EACrC;YACE,KAAK;YACL,IAAI;YACJ,GAAG,CAAC,sBAA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AAC,sBAAsB,KAAK,SAAS,IAAI;gBAC1C,wBAAwB,EAAE,sBAAsB;aACjD,CAAC;SACH,CACF,CAAA;QACD,OAAO,QAAQ,CAAA;IACjB,CAAC;CACF;AA/GD,kCA+GC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Chain } from "../types";
|
|
2
|
+
import type { Fetcher } from "./fetcher";
|
|
3
|
+
import type { GetContractResponse, GetNFTResponse, ListNFTsResponse, ValidateMetadataResponse } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* NFT-related API operations
|
|
6
|
+
*/
|
|
7
|
+
export declare class NFTsAPI {
|
|
8
|
+
private fetcher;
|
|
9
|
+
private chain;
|
|
10
|
+
constructor(fetcher: Fetcher, chain: Chain);
|
|
11
|
+
/**
|
|
12
|
+
* Fetch multiple NFTs for a collection.
|
|
13
|
+
*/
|
|
14
|
+
getNFTsByCollection(slug: string, limit?: number | undefined, next?: string | undefined): Promise<ListNFTsResponse>;
|
|
15
|
+
/**
|
|
16
|
+
* Fetch multiple NFTs for a contract.
|
|
17
|
+
*/
|
|
18
|
+
getNFTsByContract(address: string, limit?: number | undefined, next?: string | undefined, chain?: Chain): Promise<ListNFTsResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* Fetch NFTs owned by an account.
|
|
21
|
+
*/
|
|
22
|
+
getNFTsByAccount(address: string, limit?: number | undefined, next?: string | undefined, chain?: Chain): Promise<ListNFTsResponse>;
|
|
23
|
+
/**
|
|
24
|
+
* Fetch metadata, traits, ownership information, and rarity for a single NFT.
|
|
25
|
+
*/
|
|
26
|
+
getNFT(address: string, identifier: string, chain?: Chain): Promise<GetNFTResponse>;
|
|
27
|
+
/**
|
|
28
|
+
* Force refresh the metadata for an NFT.
|
|
29
|
+
*/
|
|
30
|
+
refreshNFTMetadata(address: string, identifier: string, chain?: Chain): Promise<Response>;
|
|
31
|
+
/**
|
|
32
|
+
* Fetch smart contract information for a given chain and address.
|
|
33
|
+
*/
|
|
34
|
+
getContract(address: string, chain?: Chain): Promise<GetContractResponse>;
|
|
35
|
+
/**
|
|
36
|
+
* Validate NFT metadata by fetching and parsing it.
|
|
37
|
+
*/
|
|
38
|
+
validateMetadata(address: string, identifier: string, chain?: Chain, ignoreCachedItemUrls?: boolean): Promise<ValidateMetadataResponse>;
|
|
39
|
+
}
|
package/lib/api/nfts.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NFTsAPI = void 0;
|
|
4
|
+
const apiPaths_1 = require("./apiPaths");
|
|
5
|
+
/**
|
|
6
|
+
* NFT-related API operations
|
|
7
|
+
*/
|
|
8
|
+
class NFTsAPI {
|
|
9
|
+
fetcher;
|
|
10
|
+
chain;
|
|
11
|
+
constructor(fetcher, chain) {
|
|
12
|
+
this.fetcher = fetcher;
|
|
13
|
+
this.chain = chain;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Fetch multiple NFTs for a collection.
|
|
17
|
+
*/
|
|
18
|
+
async getNFTsByCollection(slug, limit = undefined, next = undefined) {
|
|
19
|
+
const response = await this.fetcher.get((0, apiPaths_1.getListNFTsByCollectionPath)(slug), {
|
|
20
|
+
limit,
|
|
21
|
+
next,
|
|
22
|
+
});
|
|
23
|
+
return response;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Fetch multiple NFTs for a contract.
|
|
27
|
+
*/
|
|
28
|
+
async getNFTsByContract(address, limit = undefined, next = undefined, chain = this.chain) {
|
|
29
|
+
const response = await this.fetcher.get((0, apiPaths_1.getListNFTsByContractPath)(chain, address), {
|
|
30
|
+
limit,
|
|
31
|
+
next,
|
|
32
|
+
});
|
|
33
|
+
return response;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Fetch NFTs owned by an account.
|
|
37
|
+
*/
|
|
38
|
+
async getNFTsByAccount(address, limit = undefined, next = undefined, chain = this.chain) {
|
|
39
|
+
const response = await this.fetcher.get((0, apiPaths_1.getListNFTsByAccountPath)(chain, address), {
|
|
40
|
+
limit,
|
|
41
|
+
next,
|
|
42
|
+
});
|
|
43
|
+
return response;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Fetch metadata, traits, ownership information, and rarity for a single NFT.
|
|
47
|
+
*/
|
|
48
|
+
async getNFT(address, identifier, chain = this.chain) {
|
|
49
|
+
const response = await this.fetcher.get((0, apiPaths_1.getNFTPath)(chain, address, identifier));
|
|
50
|
+
return response;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Force refresh the metadata for an NFT.
|
|
54
|
+
*/
|
|
55
|
+
async refreshNFTMetadata(address, identifier, chain = this.chain) {
|
|
56
|
+
const response = await this.fetcher.post((0, apiPaths_1.getRefreshMetadataPath)(chain, address, identifier), {});
|
|
57
|
+
return response;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Fetch smart contract information for a given chain and address.
|
|
61
|
+
*/
|
|
62
|
+
async getContract(address, chain = this.chain) {
|
|
63
|
+
const response = await this.fetcher.get((0, apiPaths_1.getContractPath)(chain, address));
|
|
64
|
+
return response;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Validate NFT metadata by fetching and parsing it.
|
|
68
|
+
*/
|
|
69
|
+
async validateMetadata(address, identifier, chain = this.chain, ignoreCachedItemUrls) {
|
|
70
|
+
let path = (0, apiPaths_1.getValidateMetadataPath)(chain, address, identifier);
|
|
71
|
+
if (ignoreCachedItemUrls !== undefined) {
|
|
72
|
+
path += `?ignoreCachedItemUrls=${ignoreCachedItemUrls}`;
|
|
73
|
+
}
|
|
74
|
+
const response = await this.fetcher.post(path);
|
|
75
|
+
return response;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.NFTsAPI = NFTsAPI;
|
|
79
|
+
//# sourceMappingURL=nfts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nfts.js","sourceRoot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,CAAC,GAAG,CACrC,IAAA,qBAAU,EAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,CACvC,CAAA;QACD,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,kBAAkB,CACtB,OAAe,EACf,UAAkB,EAClB,QAAe,IAAI,CAAC,KAAK;QAEzB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CACtC,IAAA,iCAAsB,EAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,EAClD,EAAE,CACH,CAAA;QAED,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CACf,OAAe,EACf,QAAe,IAAI,CAAC,KAAK;QAEzB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CACrC,IAAA,0BAAe,EAAC,KAAK,EAAE,OAAO,CAAC,CAChC,CAAA;QACD,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,gBAAgB,CACpB,OAAe,EACf,UAAkB,EAClB,QAAe,IAAI,CAAC,KAAK,EACzB,oBAA8B;QAE9B,IAAI,IAAI,GAAG,IAAA,kCAAuB,EAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,CAAA;QAC9D,IAAI,oBAAoB,KAAK,SAAS,EAAE,CAAC;YACvC,IAAI,IAAI,yBAAyB,oBAAoB,EAAE,CAAA;QACzD,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAA2B,IAAI,CAAC,CAAA;QACxE,OAAO,QAAQ,CAAA;IACjB,CAAC;CACF;AA1HD,0BA0HC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ProtocolData } from "../orders/types";
|
|
2
|
+
import { type Chain } from "../types";
|
|
3
|
+
import type { Fetcher } from "./fetcher";
|
|
4
|
+
import type { BuildOfferResponse, CollectionOffer, GetBestOfferResponse, GetOffersResponse } from "./types";
|
|
5
|
+
/**
|
|
6
|
+
* Offer-related API operations
|
|
7
|
+
*/
|
|
8
|
+
export declare class OffersAPI {
|
|
9
|
+
private fetcher;
|
|
10
|
+
private chain;
|
|
11
|
+
constructor(fetcher: Fetcher, chain: Chain);
|
|
12
|
+
/**
|
|
13
|
+
* Gets all offers for a given collection.
|
|
14
|
+
*/
|
|
15
|
+
getAllOffers(collectionSlug: string, limit?: number, next?: string): Promise<GetOffersResponse>;
|
|
16
|
+
/**
|
|
17
|
+
* Gets trait offers for a given collection.
|
|
18
|
+
*/
|
|
19
|
+
getTraitOffers(collectionSlug: string, type: string, value: string, limit?: number, next?: string, floatValue?: number, intValue?: number): Promise<GetOffersResponse>;
|
|
20
|
+
/**
|
|
21
|
+
* Gets the best offer for a given token.
|
|
22
|
+
*/
|
|
23
|
+
getBestOffer(collectionSlug: string, tokenId: string | number): Promise<GetBestOfferResponse>;
|
|
24
|
+
/**
|
|
25
|
+
* Build a OpenSea collection offer.
|
|
26
|
+
*/
|
|
27
|
+
buildOffer(offererAddress: string, quantity: number, collectionSlug: string, offerProtectionEnabled?: boolean, traitType?: string, traitValue?: string, traits?: Array<{
|
|
28
|
+
type: string;
|
|
29
|
+
value: string;
|
|
30
|
+
}>, numericTraits?: Array<{
|
|
31
|
+
type: string;
|
|
32
|
+
min?: number;
|
|
33
|
+
max?: number;
|
|
34
|
+
}>): Promise<BuildOfferResponse>;
|
|
35
|
+
/**
|
|
36
|
+
* Get a list of collection offers for a given slug.
|
|
37
|
+
*/
|
|
38
|
+
getCollectionOffers(slug: string, limit?: number, next?: string): Promise<GetOffersResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* Post a collection offer to OpenSea.
|
|
41
|
+
*/
|
|
42
|
+
postCollectionOffer(order: ProtocolData, slug: string, traitType?: string, traitValue?: string, traits?: Array<{
|
|
43
|
+
type: string;
|
|
44
|
+
value: string;
|
|
45
|
+
}>, numericTraits?: Array<{
|
|
46
|
+
type: string;
|
|
47
|
+
min?: number;
|
|
48
|
+
max?: number;
|
|
49
|
+
}>): Promise<CollectionOffer | null>;
|
|
50
|
+
/**
|
|
51
|
+
* Gets all active offers for a specific NFT.
|
|
52
|
+
*/
|
|
53
|
+
getNFTOffers(assetContractAddress: string, tokenId: string, limit?: number, next?: string, chain?: Chain): Promise<GetOffersResponse>;
|
|
54
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OffersAPI = void 0;
|
|
4
|
+
const utils_1 = require("../orders/utils");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
const apiPaths_1 = require("./apiPaths");
|
|
7
|
+
/**
|
|
8
|
+
* Validates trait parameters for collection offers.
|
|
9
|
+
* Used by both buildOffer and postCollectionOffer.
|
|
10
|
+
*/
|
|
11
|
+
function validateTraitParams(traitType, traitValue, traits, numericTraits) {
|
|
12
|
+
if (traits && traits.length > 0 && (traitType || traitValue)) {
|
|
13
|
+
throw new Error("Cannot use both 'traits' array and individual 'traitType'/'traitValue' parameters. Please use only one approach.");
|
|
14
|
+
}
|
|
15
|
+
if (traitType || traitValue) {
|
|
16
|
+
if (!traitType || !traitValue) {
|
|
17
|
+
throw new Error("Both traitType and traitValue must be defined if one is defined.");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (traits && traits.length > 0) {
|
|
21
|
+
for (const trait of traits) {
|
|
22
|
+
if (!trait.type || !trait.value) {
|
|
23
|
+
throw new Error("Each trait must have both 'type' and 'value' properties.");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (numericTraits && numericTraits.length > 0) {
|
|
28
|
+
for (const trait of numericTraits) {
|
|
29
|
+
if (!trait.type) {
|
|
30
|
+
throw new Error("Each numeric trait must have a 'type' property.");
|
|
31
|
+
}
|
|
32
|
+
if (trait.min === undefined && trait.max === undefined) {
|
|
33
|
+
throw new Error(`Numeric trait '${trait.type}' must have at least one of 'min' or 'max'.`);
|
|
34
|
+
}
|
|
35
|
+
if (trait.min !== undefined &&
|
|
36
|
+
trait.max !== undefined &&
|
|
37
|
+
trait.min > trait.max) {
|
|
38
|
+
throw new Error(`Numeric trait '${trait.type}': 'min' (${trait.min}) must be <= 'max' (${trait.max}).`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Offer-related API operations
|
|
45
|
+
*/
|
|
46
|
+
class OffersAPI {
|
|
47
|
+
fetcher;
|
|
48
|
+
chain;
|
|
49
|
+
constructor(fetcher, chain) {
|
|
50
|
+
this.fetcher = fetcher;
|
|
51
|
+
this.chain = chain;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Gets all offers for a given collection.
|
|
55
|
+
*/
|
|
56
|
+
async getAllOffers(collectionSlug, limit, next) {
|
|
57
|
+
const response = await this.fetcher.get((0, apiPaths_1.getAllOffersAPIPath)(collectionSlug), {
|
|
58
|
+
limit,
|
|
59
|
+
next,
|
|
60
|
+
});
|
|
61
|
+
return response;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Gets trait offers for a given collection.
|
|
65
|
+
*/
|
|
66
|
+
async getTraitOffers(collectionSlug, type, value, limit, next, floatValue, intValue) {
|
|
67
|
+
const response = await this.fetcher.get((0, apiPaths_1.getTraitOffersPath)(collectionSlug), {
|
|
68
|
+
type,
|
|
69
|
+
value,
|
|
70
|
+
limit,
|
|
71
|
+
next,
|
|
72
|
+
float_value: floatValue,
|
|
73
|
+
int_value: intValue,
|
|
74
|
+
});
|
|
75
|
+
return response;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Gets the best offer for a given token.
|
|
79
|
+
*/
|
|
80
|
+
async getBestOffer(collectionSlug, tokenId) {
|
|
81
|
+
const response = await this.fetcher.get((0, apiPaths_1.getBestOfferAPIPath)(collectionSlug, tokenId));
|
|
82
|
+
return response;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Build a OpenSea collection offer.
|
|
86
|
+
*/
|
|
87
|
+
async buildOffer(offererAddress, quantity, collectionSlug, offerProtectionEnabled = true, traitType, traitValue, traits, numericTraits) {
|
|
88
|
+
validateTraitParams(traitType, traitValue, traits, numericTraits);
|
|
89
|
+
const payload = (0, utils_1.getBuildCollectionOfferPayload)(offererAddress, quantity, collectionSlug, offerProtectionEnabled, this.chain, traitType, traitValue, traits, numericTraits);
|
|
90
|
+
const response = await this.fetcher.post((0, apiPaths_1.getBuildOfferPath)(), payload);
|
|
91
|
+
return response;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get a list of collection offers for a given slug.
|
|
95
|
+
*/
|
|
96
|
+
async getCollectionOffers(slug, limit, next) {
|
|
97
|
+
return await this.fetcher.get((0, apiPaths_1.getCollectionOffersPath)(slug), {
|
|
98
|
+
limit,
|
|
99
|
+
next,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Post a collection offer to OpenSea.
|
|
104
|
+
*/
|
|
105
|
+
async postCollectionOffer(order, slug, traitType, traitValue, traits, numericTraits) {
|
|
106
|
+
validateTraitParams(traitType, traitValue, traits, numericTraits);
|
|
107
|
+
const payload = (0, utils_1.getPostCollectionOfferPayload)(slug, order, this.chain, traitType, traitValue, traits, numericTraits);
|
|
108
|
+
return await this.fetcher.post((0, apiPaths_1.getPostCollectionOfferPath)(), payload);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Gets all active offers for a specific NFT.
|
|
112
|
+
*/
|
|
113
|
+
async getNFTOffers(assetContractAddress, tokenId, limit, next, chain = this.chain) {
|
|
114
|
+
const response = await this.fetcher.get((0, apiPaths_1.getOrdersAPIPath)(chain, "seaport", types_1.OrderSide.OFFER), (0, utils_1.serializeOrdersQueryOptions)({
|
|
115
|
+
assetContractAddress,
|
|
116
|
+
tokenIds: [tokenId],
|
|
117
|
+
limit,
|
|
118
|
+
next,
|
|
119
|
+
}));
|
|
120
|
+
return response;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.OffersAPI = OffersAPI;
|
|
124
|
+
//# sourceMappingURL=offers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"offers.js","sourceRoot":"","sources":["../../src/api/offers.ts"],"names":[],"mappings":";;;AACA,2CAIwB;AACxB,oCAAgD;AAChD,yCAQmB;AASnB;;;GAGG;AACH,SAAS,mBAAmB,CAC1B,SAAkB,EAClB,UAAmB,EACnB,MAA+C,EAC/C,aAAmE;IAEnE,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,SAAS,IAAI,UAAU,CAAC,EAAE,CAAC;QAC7D,MAAM,IAAI,KAAK,CACb,kHAAkH,CACnH,CAAA;IACH,CAAC;IACD,IAAI,SAAS,IAAI,UAAU,EAAE,CAAC;QAC5B,IAAI,CAAC,SAAS,IAAI,CAAC,UAAU,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CACb,kEAAkE,CACnE,CAAA;QACH,CAAC;IACH,CAAC;IACD,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;gBAChC,MAAM,IAAI,KAAK,CACb,0DAA0D,CAC3D,CAAA;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,IAAI,aAAa,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9C,KAAK,MAAM,KAAK,IAAI,aAAa,EAAE,CAAC;YAClC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;gBAChB,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAA;YACp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CAA6B,EAC3C,IAAI,EACJ,KAAK,EACL,IAAI,CAAC,KAAK,EACV,SAAS,EACT,UAAU,EACV,MAAM,EACN,aAAa,CACd,CAAA;QACD,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAC5B,IAAA,qCAA0B,GAAE,EAC5B,OAAO,CACR,CAAA;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,YAAY,CAChB,oBAA4B,EAC5B,OAAe,EACf,KAAc,EACd,IAAa,EACb,QAAe,IAAI,CAAC,KAAK;QAEzB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CACrC,IAAA,2BAAgB,EAAC,KAAK,EAAE,SAAS,EAAE,iBAAS,CAAC,KAAK,CAAC,EACnD,IAAA,mCAA2B,EAAC;YAC1B,oBAAoB;YACpB,QAAQ,EAAE,CAAC,OAAO,CAAC;YACnB,KAAK;YACL,IAAI;SACL,CAAC,CACH,CAAA;QACD,OAAO,QAAQ,CAAA;IACjB,CAAC;CACF;AAhKD,8BAgKC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { FulfillmentDataResponse, OrderAPIOptions, OrdersQueryOptions, OrderV2, ProtocolData } from "../orders/types";
|
|
2
|
+
import { type Chain, OrderSide } from "../types";
|
|
3
|
+
import type { Fetcher } from "./fetcher";
|
|
4
|
+
import type { CancelOrderResponse, GetOrderByHashResponse, GetOrdersResponse, Listing, Offer } from "./types";
|
|
5
|
+
/**
|
|
6
|
+
* Order-related API operations
|
|
7
|
+
*/
|
|
8
|
+
export declare class OrdersAPI {
|
|
9
|
+
private fetcher;
|
|
10
|
+
private chain;
|
|
11
|
+
constructor(fetcher: Fetcher, chain: Chain);
|
|
12
|
+
/**
|
|
13
|
+
* Gets an order from API based on query options.
|
|
14
|
+
* @deprecated Use collection-based endpoints instead: getAllOffers, getAllListings, getBestOffer, getBestListing.
|
|
15
|
+
*/
|
|
16
|
+
getOrder({ side, protocol, orderDirection, orderBy, ...restOptions }: Omit<OrdersQueryOptions, "limit">): Promise<OrderV2>;
|
|
17
|
+
/**
|
|
18
|
+
* Gets a single order by its order hash.
|
|
19
|
+
* Returns the raw API response which can be either an Offer or Listing.
|
|
20
|
+
*/
|
|
21
|
+
getOrderByHash(orderHash: string, protocolAddress: string, chain?: Chain): Promise<GetOrderByHashResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* Gets a list of orders from API based on query options.
|
|
24
|
+
* @deprecated Use collection-based endpoints instead: getAllOffers, getAllListings, getBestOffer, getBestListing.
|
|
25
|
+
*/
|
|
26
|
+
getOrders({ side, protocol, orderDirection, orderBy, pageSize, ...restOptions }: Omit<OrdersQueryOptions, "limit"> & {
|
|
27
|
+
pageSize?: number;
|
|
28
|
+
}): Promise<GetOrdersResponse>;
|
|
29
|
+
/**
|
|
30
|
+
* Generate the data needed to fulfill a listing or an offer onchain.
|
|
31
|
+
*/
|
|
32
|
+
generateFulfillmentData(fulfillerAddress: string, orderHash: string, protocolAddress: string, side: OrderSide, assetContractAddress?: string, tokenId?: string, unitsToFill?: string, recipientAddress?: string, includeOptionalCreatorFees?: boolean): Promise<FulfillmentDataResponse>;
|
|
33
|
+
/**
|
|
34
|
+
* Post an order to OpenSea.
|
|
35
|
+
* @deprecated Use postListing or postOffer instead.
|
|
36
|
+
*/
|
|
37
|
+
postOrder(order: ProtocolData, apiOptions: OrderAPIOptions): Promise<OrderV2>;
|
|
38
|
+
/**
|
|
39
|
+
* Post a listing to OpenSea. Returns the new Listing response format.
|
|
40
|
+
*/
|
|
41
|
+
postListing(order: ProtocolData, protocolAddress: string): Promise<Listing>;
|
|
42
|
+
/**
|
|
43
|
+
* Post an offer to OpenSea. Returns the new Offer response format.
|
|
44
|
+
*/
|
|
45
|
+
postOffer(order: ProtocolData, protocolAddress: string): Promise<Offer>;
|
|
46
|
+
/**
|
|
47
|
+
* Offchain cancel an order, offer or listing, by its order hash when protected by the SignedZone.
|
|
48
|
+
*/
|
|
49
|
+
offchainCancelOrder(protocolAddress: string, orderHash: string, chain?: Chain, offererSignature?: string): Promise<CancelOrderResponse>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OrdersAPI = void 0;
|
|
4
|
+
const utils_1 = require("../orders/utils");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
const apiPaths_1 = require("./apiPaths");
|
|
7
|
+
/**
|
|
8
|
+
* Order-related API operations
|
|
9
|
+
*/
|
|
10
|
+
class OrdersAPI {
|
|
11
|
+
fetcher;
|
|
12
|
+
chain;
|
|
13
|
+
constructor(fetcher, chain) {
|
|
14
|
+
this.fetcher = fetcher;
|
|
15
|
+
this.chain = chain;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Gets an order from API based on query options.
|
|
19
|
+
* @deprecated Use collection-based endpoints instead: getAllOffers, getAllListings, getBestOffer, getBestListing.
|
|
20
|
+
*/
|
|
21
|
+
async getOrder({ side, protocol = "seaport", orderDirection = "desc", orderBy = "created_date", ...restOptions }) {
|
|
22
|
+
// Validate eth_price orderBy requires additional parameters
|
|
23
|
+
if (orderBy === "eth_price") {
|
|
24
|
+
const hasTokenId = (restOptions.tokenIds?.length ?? 0) > 0 ||
|
|
25
|
+
restOptions.tokenId !== undefined;
|
|
26
|
+
if (!restOptions.assetContractAddress || !hasTokenId) {
|
|
27
|
+
throw new Error('When using orderBy: "eth_price", you must provide both assetContractAddress and tokenIds (or tokenId) parameters');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const { orders } = await this.fetcher.get((0, apiPaths_1.getOrdersAPIPath)(this.chain, protocol, side), (0, utils_1.serializeOrdersQueryOptions)({
|
|
31
|
+
limit: 1,
|
|
32
|
+
orderBy,
|
|
33
|
+
orderDirection,
|
|
34
|
+
...restOptions,
|
|
35
|
+
}));
|
|
36
|
+
if (orders.length === 0) {
|
|
37
|
+
throw new Error("Not found: no matching order found");
|
|
38
|
+
}
|
|
39
|
+
return (0, utils_1.deserializeOrder)(orders[0]);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Gets a single order by its order hash.
|
|
43
|
+
* Returns the raw API response which can be either an Offer or Listing.
|
|
44
|
+
*/
|
|
45
|
+
async getOrderByHash(orderHash, protocolAddress, chain = this.chain) {
|
|
46
|
+
const response = await this.fetcher.get((0, apiPaths_1.getOrderByHashPath)(chain, protocolAddress, orderHash));
|
|
47
|
+
return response.order;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Gets a list of orders from API based on query options.
|
|
51
|
+
* @deprecated Use collection-based endpoints instead: getAllOffers, getAllListings, getBestOffer, getBestListing.
|
|
52
|
+
*/
|
|
53
|
+
async getOrders({ side, protocol = "seaport", orderDirection = "desc", orderBy = "created_date", pageSize = 20, ...restOptions }) {
|
|
54
|
+
// Validate eth_price orderBy requires additional parameters
|
|
55
|
+
if (orderBy === "eth_price") {
|
|
56
|
+
const hasTokenId = (restOptions.tokenIds?.length ?? 0) > 0 ||
|
|
57
|
+
restOptions.tokenId !== undefined;
|
|
58
|
+
if (!restOptions.assetContractAddress || !hasTokenId) {
|
|
59
|
+
throw new Error('When using orderBy: "eth_price", you must provide both assetContractAddress and tokenIds (or tokenId) parameters');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const response = await this.fetcher.get((0, apiPaths_1.getOrdersAPIPath)(this.chain, protocol, side), (0, utils_1.serializeOrdersQueryOptions)({
|
|
63
|
+
limit: pageSize,
|
|
64
|
+
orderBy,
|
|
65
|
+
orderDirection,
|
|
66
|
+
...restOptions,
|
|
67
|
+
}));
|
|
68
|
+
return {
|
|
69
|
+
...response,
|
|
70
|
+
orders: response.orders.map(utils_1.deserializeOrder),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Generate the data needed to fulfill a listing or an offer onchain.
|
|
75
|
+
*/
|
|
76
|
+
async generateFulfillmentData(fulfillerAddress, orderHash, protocolAddress, side, assetContractAddress, tokenId, unitsToFill, recipientAddress, includeOptionalCreatorFees = false) {
|
|
77
|
+
let payload = null;
|
|
78
|
+
if (side === types_1.OrderSide.LISTING) {
|
|
79
|
+
payload = (0, utils_1.getFulfillListingPayload)(fulfillerAddress, orderHash, protocolAddress, this.chain, assetContractAddress, tokenId, unitsToFill, recipientAddress, includeOptionalCreatorFees);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
payload = (0, utils_1.getFulfillOfferPayload)(fulfillerAddress, orderHash, protocolAddress, this.chain, assetContractAddress, tokenId, unitsToFill, includeOptionalCreatorFees);
|
|
83
|
+
}
|
|
84
|
+
const response = await this.fetcher.post((0, utils_1.getFulfillmentDataPath)(side), payload);
|
|
85
|
+
return response;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Post an order to OpenSea.
|
|
89
|
+
* @deprecated Use postListing or postOffer instead.
|
|
90
|
+
*/
|
|
91
|
+
async postOrder(order, apiOptions) {
|
|
92
|
+
const { protocol = "seaport", side, protocolAddress } = apiOptions;
|
|
93
|
+
// Validate required fields
|
|
94
|
+
if (!side) {
|
|
95
|
+
throw new Error("apiOptions.side is required");
|
|
96
|
+
}
|
|
97
|
+
if (!protocolAddress) {
|
|
98
|
+
throw new Error("apiOptions.protocolAddress is required");
|
|
99
|
+
}
|
|
100
|
+
if (!order) {
|
|
101
|
+
throw new Error("order data is required");
|
|
102
|
+
}
|
|
103
|
+
// Validate protocol value
|
|
104
|
+
if (protocol !== "seaport") {
|
|
105
|
+
throw new Error("Currently only 'seaport' protocol is supported");
|
|
106
|
+
}
|
|
107
|
+
// Validate side value
|
|
108
|
+
if (side !== "ask" && side !== "bid") {
|
|
109
|
+
throw new Error("side must be either 'ask' or 'bid'");
|
|
110
|
+
}
|
|
111
|
+
// Validate protocolAddress format
|
|
112
|
+
if (!/^0x[a-fA-F0-9]{40}$/.test(protocolAddress)) {
|
|
113
|
+
throw new Error("Invalid protocol address format");
|
|
114
|
+
}
|
|
115
|
+
const response = await this.fetcher.post((0, apiPaths_1.getOrdersAPIPath)(this.chain, protocol, side), { ...order, protocol_address: protocolAddress });
|
|
116
|
+
return (0, utils_1.deserializeOrder)(response.order);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Post a listing to OpenSea. Returns the new Listing response format.
|
|
120
|
+
*/
|
|
121
|
+
async postListing(order, protocolAddress) {
|
|
122
|
+
if (!order) {
|
|
123
|
+
throw new Error("order data is required");
|
|
124
|
+
}
|
|
125
|
+
if (!protocolAddress || !/^0x[a-fA-F0-9]{40}$/.test(protocolAddress)) {
|
|
126
|
+
throw new Error("Invalid protocol address format");
|
|
127
|
+
}
|
|
128
|
+
const response = await this.fetcher.post((0, apiPaths_1.getOrdersAPIPath)(this.chain, "seaport", types_1.OrderSide.LISTING), { ...order, protocol_address: protocolAddress });
|
|
129
|
+
return response.listing;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Post an offer to OpenSea. Returns the new Offer response format.
|
|
133
|
+
*/
|
|
134
|
+
async postOffer(order, protocolAddress) {
|
|
135
|
+
if (!order) {
|
|
136
|
+
throw new Error("order data is required");
|
|
137
|
+
}
|
|
138
|
+
if (!protocolAddress || !/^0x[a-fA-F0-9]{40}$/.test(protocolAddress)) {
|
|
139
|
+
throw new Error("Invalid protocol address format");
|
|
140
|
+
}
|
|
141
|
+
const response = await this.fetcher.post((0, apiPaths_1.getOrdersAPIPath)(this.chain, "seaport", types_1.OrderSide.OFFER), { ...order, protocol_address: protocolAddress });
|
|
142
|
+
return response.offer;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Offchain cancel an order, offer or listing, by its order hash when protected by the SignedZone.
|
|
146
|
+
*/
|
|
147
|
+
async offchainCancelOrder(protocolAddress, orderHash, chain = this.chain, offererSignature) {
|
|
148
|
+
const response = await this.fetcher.post((0, apiPaths_1.getCancelOrderPath)(chain, protocolAddress, orderHash), { offererSignature });
|
|
149
|
+
return response;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
exports.OrdersAPI = OrdersAPI;
|
|
153
|
+
//# sourceMappingURL=orders.js.map
|