opensea-js 7.3.2 → 7.4.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.
Files changed (128) hide show
  1. package/README.md +15 -0
  2. package/lib/api/accounts.d.ts +17 -0
  3. package/lib/api/accounts.js +30 -0
  4. package/lib/api/accounts.js.map +1 -0
  5. package/lib/api/api.d.ts +58 -38
  6. package/lib/api/api.js +103 -180
  7. package/lib/api/api.js.map +1 -1
  8. package/lib/api/apiPaths.d.ts +5 -0
  9. package/lib/api/apiPaths.js +21 -1
  10. package/lib/api/apiPaths.js.map +1 -1
  11. package/lib/api/collections.d.ts +21 -0
  12. package/lib/api/collections.js +49 -0
  13. package/lib/api/collections.js.map +1 -0
  14. package/lib/api/events.d.ts +25 -0
  15. package/lib/api/events.js +42 -0
  16. package/lib/api/events.js.map +1 -0
  17. package/lib/api/listings.d.ts +20 -0
  18. package/lib/api/listings.js +41 -0
  19. package/lib/api/listings.js.map +1 -0
  20. package/lib/api/nfts.d.ts +31 -0
  21. package/lib/api/nfts.js +60 -0
  22. package/lib/api/nfts.js.map +1 -0
  23. package/lib/api/offers.d.ts +34 -0
  24. package/lib/api/offers.js +73 -0
  25. package/lib/api/offers.js.map +1 -0
  26. package/lib/api/orders.d.ts +38 -0
  27. package/lib/api/orders.js +122 -0
  28. package/lib/api/orders.js.map +1 -0
  29. package/lib/api/types.d.ts +174 -1
  30. package/lib/api/types.js +24 -1
  31. package/lib/api/types.js.map +1 -1
  32. package/lib/constants.d.ts +2 -0
  33. package/lib/constants.js +3 -3
  34. package/lib/constants.js.map +1 -1
  35. package/lib/orders/utils.d.ts +10 -2
  36. package/lib/orders/utils.js +20 -4
  37. package/lib/orders/utils.js.map +1 -1
  38. package/lib/sdk/assets.d.ts +104 -0
  39. package/lib/sdk/assets.js +398 -0
  40. package/lib/sdk/assets.js.map +1 -0
  41. package/lib/sdk/cancellation.d.ts +97 -0
  42. package/lib/sdk/cancellation.js +219 -0
  43. package/lib/sdk/cancellation.js.map +1 -0
  44. package/lib/sdk/context.d.ts +28 -0
  45. package/lib/sdk/context.js +3 -0
  46. package/lib/sdk/context.js.map +1 -0
  47. package/lib/sdk/fulfillment.d.ts +131 -0
  48. package/lib/sdk/fulfillment.js +258 -0
  49. package/lib/sdk/fulfillment.js.map +1 -0
  50. package/lib/sdk/orders.d.ts +171 -0
  51. package/lib/sdk/orders.js +338 -0
  52. package/lib/sdk/orders.js.map +1 -0
  53. package/lib/sdk/tokens.d.ts +31 -0
  54. package/lib/sdk/tokens.js +64 -0
  55. package/lib/sdk/tokens.js.map +1 -0
  56. package/lib/sdk.d.ts +111 -72
  57. package/lib/sdk.js +188 -548
  58. package/lib/sdk.js.map +1 -1
  59. package/lib/typechain/contracts/Multicall3.d.ts +57 -0
  60. package/lib/typechain/contracts/Multicall3.js +3 -0
  61. package/lib/typechain/contracts/Multicall3.js.map +1 -0
  62. package/lib/typechain/contracts/TransferHelper.d.ts +55 -0
  63. package/lib/typechain/contracts/TransferHelper.js +3 -0
  64. package/lib/typechain/contracts/TransferHelper.js.map +1 -0
  65. package/lib/typechain/contracts/factories/Multicall3__factory.d.ts +43 -0
  66. package/lib/typechain/contracts/factories/Multicall3__factory.js +68 -0
  67. package/lib/typechain/contracts/factories/Multicall3__factory.js.map +1 -0
  68. package/lib/typechain/contracts/factories/TransferHelper__factory.d.ts +46 -0
  69. package/lib/typechain/contracts/factories/TransferHelper__factory.js +71 -0
  70. package/lib/typechain/contracts/factories/TransferHelper__factory.js.map +1 -0
  71. package/lib/typechain/contracts/factories/index.d.ts +2 -0
  72. package/lib/typechain/contracts/factories/index.js +5 -1
  73. package/lib/typechain/contracts/factories/index.js.map +1 -1
  74. package/lib/typechain/contracts/index.d.ts +4 -0
  75. package/lib/typechain/contracts/index.js +5 -1
  76. package/lib/typechain/contracts/index.js.map +1 -1
  77. package/lib/types.d.ts +13 -1
  78. package/lib/types.js +4 -0
  79. package/lib/types.js.map +1 -1
  80. package/lib/utils/chain.d.ts +53 -0
  81. package/lib/utils/chain.js +232 -0
  82. package/lib/utils/chain.js.map +1 -0
  83. package/lib/utils/converters.d.ts +31 -0
  84. package/lib/utils/converters.js +118 -0
  85. package/lib/utils/converters.js.map +1 -0
  86. package/lib/utils/fees.d.ts +13 -0
  87. package/lib/utils/fees.js +29 -0
  88. package/lib/utils/fees.js.map +1 -0
  89. package/lib/utils/protocol.d.ts +70 -0
  90. package/lib/utils/protocol.js +181 -0
  91. package/lib/utils/protocol.js.map +1 -0
  92. package/lib/utils/utils.d.ts +4 -97
  93. package/lib/utils/utils.js +22 -416
  94. package/lib/utils/utils.js.map +1 -1
  95. package/package.json +1 -1
  96. package/src/abi/Multicall3.json +50 -0
  97. package/src/abi/TransferHelper.json +53 -0
  98. package/src/api/accounts.ts +34 -0
  99. package/src/api/api.ts +179 -308
  100. package/src/api/apiPaths.ts +28 -0
  101. package/src/api/collections.ts +67 -0
  102. package/src/api/events.ts +72 -0
  103. package/src/api/listings.ts +64 -0
  104. package/src/api/nfts.ts +111 -0
  105. package/src/api/offers.ts +156 -0
  106. package/src/api/orders.ts +227 -0
  107. package/src/api/types.ts +185 -1
  108. package/src/constants.ts +5 -2
  109. package/src/orders/utils.ts +52 -2
  110. package/src/sdk/assets.ts +595 -0
  111. package/src/sdk/cancellation.ts +329 -0
  112. package/src/sdk/context.ts +33 -0
  113. package/src/sdk/fulfillment.ts +438 -0
  114. package/src/sdk/orders.ts +669 -0
  115. package/src/sdk/tokens.ts +95 -0
  116. package/src/sdk.ts +238 -964
  117. package/src/typechain/contracts/Multicall3.ts +117 -0
  118. package/src/typechain/contracts/TransferHelper.ts +122 -0
  119. package/src/typechain/contracts/factories/Multicall3__factory.ts +67 -0
  120. package/src/typechain/contracts/factories/TransferHelper__factory.ts +76 -0
  121. package/src/typechain/contracts/factories/index.ts +2 -0
  122. package/src/typechain/contracts/index.ts +4 -0
  123. package/src/types.ts +12 -0
  124. package/src/utils/chain.ts +243 -0
  125. package/src/utils/converters.ts +124 -0
  126. package/src/utils/fees.ts +31 -0
  127. package/src/utils/protocol.ts +206 -0
  128. package/src/utils/utils.ts +7 -456
