@opensea/sdk 9.0.0 → 10.1.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 (311) hide show
  1. package/README.md +35 -6
  2. package/lib/abi/abis.d.ts +301 -0
  3. package/lib/abi/abis.js +231 -0
  4. package/lib/abi/abis.js.map +1 -0
  5. package/lib/api/api.d.ts +26 -2
  6. package/lib/api/api.js +83 -51
  7. package/lib/api/api.js.map +1 -1
  8. package/lib/api/apiPaths.d.ts +2 -0
  9. package/lib/api/apiPaths.js +9 -1
  10. package/lib/api/apiPaths.js.map +1 -1
  11. package/lib/api/nfts.d.ts +13 -2
  12. package/lib/api/nfts.js +18 -0
  13. package/lib/api/nfts.js.map +1 -1
  14. package/lib/api/orders.js +2 -2
  15. package/lib/api/orders.js.map +1 -1
  16. package/lib/api/types.d.ts +7 -0
  17. package/lib/api/types.js.map +1 -1
  18. package/lib/constants.d.ts +2 -2
  19. package/lib/constants.js +7 -4
  20. package/lib/constants.js.map +1 -1
  21. package/lib/index.d.ts +2 -0
  22. package/lib/index.js +1 -0
  23. package/lib/index.js.map +1 -1
  24. package/lib/orders/privateListings.js +2 -2
  25. package/lib/orders/privateListings.js.map +1 -1
  26. package/lib/orders/utils.js +9 -1
  27. package/lib/orders/utils.js.map +1 -1
  28. package/lib/provider/ethers-adapter.d.ts +17 -0
  29. package/lib/provider/ethers-adapter.js +135 -0
  30. package/lib/provider/ethers-adapter.js.map +1 -0
  31. package/lib/provider/seaport-bridge.d.ts +11 -0
  32. package/lib/provider/seaport-bridge.js +130 -0
  33. package/lib/provider/seaport-bridge.js.map +1 -0
  34. package/lib/provider/types.d.ts +62 -0
  35. package/lib/provider/types.js +7 -0
  36. package/lib/provider/types.js.map +1 -0
  37. package/lib/provider/viem-adapter.d.ts +27 -0
  38. package/lib/provider/viem-adapter.js +122 -0
  39. package/lib/provider/viem-adapter.js.map +1 -0
  40. package/lib/sdk/assets.d.ts +7 -23
  41. package/lib/sdk/assets.js +101 -77
  42. package/lib/sdk/assets.js.map +1 -1
  43. package/lib/sdk/base.d.ts +350 -0
  44. package/lib/sdk/base.js +325 -0
  45. package/lib/sdk/base.js.map +1 -0
  46. package/lib/sdk/cancellation.d.ts +1 -2
  47. package/lib/sdk/cancellation.js +4 -4
  48. package/lib/sdk/cancellation.js.map +1 -1
  49. package/lib/sdk/context.d.ts +5 -5
  50. package/lib/sdk/fulfillment.d.ts +20 -59
  51. package/lib/sdk/fulfillment.js +18 -58
  52. package/lib/sdk/fulfillment.js.map +1 -1
  53. package/lib/sdk/orders.d.ts +25 -26
  54. package/lib/sdk/orders.js +8 -9
  55. package/lib/sdk/orders.js.map +1 -1
  56. package/lib/sdk/tokens.d.ts +3 -3
  57. package/lib/sdk/tokens.js +17 -7
  58. package/lib/sdk/tokens.js.map +1 -1
  59. package/lib/sdk.d.ts +16 -550
  60. package/lib/sdk.js +35 -663
  61. package/lib/sdk.js.map +1 -1
  62. package/lib/types.d.ts +11 -6
  63. package/lib/types.js +3 -3
  64. package/lib/types.js.map +1 -1
  65. package/lib/utils/address.d.ts +12 -0
  66. package/lib/utils/address.js +39 -0
  67. package/lib/utils/address.js.map +1 -0
  68. package/lib/utils/chain.d.ts +1 -1
  69. package/lib/utils/fees.d.ts +5 -0
  70. package/lib/utils/fees.js +24 -6
  71. package/lib/utils/fees.js.map +1 -1
  72. package/lib/utils/protocol.js +5 -5
  73. package/lib/utils/protocol.js.map +1 -1
  74. package/lib/utils/units.d.ts +12 -0
  75. package/lib/utils/units.js +43 -0
  76. package/lib/utils/units.js.map +1 -0
  77. package/lib/utils/utils.d.ts +2 -10
  78. package/lib/utils/utils.js +2 -17
  79. package/lib/utils/utils.js.map +1 -1
  80. package/lib/viem.d.ts +44 -0
  81. package/lib/viem.js +114 -0
  82. package/lib/viem.js.map +1 -0
  83. package/package.json +31 -13
  84. package/src/abi/abis.ts +236 -0
  85. package/src/api/api.ts +100 -59
  86. package/src/api/apiPaths.ts +16 -0
  87. package/src/api/nfts.ts +37 -1
  88. package/src/api/orders.ts +2 -2
  89. package/src/api/types.ts +8 -0
  90. package/src/constants.ts +7 -3
  91. package/src/index.ts +8 -0
  92. package/src/orders/privateListings.ts +2 -2
  93. package/src/orders/utils.ts +8 -1
  94. package/src/provider/ethers-adapter.ts +182 -0
  95. package/src/provider/seaport-bridge.ts +163 -0
  96. package/src/provider/types.ts +67 -0
  97. package/src/provider/viem-adapter.ts +165 -0
  98. package/src/sdk/assets.ts +128 -158
  99. package/src/sdk/base.ts +577 -0
  100. package/src/sdk/cancellation.ts +6 -9
  101. package/src/sdk/context.ts +5 -5
  102. package/src/sdk/fulfillment.ts +34 -73
  103. package/src/sdk/orders.ts +44 -44
  104. package/src/sdk/tokens.ts +18 -18
  105. package/src/sdk.ts +40 -1011
  106. package/src/types.ts +12 -6
  107. package/src/utils/address.ts +40 -0
  108. package/src/utils/fees.ts +28 -8
  109. package/src/utils/protocol.ts +5 -5
  110. package/src/utils/units.ts +47 -0
  111. package/src/utils/utils.ts +2 -22
  112. package/src/viem.ts +125 -0
  113. package/lib/src/api/accounts.d.ts +0 -18
  114. package/lib/src/api/accounts.js +0 -30
  115. package/lib/src/api/accounts.js.map +0 -1
  116. package/lib/src/api/api.d.ts +0 -429
  117. package/lib/src/api/api.js +0 -652
  118. package/lib/src/api/api.js.map +0 -1
  119. package/lib/src/api/apiPaths.d.ts +0 -37
  120. package/lib/src/api/apiPaths.js +0 -140
  121. package/lib/src/api/apiPaths.js.map +0 -1
  122. package/lib/src/api/collections.d.ts +0 -26
  123. package/lib/src/api/collections.js +0 -57
  124. package/lib/src/api/collections.js.map +0 -1
  125. package/lib/src/api/events.d.ts +0 -26
  126. package/lib/src/api/events.js +0 -42
  127. package/lib/src/api/events.js.map +0 -1
  128. package/lib/src/api/fetcher.d.ts +0 -24
  129. package/lib/src/api/fetcher.js +0 -3
  130. package/lib/src/api/fetcher.js.map +0 -1
  131. package/lib/src/api/index.d.ts +0 -2
  132. package/lib/src/api/index.js +0 -19
  133. package/lib/src/api/index.js.map +0 -1
  134. package/lib/src/api/listings.d.ts +0 -44
  135. package/lib/src/api/listings.js +0 -86
  136. package/lib/src/api/listings.js.map +0 -1
  137. package/lib/src/api/nfts.d.ts +0 -35
  138. package/lib/src/api/nfts.js +0 -66
  139. package/lib/src/api/nfts.js.map +0 -1
  140. package/lib/src/api/offers.d.ts +0 -54
  141. package/lib/src/api/offers.js +0 -122
  142. package/lib/src/api/offers.js.map +0 -1
  143. package/lib/src/api/orders.d.ts +0 -50
  144. package/lib/src/api/orders.js +0 -151
  145. package/lib/src/api/orders.js.map +0 -1
  146. package/lib/src/api/search.d.ts +0 -13
  147. package/lib/src/api/search.js +0 -21
  148. package/lib/src/api/search.js.map +0 -1
  149. package/lib/src/api/tokens.d.ts +0 -25
  150. package/lib/src/api/tokens.js +0 -42
  151. package/lib/src/api/tokens.js.map +0 -1
  152. package/lib/src/api/types.d.ts +0 -840
  153. package/lib/src/api/types.js +0 -65
  154. package/lib/src/api/types.js.map +0 -1
  155. package/lib/src/constants.d.ts +0 -22
  156. package/lib/src/constants.js +0 -52
  157. package/lib/src/constants.js.map +0 -1
  158. package/lib/src/index.d.ts +0 -18
  159. package/lib/src/index.js +0 -24
  160. package/lib/src/index.js.map +0 -1
  161. package/lib/src/orders/privateListings.d.ts +0 -12
  162. package/lib/src/orders/privateListings.js +0 -130
  163. package/lib/src/orders/privateListings.js.map +0 -1
  164. package/lib/src/orders/types.d.ts +0 -160
  165. package/lib/src/orders/types.js +0 -10
  166. package/lib/src/orders/types.js.map +0 -1
  167. package/lib/src/orders/utils.d.ts +0 -89
  168. package/lib/src/orders/utils.js +0 -177
  169. package/lib/src/orders/utils.js.map +0 -1
  170. package/lib/src/sdk/assets.d.ts +0 -104
  171. package/lib/src/sdk/assets.js +0 -397
  172. package/lib/src/sdk/assets.js.map +0 -1
  173. package/lib/src/sdk/cancellation.d.ts +0 -97
  174. package/lib/src/sdk/cancellation.js +0 -234
  175. package/lib/src/sdk/cancellation.js.map +0 -1
  176. package/lib/src/sdk/context.d.ts +0 -28
  177. package/lib/src/sdk/context.js +0 -3
  178. package/lib/src/sdk/context.js.map +0 -1
  179. package/lib/src/sdk/fulfillment.d.ts +0 -153
  180. package/lib/src/sdk/fulfillment.js +0 -296
  181. package/lib/src/sdk/fulfillment.js.map +0 -1
  182. package/lib/src/sdk/orders.d.ts +0 -253
  183. package/lib/src/sdk/orders.js +0 -677
  184. package/lib/src/sdk/orders.js.map +0 -1
  185. package/lib/src/sdk/tokens.d.ts +0 -31
  186. package/lib/src/sdk/tokens.js +0 -64
  187. package/lib/src/sdk/tokens.js.map +0 -1
  188. package/lib/src/sdk.d.ts +0 -560
  189. package/lib/src/sdk.js +0 -675
  190. package/lib/src/sdk.js.map +0 -1
  191. package/lib/src/typechain/contracts/ERC1155.d.ts +0 -236
  192. package/lib/src/typechain/contracts/ERC1155.js +0 -3
  193. package/lib/src/typechain/contracts/ERC1155.js.map +0 -1
  194. package/lib/src/typechain/contracts/ERC20.d.ts +0 -141
  195. package/lib/src/typechain/contracts/ERC20.js +0 -3
  196. package/lib/src/typechain/contracts/ERC20.js.map +0 -1
  197. package/lib/src/typechain/contracts/ERC721.d.ts +0 -213
  198. package/lib/src/typechain/contracts/ERC721.js +0 -3
  199. package/lib/src/typechain/contracts/ERC721.js.map +0 -1
  200. package/lib/src/typechain/contracts/Multicall3.d.ts +0 -57
  201. package/lib/src/typechain/contracts/Multicall3.js +0 -3
  202. package/lib/src/typechain/contracts/Multicall3.js.map +0 -1
  203. package/lib/src/typechain/contracts/TransferHelper.d.ts +0 -55
  204. package/lib/src/typechain/contracts/TransferHelper.js +0 -3
  205. package/lib/src/typechain/contracts/TransferHelper.js.map +0 -1
  206. package/lib/src/typechain/contracts/common.d.ts +0 -50
  207. package/lib/src/typechain/contracts/common.js +0 -3
  208. package/lib/src/typechain/contracts/common.js.map +0 -1
  209. package/lib/src/typechain/contracts/factories/ERC1155__factory.d.ts +0 -250
  210. package/lib/src/typechain/contracts/factories/ERC1155__factory.js +0 -332
  211. package/lib/src/typechain/contracts/factories/ERC1155__factory.js.map +0 -1
  212. package/lib/src/typechain/contracts/factories/ERC20__factory.d.ts +0 -174
  213. package/lib/src/typechain/contracts/factories/ERC20__factory.js +0 -240
  214. package/lib/src/typechain/contracts/factories/ERC20__factory.js.map +0 -1
  215. package/lib/src/typechain/contracts/factories/ERC721__factory.d.ts +0 -268
  216. package/lib/src/typechain/contracts/factories/ERC721__factory.js +0 -351
  217. package/lib/src/typechain/contracts/factories/ERC721__factory.js.map +0 -1
  218. package/lib/src/typechain/contracts/factories/Multicall3__factory.d.ts +0 -43
  219. package/lib/src/typechain/contracts/factories/Multicall3__factory.js +0 -68
  220. package/lib/src/typechain/contracts/factories/Multicall3__factory.js.map +0 -1
  221. package/lib/src/typechain/contracts/factories/TransferHelper__factory.d.ts +0 -46
  222. package/lib/src/typechain/contracts/factories/TransferHelper__factory.js +0 -71
  223. package/lib/src/typechain/contracts/factories/TransferHelper__factory.js.map +0 -1
  224. package/lib/src/typechain/contracts/factories/index.d.ts +0 -5
  225. package/lib/src/typechain/contracts/factories/index.js +0 -17
  226. package/lib/src/typechain/contracts/factories/index.js.map +0 -1
  227. package/lib/src/typechain/contracts/index.d.ts +0 -11
  228. package/lib/src/typechain/contracts/index.js +0 -48
  229. package/lib/src/typechain/contracts/index.js.map +0 -1
  230. package/lib/src/types.d.ts +0 -387
  231. package/lib/src/types.js +0 -127
  232. package/lib/src/types.js.map +0 -1
  233. package/lib/src/utils/chain.d.ts +0 -60
  234. package/lib/src/utils/chain.js +0 -248
  235. package/lib/src/utils/chain.js.map +0 -1
  236. package/lib/src/utils/converters.d.ts +0 -37
  237. package/lib/src/utils/converters.js +0 -137
  238. package/lib/src/utils/converters.js.map +0 -1
  239. package/lib/src/utils/dateHelper.d.ts +0 -38
  240. package/lib/src/utils/dateHelper.js +0 -52
  241. package/lib/src/utils/dateHelper.js.map +0 -1
  242. package/lib/src/utils/fees.d.ts +0 -13
  243. package/lib/src/utils/fees.js +0 -29
  244. package/lib/src/utils/fees.js.map +0 -1
  245. package/lib/src/utils/index.d.ts +0 -2
  246. package/lib/src/utils/index.js +0 -19
  247. package/lib/src/utils/index.js.map +0 -1
  248. package/lib/src/utils/protocol.d.ts +0 -75
  249. package/lib/src/utils/protocol.js +0 -161
  250. package/lib/src/utils/protocol.js.map +0 -1
  251. package/lib/src/utils/rateLimit.d.ts +0 -34
  252. package/lib/src/utils/rateLimit.js +0 -97
  253. package/lib/src/utils/rateLimit.js.map +0 -1
  254. package/lib/src/utils/stringHelper.d.ts +0 -18
  255. package/lib/src/utils/stringHelper.js +0 -24
  256. package/lib/src/utils/stringHelper.js.map +0 -1
  257. package/lib/src/utils/utils.d.ts +0 -18
  258. package/lib/src/utils/utils.js +0 -45
  259. package/lib/src/utils/utils.js.map +0 -1
  260. package/lib/typechain/contracts/ERC1155.d.ts +0 -236
  261. package/lib/typechain/contracts/ERC1155.js +0 -3
  262. package/lib/typechain/contracts/ERC1155.js.map +0 -1
  263. package/lib/typechain/contracts/ERC20.d.ts +0 -141
  264. package/lib/typechain/contracts/ERC20.js +0 -3
  265. package/lib/typechain/contracts/ERC20.js.map +0 -1
  266. package/lib/typechain/contracts/ERC721.d.ts +0 -213
  267. package/lib/typechain/contracts/ERC721.js +0 -3
  268. package/lib/typechain/contracts/ERC721.js.map +0 -1
  269. package/lib/typechain/contracts/Multicall3.d.ts +0 -57
  270. package/lib/typechain/contracts/Multicall3.js +0 -3
  271. package/lib/typechain/contracts/Multicall3.js.map +0 -1
  272. package/lib/typechain/contracts/TransferHelper.d.ts +0 -55
  273. package/lib/typechain/contracts/TransferHelper.js +0 -3
  274. package/lib/typechain/contracts/TransferHelper.js.map +0 -1
  275. package/lib/typechain/contracts/common.d.ts +0 -50
  276. package/lib/typechain/contracts/common.js +0 -3
  277. package/lib/typechain/contracts/common.js.map +0 -1
  278. package/lib/typechain/contracts/factories/ERC1155__factory.d.ts +0 -250
  279. package/lib/typechain/contracts/factories/ERC1155__factory.js +0 -332
  280. package/lib/typechain/contracts/factories/ERC1155__factory.js.map +0 -1
  281. package/lib/typechain/contracts/factories/ERC20__factory.d.ts +0 -174
  282. package/lib/typechain/contracts/factories/ERC20__factory.js +0 -240
  283. package/lib/typechain/contracts/factories/ERC20__factory.js.map +0 -1
  284. package/lib/typechain/contracts/factories/ERC721__factory.d.ts +0 -268
  285. package/lib/typechain/contracts/factories/ERC721__factory.js +0 -351
  286. package/lib/typechain/contracts/factories/ERC721__factory.js.map +0 -1
  287. package/lib/typechain/contracts/factories/Multicall3__factory.d.ts +0 -43
  288. package/lib/typechain/contracts/factories/Multicall3__factory.js +0 -68
  289. package/lib/typechain/contracts/factories/Multicall3__factory.js.map +0 -1
  290. package/lib/typechain/contracts/factories/TransferHelper__factory.d.ts +0 -46
  291. package/lib/typechain/contracts/factories/TransferHelper__factory.js +0 -71
  292. package/lib/typechain/contracts/factories/TransferHelper__factory.js.map +0 -1
  293. package/lib/typechain/contracts/factories/index.d.ts +0 -5
  294. package/lib/typechain/contracts/factories/index.js +0 -17
  295. package/lib/typechain/contracts/factories/index.js.map +0 -1
  296. package/lib/typechain/contracts/index.d.ts +0 -11
  297. package/lib/typechain/contracts/index.js +0 -48
  298. package/lib/typechain/contracts/index.js.map +0 -1
  299. package/src/typechain/contracts/ERC1155.ts +0 -440
  300. package/src/typechain/contracts/ERC20.ts +0 -286
  301. package/src/typechain/contracts/ERC721.ts +0 -412
  302. package/src/typechain/contracts/Multicall3.ts +0 -117
  303. package/src/typechain/contracts/TransferHelper.ts +0 -122
  304. package/src/typechain/contracts/common.ts +0 -131
  305. package/src/typechain/contracts/factories/ERC1155__factory.ts +0 -331
  306. package/src/typechain/contracts/factories/ERC20__factory.ts +0 -239
  307. package/src/typechain/contracts/factories/ERC721__factory.ts +0 -350
  308. package/src/typechain/contracts/factories/Multicall3__factory.ts +0 -67
  309. package/src/typechain/contracts/factories/TransferHelper__factory.ts +0 -76
  310. package/src/typechain/contracts/factories/index.ts +0 -8
  311. package/src/typechain/contracts/index.ts +0 -14
