@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,679 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.OrdersManager = void 0;
37
+ const ethers_1 = require("ethers");
38
+ const constants_1 = require("../constants");
39
+ const types_1 = require("../types");
40
+ const dateHelper_1 = require("../utils/dateHelper");
41
+ const stringHelper_1 = require("../utils/stringHelper");
42
+ const utils_1 = require("../utils/utils");
43
+ /**
44
+ * Manager for order building and creation operations.
45
+ * Handles listing creation, offer creation, and collection offers.
46
+ */
47
+ class OrdersManager {
48
+ context;
49
+ getPriceParametersCallback;
50
+ constructor(context, getPriceParametersCallback) {
51
+ this.context = context;
52
+ this.getPriceParametersCallback = getPriceParametersCallback;
53
+ }
54
+ getAmountWithBasisPointsApplied(amount, basisPoints) {
55
+ return ((amount * basisPoints) / constants_1.INVERSE_BASIS_POINT).toString();
56
+ }
57
+ isNotMarketplaceFee(fee) {
58
+ return (fee.recipient.toLowerCase() !==
59
+ (0, utils_1.getFeeRecipient)(this.context.chain).toLowerCase());
60
+ }
61
+ getNFTItems(nfts, quantities = []) {
62
+ return nfts.map((nft, index) => ({
63
+ itemType: (0, utils_1.getAssetItemType)(nft.token_standard.toUpperCase()),
64
+ token: (0, utils_1.remapSharedStorefrontAddress)(nft.contract),
65
+ identifier: nft.identifier ?? undefined,
66
+ amount: quantities[index]?.toString() ?? "1",
67
+ }));
68
+ }
69
+ async getFees({ collection, seller, paymentTokenAddress, amount, includeOptionalCreatorFees = false, isPrivateListing = false, }) {
70
+ let collectionFees = includeOptionalCreatorFees
71
+ ? collection.fees
72
+ : collection.fees.filter(fee => fee.required);
73
+ if (isPrivateListing) {
74
+ collectionFees = collectionFees.filter(fee => this.isNotMarketplaceFee(fee));
75
+ }
76
+ const collectionFeesBasisPoints = (0, utils_1.totalBasisPointsForFees)(collectionFees);
77
+ const sellerBasisPoints = constants_1.INVERSE_BASIS_POINT - collectionFeesBasisPoints;
78
+ const getConsiderationItem = (basisPoints, recipient) => {
79
+ return {
80
+ token: paymentTokenAddress,
81
+ amount: this.getAmountWithBasisPointsApplied(amount, basisPoints),
82
+ recipient,
83
+ };
84
+ };
85
+ const considerationItems = [];
86
+ if (seller) {
87
+ considerationItems.push(getConsiderationItem(sellerBasisPoints, seller));
88
+ }
89
+ if (collectionFeesBasisPoints > 0) {
90
+ for (const fee of collectionFees) {
91
+ considerationItems.push(getConsiderationItem((0, utils_1.basisPointsForFee)(fee), fee.recipient));
92
+ }
93
+ }
94
+ return considerationItems;
95
+ }
96
+ /**
97
+ * Build listing order without submitting to API
98
+ * @param options Listing parameters
99
+ * @returns OrderWithCounter ready for API submission or onchain validation
100
+ */
101
+ async _buildListingOrder({ asset, accountAddress, amount, quantity = 1, domain, salt, listingTime, expirationTime, buyerAddress, includeOptionalCreatorFees = false, zone = ethers_1.ZeroAddress, }) {
102
+ await this.context.requireAccountIsAvailable(accountAddress);
103
+ const { nft } = await this.context.api.getNFT(asset.tokenAddress, asset.tokenId);
104
+ const offerAssetItems = this.getNFTItems([nft], [BigInt(quantity ?? 1)]);
105
+ const collection = await this.context.api.getCollection(nft.collection);
106
+ const paymentTokenAddress = collection.pricingCurrencies?.listingCurrency?.address ??
107
+ (0, utils_1.getListingPaymentToken)(this.context.chain);
108
+ const { basePrice } = await this.getPriceParametersCallback(types_1.OrderSide.LISTING, paymentTokenAddress, amount);
109
+ const considerationFeeItems = await this.getFees({
110
+ collection,
111
+ seller: accountAddress,
112
+ paymentTokenAddress,
113
+ amount: basePrice,
114
+ includeOptionalCreatorFees,
115
+ isPrivateListing: !!buyerAddress,
116
+ });
117
+ if (buyerAddress) {
118
+ const { getPrivateListingConsiderations } = await Promise.resolve().then(() => __importStar(require("../orders/privateListings")));
119
+ considerationFeeItems.push(...getPrivateListingConsiderations(offerAssetItems, buyerAddress));
120
+ }
121
+ if (collection.requiredZone) {
122
+ zone = collection.requiredZone;
123
+ }
124
+ const { executeAllActions } = await this.context.seaport.createOrder({
125
+ offer: offerAssetItems,
126
+ consideration: considerationFeeItems,
127
+ startTime: listingTime?.toString(),
128
+ endTime: expirationTime?.toString() ?? (0, dateHelper_1.oneMonthFromNowInSeconds)().toString(),
129
+ zone,
130
+ domain,
131
+ salt: BigInt(salt ?? 0).toString(),
132
+ restrictedByZone: zone !== ethers_1.ZeroAddress,
133
+ allowPartialFills: true,
134
+ }, accountAddress);
135
+ return executeAllActions();
136
+ }
137
+ /**
138
+ * Build listing order components without submitting to API
139
+ * @param options Listing parameters
140
+ * @returns OrderComponents ready for onchain validation
141
+ */
142
+ async buildListingOrderComponents({ asset, accountAddress, amount, quantity = 1, domain, salt, listingTime, expirationTime, buyerAddress, includeOptionalCreatorFees = false, zone = ethers_1.ZeroAddress, }) {
143
+ const order = await this._buildListingOrder({
144
+ asset,
145
+ accountAddress,
146
+ amount,
147
+ quantity,
148
+ domain,
149
+ salt,
150
+ listingTime,
151
+ expirationTime,
152
+ buyerAddress,
153
+ includeOptionalCreatorFees,
154
+ zone,
155
+ });
156
+ return order.parameters;
157
+ }
158
+ /**
159
+ * Build offer order without submitting to API
160
+ * @param options Offer parameters
161
+ * @returns OrderWithCounter ready for API submission or onchain validation
162
+ */
163
+ async _buildOfferOrder({ asset, accountAddress, amount, quantity = 1, domain, salt, expirationTime, zone = (0, utils_1.getSignedZone)(this.context.chain), }) {
164
+ await this.context.requireAccountIsAvailable(accountAddress);
165
+ const { nft } = await this.context.api.getNFT(asset.tokenAddress, asset.tokenId);
166
+ const considerationAssetItems = this.getNFTItems([nft], [BigInt(quantity ?? 1)]);
167
+ const collection = await this.context.api.getCollection(nft.collection);
168
+ const paymentTokenAddress = collection.pricingCurrencies?.offerCurrency?.address ??
169
+ (0, utils_1.getOfferPaymentToken)(this.context.chain);
170
+ const { basePrice } = await this.getPriceParametersCallback(types_1.OrderSide.OFFER, paymentTokenAddress, amount);
171
+ const considerationFeeItems = await this.getFees({
172
+ collection,
173
+ paymentTokenAddress,
174
+ amount: basePrice,
175
+ });
176
+ if (collection.requiredZone) {
177
+ zone = collection.requiredZone;
178
+ }
179
+ const { executeAllActions } = await this.context.seaport.createOrder({
180
+ offer: [
181
+ {
182
+ token: paymentTokenAddress,
183
+ amount: basePrice.toString(),
184
+ },
185
+ ],
186
+ consideration: [...considerationAssetItems, ...considerationFeeItems],
187
+ endTime: expirationTime !== undefined
188
+ ? BigInt(expirationTime).toString()
189
+ : (0, dateHelper_1.oneMonthFromNowInSeconds)().toString(),
190
+ zone,
191
+ domain,
192
+ salt: BigInt(salt ?? 0).toString(),
193
+ restrictedByZone: zone !== ethers_1.ZeroAddress,
194
+ allowPartialFills: true,
195
+ }, accountAddress);
196
+ return executeAllActions();
197
+ }
198
+ /**
199
+ * Build offer order components without submitting to API
200
+ * @param options Offer parameters
201
+ * @returns OrderComponents ready for onchain validation
202
+ */
203
+ async buildOfferOrderComponents({ asset, accountAddress, amount, quantity = 1, domain, salt, expirationTime, zone = (0, utils_1.getSignedZone)(this.context.chain), }) {
204
+ const order = await this._buildOfferOrder({
205
+ asset,
206
+ accountAddress,
207
+ amount,
208
+ quantity,
209
+ domain,
210
+ salt,
211
+ expirationTime,
212
+ zone,
213
+ });
214
+ return order.parameters;
215
+ }
216
+ /**
217
+ * Create and submit an offer on an asset.
218
+ * @param options
219
+ * @param options.asset The asset to trade. tokenAddress and tokenId must be defined.
220
+ * @param options.accountAddress Address of the wallet making the offer.
221
+ * @param options.amount Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units.
222
+ * @param options.quantity Number of assets to bid for. Defaults to 1.
223
+ * @param options.domain Optional domain for onchain attribution. Hashed and included in salt.
224
+ * @param options.salt Arbitrary salt. Auto-generated if not provided.
225
+ * @param options.expirationTime Expiration time for the order, in UTC seconds
226
+ * @param options.zone Zone for order protection. Defaults to chain's signed zone.
227
+ *
228
+ * @returns The {@link OrderV2} that was created.
229
+ *
230
+ * @throws Error if the asset does not contain a token id.
231
+ * @throws Error if the accountAddress is not available through wallet or provider.
232
+ * @throws Error if the amount is not greater than 0.
233
+ */
234
+ async createOffer({ asset, accountAddress, amount, quantity = 1, domain, salt, expirationTime, zone = (0, utils_1.getSignedZone)(this.context.chain), }) {
235
+ const order = await this._buildOfferOrder({
236
+ asset,
237
+ accountAddress,
238
+ amount,
239
+ quantity,
240
+ domain,
241
+ salt,
242
+ expirationTime,
243
+ zone,
244
+ });
245
+ return this.context.api.postOrder(order, {
246
+ protocol: "seaport",
247
+ protocolAddress: this.context.seaport.contract.target,
248
+ side: types_1.OrderSide.OFFER,
249
+ });
250
+ }
251
+ /**
252
+ * Create and submit a listing for an asset.
253
+ * @param options
254
+ * @param options.asset The asset to trade. tokenAddress and tokenId must be defined.
255
+ * @param options.accountAddress Address of the wallet making the listing
256
+ * @param options.amount Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units.
257
+ * @param options.quantity Number of assets to list. Defaults to 1.
258
+ * @param options.domain Optional domain for onchain attribution. Hashed and included in salt. This can be used for onchain order attribution to assist with analytics.
259
+ * @param options.salt Arbitrary salt. Auto-generated if not provided.
260
+ * @param options.listingTime Optional time when the order will become fulfillable, in UTC seconds. Undefined means it will start now.
261
+ * @param options.expirationTime Expiration time for the order, in UTC seconds.
262
+ * @param options.buyerAddress Optional address that's allowed to purchase this item. If specified, no other address will be able to take the order, unless its value is the null address.
263
+ * @param options.includeOptionalCreatorFees If true, optional creator fees will be included in the listing. Default: false.
264
+ * @param options.zone Zone for order protection. Defaults to no zone.
265
+ * @returns The {@link OrderV2} that was created.
266
+ *
267
+ * @throws Error if the asset does not contain a token id.
268
+ * @throws Error if the accountAddress is not available through wallet or provider.
269
+ * @throws Error if the amount is not greater than 0.
270
+ */
271
+ async createListing({ asset, accountAddress, amount, quantity = 1, domain, salt, listingTime, expirationTime, buyerAddress, includeOptionalCreatorFees = false, zone = ethers_1.ZeroAddress, }) {
272
+ const order = await this._buildListingOrder({
273
+ asset,
274
+ accountAddress,
275
+ amount,
276
+ quantity,
277
+ domain,
278
+ salt,
279
+ listingTime,
280
+ expirationTime,
281
+ buyerAddress,
282
+ includeOptionalCreatorFees,
283
+ zone,
284
+ });
285
+ return this.context.api.postOrder(order, {
286
+ protocol: "seaport",
287
+ protocolAddress: this.context.seaport.contract.target,
288
+ side: types_1.OrderSide.LISTING,
289
+ });
290
+ }
291
+ /**
292
+ * Create and submit multiple listings using Seaport's bulk order creation.
293
+ * This method uses a single signature for all listings and submits them individually to the OpenSea API with rate limit handling.
294
+ * All listings must be from the same account address.
295
+ *
296
+ * Note: If only one listing is provided, this method will use a normal order signature instead of a bulk signature,
297
+ * as bulk signatures are more expensive to decode onchain due to the merkle proof verification.
298
+ *
299
+ * @param options
300
+ * @param options.listings Array of listing parameters. Each listing requires asset, amount, and optionally other listing parameters.
301
+ * @param options.accountAddress Address of the wallet making the listings
302
+ * @param options.continueOnError If true, continue submitting remaining listings even if some fail. Default: false (throw on first error).
303
+ * @param options.onProgress Optional callback for progress updates. Called after each listing is submitted (successfully or not).
304
+ * @returns {@link BulkOrderResult} containing successful orders and any failures.
305
+ *
306
+ * @throws Error if listings array is empty
307
+ * @throws Error if the accountAddress is not available through wallet or provider.
308
+ * @throws Error if any asset does not contain a token id.
309
+ * @throws Error if continueOnError is false and any submission fails.
310
+ */
311
+ async createBulkListings({ listings, accountAddress, continueOnError = false, onProgress, }) {
312
+ if (listings.length === 0) {
313
+ throw new Error("Listings array cannot be empty");
314
+ }
315
+ // If only one listing, use normal signature to avoid bulk signature overhead
316
+ if (listings.length === 1) {
317
+ try {
318
+ const order = await this.createListing({
319
+ ...listings[0],
320
+ accountAddress,
321
+ });
322
+ return {
323
+ successful: [order],
324
+ failed: [],
325
+ };
326
+ }
327
+ catch (error) {
328
+ if (continueOnError) {
329
+ return {
330
+ successful: [],
331
+ failed: [
332
+ {
333
+ index: 0,
334
+ order: {}, // Order wasn't created
335
+ error: error,
336
+ },
337
+ ],
338
+ };
339
+ }
340
+ throw error;
341
+ }
342
+ }
343
+ await this.context.requireAccountIsAvailable(accountAddress);
344
+ // Build metadata array for each listing
345
+ const listingMetadata = [];
346
+ // Build all order inputs
347
+ for (const listing of listings) {
348
+ const { asset, amount, quantity = 1, domain, salt, listingTime, expirationTime, buyerAddress, includeOptionalCreatorFees = false, zone = ethers_1.ZeroAddress, } = listing;
349
+ // Fetch NFT and collection data
350
+ const { nft } = await this.context.api.getNFT(asset.tokenAddress, asset.tokenId);
351
+ const collection = await this.context.api.getCollection(nft.collection);
352
+ const paymentTokenAddress = collection.pricingCurrencies?.listingCurrency?.address ??
353
+ (0, utils_1.getListingPaymentToken)(this.context.chain);
354
+ const offerAssetItems = this.getNFTItems([nft], [BigInt(quantity ?? 1)]);
355
+ const { basePrice } = await this.getPriceParametersCallback(types_1.OrderSide.LISTING, paymentTokenAddress, amount);
356
+ const considerationFeeItems = await this.getFees({
357
+ collection,
358
+ seller: accountAddress,
359
+ paymentTokenAddress,
360
+ amount: basePrice,
361
+ includeOptionalCreatorFees,
362
+ isPrivateListing: !!buyerAddress,
363
+ });
364
+ if (buyerAddress) {
365
+ const { getPrivateListingConsiderations } = await Promise.resolve().then(() => __importStar(require("../orders/privateListings")));
366
+ considerationFeeItems.push(...getPrivateListingConsiderations(offerAssetItems, buyerAddress));
367
+ }
368
+ let finalZone = zone;
369
+ if (collection.requiredZone) {
370
+ finalZone = collection.requiredZone;
371
+ }
372
+ listingMetadata.push({
373
+ nft,
374
+ collection,
375
+ paymentTokenAddress,
376
+ zone: finalZone,
377
+ domain,
378
+ salt,
379
+ listingTime,
380
+ expirationTime,
381
+ });
382
+ }
383
+ // Create the bulk orders using seaport's createBulkOrders method
384
+ const createOrderInputsForSeaport = listings.map((listing, index) => {
385
+ const { amount, quantity = 1, listingTime, expirationTime, buyerAddress, includeOptionalCreatorFees = false, } = listing;
386
+ const metadata = listingMetadata[index];
387
+ const offerAssetItems = this.getNFTItems([metadata.nft], [BigInt(quantity ?? 1)]);
388
+ return this.getPriceParametersCallback(types_1.OrderSide.LISTING, metadata.paymentTokenAddress, amount).then(async ({ basePrice }) => {
389
+ const considerationFeeItems = await this.getFees({
390
+ collection: metadata.collection,
391
+ seller: accountAddress,
392
+ paymentTokenAddress: metadata.paymentTokenAddress,
393
+ amount: basePrice,
394
+ includeOptionalCreatorFees,
395
+ isPrivateListing: !!buyerAddress,
396
+ });
397
+ if (buyerAddress) {
398
+ const { getPrivateListingConsiderations } = await Promise.resolve().then(() => __importStar(require("../orders/privateListings")));
399
+ considerationFeeItems.push(...getPrivateListingConsiderations(offerAssetItems, buyerAddress));
400
+ }
401
+ return {
402
+ offer: offerAssetItems,
403
+ consideration: considerationFeeItems,
404
+ startTime: listingTime?.toString(),
405
+ endTime: expirationTime?.toString() ?? (0, dateHelper_1.oneMonthFromNowInSeconds)().toString(),
406
+ zone: metadata.zone,
407
+ domain: metadata.domain,
408
+ salt: metadata.salt
409
+ ? BigInt(metadata.salt ?? 0).toString()
410
+ : undefined,
411
+ restrictedByZone: metadata.zone !== ethers_1.ZeroAddress,
412
+ allowPartialFills: true,
413
+ };
414
+ });
415
+ });
416
+ const resolvedInputs = await Promise.all(createOrderInputsForSeaport);
417
+ const { executeAllActions } = await this.context.seaport.createBulkOrders(resolvedInputs, accountAddress);
418
+ const orders = await executeAllActions();
419
+ // Submit each order individually to the OpenSea API
420
+ // Rate limiting is handled automatically by the API client
421
+ this.context.logger(`Starting submission of ${orders.length} bulk-signed ${(0, stringHelper_1.pluralize)(orders.length, "listing")} to OpenSea API...`);
422
+ const submittedOrders = [];
423
+ const failedOrders = [];
424
+ for (let i = 0; i < orders.length; i++) {
425
+ this.context.logger(`Submitting listing ${i + 1}/${orders.length}...`);
426
+ try {
427
+ const submittedOrder = await this.context.api.postOrder(orders[i], {
428
+ protocol: "seaport",
429
+ protocolAddress: this.context.seaport.contract.target,
430
+ side: types_1.OrderSide.LISTING,
431
+ });
432
+ submittedOrders.push(submittedOrder);
433
+ this.context.logger(`Completed listing ${i + 1}/${orders.length}`);
434
+ }
435
+ catch (error) {
436
+ const errorMessage = error.message;
437
+ this.context.logger(`Failed listing ${i + 1}/${orders.length}: ${errorMessage}`);
438
+ failedOrders.push({
439
+ index: i,
440
+ order: orders[i],
441
+ error: error,
442
+ });
443
+ // If not continuing on error, throw immediately
444
+ if (!continueOnError) {
445
+ throw error;
446
+ }
447
+ }
448
+ // Call progress callback after each listing (successful or failed)
449
+ onProgress?.(i + 1, orders.length);
450
+ }
451
+ if (submittedOrders.length > 0) {
452
+ this.context.logger(`Successfully submitted ${submittedOrders.length}/${orders.length} ${(0, stringHelper_1.pluralize)(submittedOrders.length, "listing")}`);
453
+ }
454
+ if (failedOrders.length > 0) {
455
+ this.context.logger(`Failed to submit ${failedOrders.length}/${orders.length} ${(0, stringHelper_1.pluralize)(failedOrders.length, "listing")}`);
456
+ }
457
+ return {
458
+ successful: submittedOrders,
459
+ failed: failedOrders,
460
+ };
461
+ }
462
+ /**
463
+ * Create and submit multiple offers using Seaport's bulk order creation.
464
+ * This method uses a single signature for all offers and submits them individually to the OpenSea API with rate limit handling.
465
+ * All offers must be from the same account address.
466
+ *
467
+ * Note: If only one offer is provided, this method will use a normal order signature instead of a bulk signature,
468
+ * as bulk signatures are more expensive to decode onchain due to the merkle proof verification.
469
+ *
470
+ * @param options
471
+ * @param options.offers Array of offer parameters. Each offer requires asset, amount, and optionally other offer parameters.
472
+ * @param options.accountAddress Address of the wallet making the offers
473
+ * @param options.continueOnError If true, continue submitting remaining offers even if some fail. Default: false (throw on first error).
474
+ * @param options.onProgress Optional callback for progress updates. Called after each offer is submitted (successfully or not).
475
+ * @returns {@link BulkOrderResult} containing successful orders and any failures.
476
+ *
477
+ * @throws Error if offers array is empty
478
+ * @throws Error if the accountAddress is not available through wallet or provider.
479
+ * @throws Error if any asset does not contain a token id.
480
+ * @throws Error if continueOnError is false and any submission fails.
481
+ */
482
+ async createBulkOffers({ offers, accountAddress, continueOnError = false, onProgress, }) {
483
+ if (offers.length === 0) {
484
+ throw new Error("Offers array cannot be empty");
485
+ }
486
+ // If only one offer, use normal signature to avoid bulk signature overhead
487
+ if (offers.length === 1) {
488
+ try {
489
+ const order = await this.createOffer({
490
+ ...offers[0],
491
+ accountAddress,
492
+ });
493
+ return {
494
+ successful: [order],
495
+ failed: [],
496
+ };
497
+ }
498
+ catch (error) {
499
+ if (continueOnError) {
500
+ return {
501
+ successful: [],
502
+ failed: [
503
+ {
504
+ index: 0,
505
+ order: {}, // Order wasn't created
506
+ error: error,
507
+ },
508
+ ],
509
+ };
510
+ }
511
+ throw error;
512
+ }
513
+ }
514
+ await this.context.requireAccountIsAvailable(accountAddress);
515
+ // Build metadata array for each offer
516
+ const offerMetadata = [];
517
+ // Build all order inputs
518
+ for (const offer of offers) {
519
+ const { asset, domain, salt, expirationTime, zone = (0, utils_1.getSignedZone)(this.context.chain), } = offer;
520
+ // Fetch NFT and collection data
521
+ const { nft } = await this.context.api.getNFT(asset.tokenAddress, asset.tokenId);
522
+ const collection = await this.context.api.getCollection(nft.collection);
523
+ const paymentTokenAddress = collection.pricingCurrencies?.offerCurrency?.address ??
524
+ (0, utils_1.getOfferPaymentToken)(this.context.chain);
525
+ let finalZone = zone;
526
+ if (collection.requiredZone) {
527
+ finalZone = collection.requiredZone;
528
+ }
529
+ offerMetadata.push({
530
+ nft,
531
+ collection,
532
+ paymentTokenAddress,
533
+ zone: finalZone,
534
+ domain,
535
+ salt,
536
+ expirationTime,
537
+ });
538
+ }
539
+ // Create the bulk orders using seaport's createBulkOrders method
540
+ const createOrderInputsForSeaport = offers.map((offer, index) => {
541
+ const { amount, quantity = 1 } = offer;
542
+ const metadata = offerMetadata[index];
543
+ const considerationAssetItems = this.getNFTItems([metadata.nft], [BigInt(quantity ?? 1)]);
544
+ return this.getPriceParametersCallback(types_1.OrderSide.OFFER, metadata.paymentTokenAddress, amount).then(async ({ basePrice }) => {
545
+ const considerationFeeItems = await this.getFees({
546
+ collection: metadata.collection,
547
+ paymentTokenAddress: metadata.paymentTokenAddress,
548
+ amount: basePrice,
549
+ });
550
+ return {
551
+ offer: [
552
+ {
553
+ token: metadata.paymentTokenAddress,
554
+ amount: basePrice.toString(),
555
+ },
556
+ ],
557
+ consideration: [...considerationAssetItems, ...considerationFeeItems],
558
+ endTime: metadata.expirationTime !== undefined
559
+ ? BigInt(metadata.expirationTime).toString()
560
+ : (0, dateHelper_1.oneMonthFromNowInSeconds)().toString(),
561
+ zone: metadata.zone,
562
+ domain: metadata.domain,
563
+ salt: metadata.salt
564
+ ? BigInt(metadata.salt ?? 0).toString()
565
+ : undefined,
566
+ restrictedByZone: metadata.zone !== ethers_1.ZeroAddress,
567
+ allowPartialFills: true,
568
+ };
569
+ });
570
+ });
571
+ const resolvedInputs = await Promise.all(createOrderInputsForSeaport);
572
+ const { executeAllActions } = await this.context.seaport.createBulkOrders(resolvedInputs, accountAddress);
573
+ const orders = await executeAllActions();
574
+ // Submit each order individually to the OpenSea API
575
+ // Rate limiting is handled automatically by the API client
576
+ this.context.logger(`Starting submission of ${orders.length} bulk-signed ${(0, stringHelper_1.pluralize)(orders.length, "offer")} to OpenSea API...`);
577
+ const submittedOrders = [];
578
+ const failedOrders = [];
579
+ for (let i = 0; i < orders.length; i++) {
580
+ this.context.logger(`Submitting offer ${i + 1}/${orders.length}...`);
581
+ try {
582
+ const submittedOrder = await this.context.api.postOrder(orders[i], {
583
+ protocol: "seaport",
584
+ protocolAddress: this.context.seaport.contract.target,
585
+ side: types_1.OrderSide.OFFER,
586
+ });
587
+ submittedOrders.push(submittedOrder);
588
+ this.context.logger(`Completed offer ${i + 1}/${orders.length}`);
589
+ }
590
+ catch (error) {
591
+ const errorMessage = error.message;
592
+ this.context.logger(`Failed offer ${i + 1}/${orders.length}: ${errorMessage}`);
593
+ failedOrders.push({
594
+ index: i,
595
+ order: orders[i],
596
+ error: error,
597
+ });
598
+ // If not continuing on error, throw immediately
599
+ if (!continueOnError) {
600
+ throw error;
601
+ }
602
+ }
603
+ // Call progress callback after each offer (successful or failed)
604
+ onProgress?.(i + 1, orders.length);
605
+ }
606
+ if (submittedOrders.length > 0) {
607
+ this.context.logger(`Successfully submitted ${submittedOrders.length}/${orders.length} ${(0, stringHelper_1.pluralize)(submittedOrders.length, "offer")}`);
608
+ }
609
+ if (failedOrders.length > 0) {
610
+ this.context.logger(`Failed to submit ${failedOrders.length}/${orders.length} ${(0, stringHelper_1.pluralize)(failedOrders.length, "offer")}`);
611
+ }
612
+ return {
613
+ successful: submittedOrders,
614
+ failed: failedOrders,
615
+ };
616
+ }
617
+ /**
618
+ * Create and submit a collection offer.
619
+ * @param options
620
+ * @param options.collectionSlug Identifier for the collection.
621
+ * @param options.accountAddress Address of the wallet making the offer.
622
+ * @param options.amount Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units.
623
+ * @param options.quantity Number of assets to bid for.
624
+ * @param options.domain Optional domain for onchain attribution. Hashed and included in salt. This can be used for onchain order attribution to assist with analytics.
625
+ * @param options.salt Arbitrary salt. Auto-generated if not provided.
626
+ * @param options.expirationTime Expiration time for the order, in UTC seconds.
627
+ * @param options.offerProtectionEnabled Use signed zone for protection against disabled items. Default: true.
628
+ * @param options.traitType If defined, the trait name to create the collection offer for.
629
+ * @param options.traitValue If defined, the trait value to create the collection offer for.
630
+ * @param options.traits If defined, an array of traits to create the multi-trait collection offer for.
631
+ * @param options.numericTraits If defined, an array of numeric trait criteria with min/max ranges.
632
+ * @returns The {@link CollectionOffer} that was created.
633
+ */
634
+ async createCollectionOffer({ collectionSlug, accountAddress, amount, quantity, domain, salt, expirationTime, offerProtectionEnabled = true, traitType, traitValue, traits, numericTraits, }) {
635
+ await this.context.requireAccountIsAvailable(accountAddress);
636
+ const collection = await this.context.api.getCollection(collectionSlug);
637
+ const paymentTokenAddress = collection.pricingCurrencies?.offerCurrency?.address ??
638
+ (0, utils_1.getOfferPaymentToken)(this.context.chain);
639
+ const buildOfferResult = await this.context.api.buildOffer(accountAddress, quantity, collectionSlug, offerProtectionEnabled, traitType, traitValue, traits, numericTraits);
640
+ const item = buildOfferResult.partialParameters.consideration[0];
641
+ const convertedConsiderationItem = {
642
+ itemType: item.itemType,
643
+ token: item.token,
644
+ identifier: item.identifierOrCriteria,
645
+ amount: item.startAmount,
646
+ };
647
+ const { basePrice } = await this.getPriceParametersCallback(types_1.OrderSide.OFFER, paymentTokenAddress, amount);
648
+ const considerationFeeItems = await this.getFees({
649
+ collection,
650
+ paymentTokenAddress,
651
+ amount: basePrice,
652
+ });
653
+ const considerationItems = [
654
+ convertedConsiderationItem,
655
+ ...considerationFeeItems,
656
+ ];
657
+ const payload = {
658
+ offerer: accountAddress,
659
+ offer: [
660
+ {
661
+ token: paymentTokenAddress,
662
+ amount: basePrice.toString(),
663
+ },
664
+ ],
665
+ consideration: considerationItems,
666
+ endTime: expirationTime?.toString() ?? (0, dateHelper_1.oneMonthFromNowInSeconds)().toString(),
667
+ zone: buildOfferResult.partialParameters.zone,
668
+ domain,
669
+ salt: BigInt(salt ?? 0).toString(),
670
+ restrictedByZone: true,
671
+ allowPartialFills: true,
672
+ };
673
+ const { executeAllActions } = await this.context.seaport.createOrder(payload, accountAddress);
674
+ const order = await executeAllActions();
675
+ return this.context.api.postCollectionOffer(order, collectionSlug, traitType, traitValue, traits, numericTraits);
676
+ }
677
+ }
678
+ exports.OrdersManager = OrdersManager;
679
+ //# sourceMappingURL=orders.js.map