@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,298 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FulfillmentManager = void 0;
4
+ const Seaport_1 = require("@opensea/seaport-js/lib/abi/Seaport");
5
+ const ethers_1 = require("ethers");
6
+ const privateListings_1 = require("../orders/privateListings");
7
+ const types_1 = require("../orders/types");
8
+ const utils_1 = require("../orders/utils");
9
+ const types_2 = require("../types");
10
+ const utils_2 = require("../utils/utils");
11
+ const FULFILL_BASIC_ORDER_ALIAS = "fulfillBasicOrder_efficient_6GL6yc";
12
+ /**
13
+ * Manager for order fulfillment and validation operations.
14
+ * Handles fulfilling orders, validating orders onchain, and approving orders.
15
+ */
16
+ class FulfillmentManager {
17
+ context;
18
+ ordersManager;
19
+ constructor(context, ordersManager) {
20
+ this.context = context;
21
+ this.ordersManager = ordersManager;
22
+ }
23
+ /**
24
+ * Fulfill a private order for a designated address.
25
+ * @param options
26
+ * @param options.order The order to fulfill
27
+ * @param options.accountAddress Address of the wallet taking the order.
28
+ * @param options.domain An optional domain to be hashed and included at the end of fulfillment calldata.
29
+ * This can be used for onchain order attribution to assist with analytics.
30
+ * @param options.overrides Transaction overrides, ignored if not set.
31
+ * @returns Transaction hash of the order.
32
+ */
33
+ async fulfillPrivateOrder({ order, accountAddress, domain, overrides, }) {
34
+ if (!order.taker?.address) {
35
+ throw new Error("Order is not a private listing - must have a taker address");
36
+ }
37
+ const counterOrder = (0, privateListings_1.constructPrivateListingCounterOrder)(order.protocolData, order.taker.address);
38
+ const fulfillments = (0, privateListings_1.getPrivateListingFulfillments)(order.protocolData);
39
+ // Compute ETH value from original order's consideration items
40
+ // This handles both standard private listings and zero-payment listings (e.g., rewards)
41
+ const value = (0, privateListings_1.computePrivateListingValue)(order.protocolData, order.taker.address);
42
+ const seaport = (0, utils_2.getSeaportInstance)(order.protocolAddress, this.context.seaport);
43
+ const transaction = await seaport
44
+ .matchOrders({
45
+ orders: [order.protocolData, counterOrder],
46
+ fulfillments,
47
+ overrides: {
48
+ ...overrides,
49
+ value,
50
+ },
51
+ accountAddress,
52
+ domain,
53
+ })
54
+ .transact();
55
+ const transactionReceipt = await transaction.wait();
56
+ if (!transactionReceipt) {
57
+ throw new Error("Missing transaction receipt");
58
+ }
59
+ await this.context.confirmTransaction(transactionReceipt.hash, types_2.EventType.MatchOrders, "Fulfilling order");
60
+ return transactionReceipt.hash;
61
+ }
62
+ /**
63
+ * Fulfill an order for an asset. The order can be either a listing or an offer.
64
+ * Uses the OpenSea API to generate fulfillment transaction data and executes it directly.
65
+ * @param options
66
+ * @param options.order The order to fulfill, a.k.a. "take"
67
+ * @param options.accountAddress Address of the wallet taking the offer.
68
+ * @param options.assetContractAddress Optional address of the NFT contract for criteria offers (e.g., collection offers). Required when fulfilling collection offers.
69
+ * @param options.tokenId Optional token ID for criteria offers (e.g., collection offers). Required when fulfilling collection offers.
70
+ * @param options.unitsToFill Optional number of units to fill. Defaults to 1 for both listings and offers.
71
+ * @param options.recipientAddress Optional recipient address for the NFT when fulfilling a listing. Not applicable for offers.
72
+ * @param options.includeOptionalCreatorFees Whether to include optional creator fees in the fulfillment. If creator fees are already required, this is a no-op. Defaults to false.
73
+ * @param options.overrides Transaction overrides, ignored if not set.
74
+ * @returns Transaction hash of the order.
75
+ *
76
+ * @throws Error if the accountAddress is not available through wallet or provider.
77
+ * @throws Error if the order's protocol address is not supported by OpenSea. See {@link isValidProtocol}.
78
+ * @throws Error if a signer is not provided (read-only providers cannot fulfill orders).
79
+ * @throws Error if the order hash is not available.
80
+ */
81
+ async fulfillOrder({ order, accountAddress, assetContractAddress, tokenId, unitsToFill, recipientAddress, includeOptionalCreatorFees = false, overrides, }) {
82
+ await this.context.requireAccountIsAvailable(accountAddress);
83
+ const protocolAddress = order.protocolAddress ?? order.protocol_address;
84
+ (0, utils_2.requireValidProtocol)(protocolAddress);
85
+ const orderHash = order.orderHash ?? order.order_hash;
86
+ const side = order.side ??
87
+ ("type" in order &&
88
+ [types_1.OrderType.BASIC, types_1.OrderType.ENGLISH].includes(order.type)
89
+ ? types_2.OrderSide.LISTING
90
+ : types_2.OrderSide.OFFER);
91
+ const isPrivateListing = "taker" in order ? !!order.taker : false;
92
+ if (isPrivateListing) {
93
+ return this.fulfillPrivateOrder({
94
+ order: order,
95
+ accountAddress,
96
+ overrides,
97
+ });
98
+ }
99
+ // Get fulfillment data from the API
100
+ if (!orderHash) {
101
+ throw new Error("Order hash is required to fulfill an order");
102
+ }
103
+ // Convert unitsToFill to string, defaulting to "1" if not provided
104
+ const unitsToFillStr = unitsToFill !== undefined ? unitsToFill.toString() : "1";
105
+ const fulfillmentData = await this.context.api.generateFulfillmentData(accountAddress, orderHash, protocolAddress, side, assetContractAddress, tokenId, unitsToFillStr, recipientAddress, includeOptionalCreatorFees);
106
+ // Use the transaction data returned by the API
107
+ const transaction = fulfillmentData.fulfillment_data.transaction;
108
+ const inputData = transaction.input_data;
109
+ // Use Seaport ABI to encode the transaction
110
+ const seaportInterface = new ethers_1.ethers.Interface(Seaport_1.SeaportABI);
111
+ // Extract function name and build parameters array in correct order
112
+ const rawFunctionName = transaction.function.split("(")[0];
113
+ const functionName = rawFunctionName === FULFILL_BASIC_ORDER_ALIAS
114
+ ? "fulfillBasicOrder"
115
+ : rawFunctionName;
116
+ let params;
117
+ // Order parameters based on the function being called
118
+ if (functionName === "fulfillAdvancedOrder" &&
119
+ "advancedOrder" in inputData) {
120
+ params = [
121
+ inputData.advancedOrder,
122
+ inputData.criteriaResolvers || [],
123
+ inputData.fulfillerConduitKey ||
124
+ "0x0000000000000000000000000000000000000000000000000000000000000000",
125
+ inputData.recipient,
126
+ ];
127
+ }
128
+ else if ((functionName === "fulfillBasicOrder" ||
129
+ rawFunctionName === FULFILL_BASIC_ORDER_ALIAS) &&
130
+ "basicOrderParameters" in inputData) {
131
+ params = [inputData.basicOrderParameters];
132
+ }
133
+ else if (functionName === "fulfillOrder" && "order" in inputData) {
134
+ params = [
135
+ inputData.order,
136
+ inputData.fulfillerConduitKey ||
137
+ "0x0000000000000000000000000000000000000000000000000000000000000000",
138
+ ];
139
+ }
140
+ else {
141
+ // Fallback: try to use values in object order
142
+ params = Object.values(inputData);
143
+ }
144
+ const encodedData = seaportInterface.encodeFunctionData(functionName, params);
145
+ // Send the transaction using the signer from context
146
+ const signer = this.context.signerOrProvider;
147
+ const tx = await signer.sendTransaction({
148
+ to: transaction.to,
149
+ value: transaction.value,
150
+ data: encodedData,
151
+ ...overrides,
152
+ });
153
+ await this.context.confirmTransaction(tx.hash, types_2.EventType.MatchOrders, "Fulfilling order");
154
+ return tx.hash;
155
+ }
156
+ /**
157
+ * Returns whether an order is fulfillable.
158
+ * An order may not be fulfillable if a target item's transfer function
159
+ * is locked for some reason, e.g. an item is being rented within a game
160
+ * or trading has been locked for an item type.
161
+ * @param options
162
+ * @param options.order Order to check
163
+ * @param options.accountAddress The account address that will be fulfilling the order
164
+ * @returns True if the order is fulfillable, else False.
165
+ *
166
+ * @throws Error if the order's protocol address is not supported by OpenSea. See {@link isValidProtocol}.
167
+ */
168
+ async isOrderFulfillable({ order, accountAddress, }) {
169
+ (0, utils_2.requireValidProtocol)(order.protocolAddress);
170
+ const seaport = (0, utils_2.getSeaportInstance)(order.protocolAddress, this.context.seaport);
171
+ try {
172
+ const isValid = await seaport
173
+ .validate([order.protocolData], accountAddress)
174
+ .staticCall();
175
+ return !!isValid;
176
+ }
177
+ catch (error) {
178
+ if ((0, utils_2.hasErrorCode)(error) && error.code === "CALL_EXCEPTION") {
179
+ return false;
180
+ }
181
+ throw error;
182
+ }
183
+ }
184
+ /**
185
+ * Instead of signing an off-chain order, this method allows you to approve an order
186
+ * with an onchain transaction.
187
+ * @param order Order to approve
188
+ * @param domain An optional domain to be hashed and included at the end of fulfillment calldata. This can be used for onchain order attribution to assist with analytics.
189
+ * @returns Transaction hash of the approval transaction
190
+ *
191
+ * @throws Error if the accountAddress is not available through wallet or provider.
192
+ * @throws Error if the order's protocol address is not supported by OpenSea. See {@link isValidProtocol}.
193
+ */
194
+ async approveOrder(order, domain) {
195
+ await this.context.requireAccountIsAvailable(order.maker.address);
196
+ (0, utils_2.requireValidProtocol)(order.protocolAddress);
197
+ this.context.dispatch(types_2.EventType.ApproveOrder, {
198
+ orderV2: order,
199
+ accountAddress: order.maker.address,
200
+ });
201
+ const seaport = (0, utils_2.getSeaportInstance)(order.protocolAddress, this.context.seaport);
202
+ const transaction = await seaport
203
+ .validate([order.protocolData], order.maker.address, domain)
204
+ .transact();
205
+ await this.context.confirmTransaction(transaction.hash, types_2.EventType.ApproveOrder, "Approving order");
206
+ return transaction.hash;
207
+ }
208
+ /**
209
+ * Validates an order onchain using Seaport's validate() method. This submits the order onchain
210
+ * and pre-validates the order using Seaport, which makes it cheaper to fulfill since a signature
211
+ * is not needed to be verified during fulfillment for the order, but is not strictly required
212
+ * and the alternative is orders can be submitted to the API for free instead of sent onchain.
213
+ * @param orderComponents Order components to validate onchain
214
+ * @param accountAddress Address of the wallet that will pay the gas to validate the order
215
+ * @returns Transaction hash of the validation transaction
216
+ *
217
+ * @throws Error if the accountAddress is not available through wallet or provider.
218
+ */
219
+ async validateOrderOnchain(orderComponents, accountAddress) {
220
+ await this.context.requireAccountIsAvailable(accountAddress);
221
+ this.context.dispatch(types_2.EventType.ApproveOrder, {
222
+ orderV2: { protocolData: orderComponents },
223
+ accountAddress,
224
+ });
225
+ const seaport = (0, utils_2.getSeaportInstance)(utils_1.DEFAULT_SEAPORT_CONTRACT_ADDRESS, this.context.seaport);
226
+ const transaction = await seaport
227
+ .validate([{ parameters: orderComponents, signature: "0x" }], accountAddress)
228
+ .transact();
229
+ await this.context.confirmTransaction(transaction.hash, types_2.EventType.ApproveOrder, "Validating order onchain");
230
+ return transaction.hash;
231
+ }
232
+ /**
233
+ * Create and validate a listing onchain. Combines order building with onchain validation.
234
+ * Validation costs gas upfront but makes fulfillment cheaper (no signature verification needed).
235
+ * @param options
236
+ * @param options.asset The asset to trade. tokenAddress and tokenId must be defined.
237
+ * @param options.accountAddress Address of the wallet making the listing
238
+ * @param options.amount Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units.
239
+ * @param options.quantity Number of assets to list. Defaults to 1.
240
+ * @param options.domain Optional domain for onchain attribution. Hashed and included in salt.
241
+ * @param options.salt Arbitrary salt. Auto-generated if not provided.
242
+ * @param options.listingTime When order becomes fulfillable (UTC seconds). Defaults to now.
243
+ * @param options.expirationTime Expiration time (UTC seconds).
244
+ * @param options.buyerAddress Optional buyer restriction. Only this address can purchase.
245
+ * @param options.includeOptionalCreatorFees Include optional creator fees. Default: false.
246
+ * @param options.zone Zone for order protection. Defaults to no zone.
247
+ * @returns Transaction hash
248
+ *
249
+ * @throws Error if asset missing token id or accountAddress unavailable.
250
+ */
251
+ async createListingAndValidateOnchain({ asset, accountAddress, amount, quantity = 1, domain, salt, listingTime, expirationTime, buyerAddress, includeOptionalCreatorFees = false, zone, }) {
252
+ const orderComponents = await this.ordersManager.buildListingOrderComponents({
253
+ asset,
254
+ accountAddress,
255
+ amount,
256
+ quantity,
257
+ domain,
258
+ salt,
259
+ listingTime,
260
+ expirationTime,
261
+ buyerAddress,
262
+ includeOptionalCreatorFees,
263
+ zone,
264
+ });
265
+ return this.validateOrderOnchain(orderComponents, accountAddress);
266
+ }
267
+ /**
268
+ * Create and validate an offer onchain. Combines order building with onchain validation.
269
+ * Validation costs gas upfront but makes fulfillment cheaper (no signature verification needed).
270
+ * @param options
271
+ * @param options.asset The asset to trade. tokenAddress and tokenId must be defined.
272
+ * @param options.accountAddress Address of the wallet making the offer.
273
+ * @param options.amount Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units.
274
+ * @param options.quantity Number of assets to bid for. Defaults to 1.
275
+ * @param options.domain Optional domain for onchain attribution. Hashed and included in salt.
276
+ * @param options.salt Arbitrary salt. Auto-generated if not provided.
277
+ * @param options.expirationTime Expiration time (UTC seconds).
278
+ * @param options.zone Zone for order protection. Defaults to chain's signed zone.
279
+ * @returns Transaction hash
280
+ *
281
+ * @throws Error if asset missing token id or accountAddress unavailable.
282
+ */
283
+ async createOfferAndValidateOnchain({ asset, accountAddress, amount, quantity = 1, domain, salt, expirationTime, zone, }) {
284
+ const orderComponents = await this.ordersManager.buildOfferOrderComponents({
285
+ asset,
286
+ accountAddress,
287
+ amount,
288
+ quantity,
289
+ domain,
290
+ salt,
291
+ expirationTime,
292
+ zone,
293
+ });
294
+ return this.validateOrderOnchain(orderComponents, accountAddress);
295
+ }
296
+ }
297
+ exports.FulfillmentManager = FulfillmentManager;
298
+ //# sourceMappingURL=fulfillment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fulfillment.js","sourceRoot":"","sources":["../../src/sdk/fulfillment.ts"],"names":[],"mappings":";;;AAAA,iEAAgE;AAEhE,mCAA+E;AAE/E,+DAIkC;AAClC,2CAAyD;AACzD,2CAAkE;AAClE,oCAAsE;AACtE,0CAIuB;AAIvB,MAAM,yBAAyB,GAAG,oCAAoC,CAAA;AAEtE;;;GAGG;AACH,MAAa,kBAAkB;IAEnB;IACA;IAFV,YACU,OAAmB,EACnB,aAA4B;QAD5B,YAAO,GAAP,OAAO,CAAY;QACnB,kBAAa,GAAb,aAAa,CAAe;IACnC,CAAC;IAEJ;;;;;;;;;OASG;IACK,KAAK,CAAC,mBAAmB,CAAC,EAChC,KAAK,EACL,cAAc,EACd,MAAM,EACN,SAAS,GAMV;QACC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CACb,4DAA4D,CAC7D,CAAA;QACH,CAAC;QACD,MAAM,YAAY,GAAG,IAAA,qDAAmC,EACtD,KAAK,CAAC,YAAY,EAClB,KAAK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0B,CAC3B,CAAA;QAED,OAAO,WAAW,CAAC,IAAI,CAAA;IACzB,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,KAAK,CAAC,+BAA+B,CAAC,EACpC,KAAK,EACL,cAAc,EACd,MAAM,EACN,QAAQ,GAAG,CAAC,EACZ,MAAM,EACN,IAAI,EACJ,WAAW,EACX,cAAc,EACd,YAAY,EACZ,0BAA0B,GAAG,KAAK,EAClC,IAAI,GAaL;QACC,MAAM,eAAe,GACnB,MAAM,IAAI,CAAC,aAAa,CAAC,2BAA2B,CAAC;YACnD,KAAK;YACL,cAAc;YACd,MAAM;YACN,QAAQ;YACR,MAAM;YACN,IAAI;YACJ,WAAW;YACX,cAAc;YACd,YAAY;YACZ,0BAA0B;YAC1B,IAAI;SACL,CAAC,CAAA;QAEJ,OAAO,IAAI,CAAC,oBAAoB,CAAC,eAAe,EAAE,cAAc,CAAC,CAAA;IACnE,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,KAAK,CAAC,6BAA6B,CAAC,EAClC,KAAK,EACL,cAAc,EACd,MAAM,EACN,QAAQ,GAAG,CAAC,EACZ,MAAM,EACN,IAAI,EACJ,cAAc,EACd,IAAI,GAUL;QACC,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;YACzE,KAAK;YACL,cAAc;YACd,MAAM;YACN,QAAQ;YACR,MAAM;YACN,IAAI;YACJ,cAAc;YACd,IAAI;SACL,CAAC,CAAA;QAEF,OAAO,IAAI,CAAC,oBAAoB,CAAC,eAAe,EAAE,cAAc,CAAC,CAAA;IACnE,CAAC;CACF;AAncD,gDAmcC"}
@@ -0,0 +1,253 @@
1
+ import type { OrderComponents } from "@opensea/seaport-js/lib/types";
2
+ import { type BigNumberish } from "ethers";
3
+ import type { CollectionOffer } from "../api/types";
4
+ import type { OrderV2, ProtocolData } from "../orders/types";
5
+ import { type AssetWithTokenId, OrderSide } from "../types";
6
+ import type { SDKContext } from "./context";
7
+ /**
8
+ * Result type for bulk operations that may partially succeed.
9
+ * Contains successfully submitted orders and any failures with error information.
10
+ */
11
+ export interface BulkOrderResult {
12
+ /** Successfully submitted orders */
13
+ successful: OrderV2[];
14
+ /** Failed order submissions with error information */
15
+ failed: Array<{
16
+ /** Index of the failed order in the original input array */
17
+ index: number;
18
+ /** The signed order that failed to submit (undefined if order creation failed before signing) */
19
+ order?: ProtocolData;
20
+ /** The error that occurred during submission */
21
+ error: Error;
22
+ }>;
23
+ }
24
+ /**
25
+ * Manager for order building and creation operations.
26
+ * Handles listing creation, offer creation, and collection offers.
27
+ */
28
+ export declare class OrdersManager {
29
+ private context;
30
+ private getPriceParametersCallback;
31
+ constructor(context: SDKContext, getPriceParametersCallback: (orderSide: OrderSide, tokenAddress: string, amount: BigNumberish) => Promise<{
32
+ basePrice: bigint;
33
+ }>);
34
+ private getAmountWithBasisPointsApplied;
35
+ private isNotMarketplaceFee;
36
+ private getNFTItems;
37
+ private getFees;
38
+ /**
39
+ * Build listing order without submitting to API
40
+ * @param options Listing parameters
41
+ * @returns OrderWithCounter ready for API submission or onchain validation
42
+ */
43
+ private _buildListingOrder;
44
+ /**
45
+ * Build listing order components without submitting to API
46
+ * @param options Listing parameters
47
+ * @returns OrderComponents ready for onchain validation
48
+ */
49
+ buildListingOrderComponents({ asset, accountAddress, amount, quantity, domain, salt, listingTime, expirationTime, buyerAddress, includeOptionalCreatorFees, zone, }: {
50
+ asset: AssetWithTokenId;
51
+ accountAddress: string;
52
+ amount: BigNumberish;
53
+ quantity?: BigNumberish;
54
+ domain?: string;
55
+ salt?: BigNumberish;
56
+ listingTime?: number;
57
+ expirationTime?: number;
58
+ buyerAddress?: string;
59
+ includeOptionalCreatorFees?: boolean;
60
+ zone?: string;
61
+ }): Promise<OrderComponents>;
62
+ /**
63
+ * Build offer order without submitting to API
64
+ * @param options Offer parameters
65
+ * @returns OrderWithCounter ready for API submission or onchain validation
66
+ */
67
+ private _buildOfferOrder;
68
+ /**
69
+ * Build offer order components without submitting to API
70
+ * @param options Offer parameters
71
+ * @returns OrderComponents ready for onchain validation
72
+ */
73
+ buildOfferOrderComponents({ asset, accountAddress, amount, quantity, domain, salt, expirationTime, zone, }: {
74
+ asset: AssetWithTokenId;
75
+ accountAddress: string;
76
+ amount: BigNumberish;
77
+ quantity?: BigNumberish;
78
+ domain?: string;
79
+ salt?: BigNumberish;
80
+ expirationTime?: BigNumberish;
81
+ zone?: string;
82
+ }): Promise<OrderComponents>;
83
+ /**
84
+ * Create and submit an offer on an asset.
85
+ * @param options
86
+ * @param options.asset The asset to trade. tokenAddress and tokenId must be defined.
87
+ * @param options.accountAddress Address of the wallet making the offer.
88
+ * @param options.amount Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units.
89
+ * @param options.quantity Number of assets to bid for. Defaults to 1.
90
+ * @param options.domain Optional domain for onchain attribution. Hashed and included in salt.
91
+ * @param options.salt Arbitrary salt. Auto-generated if not provided.
92
+ * @param options.expirationTime Expiration time for the order, in UTC seconds
93
+ * @param options.zone Zone for order protection. Defaults to chain's signed zone.
94
+ *
95
+ * @returns The {@link OrderV2} that was created.
96
+ *
97
+ * @throws Error if the asset does not contain a token id.
98
+ * @throws Error if the accountAddress is not available through wallet or provider.
99
+ * @throws Error if the amount is not greater than 0.
100
+ */
101
+ createOffer({ asset, accountAddress, amount, quantity, domain, salt, expirationTime, zone, }: {
102
+ asset: AssetWithTokenId;
103
+ accountAddress: string;
104
+ amount: BigNumberish;
105
+ quantity?: BigNumberish;
106
+ domain?: string;
107
+ salt?: BigNumberish;
108
+ expirationTime?: BigNumberish;
109
+ zone?: string;
110
+ }): Promise<OrderV2>;
111
+ /**
112
+ * Create and submit a listing for an asset.
113
+ * @param options
114
+ * @param options.asset The asset to trade. tokenAddress and tokenId must be defined.
115
+ * @param options.accountAddress Address of the wallet making the listing
116
+ * @param options.amount Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units.
117
+ * @param options.quantity Number of assets to list. Defaults to 1.
118
+ * @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.
119
+ * @param options.salt Arbitrary salt. Auto-generated if not provided.
120
+ * @param options.listingTime Optional time when the order will become fulfillable, in UTC seconds. Undefined means it will start now.
121
+ * @param options.expirationTime Expiration time for the order, in UTC seconds.
122
+ * @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.
123
+ * @param options.includeOptionalCreatorFees If true, optional creator fees will be included in the listing. Default: false.
124
+ * @param options.zone Zone for order protection. Defaults to no zone.
125
+ * @returns The {@link OrderV2} that was created.
126
+ *
127
+ * @throws Error if the asset does not contain a token id.
128
+ * @throws Error if the accountAddress is not available through wallet or provider.
129
+ * @throws Error if the amount is not greater than 0.
130
+ */
131
+ createListing({ asset, accountAddress, amount, quantity, domain, salt, listingTime, expirationTime, buyerAddress, includeOptionalCreatorFees, zone, }: {
132
+ asset: AssetWithTokenId;
133
+ accountAddress: string;
134
+ amount: BigNumberish;
135
+ quantity?: BigNumberish;
136
+ domain?: string;
137
+ salt?: BigNumberish;
138
+ listingTime?: number;
139
+ expirationTime?: number;
140
+ buyerAddress?: string;
141
+ includeOptionalCreatorFees?: boolean;
142
+ zone?: string;
143
+ }): Promise<OrderV2>;
144
+ /**
145
+ * Create and submit multiple listings using Seaport's bulk order creation.
146
+ * This method uses a single signature for all listings and submits them individually to the OpenSea API with rate limit handling.
147
+ * All listings must be from the same account address.
148
+ *
149
+ * Note: If only one listing is provided, this method will use a normal order signature instead of a bulk signature,
150
+ * as bulk signatures are more expensive to decode onchain due to the merkle proof verification.
151
+ *
152
+ * @param options
153
+ * @param options.listings Array of listing parameters. Each listing requires asset, amount, and optionally other listing parameters.
154
+ * @param options.accountAddress Address of the wallet making the listings
155
+ * @param options.continueOnError If true, continue submitting remaining listings even if some fail. Default: false (throw on first error).
156
+ * @param options.onProgress Optional callback for progress updates. Called after each listing is submitted (successfully or not).
157
+ * @returns {@link BulkOrderResult} containing successful orders and any failures.
158
+ *
159
+ * @throws Error if listings array is empty
160
+ * @throws Error if the accountAddress is not available through wallet or provider.
161
+ * @throws Error if any asset does not contain a token id.
162
+ * @throws Error if continueOnError is false and any submission fails.
163
+ */
164
+ createBulkListings({ listings, accountAddress, continueOnError, onProgress, }: {
165
+ listings: Array<{
166
+ asset: AssetWithTokenId;
167
+ amount: BigNumberish;
168
+ quantity?: BigNumberish;
169
+ domain?: string;
170
+ salt?: BigNumberish;
171
+ listingTime?: number;
172
+ expirationTime?: number;
173
+ buyerAddress?: string;
174
+ includeOptionalCreatorFees?: boolean;
175
+ zone?: string;
176
+ }>;
177
+ accountAddress: string;
178
+ continueOnError?: boolean;
179
+ onProgress?: (completed: number, total: number) => void;
180
+ }): Promise<BulkOrderResult>;
181
+ /**
182
+ * Create and submit multiple offers using Seaport's bulk order creation.
183
+ * This method uses a single signature for all offers and submits them individually to the OpenSea API with rate limit handling.
184
+ * All offers must be from the same account address.
185
+ *
186
+ * Note: If only one offer is provided, this method will use a normal order signature instead of a bulk signature,
187
+ * as bulk signatures are more expensive to decode onchain due to the merkle proof verification.
188
+ *
189
+ * @param options
190
+ * @param options.offers Array of offer parameters. Each offer requires asset, amount, and optionally other offer parameters.
191
+ * @param options.accountAddress Address of the wallet making the offers
192
+ * @param options.continueOnError If true, continue submitting remaining offers even if some fail. Default: false (throw on first error).
193
+ * @param options.onProgress Optional callback for progress updates. Called after each offer is submitted (successfully or not).
194
+ * @returns {@link BulkOrderResult} containing successful orders and any failures.
195
+ *
196
+ * @throws Error if offers array is empty
197
+ * @throws Error if the accountAddress is not available through wallet or provider.
198
+ * @throws Error if any asset does not contain a token id.
199
+ * @throws Error if continueOnError is false and any submission fails.
200
+ */
201
+ createBulkOffers({ offers, accountAddress, continueOnError, onProgress, }: {
202
+ offers: Array<{
203
+ asset: AssetWithTokenId;
204
+ amount: BigNumberish;
205
+ quantity?: BigNumberish;
206
+ domain?: string;
207
+ salt?: BigNumberish;
208
+ expirationTime?: BigNumberish;
209
+ zone?: string;
210
+ }>;
211
+ accountAddress: string;
212
+ continueOnError?: boolean;
213
+ onProgress?: (completed: number, total: number) => void;
214
+ }): Promise<BulkOrderResult>;
215
+ /**
216
+ * Create and submit a collection offer.
217
+ * @param options
218
+ * @param options.collectionSlug Identifier for the collection.
219
+ * @param options.accountAddress Address of the wallet making the offer.
220
+ * @param options.amount Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units.
221
+ * @param options.quantity Number of assets to bid for.
222
+ * @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.
223
+ * @param options.salt Arbitrary salt. Auto-generated if not provided.
224
+ * @param options.expirationTime Expiration time for the order, in UTC seconds.
225
+ * @param options.offerProtectionEnabled Use signed zone for protection against disabled items. Default: true.
226
+ * @param options.traitType If defined, the trait name to create the collection offer for.
227
+ * @param options.traitValue If defined, the trait value to create the collection offer for.
228
+ * @param options.traits If defined, an array of traits to create the multi-trait collection offer for.
229
+ * @param options.numericTraits If defined, an array of numeric trait criteria with min/max ranges.
230
+ * @returns The {@link CollectionOffer} that was created.
231
+ */
232
+ createCollectionOffer({ collectionSlug, accountAddress, amount, quantity, domain, salt, expirationTime, offerProtectionEnabled, traitType, traitValue, traits, numericTraits, }: {
233
+ collectionSlug: string;
234
+ accountAddress: string;
235
+ amount: BigNumberish;
236
+ quantity: number;
237
+ domain?: string;
238
+ salt?: BigNumberish;
239
+ expirationTime?: number | string;
240
+ offerProtectionEnabled?: boolean;
241
+ traitType?: string;
242
+ traitValue?: string;
243
+ traits?: Array<{
244
+ type: string;
245
+ value: string;
246
+ }>;
247
+ numericTraits?: Array<{
248
+ type: string;
249
+ min?: number;
250
+ max?: number;
251
+ }>;
252
+ }): Promise<CollectionOffer | null>;
253
+ }