@@ -1,6 +1,5 @@
1
1
  import { SeaportABI } from "@opensea/seaport-js/lib/abi/Seaport"
2
2
  import type { OrderComponents } from "@opensea/seaport-js/lib/types"
3
- import { type BigNumberish, ethers, type Overrides, type Signer } from "ethers"
4
3
  import type { Listing, Offer, Order } from "../api/types"
5
4
  import {
6
5
  computePrivateListingValue,
@@ -9,7 +8,12 @@ import {
9
8
  } from "../orders/privateListings"
10
9
  import { OrderType, type OrderV2 } from "../orders/types"
11
10
  import { DEFAULT_SEAPORT_CONTRACT_ADDRESS } from "../orders/utils"
12
- import { type AssetWithTokenId, EventType, OrderSide } from "../types"
11
+ import {
12
+ type Amount,
13
+ type AssetWithTokenId,
14
+ EventType,
15
+ OrderSide,
16
+ } from "../types"
13
17
  import {
14
18
  getSeaportInstance,
15
19
  hasErrorCode,
@@ -32,15 +36,9 @@ export class FulfillmentManager {
32
36
 
33
37
  /**
34
38
  * Fulfill a private order for a designated address.
35
- * @param options
36
- * @param options.order The order to fulfill
37
- * @param options.accountAddress Address of the wallet taking the order.
38
- * @param options.domain An optional domain to be hashed and included at the end of fulfillment calldata.
39
- * This can be used for onchain order attribution to assist with analytics.
40
- * @param options.overrides Transaction overrides, ignored if not set.
41
- * @returns Transaction hash of the order.
39
+ * The order must have a taker address set (i.e., it is a private listing).
42
40
  */
43
- private async fulfillPrivateOrder({
41
+ async fulfillPrivateOrder({
44
42
  order,
45
43
  accountAddress,
46
44
  domain,
@@ -49,8 +47,9 @@ export class FulfillmentManager {
49
47
  order: OrderV2
50
48
  accountAddress: string
51
49
  domain?: string
52
- overrides?: Overrides
50
+ overrides?: Record<string, unknown>
53
51
  }): Promise<string> {
52
+ await this.context.requireAccountIsAvailable(accountAddress)
54
53
  if (!order.taker?.address) {
55
54
  throw new Error(
56
55
  "Order is not a private listing - must have a taker address",
@@ -62,8 +61,6 @@ export class FulfillmentManager {
62
61
  )
63
62
  const fulfillments = getPrivateListingFulfillments(order.protocolData)
64
63
 
65
- // Compute ETH value from original order's consideration items
66
- // This handles both standard private listings and zero-payment listings (e.g., rewards)
67
64
  const value = computePrivateListingValue(
68
65
  order.protocolData,
69
66
  order.taker.address,
@@ -131,10 +128,10 @@ export class FulfillmentManager {
131
128
  accountAddress: string
132
129
  assetContractAddress?: string
133
130
  tokenId?: string
134
- unitsToFill?: BigNumberish
131
+ unitsToFill?: Amount
135
132
  recipientAddress?: string
136
133
  includeOptionalCreatorFees?: boolean
137
- overrides?: Overrides
134
+ overrides?: Record<string, unknown>
138
135
  }): Promise<string> {
139
136
  await this.context.requireAccountIsAvailable(accountAddress)
140
137
 
@@ -186,9 +183,6 @@ export class FulfillmentManager {
186
183
  const transaction = fulfillmentData.fulfillment_data.transaction
187
184
  const inputData = transaction.input_data
188
185
 
189
- // Use Seaport ABI to encode the transaction
190
- const seaportInterface = new ethers.Interface(SeaportABI)
191
-
192
186
  // Extract function name and build parameters array in correct order
193
187
  const rawFunctionName = transaction.function.split("(")[0]
194
188
  const functionName =
@@ -226,18 +220,22 @@ export class FulfillmentManager {
226
220
  params = Object.values(inputData)
227
221
  }
228
222
 
229
- const encodedData = seaportInterface.encodeFunctionData(
223
+ const encodedData = this.context.contractCaller.encodeFunctionData({
224
+ abi: SeaportABI,
230
225
  functionName,
231
- params,
232
- )
226
+ args: params,
227
+ })
233
228
 
234
- // Send the transaction using the signer from context
235
- const signer = this.context.signerOrProvider as Signer
236
- const tx = await signer.sendTransaction({
229
+ // Send the transaction using the signer from wallet
230
+ const wallet = this.context.wallet
231
+ if (!("signer" in wallet)) {
232
+ throw new Error("A signer is required to fulfill orders")
233
+ }
234
+ const tx = await wallet.signer.sendTransaction({
237
235
  to: transaction.to,
238
- value: transaction.value,
236
+ value: BigInt(transaction.value),
239
237
  data: encodedData,
240
- ...overrides,
238
+ overrides: overrides as Record<string, unknown>,
241
239
  })
242
240
 
243
241
  await this.context.confirmTransaction(
@@ -324,15 +322,7 @@ export class FulfillmentManager {
324
322
  }
325
323
 
326
324
  /**
327
- * Validates an order onchain using Seaport's validate() method. This submits the order onchain
328
- * and pre-validates the order using Seaport, which makes it cheaper to fulfill since a signature
329
- * is not needed to be verified during fulfillment for the order, but is not strictly required
330
- * and the alternative is orders can be submitted to the API for free instead of sent onchain.
331
- * @param orderComponents Order components to validate onchain
332
- * @param accountAddress Address of the wallet that will pay the gas to validate the order
333
- * @returns Transaction hash of the validation transaction
334
- *
335
- * @throws Error if the accountAddress is not available through wallet or provider.
325
+ * Validates an order onchain using Seaport's validate() method.
336
326
  */
337
327
  async validateOrderOnchain(
338
328
  orderComponents: OrderComponents,
@@ -366,23 +356,7 @@ export class FulfillmentManager {
366
356
  }
367
357
 
368
358
  /**
369
- * Create and validate a listing onchain. Combines order building with onchain validation.
370
- * Validation costs gas upfront but makes fulfillment cheaper (no signature verification needed).
371
- * @param options
372
- * @param options.asset The asset to trade. tokenAddress and tokenId must be defined.
373
- * @param options.accountAddress Address of the wallet making the listing
374
- * @param options.amount Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units.
375
- * @param options.quantity Number of assets to list. Defaults to 1.
376
- * @param options.domain Optional domain for onchain attribution. Hashed and included in salt.
377
- * @param options.salt Arbitrary salt. Auto-generated if not provided.
378
- * @param options.listingTime When order becomes fulfillable (UTC seconds). Defaults to now.
379
- * @param options.expirationTime Expiration time (UTC seconds).
380
- * @param options.buyerAddress Optional buyer restriction. Only this address can purchase.
381
- * @param options.includeOptionalCreatorFees Include optional creator fees. Default: false.
382
- * @param options.zone Zone for order protection. Defaults to no zone.
383
- * @returns Transaction hash
384
- *
385
- * @throws Error if asset missing token id or accountAddress unavailable.
359
+ * Create and validate a listing onchain.
386
360
  */
387
361
  async createListingAndValidateOnchain({
388
362
  asset,
@@ -399,10 +373,10 @@ export class FulfillmentManager {
399
373
  }: {
400
374
  asset: AssetWithTokenId
401
375
  accountAddress: string
402
- amount: BigNumberish
403
- quantity?: BigNumberish
376
+ amount: Amount
377
+ quantity?: Amount
404
378
  domain?: string
405
- salt?: BigNumberish
379
+ salt?: Amount
406
380
  listingTime?: number
407
381
  expirationTime?: number
408
382
  buyerAddress?: string
@@ -428,20 +402,7 @@ export class FulfillmentManager {
428
402
  }
429
403
 
430
404
  /**
431
- * Create and validate an offer onchain. Combines order building with onchain validation.
432
- * Validation costs gas upfront but makes fulfillment cheaper (no signature verification needed).
433
- * @param options
434
- * @param options.asset The asset to trade. tokenAddress and tokenId must be defined.
435
- * @param options.accountAddress Address of the wallet making the offer.
436
- * @param options.amount Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units.
437
- * @param options.quantity Number of assets to bid for. Defaults to 1.
438
- * @param options.domain Optional domain for onchain attribution. Hashed and included in salt.
439
- * @param options.salt Arbitrary salt. Auto-generated if not provided.
440
- * @param options.expirationTime Expiration time (UTC seconds).
441
- * @param options.zone Zone for order protection. Defaults to chain's signed zone.
442
- * @returns Transaction hash
443
- *
444
- * @throws Error if asset missing token id or accountAddress unavailable.
405
+ * Create and validate an offer onchain.
445
406
  */
446
407
  async createOfferAndValidateOnchain({
447
408
  asset,
@@ -455,11 +416,11 @@ export class FulfillmentManager {
455
416
  }: {
456
417
  asset: AssetWithTokenId
457
418
  accountAddress: string
458
- amount: BigNumberish
459
- quantity?: BigNumberish
419
+ amount: Amount
420
+ quantity?: Amount
460
421
  domain?: string
461
- salt?: BigNumberish
462
- expirationTime?: BigNumberish
422
+ salt?: Amount
423
+ expirationTime?: Amount
463
424
  zone?: string
464
425
  }): Promise<string> {
465
426
  const orderComponents = await this.ordersManager.buildOfferOrderComponents({
package/src/sdk/orders.ts CHANGED
@@ -3,11 +3,11 @@ import type {
3
3
  CreateInputItem,
4
4
  OrderComponents,
5
5
  } from "@opensea/seaport-js/lib/types"
6
- import { type BigNumberish, ZeroAddress } from "ethers"
7
6
  import type { CollectionOffer, NFT } from "../api/types"
8
- import { INVERSE_BASIS_POINT } from "../constants"
7
+ import { INVERSE_BASIS_POINT, ZERO_ADDRESS } from "../constants"
9
8
  import type { OrderV2, ProtocolData } from "../orders/types"
10
9
  import {
10
+ type Amount,
11
11
  type AssetWithTokenId,
12
12
  type Fee,
13
13
  type OpenSeaCollection,
@@ -56,7 +56,7 @@ export class OrdersManager {
56
56
  private getPriceParametersCallback: (
57
57
  orderSide: OrderSide,
58
58
  tokenAddress: string,
59
- amount: BigNumberish,
59
+ amount: Amount,
60
60
  ) => Promise<{ basePrice: bigint }>,
61
61
  ) {}
62
62
 
@@ -153,14 +153,14 @@ export class OrdersManager {
153
153
  expirationTime,
154
154
  buyerAddress,
155
155
  includeOptionalCreatorFees = false,
156
- zone = ZeroAddress,
156
+ zone = ZERO_ADDRESS,
157
157
  }: {
158
158
  asset: AssetWithTokenId
159
159
  accountAddress: string
160
- amount: BigNumberish
161
- quantity?: BigNumberish
160
+ amount: Amount
161
+ quantity?: Amount
162
162
  domain?: string
163
- salt?: BigNumberish
163
+ salt?: Amount
164
164
  listingTime?: number
165
165
  expirationTime?: number
166
166
  buyerAddress?: string
@@ -219,7 +219,7 @@ export class OrdersManager {
219
219
  zone,
220
220
  domain,
221
221
  salt: BigInt(salt ?? 0).toString(),
222
- restrictedByZone: zone !== ZeroAddress,
222
+ restrictedByZone: zone !== ZERO_ADDRESS,
223
223
  allowPartialFills: true,
224
224
  },
225
225
  accountAddress,
@@ -244,14 +244,14 @@ export class OrdersManager {
244
244
  expirationTime,
245
245
  buyerAddress,
246
246
  includeOptionalCreatorFees = false,
247
- zone = ZeroAddress,
247
+ zone = ZERO_ADDRESS,
248
248
  }: {
249
249
  asset: AssetWithTokenId
250
250
  accountAddress: string
251
- amount: BigNumberish
252
- quantity?: BigNumberish
251
+ amount: Amount
252
+ quantity?: Amount
253
253
  domain?: string
254
- salt?: BigNumberish
254
+ salt?: Amount
255
255
  listingTime?: number
256
256
  expirationTime?: number
257
257
  buyerAddress?: string
@@ -291,11 +291,11 @@ export class OrdersManager {
291
291
  }: {
292
292
  asset: AssetWithTokenId
293
293
  accountAddress: string
294
- amount: BigNumberish
295
- quantity?: BigNumberish
294
+ amount: Amount
295
+ quantity?: Amount
296
296
  domain?: string
297
- salt?: BigNumberish
298
- expirationTime?: BigNumberish
297
+ salt?: Amount
298
+ expirationTime?: Amount
299
299
  zone?: string
300
300
  }) {
301
301
  await this.context.requireAccountIsAvailable(accountAddress)
@@ -347,7 +347,7 @@ export class OrdersManager {
347
347
  zone,
348
348
  domain,
349
349
  salt: BigInt(salt ?? 0).toString(),
350
- restrictedByZone: zone !== ZeroAddress,
350
+ restrictedByZone: zone !== ZERO_ADDRESS,
351
351
  allowPartialFills: true,
352
352
  },
353
353
  accountAddress,
@@ -373,11 +373,11 @@ export class OrdersManager {
373
373
  }: {
374
374
  asset: AssetWithTokenId
375
375
  accountAddress: string
376
- amount: BigNumberish
377
- quantity?: BigNumberish
376
+ amount: Amount
377
+ quantity?: Amount
378
378
  domain?: string
379
- salt?: BigNumberish
380
- expirationTime?: BigNumberish
379
+ salt?: Amount
380
+ expirationTime?: Amount
381
381
  zone?: string
382
382
  }): Promise<OrderComponents> {
383
383
  const order = await this._buildOfferOrder({
@@ -423,11 +423,11 @@ export class OrdersManager {
423
423
  }: {
424
424
  asset: AssetWithTokenId
425
425
  accountAddress: string
426
- amount: BigNumberish
427
- quantity?: BigNumberish
426
+ amount: Amount
427
+ quantity?: Amount
428
428
  domain?: string
429
- salt?: BigNumberish
430
- expirationTime?: BigNumberish
429
+ salt?: Amount
430
+ expirationTime?: Amount
431
431
  zone?: string
432
432
  }): Promise<OrderV2> {
433
433
  const order = await this._buildOfferOrder({
@@ -479,14 +479,14 @@ export class OrdersManager {
479
479
  expirationTime,
480
480
  buyerAddress,
481
481
  includeOptionalCreatorFees = false,
482
- zone = ZeroAddress,
482
+ zone = ZERO_ADDRESS,
483
483
  }: {
484
484
  asset: AssetWithTokenId
485
485
  accountAddress: string
486
- amount: BigNumberish
487
- quantity?: BigNumberish
486
+ amount: Amount
487
+ quantity?: Amount
488
488
  domain?: string
489
- salt?: BigNumberish
489
+ salt?: Amount
490
490
  listingTime?: number
491
491
  expirationTime?: number
492
492
  buyerAddress?: string
@@ -542,10 +542,10 @@ export class OrdersManager {
542
542
  }: {
543
543
  listings: Array<{
544
544
  asset: AssetWithTokenId
545
- amount: BigNumberish
546
- quantity?: BigNumberish
545
+ amount: Amount
546
+ quantity?: Amount
547
547
  domain?: string
548
- salt?: BigNumberish
548
+ salt?: Amount
549
549
  listingTime?: number
550
550
  expirationTime?: number
551
551
  buyerAddress?: string
@@ -597,7 +597,7 @@ export class OrdersManager {
597
597
  paymentTokenAddress: string
598
598
  zone: string
599
599
  domain?: string
600
- salt?: BigNumberish
600
+ salt?: Amount
601
601
  listingTime?: number
602
602
  expirationTime?: number
603
603
  }> = []
@@ -614,7 +614,7 @@ export class OrdersManager {
614
614
  expirationTime,
615
615
  buyerAddress,
616
616
  includeOptionalCreatorFees = false,
617
- zone = ZeroAddress,
617
+ zone = ZERO_ADDRESS,
618
618
  } = listing
619
619
 
620
620
  // Fetch NFT and collection data
@@ -722,7 +722,7 @@ export class OrdersManager {
722
722
  salt: metadata.salt
723
723
  ? BigInt(metadata.salt ?? 0).toString()
724
724
  : undefined,
725
- restrictedByZone: metadata.zone !== ZeroAddress,
725
+ restrictedByZone: metadata.zone !== ZERO_ADDRESS,
726
726
  allowPartialFills: true,
727
727
  }
728
728
  })
@@ -823,11 +823,11 @@ export class OrdersManager {
823
823
  }: {
824
824
  offers: Array<{
825
825
  asset: AssetWithTokenId
826
- amount: BigNumberish
827
- quantity?: BigNumberish
826
+ amount: Amount
827
+ quantity?: Amount
828
828
  domain?: string
829
- salt?: BigNumberish
830
- expirationTime?: BigNumberish
829
+ salt?: Amount
830
+ expirationTime?: Amount
831
831
  zone?: string
832
832
  }>
833
833
  accountAddress: string
@@ -875,8 +875,8 @@ export class OrdersManager {
875
875
  paymentTokenAddress: string
876
876
  zone: string
877
877
  domain?: string
878
- salt?: BigNumberish
879
- expirationTime?: BigNumberish
878
+ salt?: Amount
879
+ expirationTime?: Amount
880
880
  }> = []
881
881
 
882
882
  // Build all order inputs
@@ -954,7 +954,7 @@ export class OrdersManager {
954
954
  salt: metadata.salt
955
955
  ? BigInt(metadata.salt ?? 0).toString()
956
956
  : undefined,
957
- restrictedByZone: metadata.zone !== ZeroAddress,
957
+ restrictedByZone: metadata.zone !== ZERO_ADDRESS,
958
958
  allowPartialFills: true,
959
959
  }
960
960
  })
@@ -1060,10 +1060,10 @@ export class OrdersManager {
1060
1060
  }: {
1061
1061
  collectionSlug: string
1062
1062
  accountAddress: string
1063
- amount: BigNumberish
1063
+ amount: Amount
1064
1064
  quantity: number
1065
1065
  domain?: string
1066
- salt?: BigNumberish
1066
+ salt?: Amount
1067
1067
  expirationTime?: number | string
1068
1068
  offerProtectionEnabled?: boolean
1069
1069
  traitType?: string
package/src/sdk/tokens.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { type BigNumberish, Contract, parseEther } from "ethers"
2
- import { EventType } from "../types"
1
+ import { WETH_DEPOSIT_ABI, WETH_WITHDRAW_ABI } from "../abi/abis"
2
+ import { type Amount, EventType } from "../types"
3
3
  import { getNativeWrapTokenAddress } from "../utils/chain"
4
+ import { parseEther } from "../utils/units"
4
5
  import type { SDKContext } from "./context"
5
6
 
6
7
  /**
@@ -20,7 +21,7 @@ export class TokensManager {
20
21
  amountInEth,
21
22
  accountAddress,
22
23
  }: {
23
- amountInEth: BigNumberish
24
+ amountInEth: Amount
24
25
  accountAddress: string
25
26
  }) {
26
27
  await this.context.requireAccountIsAvailable(accountAddress)
@@ -29,14 +30,14 @@ export class TokensManager {
29
30
 
30
31
  this.context.dispatch(EventType.WrapEth, { accountAddress, amount: value })
31
32
 
32
- const wethContract = new Contract(
33
- getNativeWrapTokenAddress(this.context.chain),
34
- ["function deposit() payable"],
35
- this.context.signerOrProvider,
36
- )
37
-
38
33
  try {
39
- const transaction = await wethContract.deposit({ value })
34
+ const transaction = await this.context.contractCaller.writeContract({
35
+ address: getNativeWrapTokenAddress(this.context.chain),
36
+ abi: WETH_DEPOSIT_ABI,
37
+ functionName: "deposit",
38
+ args: [],
39
+ value,
40
+ })
40
41
  await this.context.confirmTransaction(
41
42
  transaction.hash,
42
43
  EventType.WrapEth,
@@ -62,7 +63,7 @@ export class TokensManager {
62
63
  amountInEth,
63
64
  accountAddress,
64
65
  }: {
65
- amountInEth: BigNumberish
66
+ amountInEth: Amount
66
67
  accountAddress: string
67
68
  }) {
68
69
  await this.context.requireAccountIsAvailable(accountAddress)
@@ -71,14 +72,13 @@ export class TokensManager {
71
72
 
72
73
  this.context.dispatch(EventType.UnwrapWeth, { accountAddress, amount })
73
74
 
74
- const wethContract = new Contract(
75
- getNativeWrapTokenAddress(this.context.chain),
76
- ["function withdraw(uint wad) public"],
77
- this.context.signerOrProvider,
78
- )
79
-
80
75
  try {
81
- const transaction = await wethContract.withdraw(amount)
76
+ const transaction = await this.context.contractCaller.writeContract({
77
+ address: getNativeWrapTokenAddress(this.context.chain),
78
+ abi: WETH_WITHDRAW_ABI,
79
+ functionName: "withdraw",
80
+ args: [amount],
81
+ })
82
82
  await this.context.confirmTransaction(
83
83
  transaction.hash,
84
84
  EventType.UnwrapWeth,