@opensea/sdk 9.0.0 → 10.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 (300) hide show
  1. package/README.md +25 -4
  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 +6 -1
  6. package/lib/api/api.js +60 -51
  7. package/lib/api/api.js.map +1 -1
  8. package/lib/api/orders.js +2 -2
  9. package/lib/api/orders.js.map +1 -1
  10. package/lib/constants.d.ts +2 -2
  11. package/lib/constants.js +7 -4
  12. package/lib/constants.js.map +1 -1
  13. package/lib/index.d.ts +2 -0
  14. package/lib/index.js +1 -0
  15. package/lib/index.js.map +1 -1
  16. package/lib/orders/privateListings.js +2 -2
  17. package/lib/orders/privateListings.js.map +1 -1
  18. package/lib/orders/utils.js +9 -1
  19. package/lib/orders/utils.js.map +1 -1
  20. package/lib/provider/ethers-adapter.d.ts +17 -0
  21. package/lib/provider/ethers-adapter.js +135 -0
  22. package/lib/provider/ethers-adapter.js.map +1 -0
  23. package/lib/provider/seaport-bridge.d.ts +11 -0
  24. package/lib/provider/seaport-bridge.js +130 -0
  25. package/lib/provider/seaport-bridge.js.map +1 -0
  26. package/lib/provider/types.d.ts +62 -0
  27. package/lib/provider/types.js +7 -0
  28. package/lib/provider/types.js.map +1 -0
  29. package/lib/provider/viem-adapter.d.ts +27 -0
  30. package/lib/provider/viem-adapter.js +122 -0
  31. package/lib/provider/viem-adapter.js.map +1 -0
  32. package/lib/sdk/assets.d.ts +7 -23
  33. package/lib/sdk/assets.js +101 -77
  34. package/lib/sdk/assets.js.map +1 -1
  35. package/lib/sdk/base.d.ts +334 -0
  36. package/lib/sdk/base.js +312 -0
  37. package/lib/sdk/base.js.map +1 -0
  38. package/lib/sdk/cancellation.d.ts +1 -2
  39. package/lib/sdk/cancellation.js +4 -4
  40. package/lib/sdk/cancellation.js.map +1 -1
  41. package/lib/sdk/context.d.ts +5 -5
  42. package/lib/sdk/fulfillment.d.ts +13 -58
  43. package/lib/sdk/fulfillment.js +16 -58
  44. package/lib/sdk/fulfillment.js.map +1 -1
  45. package/lib/sdk/orders.d.ts +25 -26
  46. package/lib/sdk/orders.js +8 -9
  47. package/lib/sdk/orders.js.map +1 -1
  48. package/lib/sdk/tokens.d.ts +3 -3
  49. package/lib/sdk/tokens.js +17 -7
  50. package/lib/sdk/tokens.js.map +1 -1
  51. package/lib/sdk.d.ts +16 -550
  52. package/lib/sdk.js +35 -663
  53. package/lib/sdk.js.map +1 -1
  54. package/lib/types.d.ts +11 -6
  55. package/lib/types.js +3 -3
  56. package/lib/types.js.map +1 -1
  57. package/lib/utils/address.d.ts +12 -0
  58. package/lib/utils/address.js +39 -0
  59. package/lib/utils/address.js.map +1 -0
  60. package/lib/utils/chain.d.ts +1 -1
  61. package/lib/utils/fees.d.ts +5 -0
  62. package/lib/utils/fees.js +24 -6
  63. package/lib/utils/fees.js.map +1 -1
  64. package/lib/utils/protocol.js +5 -5
  65. package/lib/utils/protocol.js.map +1 -1
  66. package/lib/utils/units.d.ts +12 -0
  67. package/lib/utils/units.js +43 -0
  68. package/lib/utils/units.js.map +1 -0
  69. package/lib/utils/utils.d.ts +2 -10
  70. package/lib/utils/utils.js +2 -17
  71. package/lib/utils/utils.js.map +1 -1
  72. package/lib/viem.d.ts +44 -0
  73. package/lib/viem.js +114 -0
  74. package/lib/viem.js.map +1 -0
  75. package/package.json +25 -8
  76. package/src/abi/abis.ts +236 -0
  77. package/src/api/api.ts +66 -59
  78. package/src/api/orders.ts +2 -2
  79. package/src/constants.ts +7 -3
  80. package/src/index.ts +8 -0
  81. package/src/orders/privateListings.ts +2 -2
  82. package/src/orders/utils.ts +8 -1
  83. package/src/provider/ethers-adapter.ts +182 -0
  84. package/src/provider/seaport-bridge.ts +163 -0
  85. package/src/provider/types.ts +67 -0
  86. package/src/provider/viem-adapter.ts +165 -0
  87. package/src/sdk/assets.ts +128 -158
  88. package/src/sdk/base.ts +558 -0
  89. package/src/sdk/cancellation.ts +6 -9
  90. package/src/sdk/context.ts +5 -5
  91. package/src/sdk/fulfillment.ts +31 -72
  92. package/src/sdk/orders.ts +44 -44
  93. package/src/sdk/tokens.ts +18 -18
  94. package/src/sdk.ts +40 -1011
  95. package/src/types.ts +12 -6
  96. package/src/utils/address.ts +40 -0
  97. package/src/utils/fees.ts +28 -8
  98. package/src/utils/protocol.ts +5 -5
  99. package/src/utils/units.ts +47 -0
  100. package/src/utils/utils.ts +2 -22
  101. package/src/viem.ts +125 -0
  102. package/lib/src/api/accounts.d.ts +0 -18
  103. package/lib/src/api/accounts.js +0 -30
  104. package/lib/src/api/accounts.js.map +0 -1
  105. package/lib/src/api/api.d.ts +0 -429
  106. package/lib/src/api/api.js +0 -652
  107. package/lib/src/api/api.js.map +0 -1
  108. package/lib/src/api/apiPaths.d.ts +0 -37
  109. package/lib/src/api/apiPaths.js +0 -140
  110. package/lib/src/api/apiPaths.js.map +0 -1
  111. package/lib/src/api/collections.d.ts +0 -26
  112. package/lib/src/api/collections.js +0 -57
  113. package/lib/src/api/collections.js.map +0 -1
  114. package/lib/src/api/events.d.ts +0 -26
  115. package/lib/src/api/events.js +0 -42
  116. package/lib/src/api/events.js.map +0 -1
  117. package/lib/src/api/fetcher.d.ts +0 -24
  118. package/lib/src/api/fetcher.js +0 -3
  119. package/lib/src/api/fetcher.js.map +0 -1
  120. package/lib/src/api/index.d.ts +0 -2
  121. package/lib/src/api/index.js +0 -19
  122. package/lib/src/api/index.js.map +0 -1
  123. package/lib/src/api/listings.d.ts +0 -44
  124. package/lib/src/api/listings.js +0 -86
  125. package/lib/src/api/listings.js.map +0 -1
  126. package/lib/src/api/nfts.d.ts +0 -35
  127. package/lib/src/api/nfts.js +0 -66
  128. package/lib/src/api/nfts.js.map +0 -1
  129. package/lib/src/api/offers.d.ts +0 -54
  130. package/lib/src/api/offers.js +0 -122
  131. package/lib/src/api/offers.js.map +0 -1
  132. package/lib/src/api/orders.d.ts +0 -50
  133. package/lib/src/api/orders.js +0 -151
  134. package/lib/src/api/orders.js.map +0 -1
  135. package/lib/src/api/search.d.ts +0 -13
  136. package/lib/src/api/search.js +0 -21
  137. package/lib/src/api/search.js.map +0 -1
  138. package/lib/src/api/tokens.d.ts +0 -25
  139. package/lib/src/api/tokens.js +0 -42
  140. package/lib/src/api/tokens.js.map +0 -1
  141. package/lib/src/api/types.d.ts +0 -840
  142. package/lib/src/api/types.js +0 -65
  143. package/lib/src/api/types.js.map +0 -1
  144. package/lib/src/constants.d.ts +0 -22
  145. package/lib/src/constants.js +0 -52
  146. package/lib/src/constants.js.map +0 -1
  147. package/lib/src/index.d.ts +0 -18
  148. package/lib/src/index.js +0 -24
  149. package/lib/src/index.js.map +0 -1
  150. package/lib/src/orders/privateListings.d.ts +0 -12
  151. package/lib/src/orders/privateListings.js +0 -130
  152. package/lib/src/orders/privateListings.js.map +0 -1
  153. package/lib/src/orders/types.d.ts +0 -160
  154. package/lib/src/orders/types.js +0 -10
  155. package/lib/src/orders/types.js.map +0 -1
  156. package/lib/src/orders/utils.d.ts +0 -89
  157. package/lib/src/orders/utils.js +0 -177
  158. package/lib/src/orders/utils.js.map +0 -1
  159. package/lib/src/sdk/assets.d.ts +0 -104
  160. package/lib/src/sdk/assets.js +0 -397
  161. package/lib/src/sdk/assets.js.map +0 -1
  162. package/lib/src/sdk/cancellation.d.ts +0 -97
  163. package/lib/src/sdk/cancellation.js +0 -234
  164. package/lib/src/sdk/cancellation.js.map +0 -1
  165. package/lib/src/sdk/context.d.ts +0 -28
  166. package/lib/src/sdk/context.js +0 -3
  167. package/lib/src/sdk/context.js.map +0 -1
  168. package/lib/src/sdk/fulfillment.d.ts +0 -153
  169. package/lib/src/sdk/fulfillment.js +0 -296
  170. package/lib/src/sdk/fulfillment.js.map +0 -1
  171. package/lib/src/sdk/orders.d.ts +0 -253
  172. package/lib/src/sdk/orders.js +0 -677
  173. package/lib/src/sdk/orders.js.map +0 -1
  174. package/lib/src/sdk/tokens.d.ts +0 -31
  175. package/lib/src/sdk/tokens.js +0 -64
  176. package/lib/src/sdk/tokens.js.map +0 -1
  177. package/lib/src/sdk.d.ts +0 -560
  178. package/lib/src/sdk.js +0 -675
  179. package/lib/src/sdk.js.map +0 -1
  180. package/lib/src/typechain/contracts/ERC1155.d.ts +0 -236
  181. package/lib/src/typechain/contracts/ERC1155.js +0 -3
  182. package/lib/src/typechain/contracts/ERC1155.js.map +0 -1
  183. package/lib/src/typechain/contracts/ERC20.d.ts +0 -141
  184. package/lib/src/typechain/contracts/ERC20.js +0 -3
  185. package/lib/src/typechain/contracts/ERC20.js.map +0 -1
  186. package/lib/src/typechain/contracts/ERC721.d.ts +0 -213
  187. package/lib/src/typechain/contracts/ERC721.js +0 -3
  188. package/lib/src/typechain/contracts/ERC721.js.map +0 -1
  189. package/lib/src/typechain/contracts/Multicall3.d.ts +0 -57
  190. package/lib/src/typechain/contracts/Multicall3.js +0 -3
  191. package/lib/src/typechain/contracts/Multicall3.js.map +0 -1
  192. package/lib/src/typechain/contracts/TransferHelper.d.ts +0 -55
  193. package/lib/src/typechain/contracts/TransferHelper.js +0 -3
  194. package/lib/src/typechain/contracts/TransferHelper.js.map +0 -1
  195. package/lib/src/typechain/contracts/common.d.ts +0 -50
  196. package/lib/src/typechain/contracts/common.js +0 -3
  197. package/lib/src/typechain/contracts/common.js.map +0 -1
  198. package/lib/src/typechain/contracts/factories/ERC1155__factory.d.ts +0 -250
  199. package/lib/src/typechain/contracts/factories/ERC1155__factory.js +0 -332
  200. package/lib/src/typechain/contracts/factories/ERC1155__factory.js.map +0 -1
  201. package/lib/src/typechain/contracts/factories/ERC20__factory.d.ts +0 -174
  202. package/lib/src/typechain/contracts/factories/ERC20__factory.js +0 -240
  203. package/lib/src/typechain/contracts/factories/ERC20__factory.js.map +0 -1
  204. package/lib/src/typechain/contracts/factories/ERC721__factory.d.ts +0 -268
  205. package/lib/src/typechain/contracts/factories/ERC721__factory.js +0 -351
  206. package/lib/src/typechain/contracts/factories/ERC721__factory.js.map +0 -1
  207. package/lib/src/typechain/contracts/factories/Multicall3__factory.d.ts +0 -43
  208. package/lib/src/typechain/contracts/factories/Multicall3__factory.js +0 -68
  209. package/lib/src/typechain/contracts/factories/Multicall3__factory.js.map +0 -1
  210. package/lib/src/typechain/contracts/factories/TransferHelper__factory.d.ts +0 -46
  211. package/lib/src/typechain/contracts/factories/TransferHelper__factory.js +0 -71
  212. package/lib/src/typechain/contracts/factories/TransferHelper__factory.js.map +0 -1
  213. package/lib/src/typechain/contracts/factories/index.d.ts +0 -5
  214. package/lib/src/typechain/contracts/factories/index.js +0 -17
  215. package/lib/src/typechain/contracts/factories/index.js.map +0 -1
  216. package/lib/src/typechain/contracts/index.d.ts +0 -11
  217. package/lib/src/typechain/contracts/index.js +0 -48
  218. package/lib/src/typechain/contracts/index.js.map +0 -1
  219. package/lib/src/types.d.ts +0 -387
  220. package/lib/src/types.js +0 -127
  221. package/lib/src/types.js.map +0 -1
  222. package/lib/src/utils/chain.d.ts +0 -60
  223. package/lib/src/utils/chain.js +0 -248
  224. package/lib/src/utils/chain.js.map +0 -1
  225. package/lib/src/utils/converters.d.ts +0 -37
  226. package/lib/src/utils/converters.js +0 -137
  227. package/lib/src/utils/converters.js.map +0 -1
  228. package/lib/src/utils/dateHelper.d.ts +0 -38
  229. package/lib/src/utils/dateHelper.js +0 -52
  230. package/lib/src/utils/dateHelper.js.map +0 -1
  231. package/lib/src/utils/fees.d.ts +0 -13
  232. package/lib/src/utils/fees.js +0 -29
  233. package/lib/src/utils/fees.js.map +0 -1
  234. package/lib/src/utils/index.d.ts +0 -2
  235. package/lib/src/utils/index.js +0 -19
  236. package/lib/src/utils/index.js.map +0 -1
  237. package/lib/src/utils/protocol.d.ts +0 -75
  238. package/lib/src/utils/protocol.js +0 -161
  239. package/lib/src/utils/protocol.js.map +0 -1
  240. package/lib/src/utils/rateLimit.d.ts +0 -34
  241. package/lib/src/utils/rateLimit.js +0 -97
  242. package/lib/src/utils/rateLimit.js.map +0 -1
  243. package/lib/src/utils/stringHelper.d.ts +0 -18
  244. package/lib/src/utils/stringHelper.js +0 -24
  245. package/lib/src/utils/stringHelper.js.map +0 -1
  246. package/lib/src/utils/utils.d.ts +0 -18
  247. package/lib/src/utils/utils.js +0 -45
  248. package/lib/src/utils/utils.js.map +0 -1
  249. package/lib/typechain/contracts/ERC1155.d.ts +0 -236
  250. package/lib/typechain/contracts/ERC1155.js +0 -3
  251. package/lib/typechain/contracts/ERC1155.js.map +0 -1
  252. package/lib/typechain/contracts/ERC20.d.ts +0 -141
  253. package/lib/typechain/contracts/ERC20.js +0 -3
  254. package/lib/typechain/contracts/ERC20.js.map +0 -1
  255. package/lib/typechain/contracts/ERC721.d.ts +0 -213
  256. package/lib/typechain/contracts/ERC721.js +0 -3
  257. package/lib/typechain/contracts/ERC721.js.map +0 -1
  258. package/lib/typechain/contracts/Multicall3.d.ts +0 -57
  259. package/lib/typechain/contracts/Multicall3.js +0 -3
  260. package/lib/typechain/contracts/Multicall3.js.map +0 -1
  261. package/lib/typechain/contracts/TransferHelper.d.ts +0 -55
  262. package/lib/typechain/contracts/TransferHelper.js +0 -3
  263. package/lib/typechain/contracts/TransferHelper.js.map +0 -1
  264. package/lib/typechain/contracts/common.d.ts +0 -50
  265. package/lib/typechain/contracts/common.js +0 -3
  266. package/lib/typechain/contracts/common.js.map +0 -1
  267. package/lib/typechain/contracts/factories/ERC1155__factory.d.ts +0 -250
  268. package/lib/typechain/contracts/factories/ERC1155__factory.js +0 -332
  269. package/lib/typechain/contracts/factories/ERC1155__factory.js.map +0 -1
  270. package/lib/typechain/contracts/factories/ERC20__factory.d.ts +0 -174
  271. package/lib/typechain/contracts/factories/ERC20__factory.js +0 -240
  272. package/lib/typechain/contracts/factories/ERC20__factory.js.map +0 -1
  273. package/lib/typechain/contracts/factories/ERC721__factory.d.ts +0 -268
  274. package/lib/typechain/contracts/factories/ERC721__factory.js +0 -351
  275. package/lib/typechain/contracts/factories/ERC721__factory.js.map +0 -1
  276. package/lib/typechain/contracts/factories/Multicall3__factory.d.ts +0 -43
  277. package/lib/typechain/contracts/factories/Multicall3__factory.js +0 -68
  278. package/lib/typechain/contracts/factories/Multicall3__factory.js.map +0 -1
  279. package/lib/typechain/contracts/factories/TransferHelper__factory.d.ts +0 -46
  280. package/lib/typechain/contracts/factories/TransferHelper__factory.js +0 -71
  281. package/lib/typechain/contracts/factories/TransferHelper__factory.js.map +0 -1
  282. package/lib/typechain/contracts/factories/index.d.ts +0 -5
  283. package/lib/typechain/contracts/factories/index.js +0 -17
  284. package/lib/typechain/contracts/factories/index.js.map +0 -1
  285. package/lib/typechain/contracts/index.d.ts +0 -11
  286. package/lib/typechain/contracts/index.js +0 -48
  287. package/lib/typechain/contracts/index.js.map +0 -1
  288. package/src/typechain/contracts/ERC1155.ts +0 -440
  289. package/src/typechain/contracts/ERC20.ts +0 -286
  290. package/src/typechain/contracts/ERC721.ts +0 -412
  291. package/src/typechain/contracts/Multicall3.ts +0 -117
  292. package/src/typechain/contracts/TransferHelper.ts +0 -122
  293. package/src/typechain/contracts/common.ts +0 -131
  294. package/src/typechain/contracts/factories/ERC1155__factory.ts +0 -331
  295. package/src/typechain/contracts/factories/ERC20__factory.ts +0 -239
  296. package/src/typechain/contracts/factories/ERC721__factory.ts +0 -350
  297. package/src/typechain/contracts/factories/Multicall3__factory.ts +0 -67
  298. package/src/typechain/contracts/factories/TransferHelper__factory.ts +0 -76
  299. package/src/typechain/contracts/factories/index.ts +0 -8
  300. 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,13 +36,6 @@ 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.
