@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.
Files changed (363) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +70 -0
  3. package/lib/api/accounts.d.ts +27 -0
  4. package/lib/api/accounts.js +46 -0
  5. package/lib/api/accounts.js.map +1 -0
  6. package/lib/api/api.d.ts +489 -0
  7. package/lib/api/api.js +754 -0
  8. package/lib/api/api.js.map +1 -0
  9. package/lib/api/apiPaths.d.ts +46 -0
  10. package/lib/api/apiPaths.js +176 -0
  11. package/lib/api/apiPaths.js.map +1 -0
  12. package/lib/api/chains.d.ts +13 -0
  13. package/lib/api/chains.js +22 -0
  14. package/lib/api/chains.js.map +1 -0
  15. package/lib/api/collections.d.ts +34 -0
  16. package/lib/api/collections.js +80 -0
  17. package/lib/api/collections.js.map +1 -0
  18. package/lib/api/drops.d.ts +21 -0
  19. package/lib/api/drops.js +39 -0
  20. package/lib/api/drops.js.map +1 -0
  21. package/lib/api/events.d.ts +26 -0
  22. package/lib/api/events.js +43 -0
  23. package/lib/api/events.js.map +1 -0
  24. package/lib/api/fetcher.d.ts +24 -0
  25. package/lib/api/fetcher.js +3 -0
  26. package/lib/api/fetcher.js.map +1 -0
  27. package/lib/api/index.d.ts +2 -0
  28. package/lib/api/index.js +19 -0
  29. package/lib/api/index.js.map +1 -0
  30. package/lib/api/listings.d.ts +44 -0
  31. package/lib/api/listings.js +88 -0
  32. package/lib/api/listings.js.map +1 -0
  33. package/lib/api/nfts.d.ts +39 -0
  34. package/lib/api/nfts.js +79 -0
  35. package/lib/api/nfts.js.map +1 -0
  36. package/lib/api/offers.d.ts +54 -0
  37. package/lib/api/offers.js +124 -0
  38. package/lib/api/offers.js.map +1 -0
  39. package/lib/api/orders.d.ts +50 -0
  40. package/lib/api/orders.js +153 -0
  41. package/lib/api/orders.js.map +1 -0
  42. package/lib/api/search.d.ts +13 -0
  43. package/lib/api/search.js +22 -0
  44. package/lib/api/search.js.map +1 -0
  45. package/lib/api/tokens.d.ts +25 -0
  46. package/lib/api/tokens.js +43 -0
  47. package/lib/api/tokens.js.map +1 -0
  48. package/lib/api/types.d.ts +1113 -0
  49. package/lib/api/types.js +65 -0
  50. package/lib/api/types.js.map +1 -0
  51. package/lib/constants.d.ts +22 -0
  52. package/lib/constants.js +52 -0
  53. package/lib/constants.js.map +1 -0
  54. package/lib/index.d.ts +18 -0
  55. package/lib/index.js +24 -0
  56. package/lib/index.js.map +1 -0
  57. package/lib/orders/privateListings.d.ts +12 -0
  58. package/lib/orders/privateListings.js +130 -0
  59. package/lib/orders/privateListings.js.map +1 -0
  60. package/lib/orders/types.d.ts +160 -0
  61. package/lib/orders/types.js +10 -0
  62. package/lib/orders/types.js.map +1 -0
  63. package/lib/orders/utils.d.ts +89 -0
  64. package/lib/orders/utils.js +177 -0
  65. package/lib/orders/utils.js.map +1 -0
  66. package/lib/sdk/assets.d.ts +104 -0
  67. package/lib/sdk/assets.js +398 -0
  68. package/lib/sdk/assets.js.map +1 -0
  69. package/lib/sdk/cancellation.d.ts +97 -0
  70. package/lib/sdk/cancellation.js +235 -0
  71. package/lib/sdk/cancellation.js.map +1 -0
  72. package/lib/sdk/context.d.ts +28 -0
  73. package/lib/sdk/context.js +3 -0
  74. package/lib/sdk/context.js.map +1 -0
  75. package/lib/sdk/fulfillment.d.ts +153 -0
  76. package/lib/sdk/fulfillment.js +298 -0
  77. package/lib/sdk/fulfillment.js.map +1 -0
  78. package/lib/sdk/orders.d.ts +253 -0
  79. package/lib/sdk/orders.js +679 -0
  80. package/lib/sdk/orders.js.map +1 -0
  81. package/lib/sdk/tokens.d.ts +31 -0
  82. package/lib/sdk/tokens.js +65 -0
  83. package/lib/sdk/tokens.js.map +1 -0
  84. package/lib/sdk.d.ts +560 -0
  85. package/lib/sdk.js +693 -0
  86. package/lib/sdk.js.map +1 -0
  87. package/lib/src/api/accounts.d.ts +18 -0
  88. package/lib/src/api/accounts.js +30 -0
  89. package/lib/src/api/accounts.js.map +1 -0
  90. package/lib/src/api/api.d.ts +429 -0
  91. package/lib/src/api/api.js +652 -0
  92. package/lib/src/api/api.js.map +1 -0
  93. package/lib/src/api/apiPaths.d.ts +37 -0
  94. package/lib/src/api/apiPaths.js +140 -0
  95. package/lib/src/api/apiPaths.js.map +1 -0
  96. package/lib/src/api/collections.d.ts +26 -0
  97. package/lib/src/api/collections.js +57 -0
  98. package/lib/src/api/collections.js.map +1 -0
  99. package/lib/src/api/events.d.ts +26 -0
  100. package/lib/src/api/events.js +42 -0
  101. package/lib/src/api/events.js.map +1 -0
  102. package/lib/src/api/fetcher.d.ts +24 -0
  103. package/lib/src/api/fetcher.js +3 -0
  104. package/lib/src/api/fetcher.js.map +1 -0
  105. package/lib/src/api/index.d.ts +2 -0
  106. package/lib/src/api/index.js +19 -0
  107. package/lib/src/api/index.js.map +1 -0
  108. package/lib/src/api/listings.d.ts +44 -0
  109. package/lib/src/api/listings.js +86 -0
  110. package/lib/src/api/listings.js.map +1 -0
  111. package/lib/src/api/nfts.d.ts +35 -0
  112. package/lib/src/api/nfts.js +66 -0
  113. package/lib/src/api/nfts.js.map +1 -0
  114. package/lib/src/api/offers.d.ts +54 -0
  115. package/lib/src/api/offers.js +122 -0
  116. package/lib/src/api/offers.js.map +1 -0
  117. package/lib/src/api/orders.d.ts +50 -0
  118. package/lib/src/api/orders.js +151 -0
  119. package/lib/src/api/orders.js.map +1 -0
  120. package/lib/src/api/search.d.ts +13 -0
  121. package/lib/src/api/search.js +21 -0
  122. package/lib/src/api/search.js.map +1 -0
  123. package/lib/src/api/tokens.d.ts +25 -0
  124. package/lib/src/api/tokens.js +42 -0
  125. package/lib/src/api/tokens.js.map +1 -0
  126. package/lib/src/api/types.d.ts +840 -0
  127. package/lib/src/api/types.js +65 -0
  128. package/lib/src/api/types.js.map +1 -0
  129. package/lib/src/constants.d.ts +22 -0
  130. package/lib/src/constants.js +52 -0
  131. package/lib/src/constants.js.map +1 -0
  132. package/lib/src/index.d.ts +18 -0
  133. package/lib/src/index.js +24 -0
  134. package/lib/src/index.js.map +1 -0
  135. package/lib/src/orders/privateListings.d.ts +12 -0
  136. package/lib/src/orders/privateListings.js +130 -0
  137. package/lib/src/orders/privateListings.js.map +1 -0
  138. package/lib/src/orders/types.d.ts +160 -0
  139. package/lib/src/orders/types.js +10 -0
  140. package/lib/src/orders/types.js.map +1 -0
  141. package/lib/src/orders/utils.d.ts +89 -0
  142. package/lib/src/orders/utils.js +177 -0
  143. package/lib/src/orders/utils.js.map +1 -0
  144. package/lib/src/sdk/assets.d.ts +104 -0
  145. package/lib/src/sdk/assets.js +397 -0
  146. package/lib/src/sdk/assets.js.map +1 -0
  147. package/lib/src/sdk/cancellation.d.ts +97 -0
  148. package/lib/src/sdk/cancellation.js +234 -0
  149. package/lib/src/sdk/cancellation.js.map +1 -0
  150. package/lib/src/sdk/context.d.ts +28 -0
  151. package/lib/src/sdk/context.js +3 -0
  152. package/lib/src/sdk/context.js.map +1 -0
  153. package/lib/src/sdk/fulfillment.d.ts +153 -0
  154. package/lib/src/sdk/fulfillment.js +296 -0
  155. package/lib/src/sdk/fulfillment.js.map +1 -0
  156. package/lib/src/sdk/orders.d.ts +253 -0
  157. package/lib/src/sdk/orders.js +677 -0
  158. package/lib/src/sdk/orders.js.map +1 -0
  159. package/lib/src/sdk/tokens.d.ts +31 -0
  160. package/lib/src/sdk/tokens.js +64 -0
  161. package/lib/src/sdk/tokens.js.map +1 -0
  162. package/lib/src/sdk.d.ts +560 -0
  163. package/lib/src/sdk.js +675 -0
  164. package/lib/src/sdk.js.map +1 -0
  165. package/lib/src/typechain/contracts/ERC1155.d.ts +236 -0
  166. package/lib/src/typechain/contracts/ERC1155.js +3 -0
  167. package/lib/src/typechain/contracts/ERC1155.js.map +1 -0
  168. package/lib/src/typechain/contracts/ERC20.d.ts +141 -0
  169. package/lib/src/typechain/contracts/ERC20.js +3 -0
  170. package/lib/src/typechain/contracts/ERC20.js.map +1 -0
  171. package/lib/src/typechain/contracts/ERC721.d.ts +213 -0
  172. package/lib/src/typechain/contracts/ERC721.js +3 -0
  173. package/lib/src/typechain/contracts/ERC721.js.map +1 -0
  174. package/lib/src/typechain/contracts/Multicall3.d.ts +57 -0
  175. package/lib/src/typechain/contracts/Multicall3.js +3 -0
  176. package/lib/src/typechain/contracts/Multicall3.js.map +1 -0
  177. package/lib/src/typechain/contracts/TransferHelper.d.ts +55 -0
  178. package/lib/src/typechain/contracts/TransferHelper.js +3 -0
  179. package/lib/src/typechain/contracts/TransferHelper.js.map +1 -0
  180. package/lib/src/typechain/contracts/common.d.ts +50 -0
  181. package/lib/src/typechain/contracts/common.js +3 -0
  182. package/lib/src/typechain/contracts/common.js.map +1 -0
  183. package/lib/src/typechain/contracts/factories/ERC1155__factory.d.ts +250 -0
  184. package/lib/src/typechain/contracts/factories/ERC1155__factory.js +332 -0
  185. package/lib/src/typechain/contracts/factories/ERC1155__factory.js.map +1 -0
  186. package/lib/src/typechain/contracts/factories/ERC20__factory.d.ts +174 -0
  187. package/lib/src/typechain/contracts/factories/ERC20__factory.js +240 -0
  188. package/lib/src/typechain/contracts/factories/ERC20__factory.js.map +1 -0
  189. package/lib/src/typechain/contracts/factories/ERC721__factory.d.ts +268 -0
  190. package/lib/src/typechain/contracts/factories/ERC721__factory.js +351 -0
  191. package/lib/src/typechain/contracts/factories/ERC721__factory.js.map +1 -0
  192. package/lib/src/typechain/contracts/factories/Multicall3__factory.d.ts +43 -0
  193. package/lib/src/typechain/contracts/factories/Multicall3__factory.js +68 -0
  194. package/lib/src/typechain/contracts/factories/Multicall3__factory.js.map +1 -0
  195. package/lib/src/typechain/contracts/factories/TransferHelper__factory.d.ts +46 -0
  196. package/lib/src/typechain/contracts/factories/TransferHelper__factory.js +71 -0
  197. package/lib/src/typechain/contracts/factories/TransferHelper__factory.js.map +1 -0
  198. package/lib/src/typechain/contracts/factories/index.d.ts +5 -0
  199. package/lib/src/typechain/contracts/factories/index.js +17 -0
  200. package/lib/src/typechain/contracts/factories/index.js.map +1 -0
  201. package/lib/src/typechain/contracts/index.d.ts +11 -0
  202. package/lib/src/typechain/contracts/index.js +48 -0
  203. package/lib/src/typechain/contracts/index.js.map +1 -0
  204. package/lib/src/types.d.ts +387 -0
  205. package/lib/src/types.js +127 -0
  206. package/lib/src/types.js.map +1 -0
  207. package/lib/src/utils/chain.d.ts +60 -0
  208. package/lib/src/utils/chain.js +248 -0
  209. package/lib/src/utils/chain.js.map +1 -0
  210. package/lib/src/utils/converters.d.ts +37 -0
  211. package/lib/src/utils/converters.js +137 -0
  212. package/lib/src/utils/converters.js.map +1 -0
  213. package/lib/src/utils/dateHelper.d.ts +38 -0
  214. package/lib/src/utils/dateHelper.js +52 -0
  215. package/lib/src/utils/dateHelper.js.map +1 -0
  216. package/lib/src/utils/fees.d.ts +13 -0
  217. package/lib/src/utils/fees.js +29 -0
  218. package/lib/src/utils/fees.js.map +1 -0
  219. package/lib/src/utils/index.d.ts +2 -0
  220. package/lib/src/utils/index.js +19 -0
  221. package/lib/src/utils/index.js.map +1 -0
  222. package/lib/src/utils/protocol.d.ts +75 -0
  223. package/lib/src/utils/protocol.js +161 -0
  224. package/lib/src/utils/protocol.js.map +1 -0
  225. package/lib/src/utils/rateLimit.d.ts +34 -0
  226. package/lib/src/utils/rateLimit.js +97 -0
  227. package/lib/src/utils/rateLimit.js.map +1 -0
  228. package/lib/src/utils/stringHelper.d.ts +18 -0
  229. package/lib/src/utils/stringHelper.js +24 -0
  230. package/lib/src/utils/stringHelper.js.map +1 -0
  231. package/lib/src/utils/utils.d.ts +18 -0
  232. package/lib/src/utils/utils.js +45 -0
  233. package/lib/src/utils/utils.js.map +1 -0
  234. package/lib/typechain/contracts/ERC1155.d.ts +236 -0
  235. package/lib/typechain/contracts/ERC1155.js +3 -0
  236. package/lib/typechain/contracts/ERC1155.js.map +1 -0
  237. package/lib/typechain/contracts/ERC20.d.ts +141 -0
  238. package/lib/typechain/contracts/ERC20.js +3 -0
  239. package/lib/typechain/contracts/ERC20.js.map +1 -0
  240. package/lib/typechain/contracts/ERC721.d.ts +213 -0
  241. package/lib/typechain/contracts/ERC721.js +3 -0
  242. package/lib/typechain/contracts/ERC721.js.map +1 -0
  243. package/lib/typechain/contracts/Multicall3.d.ts +57 -0
  244. package/lib/typechain/contracts/Multicall3.js +3 -0
  245. package/lib/typechain/contracts/Multicall3.js.map +1 -0
  246. package/lib/typechain/contracts/TransferHelper.d.ts +55 -0
  247. package/lib/typechain/contracts/TransferHelper.js +3 -0
  248. package/lib/typechain/contracts/TransferHelper.js.map +1 -0
  249. package/lib/typechain/contracts/common.d.ts +50 -0
  250. package/lib/typechain/contracts/common.js +3 -0
  251. package/lib/typechain/contracts/common.js.map +1 -0
  252. package/lib/typechain/contracts/factories/ERC1155__factory.d.ts +250 -0
  253. package/lib/typechain/contracts/factories/ERC1155__factory.js +332 -0
  254. package/lib/typechain/contracts/factories/ERC1155__factory.js.map +1 -0
  255. package/lib/typechain/contracts/factories/ERC20__factory.d.ts +174 -0
  256. package/lib/typechain/contracts/factories/ERC20__factory.js +240 -0
  257. package/lib/typechain/contracts/factories/ERC20__factory.js.map +1 -0
  258. package/lib/typechain/contracts/factories/ERC721__factory.d.ts +268 -0
  259. package/lib/typechain/contracts/factories/ERC721__factory.js +351 -0
  260. package/lib/typechain/contracts/factories/ERC721__factory.js.map +1 -0
  261. package/lib/typechain/contracts/factories/Multicall3__factory.d.ts +43 -0
  262. package/lib/typechain/contracts/factories/Multicall3__factory.js +68 -0
  263. package/lib/typechain/contracts/factories/Multicall3__factory.js.map +1 -0
  264. package/lib/typechain/contracts/factories/TransferHelper__factory.d.ts +46 -0
  265. package/lib/typechain/contracts/factories/TransferHelper__factory.js +71 -0
  266. package/lib/typechain/contracts/factories/TransferHelper__factory.js.map +1 -0
  267. package/lib/typechain/contracts/factories/index.d.ts +5 -0
  268. package/lib/typechain/contracts/factories/index.js +17 -0
  269. package/lib/typechain/contracts/factories/index.js.map +1 -0
  270. package/lib/typechain/contracts/index.d.ts +11 -0
  271. package/lib/typechain/contracts/index.js +48 -0
  272. package/lib/typechain/contracts/index.js.map +1 -0
  273. package/lib/types.d.ts +389 -0
  274. package/lib/types.js +129 -0
  275. package/lib/types.js.map +1 -0
  276. package/lib/utils/chain.d.ts +64 -0
  277. package/lib/utils/chain.js +211 -0
  278. package/lib/utils/chain.js.map +1 -0
  279. package/lib/utils/chainIds.generated.d.ts +7 -0
  280. package/lib/utils/chainIds.generated.js +37 -0
  281. package/lib/utils/chainIds.generated.js.map +1 -0
  282. package/lib/utils/converters.d.ts +37 -0
  283. package/lib/utils/converters.js +137 -0
  284. package/lib/utils/converters.js.map +1 -0
  285. package/lib/utils/dateHelper.d.ts +38 -0
  286. package/lib/utils/dateHelper.js +52 -0
  287. package/lib/utils/dateHelper.js.map +1 -0
  288. package/lib/utils/fees.d.ts +13 -0
  289. package/lib/utils/fees.js +29 -0
  290. package/lib/utils/fees.js.map +1 -0
  291. package/lib/utils/index.d.ts +2 -0
  292. package/lib/utils/index.js +19 -0
  293. package/lib/utils/index.js.map +1 -0
  294. package/lib/utils/protocol.d.ts +75 -0
  295. package/lib/utils/protocol.js +161 -0
  296. package/lib/utils/protocol.js.map +1 -0
  297. package/lib/utils/rateLimit.d.ts +34 -0
  298. package/lib/utils/rateLimit.js +97 -0
  299. package/lib/utils/rateLimit.js.map +1 -0
  300. package/lib/utils/stringHelper.d.ts +18 -0
  301. package/lib/utils/stringHelper.js +24 -0
  302. package/lib/utils/stringHelper.js.map +1 -0
  303. package/lib/utils/utils.d.ts +18 -0
  304. package/lib/utils/utils.js +45 -0
  305. package/lib/utils/utils.js.map +1 -0
  306. package/package.json +72 -0
  307. package/src/abi/ERC1155.json +314 -0
  308. package/src/abi/ERC20.json +222 -0
  309. package/src/abi/ERC721.json +333 -0
  310. package/src/abi/Multicall3.json +50 -0
  311. package/src/abi/TransferHelper.json +53 -0
  312. package/src/api/accounts.ts +69 -0
  313. package/src/api/api.ts +1152 -0
  314. package/src/api/apiPaths.ts +208 -0
  315. package/src/api/chains.ts +18 -0
  316. package/src/api/collections.ts +120 -0
  317. package/src/api/drops.ts +49 -0
  318. package/src/api/events.ts +71 -0
  319. package/src/api/fetcher.ts +31 -0
  320. package/src/api/index.ts +2 -0
  321. package/src/api/listings.ts +126 -0
  322. package/src/api/nfts.ts +144 -0
  323. package/src/api/offers.ts +242 -0
  324. package/src/api/orders.ts +283 -0
  325. package/src/api/search.ts +21 -0
  326. package/src/api/tokens.ts +67 -0
  327. package/src/api/types.ts +1210 -0
  328. package/src/constants.ts +90 -0
  329. package/src/index.ts +22 -0
  330. package/src/orders/privateListings.ts +173 -0
  331. package/src/orders/types.ts +191 -0
  332. package/src/orders/utils.ts +253 -0
  333. package/src/sdk/assets.ts +591 -0
  334. package/src/sdk/cancellation.ts +346 -0
  335. package/src/sdk/context.ts +33 -0
  336. package/src/sdk/fulfillment.ts +478 -0
  337. package/src/sdk/orders.ts +1149 -0
  338. package/src/sdk/tokens.ts +95 -0
  339. package/src/sdk.ts +1051 -0
  340. package/src/typechain/contracts/ERC1155.ts +440 -0
  341. package/src/typechain/contracts/ERC20.ts +286 -0
  342. package/src/typechain/contracts/ERC721.ts +412 -0
  343. package/src/typechain/contracts/Multicall3.ts +117 -0
  344. package/src/typechain/contracts/TransferHelper.ts +122 -0
  345. package/src/typechain/contracts/common.ts +131 -0
  346. package/src/typechain/contracts/factories/ERC1155__factory.ts +331 -0
  347. package/src/typechain/contracts/factories/ERC20__factory.ts +239 -0
  348. package/src/typechain/contracts/factories/ERC721__factory.ts +350 -0
  349. package/src/typechain/contracts/factories/Multicall3__factory.ts +67 -0
  350. package/src/typechain/contracts/factories/TransferHelper__factory.ts +76 -0
  351. package/src/typechain/contracts/factories/index.ts +8 -0
  352. package/src/typechain/contracts/index.ts +14 -0
  353. package/src/types.ts +413 -0
  354. package/src/utils/chain.ts +224 -0
  355. package/src/utils/chainIds.generated.ts +34 -0
  356. package/src/utils/converters.ts +145 -0
  357. package/src/utils/dateHelper.ts +48 -0
  358. package/src/utils/fees.ts +31 -0
  359. package/src/utils/index.ts +2 -0
  360. package/src/utils/protocol.ts +185 -0
  361. package/src/utils/rateLimit.ts +147 -0
  362. package/src/utils/stringHelper.ts +25 -0
  363. package/src/utils/utils.ts +36 -0
@@ -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
+ }