@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
package/src/constants.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { FixedNumber } from "ethers"
|
|
2
|
+
|
|
3
|
+
// =============================================================================
|
|
4
|
+
// Math & Calculation Constants
|
|
5
|
+
// =============================================================================
|
|
6
|
+
|
|
7
|
+
export const FIXED_NUMBER_100 = FixedNumber.fromValue(100)
|
|
8
|
+
export const INVERSE_BASIS_POINT = 10_000n // 100 basis points per 1%
|
|
9
|
+
|
|
10
|
+
// =============================================================================
|
|
11
|
+
// API Configuration
|
|
12
|
+
// =============================================================================
|
|
13
|
+
|
|
14
|
+
export const API_BASE_MAINNET = "https://api.opensea.io"
|
|
15
|
+
|
|
16
|
+
// =============================================================================
|
|
17
|
+
// OpenSea Protocol Addresses
|
|
18
|
+
// =============================================================================
|
|
19
|
+
|
|
20
|
+
export const OPENSEA_FEE_RECIPIENT =
|
|
21
|
+
"0x0000a26b00c1f0df003000390027140000faa719"
|
|
22
|
+
|
|
23
|
+
export const OPENSEA_CONDUIT_KEY =
|
|
24
|
+
"0x0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f0000"
|
|
25
|
+
|
|
26
|
+
export const OPENSEA_CONDUIT_ADDRESS =
|
|
27
|
+
"0x1e0049783f008a0085193e00003d00cd54003c71"
|
|
28
|
+
|
|
29
|
+
export const OPENSEA_CONDUIT_KEY_2 =
|
|
30
|
+
"0x61159fefdfada89302ed55f8b9e89e2d67d8258712b3a3f89aa88525877f1d5e"
|
|
31
|
+
|
|
32
|
+
export const OPENSEA_CONDUIT_ADDRESS_2 =
|
|
33
|
+
"0x963f00d3ff000064ffcba824b800c0000000c300"
|
|
34
|
+
|
|
35
|
+
export const OPENSEA_SIGNED_ZONE_V2 =
|
|
36
|
+
"0x000056f7000000ece9003ca63978907a00ffd100"
|
|
37
|
+
|
|
38
|
+
// =============================================================================
|
|
39
|
+
// Alternate Protocol Constants (shared by Gunzilla, Somnia, etc.)
|
|
40
|
+
// =============================================================================
|
|
41
|
+
|
|
42
|
+
export const ALTERNATE_CONDUIT_ADDRESS =
|
|
43
|
+
"0x00000000001566479594a2e05532d81afa09bc52"
|
|
44
|
+
|
|
45
|
+
export const ALTERNATE_CONDUIT_KEY =
|
|
46
|
+
"0x86d26897267711ea4b173c8c124a0a73612001da35562f1ee3b26929b6575e89"
|
|
47
|
+
|
|
48
|
+
export const ALTERNATE_SEAPORT_V1_6_ADDRESS =
|
|
49
|
+
"0x00000000006687982678b03100B9bDC8be440814"
|
|
50
|
+
|
|
51
|
+
export const ALTERNATE_SIGNED_ZONE_V2_ADDRESS =
|
|
52
|
+
"0xdfe0000000005ce3008800300037e4c803ed08c7"
|
|
53
|
+
|
|
54
|
+
// =============================================================================
|
|
55
|
+
// Chain-Specific Fee Recipients
|
|
56
|
+
// =============================================================================
|
|
57
|
+
|
|
58
|
+
export const GUNZILLA_FEE_RECIPIENT =
|
|
59
|
+
"0xd9f68d28e451a83affdb7c71cc2c20552555b07f"
|
|
60
|
+
|
|
61
|
+
export const SOMNIA_FEE_RECIPIENT = "0xdfe1593dca6ad8a20eeb418643e48577c1626f7c"
|
|
62
|
+
|
|
63
|
+
export const ALTERNATE_FEE_RECIPIENT =
|
|
64
|
+
"0x07d3a100c3880830dd43fe5c938b5144721ce9d6"
|
|
65
|
+
|
|
66
|
+
// =============================================================================
|
|
67
|
+
// Token & Helper Addresses
|
|
68
|
+
// =============================================================================
|
|
69
|
+
|
|
70
|
+
export const WPOL_ADDRESS = "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270"
|
|
71
|
+
|
|
72
|
+
export const MULTICALL3_ADDRESS = "0xcA11bde05977b3631167028862bE2a173976CA11"
|
|
73
|
+
|
|
74
|
+
export const TRANSFER_HELPER_ADDRESS =
|
|
75
|
+
"0x0000000000c2d145a2526bd8c716263bfebe1a72"
|
|
76
|
+
|
|
77
|
+
// =============================================================================
|
|
78
|
+
// Shared Storefront Addresses
|
|
79
|
+
// =============================================================================
|
|
80
|
+
|
|
81
|
+
const SHARED_STOREFRONT_ADDRESS_MAINNET =
|
|
82
|
+
"0x495f947276749ce646f68ac8c248420045cb7b5e"
|
|
83
|
+
const SHARED_STOREFRONT_ADDRESS_POLYGON =
|
|
84
|
+
"0x2953399124f0cbb46d2cbacd8a89cf0599974963"
|
|
85
|
+
export const SHARED_STOREFRONT_ADDRESSES = new Set([
|
|
86
|
+
SHARED_STOREFRONT_ADDRESS_MAINNET,
|
|
87
|
+
SHARED_STOREFRONT_ADDRESS_POLYGON,
|
|
88
|
+
])
|
|
89
|
+
export const SHARED_STOREFRONT_LAZY_MINT_ADAPTER_CROSS_CHAIN_ADDRESS =
|
|
90
|
+
"0xa604060890923ff400e8c6f5290461a83aedacec"
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { OpenSeaSDK } from "./sdk"
|
|
2
|
+
|
|
3
|
+
export * from "./api/types"
|
|
4
|
+
export * from "./orders/types"
|
|
5
|
+
export * from "./types"
|
|
6
|
+
export * from "./utils"
|
|
7
|
+
/**
|
|
8
|
+
* @example
|
|
9
|
+
* // Example Setup
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { ethers } from 'ethers'
|
|
12
|
+
* import { OpenSeaSDK, Chain } from 'opensea-js'
|
|
13
|
+
* const provider = new ethers.JsonRpcProvider('https://mainnet.infura.io')
|
|
14
|
+
* const client = new OpenSeaSDK(provider, {
|
|
15
|
+
* chain: Chain.Mainnet
|
|
16
|
+
* })
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export {
|
|
20
|
+
// Main SDK export
|
|
21
|
+
OpenSeaSDK,
|
|
22
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { ItemType } from "@opensea/seaport-js/lib/constants"
|
|
2
|
+
import type {
|
|
3
|
+
ConsiderationInputItem,
|
|
4
|
+
CreateInputItem,
|
|
5
|
+
MatchOrdersFulfillment,
|
|
6
|
+
Order,
|
|
7
|
+
OrderWithCounter,
|
|
8
|
+
} from "@opensea/seaport-js/lib/types"
|
|
9
|
+
import { isCurrencyItem } from "@opensea/seaport-js/lib/utils/item"
|
|
10
|
+
import { generateRandomSalt } from "@opensea/seaport-js/lib/utils/order"
|
|
11
|
+
import { ZeroAddress } from "ethers"
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Compute the native currency (ETH) value required to fulfill a private listing.
|
|
15
|
+
* Sums all native currency consideration items not going to the taker.
|
|
16
|
+
* @param order The private listing order
|
|
17
|
+
* @param takerAddress The address of the private listing recipient
|
|
18
|
+
* @returns The total native currency value as a bigint
|
|
19
|
+
*/
|
|
20
|
+
export const computePrivateListingValue = (
|
|
21
|
+
order: OrderWithCounter,
|
|
22
|
+
takerAddress: string,
|
|
23
|
+
): bigint => {
|
|
24
|
+
return order.parameters.consideration
|
|
25
|
+
.filter(
|
|
26
|
+
item =>
|
|
27
|
+
item.recipient.toLowerCase() !== takerAddress.toLowerCase() &&
|
|
28
|
+
item.token.toLowerCase() === ZeroAddress.toLowerCase() &&
|
|
29
|
+
item.itemType === ItemType.NATIVE,
|
|
30
|
+
)
|
|
31
|
+
.reduce((sum, item) => sum + BigInt(item.startAmount), 0n)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const getPrivateListingConsiderations = (
|
|
35
|
+
offer: CreateInputItem[],
|
|
36
|
+
privateSaleRecipient: string,
|
|
37
|
+
): ConsiderationInputItem[] => {
|
|
38
|
+
return offer.map(item => {
|
|
39
|
+
return { ...item, recipient: privateSaleRecipient }
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const constructPrivateListingCounterOrder = (
|
|
44
|
+
order: OrderWithCounter,
|
|
45
|
+
privateSaleRecipient: string,
|
|
46
|
+
): Order => {
|
|
47
|
+
// Counter order offers up all the items in the private listing consideration
|
|
48
|
+
// besides the items that are going to the private listing recipient
|
|
49
|
+
const paymentItems = order.parameters.consideration.filter(
|
|
50
|
+
item => item.recipient.toLowerCase() !== privateSaleRecipient.toLowerCase(),
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
// Only validate payment items if there are any (zero-payment private listings are valid)
|
|
54
|
+
if (paymentItems.length > 0) {
|
|
55
|
+
if (!paymentItems.every(item => isCurrencyItem(item))) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
"The consideration for the private listing did not contain only currency items",
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
if (
|
|
61
|
+
!paymentItems.every(item => item.itemType === paymentItems[0].itemType)
|
|
62
|
+
) {
|
|
63
|
+
throw new Error("Not all currency items were the same for private order")
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const { aggregatedStartAmount, aggregatedEndAmount } = paymentItems.reduce(
|
|
68
|
+
({ aggregatedStartAmount, aggregatedEndAmount }, item) => ({
|
|
69
|
+
aggregatedStartAmount: aggregatedStartAmount + BigInt(item.startAmount),
|
|
70
|
+
aggregatedEndAmount: aggregatedEndAmount + BigInt(item.endAmount),
|
|
71
|
+
}),
|
|
72
|
+
{
|
|
73
|
+
aggregatedStartAmount: 0n,
|
|
74
|
+
aggregatedEndAmount: 0n,
|
|
75
|
+
},
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
const counterOrder: Order = {
|
|
79
|
+
parameters: {
|
|
80
|
+
...order.parameters,
|
|
81
|
+
offerer: privateSaleRecipient,
|
|
82
|
+
// Empty offer for zero-payment private listings, single aggregated item otherwise
|
|
83
|
+
offer:
|
|
84
|
+
paymentItems.length > 0
|
|
85
|
+
? [
|
|
86
|
+
{
|
|
87
|
+
itemType: paymentItems[0].itemType,
|
|
88
|
+
token: paymentItems[0].token,
|
|
89
|
+
identifierOrCriteria: paymentItems[0].identifierOrCriteria,
|
|
90
|
+
startAmount: aggregatedStartAmount.toString(),
|
|
91
|
+
endAmount: aggregatedEndAmount.toString(),
|
|
92
|
+
},
|
|
93
|
+
]
|
|
94
|
+
: [],
|
|
95
|
+
// The consideration here is empty as the original private listing order supplies
|
|
96
|
+
// the taker address to receive the desired items.
|
|
97
|
+
consideration: [],
|
|
98
|
+
salt: generateRandomSalt(),
|
|
99
|
+
totalOriginalConsiderationItems: 0,
|
|
100
|
+
},
|
|
101
|
+
signature: "0x",
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return counterOrder
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export const getPrivateListingFulfillments = (
|
|
108
|
+
privateListingOrder: OrderWithCounter,
|
|
109
|
+
): MatchOrdersFulfillment[] => {
|
|
110
|
+
const nftRelatedFulfillments: MatchOrdersFulfillment[] = []
|
|
111
|
+
|
|
112
|
+
// For the original order, we need to match everything offered with every consideration item
|
|
113
|
+
// on the original order that's set to go to the private listing recipient
|
|
114
|
+
privateListingOrder.parameters.offer.forEach((offerItem, offerIndex) => {
|
|
115
|
+
const considerationIndex =
|
|
116
|
+
privateListingOrder.parameters.consideration.findIndex(
|
|
117
|
+
considerationItem =>
|
|
118
|
+
considerationItem.itemType === offerItem.itemType &&
|
|
119
|
+
considerationItem.token === offerItem.token &&
|
|
120
|
+
considerationItem.identifierOrCriteria ===
|
|
121
|
+
offerItem.identifierOrCriteria,
|
|
122
|
+
)
|
|
123
|
+
if (considerationIndex === -1) {
|
|
124
|
+
throw new Error(
|
|
125
|
+
"Could not find matching offer item in the consideration for private listing",
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
nftRelatedFulfillments.push({
|
|
129
|
+
offerComponents: [
|
|
130
|
+
{
|
|
131
|
+
orderIndex: 0,
|
|
132
|
+
itemIndex: offerIndex,
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
considerationComponents: [
|
|
136
|
+
{
|
|
137
|
+
orderIndex: 0,
|
|
138
|
+
itemIndex: considerationIndex,
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
})
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
const currencyRelatedFulfillments: MatchOrdersFulfillment[] = []
|
|
145
|
+
|
|
146
|
+
// For the original order, we need to match everything offered with every consideration item
|
|
147
|
+
// on the original order that's set to go to the private listing recipient
|
|
148
|
+
privateListingOrder.parameters.consideration.forEach(
|
|
149
|
+
(considerationItem, considerationIndex) => {
|
|
150
|
+
if (!isCurrencyItem(considerationItem)) {
|
|
151
|
+
return
|
|
152
|
+
}
|
|
153
|
+
// We always match the offer item (index 0) of the counter order (index 1)
|
|
154
|
+
// with all of the payment items on the private listing
|
|
155
|
+
currencyRelatedFulfillments.push({
|
|
156
|
+
offerComponents: [
|
|
157
|
+
{
|
|
158
|
+
orderIndex: 1,
|
|
159
|
+
itemIndex: 0,
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
considerationComponents: [
|
|
163
|
+
{
|
|
164
|
+
orderIndex: 0,
|
|
165
|
+
itemIndex: considerationIndex,
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
})
|
|
169
|
+
},
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
return [...nftRelatedFulfillments, ...currencyRelatedFulfillments]
|
|
173
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import type { BasicOrderParametersStruct } from "@opensea/seaport-js/lib/typechain-types/seaport/contracts/Seaport"
|
|
2
|
+
import type {
|
|
3
|
+
AdvancedOrder,
|
|
4
|
+
OrderWithCounter,
|
|
5
|
+
} from "@opensea/seaport-js/lib/types"
|
|
6
|
+
import type { Listing, Offer } from "../api/types"
|
|
7
|
+
import type { OpenSeaAccount, OrderSide } from "../types"
|
|
8
|
+
|
|
9
|
+
// Protocol data
|
|
10
|
+
type OrderProtocolToProtocolData = {
|
|
11
|
+
seaport: OrderWithCounter
|
|
12
|
+
}
|
|
13
|
+
export type OrderProtocol = keyof OrderProtocolToProtocolData
|
|
14
|
+
export type ProtocolData =
|
|
15
|
+
OrderProtocolToProtocolData[keyof OrderProtocolToProtocolData]
|
|
16
|
+
|
|
17
|
+
export enum OrderType {
|
|
18
|
+
BASIC = "basic",
|
|
19
|
+
ENGLISH = "english",
|
|
20
|
+
CRITERIA = "criteria",
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type OrderFee = {
|
|
24
|
+
account: OpenSeaAccount
|
|
25
|
+
basisPoints: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The latest OpenSea Order schema.
|
|
30
|
+
*/
|
|
31
|
+
export type OrderV2 = {
|
|
32
|
+
/** The date the order was created. */
|
|
33
|
+
createdDate: string
|
|
34
|
+
/** The date the order was closed. */
|
|
35
|
+
closingDate: string | null
|
|
36
|
+
/** The date the order was listed. Order can be created before the listing time. */
|
|
37
|
+
listingTime: number
|
|
38
|
+
/** The date the order expires. */
|
|
39
|
+
expirationTime: number
|
|
40
|
+
/** The hash of the order. */
|
|
41
|
+
orderHash: string | null
|
|
42
|
+
/** The account that created the order. */
|
|
43
|
+
maker: OpenSeaAccount
|
|
44
|
+
/** The account that filled the order. */
|
|
45
|
+
taker: OpenSeaAccount | null
|
|
46
|
+
/** The protocol data for the order. Only 'seaport' is currently supported. */
|
|
47
|
+
protocolData: ProtocolData
|
|
48
|
+
/** The contract address of the protocol. */
|
|
49
|
+
protocolAddress: string
|
|
50
|
+
/** The current price of the order. */
|
|
51
|
+
currentPrice: bigint
|
|
52
|
+
/** The maker fees for the order. */
|
|
53
|
+
makerFees: OrderFee[]
|
|
54
|
+
/** The taker fees for the order. */
|
|
55
|
+
takerFees: OrderFee[]
|
|
56
|
+
/** The side of the order. Listing/Offer */
|
|
57
|
+
side: OrderSide
|
|
58
|
+
/** The type of the order. Basic/English/Criteria */
|
|
59
|
+
orderType: OrderType
|
|
60
|
+
/** Whether or not the maker has cancelled the order. */
|
|
61
|
+
cancelled: boolean
|
|
62
|
+
/** Whether or not the order is finalized. */
|
|
63
|
+
finalized: boolean
|
|
64
|
+
/** Whether or not the order is marked invalid and therefore not fillable. */
|
|
65
|
+
markedInvalid: boolean
|
|
66
|
+
/** The signature the order is signed with. */
|
|
67
|
+
clientSignature: string | null
|
|
68
|
+
/** Amount of items left in the order which can be taken. */
|
|
69
|
+
remainingQuantity: number
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export type FulfillmentDataResponse = {
|
|
73
|
+
protocol: string
|
|
74
|
+
fulfillment_data: FulfillmentData
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
type FulfillmentData = {
|
|
78
|
+
transaction: Transaction
|
|
79
|
+
orders: ProtocolData[]
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
type Transaction = {
|
|
83
|
+
function: string
|
|
84
|
+
chain: number
|
|
85
|
+
to: string
|
|
86
|
+
value: string
|
|
87
|
+
input_data:
|
|
88
|
+
| {
|
|
89
|
+
// For fulfillAdvancedOrder
|
|
90
|
+
advancedOrder: AdvancedOrder
|
|
91
|
+
criteriaResolvers?: unknown[]
|
|
92
|
+
fulfillerConduitKey?: string
|
|
93
|
+
recipient: string
|
|
94
|
+
}
|
|
95
|
+
| {
|
|
96
|
+
// For fulfillBasicOrder
|
|
97
|
+
basicOrderParameters: BasicOrderParametersStruct
|
|
98
|
+
}
|
|
99
|
+
| {
|
|
100
|
+
// For fulfillOrder
|
|
101
|
+
order: OrderWithCounter
|
|
102
|
+
fulfillerConduitKey?: string
|
|
103
|
+
recipient: string
|
|
104
|
+
}
|
|
105
|
+
| {
|
|
106
|
+
// Legacy: for backward compatibility
|
|
107
|
+
orders:
|
|
108
|
+
| OrderWithCounter[]
|
|
109
|
+
| AdvancedOrder[]
|
|
110
|
+
| BasicOrderParametersStruct[]
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// API query types
|
|
115
|
+
type OpenOrderOrderingOption = "created_date" | "eth_price"
|
|
116
|
+
type OrderByDirection = "asc" | "desc"
|
|
117
|
+
|
|
118
|
+
export type OrderAPIOptions = {
|
|
119
|
+
protocol?: OrderProtocol
|
|
120
|
+
protocolAddress?: string
|
|
121
|
+
side: OrderSide
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export type OrdersQueryOptions = OrderAPIOptions & {
|
|
125
|
+
limit?: number
|
|
126
|
+
cursor?: string
|
|
127
|
+
next?: string
|
|
128
|
+
|
|
129
|
+
paymentTokenAddress?: string
|
|
130
|
+
maker?: string
|
|
131
|
+
taker?: string
|
|
132
|
+
owner?: string
|
|
133
|
+
listedAfter?: number | string
|
|
134
|
+
listedBefore?: number | string
|
|
135
|
+
tokenId?: string
|
|
136
|
+
tokenIds?: string[]
|
|
137
|
+
assetContractAddress?: string
|
|
138
|
+
orderBy?: OpenOrderOrderingOption
|
|
139
|
+
orderDirection?: OrderByDirection
|
|
140
|
+
onlyEnglish?: boolean
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export type SerializedOrderV2 = {
|
|
144
|
+
created_date: string
|
|
145
|
+
closing_date: string | null
|
|
146
|
+
listing_time: number
|
|
147
|
+
expiration_time: number
|
|
148
|
+
order_hash: string | null
|
|
149
|
+
maker: unknown
|
|
150
|
+
taker: unknown | null
|
|
151
|
+
protocol_data: ProtocolData
|
|
152
|
+
protocol_address: string
|
|
153
|
+
current_price: string
|
|
154
|
+
maker_fees: {
|
|
155
|
+
account: unknown
|
|
156
|
+
basis_points: string
|
|
157
|
+
}[]
|
|
158
|
+
taker_fees: {
|
|
159
|
+
account: unknown
|
|
160
|
+
basis_points: string
|
|
161
|
+
}[]
|
|
162
|
+
side: OrderSide
|
|
163
|
+
order_type: OrderType
|
|
164
|
+
cancelled: boolean
|
|
165
|
+
finalized: boolean
|
|
166
|
+
marked_invalid: boolean
|
|
167
|
+
client_signature: string | null
|
|
168
|
+
remaining_quantity: number
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export type QueryCursors = {
|
|
172
|
+
next: string | null
|
|
173
|
+
previous: string | null
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export type OrdersQueryResponse = QueryCursors & {
|
|
177
|
+
orders: SerializedOrderV2[]
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** @deprecated Use ListingPostQueryResponse or OfferPostQueryResponse instead. */
|
|
181
|
+
export type OrdersPostQueryResponse = { order: SerializedOrderV2 }
|
|
182
|
+
|
|
183
|
+
export type ListingPostQueryResponse = {
|
|
184
|
+
order: SerializedOrderV2
|
|
185
|
+
listing: Listing
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export type OfferPostQueryResponse = {
|
|
189
|
+
order: SerializedOrderV2
|
|
190
|
+
offer: Offer
|
|
191
|
+
}
|