42
39
  */
43
40
  private async fulfillPrivateOrder({
44
41
  order,
@@ -49,7 +46,7 @@ export class FulfillmentManager {
49
46
  order: OrderV2
50
47
  accountAddress: string
51
48
  domain?: string
52
- overrides?: Overrides
49
+ overrides?: Record<string, unknown>
53
50
  }): Promise<string> {
54
51
  if (!order.taker?.address) {
55
52
  throw new Error(
@@ -62,8 +59,6 @@ export class FulfillmentManager {
62
59
  )
63
60
  const fulfillments = getPrivateListingFulfillments(order.protocolData)
64
61
 
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
62
  const value = computePrivateListingValue(
68
63
  order.protocolData,
69
64
  order.taker.address,
@@ -131,10 +126,10 @@ export class FulfillmentManager {
131
126
  accountAddress: string
132
127
  assetContractAddress?: string
133
128
  tokenId?: string
134
- unitsToFill?: BigNumberish
129
+ unitsToFill?: Amount
135
130
  recipientAddress?: string
136
131
  includeOptionalCreatorFees?: boolean
137
- overrides?: Overrides
132
+ overrides?: Record<string, unknown>
138
133
  }): Promise<string> {
139
134
  await this.context.requireAccountIsAvailable(accountAddress)
140
135
 
@@ -186,9 +181,6 @@ export class FulfillmentManager {
186
181
  const transaction = fulfillmentData.fulfillment_data.transaction
187
182
  const inputData = transaction.input_data
188
183
 
189
- // Use Seaport ABI to encode the transaction
190
- const seaportInterface = new ethers.Interface(SeaportABI)
191
-
192
184
  // Extract function name and build parameters array in correct order
193
185
  const rawFunctionName = transaction.function.split("(")[0]
194
186
  const functionName =
@@ -226,18 +218,22 @@ export class FulfillmentManager {
226
218
  params = Object.values(inputData)
227
219
  }
228
220
 
229
- const encodedData = seaportInterface.encodeFunctionData(
221
+ const encodedData = this.context.contractCaller.encodeFunctionData({
222
+ abi: SeaportABI,
230
223
  functionName,
231
- params,
232
- )
224
+ args: params,
225
+ })
233
226
 
234
- // Send the transaction using the signer from context
235
- const signer = this.context.signerOrProvider as Signer
236
- const tx = await signer.sendTransaction({
227
+ // Send the transaction using the signer from wallet
228
+ const wallet = this.context.wallet
229
+ if (!("signer" in wallet)) {
230
+ throw new Error("A signer is required to fulfill orders")
231
+ }
232
+ const tx = await wallet.signer.sendTransaction({
237
233
  to: transaction.to,
238
- value: transaction.value,
234
+ value: BigInt(transaction.value),
239
235
  data: encodedData,
240
- ...overrides,
236
+ overrides: overrides as Record<string, unknown>,
241
237
  })
242
238
 
243
239
  await this.context.confirmTransaction(
@@ -324,15 +320,7 @@ export class FulfillmentManager {
324
320
  }
325
321
 
326
322
  /**
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.
323
+ * Validates an order onchain using Seaport's validate() method.
336
324
  */
337
325
  async validateOrderOnchain(
338
326
  orderComponents: OrderComponents,
@@ -366,23 +354,7 @@ export class FulfillmentManager {
366
354
  }
367
355
 
368
356
  /**
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.
357
+ * Create and validate a listing onchain.
386
358
  */
387
359
  async createListingAndValidateOnchain({
388
360
  asset,
@@ -399,10 +371,10 @@ export class FulfillmentManager {
399
371
  }: {
400
372
  asset: AssetWithTokenId
401
373
  accountAddress: string
402
- amount: BigNumberish
403
- quantity?: BigNumberish
374
+ amount: Amount
375
+ quantity?: Amount
404
376
  domain?: string
405
- salt?: BigNumberish
377
+ salt?: Amount
406
378
  listingTime?: number
407
379
  expirationTime?: number
408
380
  buyerAddress?: string
@@ -428,20 +400,7 @@ export class FulfillmentManager {
428
400
  }
429
401
 
430
402
  /**
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.
403
+ * Create and validate an offer onchain.
445
404
  */
446
405
  async createOfferAndValidateOnchain({
447
406
  asset,
@@ -455,11 +414,11 @@ export class FulfillmentManager {
455
414
  }: {
456
415
  asset: AssetWithTokenId
457
416
  accountAddress: string
458
- amount: BigNumberish
459
- quantity?: BigNumberish
417
+ amount: Amount
418
+ quantity?: Amount
460
419
  domain?: string
461
- salt?: BigNumberish
462
- expirationTime?: BigNumberish
420
+ salt?: Amount
421
+ expirationTime?: Amount
463
422
  zone?: string
464
423
  }): Promise<string> {
465
424
  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,