package/README.md CHANGED
@@ -29,6 +29,21 @@ Happy seafaring! ⛵️
29
29
  - [Frequently Asked Questions](developerDocs/faq.md)
30
30
  - [Contributing](developerDocs/contributing.md)
31
31
 
32
+ ### Security Warning
33
+
34
+ **⚠️ Do not use this SDK directly in client-side/frontend applications.**
35
+
36
+ The OpenSea SDK requires an API key for initialization. If you embed your API key in frontend code (e.g., browser applications, mobile apps), it will be publicly exposed and could be extracted by anyone, leading to potential abuse and rate limit issues.
37
+
38
+ #### Recommended Architecture
39
+
40
+ For frontend applications that need to interact with OpenSea functionality:
41
+
42
+ 1. **Create a backend API wrapper**: Set up your own backend server that securely stores your OpenSea API key
43
+ 2. **Call OpenSea SDK server-side**: Use opensea-js on your backend to interact with OpenSea's APIs
44
+ 3. **Return data to your frontend**: Send the necessary data (like transaction parameters) back to your frontend
45
+ 4. **Execute transactions in the browser**: Have users sign transactions with their own wallets (e.g., MetaMask) in the browser
46
+
32
47
  ## Changelog
33
48
 
34
49
  The changelog for recent versions can be found at:
@@ -0,0 +1,17 @@
1
+ import { Chain, OpenSeaAccount, OpenSeaPaymentToken } from "../types";
2
+ /**
3
+ * Account and payment token related API operations
4
+ */
5
+ export declare class AccountsAPI {
6
+ private get;
7
+ private chain;
8
+ constructor(get: <T>(apiPath: string, query?: object) => Promise<T>, chain: Chain);
9
+ /**
10
+ * Fetch a payment token.
11
+ */
12
+ getPaymentToken(address: string, chain?: Chain): Promise<OpenSeaPaymentToken>;
13
+ /**
14
+ * Fetch account for an address.
15
+ */
16
+ getAccount(address: string): Promise<OpenSeaAccount>;
17
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccountsAPI = void 0;
4
+ const apiPaths_1 = require("./apiPaths");
5
+ const converters_1 = require("../utils/converters");
6
+ /**
7
+ * Account and payment token related API operations
8
+ */
9
+ class AccountsAPI {
10
+ constructor(get, chain) {
11
+ this.get = get;
12
+ this.chain = chain;
13
+ }
14
+ /**
15
+ * Fetch a payment token.
16
+ */
17
+ async getPaymentToken(address, chain = this.chain) {
18
+ const json = await this.get((0, apiPaths_1.getPaymentTokenPath)(chain, address));
19
+ return (0, converters_1.paymentTokenFromJSON)(json);
20
+ }
21
+ /**
22
+ * Fetch account for an address.
23
+ */
24
+ async getAccount(address) {
25
+ const json = await this.get((0, apiPaths_1.getAccountPath)(address));
26
+ return (0, converters_1.accountFromJSON)(json);
27
+ }
28
+ }
29
+ exports.AccountsAPI = AccountsAPI;
30
+ //# sourceMappingURL=accounts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../src/api/accounts.ts"],"names":[],"mappings":";;;AAAA,yCAAiE;AAEjE,oDAA4E;AAE5E;;GAEG;AACH,MAAa,WAAW;IACtB,YACU,GAAuD,EACvD,KAAY;QADZ,QAAG,GAAH,GAAG,CAAoD;QACvD,UAAK,GAAL,KAAK,CAAO;IACnB,CAAC;IAEJ;;OAEG;IACH,KAAK,CAAC,eAAe,CACnB,OAAe,EACf,KAAK,GAAG,IAAI,CAAC,KAAK;QAElB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,CACzB,IAAA,8BAAmB,EAAC,KAAK,EAAE,OAAO,CAAC,CACpC,CAAC;QACF,OAAO,IAAA,iCAAoB,EAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CAAC,OAAe;QAC9B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,CAAiB,IAAA,yBAAc,EAAC,OAAO,CAAC,CAAC,CAAC;QACrE,OAAO,IAAA,4BAAe,EAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF;AA1BD,kCA0BC"}
package/lib/api/api.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { BuildOfferResponse, GetCollectionsResponse, ListNFTsResponse, GetNFTResponse, ListCollectionOffersResponse, GetOrdersResponse, GetBestOfferResponse, GetBestListingResponse, GetOffersResponse, GetListingsResponse, CollectionOffer, CollectionOrderByOption, CancelOrderResponse } from "./types";
2
1
  import { FulfillmentDataResponse, OrderAPIOptions, OrdersQueryOptions, OrderV2, ProtocolData } from "../orders/types";
3
2
  import { Chain, OpenSeaAPIConfig, OpenSeaAccount, OpenSeaCollection, OpenSeaCollectionStats, OpenSeaPaymentToken, OrderSide } from "../types";
3
+ import { BuildOfferResponse, GetCollectionsResponse, ListNFTsResponse, GetNFTResponse, ListCollectionOffersResponse, GetOrdersResponse, GetBestOfferResponse, GetBestListingResponse, GetOffersResponse, GetListingsResponse, CollectionOffer, CollectionOrderByOption, CancelOrderResponse, GetEventsArgs, GetEventsResponse } from "./types";
4
4
  /**
5
5
  * The API class for the OpenSea SDK.
6
6
  * @category Main Classes
@@ -20,6 +20,13 @@ export declare class OpenSeaAPI {
20
20
  logger: (arg: string) => void;
21
21
  private apiKey;
22
22
  private chain;
23
+ private ordersAPI;
24
+ private offersAPI;
25
+ private listingsAPI;
26
+ private collectionsAPI;
27
+ private nftsAPI;
28
+ private accountsAPI;
29
+ private eventsAPI;
23
30
  /**
24
31
  * Create an instance of the OpenSeaAPI
25
32
  * @param config OpenSeaAPIConfig for setting up the API, including an optional API key, Chain name, and base URL
@@ -28,40 +35,27 @@ export declare class OpenSeaAPI {
28
35
  constructor(config: OpenSeaAPIConfig, logger?: (arg: string) => void);
29
36
  /**
30
37
  * Gets an order from API based on query options.
31
- * @param options
32
- * @param options.side The side of the order (listing or offer)
33
- * @param options.protocol The protocol, typically seaport, to query orders for
34
- * @param options.orderDirection The direction to sort the orders
35
- * @param options.orderBy The field to sort the orders by
36
- * @param options.limit The number of orders to retrieve
37
- * @param options.maker Filter by the wallet address of the order maker
38
- * @param options.taker Filter by wallet address of the order taker
39
- * @param options.asset_contract_address Address of the NFT's contract
40
- * @param options.token_ids String array of token IDs to filter by.
41
- * @param options.listed_after Filter by orders listed after the Unix epoch timestamp in seconds
42
- * @param options.listed_before Filter by orders listed before the Unix epoch timestamp in seconds
38
+ * @param options Query options for fetching an order
43
39
  * @returns The first {@link OrderV2} returned by the API
44
40
  *
45
41
  * @throws An error if there are no matching orders.
46
42
  */
47
- getOrder({ side, protocol, orderDirection, orderBy, ...restOptions }: Omit<OrdersQueryOptions, "limit">): Promise<OrderV2>;
43
+ getOrder(options: Omit<OrdersQueryOptions, "limit">): Promise<OrderV2>;
44
+ /**
45
+ * Gets a single order by its order hash.
46
+ * @param orderHash The hash of the order to fetch
47
+ * @param protocolAddress The address of the seaport contract
48
+ * @param chain The chain where the order is located. Defaults to the chain set in the constructor.
49
+ * @returns The {@link OrderV2} returned by the API
50
+ * @throws An error if the order is not found
51
+ */
52
+ getOrderByHash(orderHash: string, protocolAddress: string, chain?: Chain): Promise<OrderV2>;
48
53
  /**
49
54
  * Gets a list of orders from API based on query options.
50
- * @param options
51
- * @param options.side The side of the order (buy or sell)
52
- * @param options.protocol The protocol, typically seaport, to query orders for
53
- * @param options.orderDirection The direction to sort the orders
54
- * @param options.orderBy The field to sort the orders by
55
- * @param options.limit The number of orders to retrieve
56
- * @param options.maker Filter by the wallet address of the order maker
57
- * @param options.taker Filter by wallet address of the order taker
58
- * @param options.asset_contract_address Address of the NFT's contract
59
- * @param options.token_ids String array of token IDs to filter by.
60
- * @param options.listed_after Filter by orders listed after the Unix epoch timestamp in seconds
61
- * @param options.listed_before Filter by orders listed before the Unix epoch timestamp in seconds
55
+ * @param options Query options for fetching orders
62
56
  * @returns The {@link GetOrdersResponse} returned by the API.
63
57
  */
64
- getOrders({ side, protocol, orderDirection, orderBy, ...restOptions }: Omit<OrdersQueryOptions, "limit">): Promise<GetOrdersResponse>;
58
+ getOrders(options: Omit<OrdersQueryOptions, "limit">): Promise<GetOrdersResponse>;
65
59
  /**
66
60
  * Gets all offers for a given collection.
67
61
  * @param collectionSlug The slug of the collection.
@@ -118,17 +112,15 @@ export declare class OpenSeaAPI {
118
112
  * @param orderHash The hash of the order to fulfill
119
113
  * @param protocolAddress The address of the seaport contract
120
114
  * @side The side of the order (buy or sell)
115
+ * @param assetContractAddress Optional address of the NFT contract for criteria offers (e.g., collection offers)
116
+ * @param tokenId Optional token ID for criteria offers (e.g., collection offers)
121
117
  * @returns The {@link FulfillmentDataResponse}
122
118
  */
123
- generateFulfillmentData(fulfillerAddress: string, orderHash: string, protocolAddress: string, side: OrderSide): Promise<FulfillmentDataResponse>;
119
+ generateFulfillmentData(fulfillerAddress: string, orderHash: string, protocolAddress: string, side: OrderSide, assetContractAddress?: string, tokenId?: string): Promise<FulfillmentDataResponse>;
124
120
  /**
125
121
  * Post an order to OpenSea.
126
122
  * @param order The order to post
127
- * @param apiOptions
128
- * @param apiOptions.protocol The protocol, typically seaport, to post the order to.
129
- * @param apiOptions.side The side of the order (buy or sell).
130
- * @param apiOptions.protocolAddress The address of the seaport contract.
131
- * @param options
123
+ * @param apiOptions API options for the order
132
124
  * @returns The {@link OrderV2} posted to the API.
133
125
  */
134
126
  postOrder(order: ProtocolData, apiOptions: OrderAPIOptions): Promise<OrderV2>;
@@ -217,16 +209,15 @@ export declare class OpenSeaAPI {
217
209
  getCollectionStats(slug: string): Promise<OpenSeaCollectionStats>;
218
210
  /**
219
211
  * Fetch a payment token.
220
- * @param query Query to use for getting tokens. See {@link OpenSeaPaymentTokenQuery}.
221
- * @param next The cursor for the next page of results. This is returned from a previous request.
212
+ * @param address The address of the payment token
213
+ * @param chain The chain of the payment token
222
214
  * @returns The {@link OpenSeaPaymentToken} returned by the API.
223
215
  */
224
216
  getPaymentToken(address: string, chain?: Chain): Promise<OpenSeaPaymentToken>;
225
217
  /**
226
218
  * Fetch account for an address.
227
- * @param query Query to use for getting tokens. See {@link OpenSeaPaymentTokenQuery}.
228
- * @param next The cursor for the next page of results. This is returned from a previous request.
229
- * @returns The {@link GetAccountResponse} returned by the API.
219
+ * @param address The address to fetch the account for
220
+ * @returns The {@link OpenSeaAccount} returned by the API.
230
221
  */
231
222
  getAccount(address: string): Promise<OpenSeaAccount>;
232
223
  /**
@@ -252,6 +243,35 @@ export declare class OpenSeaAPI {
252
243
  * @returns The response from the API.
253
244
  */
254
245
  offchainCancelOrder(protocolAddress: string, orderHash: string, chain?: Chain, offererSignature?: string): Promise<CancelOrderResponse>;
246
+ /**
247
+ * Gets a list of events based on query parameters.
248
+ * @param args Query parameters for filtering events.
249
+ * @returns The {@link GetEventsResponse} returned by the API.
250
+ */
251
+ getEvents(args?: GetEventsArgs): Promise<GetEventsResponse>;
252
+ /**
253
+ * Gets a list of events for a specific account.
254
+ * @param address The account address.
255
+ * @param args Query parameters for filtering events.
256
+ * @returns The {@link GetEventsResponse} returned by the API.
257
+ */
258
+ getEventsByAccount(address: string, args?: GetEventsArgs): Promise<GetEventsResponse>;
259
+ /**
260
+ * Gets a list of events for a specific collection.
261
+ * @param collectionSlug The slug (identifier) of the collection.
262
+ * @param args Query parameters for filtering events.
263
+ * @returns The {@link GetEventsResponse} returned by the API.
264
+ */
265
+ getEventsByCollection(collectionSlug: string, args?: GetEventsArgs): Promise<GetEventsResponse>;
266
+ /**
267
+ * Gets a list of events for a specific NFT.
268
+ * @param chain The chain where the NFT is located.
269
+ * @param address The contract address of the NFT.
270
+ * @param identifier The token identifier.
271
+ * @param args Query parameters for filtering events.
272
+ * @returns The {@link GetEventsResponse} returned by the API.
273
+ */
274
+ getEventsByNFT(chain: Chain, address: string, identifier: string, args?: GetEventsArgs): Promise<GetEventsResponse>;
255
275
  /**
256
276
  * Generic fetch method for any API endpoint
257
277
  * @param apiPath Path to URL endpoint under API