@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
@@ -0,0 +1,350 @@
1
+ import type { Seaport } from "@opensea/seaport-js";
2
+ import type { OrderComponents } from "@opensea/seaport-js/lib/types";
3
+ import type { OpenSeaAPI } from "../api/api";
4
+ import type { CollectionOffer, Listing, Offer, Order } from "../api/types";
5
+ import type { OrderV2 } from "../orders/types";
6
+ import type { ContractCaller, OpenSeaWallet } from "../provider/types";
7
+ import type { Amount, AssetWithTokenId, AssetWithTokenStandard, Chain, EventData } from "../types";
8
+ import { EventType } from "../types";
9
+ import { type BulkOrderResult } from "./orders";
10
+ /**
11
+ * Configuration passed to the base SDK by entry-point constructors.
12
+ */
13
+ export interface BaseSDKConfig {
14
+ wallet: OpenSeaWallet;
15
+ contractCaller: ContractCaller;
16
+ seaport: Seaport;
17
+ api: OpenSeaAPI;
18
+ chain: Chain;
19
+ logger: (arg: string) => void;
20
+ /** Get available account addresses for requireAccountIsAvailable checks */
21
+ getAvailableAccounts: () => Promise<string[]>;
22
+ cachedPaymentTokenDecimals: {
23
+ [address: string]: number;
24
+ };
25
+ }
26
+ /**
27
+ * Base OpenSea SDK class containing all shared business logic.
28
+ * Entry-point classes (ethers, viem) extend this and only differ in constructor.
29
+ * @category Main Classes
30
+ */
31
+ export declare class BaseOpenSeaSDK {
32
+ /** Seaport client @see {@link https://github.com/ProjectOpenSea/seaport-js} */
33
+ seaport: Seaport;
34
+ /** Logger function to use when debugging */
35
+ logger: (arg: string) => void;
36
+ /** API instance */
37
+ readonly api: OpenSeaAPI;
38
+ /** The configured chain */
39
+ readonly chain: Chain;
40
+ protected _wallet: OpenSeaWallet;
41
+ protected _contractCaller: ContractCaller;
42
+ private _emitter;
43
+ private _cachedPaymentTokenDecimals;
44
+ private _getAvailableAccounts;
45
+ private _tokensManager;
46
+ private _assetsManager;
47
+ private _cancellationManager;
48
+ private _ordersManager;
49
+ private _fulfillmentManager;
50
+ protected constructor(config: BaseSDKConfig);
51
+ /**
52
+ * Add a listener for events emitted by the SDK.
53
+ * @param event The {@link EventType} to listen to.
54
+ * @param listener A callback that will accept an object with {@link EventData}
55
+ * @param once Whether the listener should only be called once.
56
+ */
57
+ addListener(event: EventType, listener: (data: EventData) => void, once?: boolean): void;
58
+ /**
59
+ * Remove an event listener.
60
+ * @param event The {@link EventType} to remove a listener for
61
+ * @param listener The listener to remove
62
+ */
63
+ removeListener(event: EventType, listener: (data: EventData) => void): void;
64
+ /**
65
+ * Remove all event listeners. Call when unmounting a component that listens to events.
66
+ * @param event Optional EventType to remove listeners for
67
+ */
68
+ removeAllListeners(event?: EventType): void;
69
+ /**
70
+ * Wrap native asset into wrapped native asset (e.g. ETH into WETH, POL into WPOL).
71
+ * Wrapped native assets are needed for making offers.
72
+ * @param options
73
+ * @param options.amountInEth Amount of native asset to wrap
74
+ * @param options.accountAddress Address of the user's wallet containing the native asset
75
+ */
76
+ wrapEth(options: {
77
+ amountInEth: Amount;
78
+ accountAddress: string;
79
+ }): Promise<void>;
80
+ /**
81
+ * Unwrap wrapped native asset into native asset (e.g. WETH into ETH, WPOL into POL).
82
+ * Emits the `UnwrapWeth` event when the transaction is prompted.
83
+ * @param options
84
+ * @param options.amountInEth How much wrapped native asset to unwrap
85
+ * @param options.accountAddress Address of the user's wallet containing the wrapped native asset
86
+ */
87
+ unwrapWeth(options: {
88
+ amountInEth: Amount;
89
+ accountAddress: string;
90
+ }): Promise<void>;
91
+ /**
92
+ * Create and submit an offer on an asset.
93
+ * @param options
94
+ * @param options.asset The asset to trade. tokenAddress and tokenId must be defined.
95
+ * @param options.accountAddress Address of the wallet making the offer.
96
+ * @param options.amount Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units.
97
+ * @param options.quantity Number of assets to bid for. Defaults to 1.
98
+ * @param options.domain Optional domain for onchain attribution.
99
+ * @param options.salt Arbitrary salt. Auto-generated if not provided.
100
+ * @param options.expirationTime Expiration time for the order, in UTC seconds
101
+ * @param options.zone Zone for order protection. Defaults to chain's signed zone.
102
+ * @returns The {@link OrderV2} that was created.
103
+ */
104
+ createOffer(options: {
105
+ asset: AssetWithTokenId;
106
+ accountAddress: string;
107
+ amount: Amount;
108
+ quantity?: Amount;
109
+ domain?: string;
110
+ salt?: Amount;
111
+ expirationTime?: Amount;
112
+ zone?: string;
113
+ }): Promise<OrderV2>;
114
+ /**
115
+ * Create and submit a listing for an asset.
116
+ * @param options
117
+ * @param options.asset The asset to trade. tokenAddress and tokenId must be defined.
118
+ * @param options.accountAddress Address of the wallet making the listing
119
+ * @param options.amount Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units.
120
+ * @param options.quantity Number of assets to list. Defaults to 1.
121
+ * @param options.domain Optional domain for onchain attribution.
122
+ * @param options.salt Arbitrary salt. Auto-generated if not provided.
123
+ * @param options.listingTime Optional time when the order will become fulfillable, in UTC seconds.
124
+ * @param options.expirationTime Expiration time for the order, in UTC seconds.
125
+ * @param options.buyerAddress Optional address that's allowed to purchase this item.
126
+ * @param options.includeOptionalCreatorFees If true, optional creator fees will be included. Default: false.
127
+ * @param options.zone Zone for order protection. Defaults to no zone.
128
+ * @returns The {@link OrderV2} that was created.
129
+ */
130
+ createListing(options: {
131
+ asset: AssetWithTokenId;
132
+ accountAddress: string;
133
+ amount: Amount;
134
+ quantity?: Amount;
135
+ domain?: string;
136
+ salt?: Amount;
137
+ listingTime?: number;
138
+ expirationTime?: number;
139
+ buyerAddress?: string;
140
+ includeOptionalCreatorFees?: boolean;
141
+ zone?: string;
142
+ }): Promise<OrderV2>;
143
+ /** Create and submit multiple listings using Seaport's bulk order creation. */
144
+ createBulkListings(options: {
145
+ listings: Array<{
146
+ asset: AssetWithTokenId;
147
+ amount: Amount;
148
+ quantity?: Amount;
149
+ domain?: string;
150
+ salt?: Amount;
151
+ listingTime?: number;
152
+ expirationTime?: number;
153
+ buyerAddress?: string;
154
+ includeOptionalCreatorFees?: boolean;
155
+ zone?: string;
156
+ }>;
157
+ accountAddress: string;
158
+ continueOnError?: boolean;
159
+ onProgress?: (completed: number, total: number) => void;
160
+ }): Promise<BulkOrderResult>;
161
+ /** Create and submit multiple offers using Seaport's bulk order creation. */
162
+ createBulkOffers(options: {
163
+ offers: Array<{
164
+ asset: AssetWithTokenId;
165
+ amount: Amount;
166
+ quantity?: Amount;
167
+ domain?: string;
168
+ salt?: Amount;
169
+ expirationTime?: Amount;
170
+ zone?: string;
171
+ }>;
172
+ accountAddress: string;
173
+ continueOnError?: boolean;
174
+ onProgress?: (completed: number, total: number) => void;
175
+ }): Promise<BulkOrderResult>;
176
+ /** Create and submit a collection offer. */
177
+ createCollectionOffer(options: {
178
+ collectionSlug: string;
179
+ accountAddress: string;
180
+ amount: Amount;
181
+ quantity: number;
182
+ domain?: string;
183
+ salt?: Amount;
184
+ expirationTime?: number | string;
185
+ offerProtectionEnabled?: boolean;
186
+ traitType?: string;
187
+ traitValue?: string;
188
+ traits?: Array<{
189
+ type: string;
190
+ value: string;
191
+ }>;
192
+ numericTraits?: Array<{
193
+ type: string;
194
+ min?: number;
195
+ max?: number;
196
+ }>;
197
+ }): Promise<CollectionOffer | null>;
198
+ /**
199
+ * Fulfill an order for an asset. The order can be either a listing or an offer.
200
+ * Uses the OpenSea API to generate fulfillment transaction data and executes it directly.
201
+ * @param options
202
+ * @param options.order The order to fulfill, a.k.a. "take"
203
+ * @param options.accountAddress Address of the wallet taking the offer.
204
+ * @param options.assetContractAddress Optional address of the NFT contract for criteria offers.
205
+ * @param options.tokenId Optional token ID for criteria offers.
206
+ * @param options.unitsToFill Optional number of units to fill. Defaults to 1.
207
+ * @param options.recipientAddress Optional recipient address for the NFT when fulfilling a listing.
208
+ * @param options.includeOptionalCreatorFees Whether to include optional creator fees. Defaults to false.
209
+ * @param options.overrides Transaction overrides (gasLimit, maxFeePerGas, etc.).
210
+ * @returns Transaction hash of the order.
211
+ */
212
+ fulfillOrder(options: {
213
+ order: OrderV2 | Order | Listing | Offer;
214
+ accountAddress: string;
215
+ assetContractAddress?: string;
216
+ tokenId?: string;
217
+ unitsToFill?: Amount;
218
+ recipientAddress?: string;
219
+ includeOptionalCreatorFees?: boolean;
220
+ overrides?: Record<string, unknown>;
221
+ }): Promise<string>;
222
+ /**
223
+ * Fulfill a private listing directly using Seaport's matchOrders.
224
+ * The order must have a taker address set (i.e., it is a private listing).
225
+ * @param options
226
+ * @param options.order The private listing order to fulfill. Must have a taker address.
227
+ * @param options.accountAddress Address of the wallet fulfilling the order.
228
+ * @param options.domain Optional domain for onchain attribution.
229
+ * @param options.overrides Transaction overrides (gasLimit, maxFeePerGas, etc.).
230
+ * @returns Transaction hash of the fulfillment.
231
+ */
232
+ fulfillPrivateOrder(options: {
233
+ order: OrderV2;
234
+ accountAddress: string;
235
+ domain?: string;
236
+ overrides?: Record<string, unknown>;
237
+ }): Promise<string>;
238
+ /** Returns whether an order is fulfillable. */
239
+ isOrderFulfillable(options: {
240
+ order: OrderV2;
241
+ accountAddress: string;
242
+ }): Promise<boolean>;
243
+ /** Approve an order with an onchain transaction. */
244
+ approveOrder(order: OrderV2, domain?: string): Promise<string>;
245
+ /** Validates an order onchain using Seaport's validate() method. */
246
+ validateOrderOnchain(orderComponents: OrderComponents, accountAddress: string): Promise<string>;
247
+ /** Create and validate a listing onchain. */
248
+ createListingAndValidateOnchain(options: {
249
+ asset: AssetWithTokenId;
250
+ accountAddress: string;
251
+ amount: Amount;
252
+ quantity?: Amount;
253
+ domain?: string;
254
+ salt?: Amount;
255
+ listingTime?: number;
256
+ expirationTime?: number;
257
+ buyerAddress?: string;
258
+ includeOptionalCreatorFees?: boolean;
259
+ zone?: string;
260
+ }): Promise<string>;
261
+ /** Create and validate an offer onchain. */
262
+ createOfferAndValidateOnchain(options: {
263
+ asset: AssetWithTokenId;
264
+ accountAddress: string;
265
+ amount: Amount;
266
+ quantity?: Amount;
267
+ domain?: string;
268
+ salt?: Amount;
269
+ expirationTime?: Amount;
270
+ zone?: string;
271
+ }): Promise<string>;
272
+ /**
273
+ * Cancel multiple orders onchain, preventing them from being fulfilled.
274
+ * @param options
275
+ * @param options.orders Array of orders to cancel. Can be OrderV2 objects or OrderComponents.
276
+ * @param options.orderHashes Optional array of order hashes to cancel.
277
+ * @param options.accountAddress The account address cancelling the orders.
278
+ * @param options.protocolAddress The Seaport protocol address for the orders.
279
+ * @param options.domain Optional domain for onchain attribution.
280
+ * @param options.overrides Transaction overrides (gasLimit, maxFeePerGas, etc.).
281
+ * @returns Transaction hash of the cancellation.
282
+ */
283
+ cancelOrders(options: {
284
+ orders?: Array<OrderV2 | OrderComponents>;
285
+ orderHashes?: string[];
286
+ accountAddress: string;
287
+ protocolAddress?: string;
288
+ domain?: string;
289
+ overrides?: Record<string, unknown>;
290
+ }): Promise<string>;
291
+ /** Cancel an order onchain, preventing it from ever being fulfilled. */
292
+ cancelOrder(options: {
293
+ order?: OrderV2;
294
+ orderHash?: string;
295
+ accountAddress: string;
296
+ protocolAddress?: string;
297
+ domain?: string;
298
+ }): Promise<void>;
299
+ /** Offchain cancel an order by its order hash when protected by the SignedZone. */
300
+ offchainCancelOrder(protocolAddress: string, orderHash: string, chain?: Chain, offererSignature?: string, useSignerToDeriveOffererSignature?: boolean): Promise<import("../api/types").CancelOrderResponse>;
301
+ /**
302
+ * Get an account's balance of any Asset.
303
+ */
304
+ getBalance(options: {
305
+ accountAddress: string;
306
+ asset: AssetWithTokenStandard;
307
+ }): Promise<bigint>;
308
+ /**
309
+ * Transfer an asset. This asset can be an ERC20, ERC1155, or ERC721.
310
+ * @param options
311
+ * @param options.asset The Asset to transfer. tokenStandard must be set.
312
+ * @param options.amount Amount of asset to transfer. Not used for ERC721.
313
+ * @param options.fromAddress The address to transfer from
314
+ * @param options.toAddress The address to transfer to
315
+ * @param options.overrides Transaction overrides (gasLimit, maxFeePerGas, etc.).
316
+ */
317
+ transfer(options: {
318
+ asset: AssetWithTokenStandard;
319
+ amount?: Amount;
320
+ fromAddress: string;
321
+ toAddress: string;
322
+ overrides?: Record<string, unknown>;
323
+ }): Promise<void>;
324
+ /** Bulk transfer multiple assets using OpenSea's TransferHelper contract. */
325
+ bulkTransfer(options: {
326
+ assets: Array<{
327
+ asset: AssetWithTokenStandard;
328
+ toAddress: string;
329
+ amount?: Amount;
330
+ }>;
331
+ fromAddress: string;
332
+ overrides?: Record<string, unknown>;
333
+ }): Promise<string>;
334
+ /** Batch approve multiple assets for transfer to the OpenSea conduit. */
335
+ batchApproveAssets(options: {
336
+ assets: Array<{
337
+ asset: AssetWithTokenStandard;
338
+ amount?: Amount;
339
+ }>;
340
+ fromAddress: string;
341
+ overrides?: Record<string, unknown>;
342
+ }): Promise<string | undefined>;
343
+ /**
344
+ * Compute the `basePrice` parameter to be used to price an order.
345
+ */
346
+ private _getPriceParameters;
347
+ private _dispatch;
348
+ private _requireAccountIsAvailable;
349
+ private _confirmTransaction;
350
+ }
@@ -0,0 +1,325 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseOpenSeaSDK = void 0;
4
+ const EventEmitter = require("node:events");
5
+ const constants_1 = require("../constants");
6
+ const types_1 = require("../types");
7
+ const address_1 = require("../utils/address");
8
+ const units_1 = require("../utils/units");
9
+ const assets_1 = require("./assets");
10
+ const cancellation_1 = require("./cancellation");
11
+ const fulfillment_1 = require("./fulfillment");
12
+ const orders_1 = require("./orders");
13
+ const tokens_1 = require("./tokens");
14
+ /**
15
+ * Base OpenSea SDK class containing all shared business logic.
16
+ * Entry-point classes (ethers, viem) extend this and only differ in constructor.
17
+ * @category Main Classes
18
+ */
19
+ class BaseOpenSeaSDK {
20
+ /** Seaport client @see {@link https://github.com/ProjectOpenSea/seaport-js} */
21
+ seaport;
22
+ /** Logger function to use when debugging */
23
+ logger;
24
+ /** API instance */
25
+ api;
26
+ /** The configured chain */
27
+ chain;
28
+ _wallet;
29
+ _contractCaller;
30
+ _emitter;
31
+ _cachedPaymentTokenDecimals;
32
+ _getAvailableAccounts;
33
+ // Manager instances
34
+ _tokensManager;
35
+ _assetsManager;
36
+ _cancellationManager;
37
+ _ordersManager;
38
+ _fulfillmentManager;
39
+ constructor(config) {
40
+ this.chain = config.chain;
41
+ this.api = config.api;
42
+ this.seaport = config.seaport;
43
+ this.logger = config.logger;
44
+ this._wallet = config.wallet;
45
+ this._contractCaller = config.contractCaller;
46
+ this._cachedPaymentTokenDecimals = config.cachedPaymentTokenDecimals;
47
+ this._getAvailableAccounts = config.getAvailableAccounts;
48
+ this._emitter = new EventEmitter();
49
+ const context = {
50
+ chain: this.chain,
51
+ wallet: this._wallet,
52
+ contractCaller: this._contractCaller,
53
+ api: this.api,
54
+ seaport: this.seaport,
55
+ logger: this.logger,
56
+ dispatch: this._dispatch.bind(this),
57
+ confirmTransaction: this._confirmTransaction.bind(this),
58
+ requireAccountIsAvailable: this._requireAccountIsAvailable.bind(this),
59
+ };
60
+ this._tokensManager = new tokens_1.TokensManager(context);
61
+ this._assetsManager = new assets_1.AssetsManager(context);
62
+ this._cancellationManager = new cancellation_1.CancellationManager(context);
63
+ this._ordersManager = new orders_1.OrdersManager(context, this._getPriceParameters.bind(this));
64
+ this._fulfillmentManager = new fulfillment_1.FulfillmentManager(context, this._ordersManager);
65
+ }
66
+ // ─── Event Listeners ───────────────────────────────────────────────
67
+ /**
68
+ * Add a listener for events emitted by the SDK.
69
+ * @param event The {@link EventType} to listen to.
70
+ * @param listener A callback that will accept an object with {@link EventData}
71
+ * @param once Whether the listener should only be called once.
72
+ */
73
+ addListener(event, listener, once = false) {
74
+ if (once) {
75
+ this._emitter.once(event, listener);
76
+ }
77
+ else {
78
+ this._emitter.addListener(event, listener);
79
+ }
80
+ }
81
+ /**
82
+ * Remove an event listener.
83
+ * @param event The {@link EventType} to remove a listener for
84
+ * @param listener The listener to remove
85
+ */
86
+ removeListener(event, listener) {
87
+ this._emitter.removeListener(event, listener);
88
+ }
89
+ /**
90
+ * Remove all event listeners. Call when unmounting a component that listens to events.
91
+ * @param event Optional EventType to remove listeners for
92
+ */
93
+ removeAllListeners(event) {
94
+ this._emitter.removeAllListeners(event);
95
+ }
96
+ // ─── Token Operations ──────────────────────────────────────────────
97
+ /**
98
+ * Wrap native asset into wrapped native asset (e.g. ETH into WETH, POL into WPOL).
99
+ * Wrapped native assets are needed for making offers.
100
+ * @param options
101
+ * @param options.amountInEth Amount of native asset to wrap
102
+ * @param options.accountAddress Address of the user's wallet containing the native asset
103
+ */
104
+ async wrapEth(options) {
105
+ return this._tokensManager.wrapEth(options);
106
+ }
107
+ /**
108
+ * Unwrap wrapped native asset into native asset (e.g. WETH into ETH, WPOL into POL).
109
+ * Emits the `UnwrapWeth` event when the transaction is prompted.
110
+ * @param options
111
+ * @param options.amountInEth How much wrapped native asset to unwrap
112
+ * @param options.accountAddress Address of the user's wallet containing the wrapped native asset
113
+ */
114
+ async unwrapWeth(options) {
115
+ return this._tokensManager.unwrapWeth(options);
116
+ }
117
+ // ─── Order Creation ────────────────────────────────────────────────
118
+ /**
119
+ * Create and submit an offer on an asset.
120
+ * @param options
121
+ * @param options.asset The asset to trade. tokenAddress and tokenId must be defined.
122
+ * @param options.accountAddress Address of the wallet making the offer.
123
+ * @param options.amount Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units.
124
+ * @param options.quantity Number of assets to bid for. Defaults to 1.
125
+ * @param options.domain Optional domain for onchain attribution.
126
+ * @param options.salt Arbitrary salt. Auto-generated if not provided.
127
+ * @param options.expirationTime Expiration time for the order, in UTC seconds
128
+ * @param options.zone Zone for order protection. Defaults to chain's signed zone.
129
+ * @returns The {@link OrderV2} that was created.
130
+ */
131
+ async createOffer(options) {
132
+ return this._ordersManager.createOffer(options);
133
+ }
134
+ /**
135
+ * Create and submit a listing for an asset.
136
+ * @param options
137
+ * @param options.asset The asset to trade. tokenAddress and tokenId must be defined.
138
+ * @param options.accountAddress Address of the wallet making the listing
139
+ * @param options.amount Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units.
140
+ * @param options.quantity Number of assets to list. Defaults to 1.
141
+ * @param options.domain Optional domain for onchain attribution.
142
+ * @param options.salt Arbitrary salt. Auto-generated if not provided.
143
+ * @param options.listingTime Optional time when the order will become fulfillable, in UTC seconds.
144
+ * @param options.expirationTime Expiration time for the order, in UTC seconds.
145
+ * @param options.buyerAddress Optional address that's allowed to purchase this item.
146
+ * @param options.includeOptionalCreatorFees If true, optional creator fees will be included. Default: false.
147
+ * @param options.zone Zone for order protection. Defaults to no zone.
148
+ * @returns The {@link OrderV2} that was created.
149
+ */
150
+ async createListing(options) {
151
+ return this._ordersManager.createListing(options);
152
+ }
153
+ /** Create and submit multiple listings using Seaport's bulk order creation. */
154
+ async createBulkListings(options) {
155
+ return this._ordersManager.createBulkListings(options);
156
+ }
157
+ /** Create and submit multiple offers using Seaport's bulk order creation. */
158
+ async createBulkOffers(options) {
159
+ return this._ordersManager.createBulkOffers(options);
160
+ }
161
+ /** Create and submit a collection offer. */
162
+ async createCollectionOffer(options) {
163
+ return this._ordersManager.createCollectionOffer(options);
164
+ }
165
+ // ─── Order Fulfillment ─────────────────────────────────────────────
166
+ /**
167
+ * Fulfill an order for an asset. The order can be either a listing or an offer.
168
+ * Uses the OpenSea API to generate fulfillment transaction data and executes it directly.
169
+ * @param options
170
+ * @param options.order The order to fulfill, a.k.a. "take"
171
+ * @param options.accountAddress Address of the wallet taking the offer.
172
+ * @param options.assetContractAddress Optional address of the NFT contract for criteria offers.
173
+ * @param options.tokenId Optional token ID for criteria offers.
174
+ * @param options.unitsToFill Optional number of units to fill. Defaults to 1.
175
+ * @param options.recipientAddress Optional recipient address for the NFT when fulfilling a listing.
176
+ * @param options.includeOptionalCreatorFees Whether to include optional creator fees. Defaults to false.
177
+ * @param options.overrides Transaction overrides (gasLimit, maxFeePerGas, etc.).
178
+ * @returns Transaction hash of the order.
179
+ */
180
+ async fulfillOrder(options) {
181
+ return this._fulfillmentManager.fulfillOrder(options);
182
+ }
183
+ /**
184
+ * Fulfill a private listing directly using Seaport's matchOrders.
185
+ * The order must have a taker address set (i.e., it is a private listing).
186
+ * @param options
187
+ * @param options.order The private listing order to fulfill. Must have a taker address.
188
+ * @param options.accountAddress Address of the wallet fulfilling the order.
189
+ * @param options.domain Optional domain for onchain attribution.
190
+ * @param options.overrides Transaction overrides (gasLimit, maxFeePerGas, etc.).
191
+ * @returns Transaction hash of the fulfillment.
192
+ */
193
+ async fulfillPrivateOrder(options) {
194
+ return this._fulfillmentManager.fulfillPrivateOrder(options);
195
+ }
196
+ /** Returns whether an order is fulfillable. */
197
+ async isOrderFulfillable(options) {
198
+ return this._fulfillmentManager.isOrderFulfillable(options);
199
+ }
200
+ /** Approve an order with an onchain transaction. */
201
+ async approveOrder(order, domain) {
202
+ return this._fulfillmentManager.approveOrder(order, domain);
203
+ }
204
+ /** Validates an order onchain using Seaport's validate() method. */
205
+ async validateOrderOnchain(orderComponents, accountAddress) {
206
+ return this._fulfillmentManager.validateOrderOnchain(orderComponents, accountAddress);
207
+ }
208
+ /** Create and validate a listing onchain. */
209
+ async createListingAndValidateOnchain(options) {
210
+ return this._fulfillmentManager.createListingAndValidateOnchain(options);
211
+ }
212
+ /** Create and validate an offer onchain. */
213
+ async createOfferAndValidateOnchain(options) {
214
+ return this._fulfillmentManager.createOfferAndValidateOnchain(options);
215
+ }
216
+ // ─── Order Cancellation ────────────────────────────────────────────
217
+ /**
218
+ * Cancel multiple orders onchain, preventing them from being fulfilled.
219
+ * @param options
220
+ * @param options.orders Array of orders to cancel. Can be OrderV2 objects or OrderComponents.
221
+ * @param options.orderHashes Optional array of order hashes to cancel.
222
+ * @param options.accountAddress The account address cancelling the orders.
223
+ * @param options.protocolAddress The Seaport protocol address for the orders.
224
+ * @param options.domain Optional domain for onchain attribution.
225
+ * @param options.overrides Transaction overrides (gasLimit, maxFeePerGas, etc.).
226
+ * @returns Transaction hash of the cancellation.
227
+ */
228
+ async cancelOrders(options) {
229
+ return this._cancellationManager.cancelOrders(options);
230
+ }
231
+ /** Cancel an order onchain, preventing it from ever being fulfilled. */
232
+ async cancelOrder(options) {
233
+ return this._cancellationManager.cancelOrder(options);
234
+ }
235
+ /** Offchain cancel an order by its order hash when protected by the SignedZone. */
236
+ async offchainCancelOrder(protocolAddress, orderHash, chain = this.chain, offererSignature, useSignerToDeriveOffererSignature) {
237
+ return this._cancellationManager.offchainCancelOrder(protocolAddress, orderHash, chain, offererSignature, useSignerToDeriveOffererSignature);
238
+ }
239
+ // ─── Asset Operations ──────────────────────────────────────────────
240
+ /**
241
+ * Get an account's balance of any Asset.
242
+ */
243
+ async getBalance(options) {
244
+ return this._assetsManager.getBalance(options);
245
+ }
246
+ /**
247
+ * Transfer an asset. This asset can be an ERC20, ERC1155, or ERC721.
248
+ * @param options
249
+ * @param options.asset The Asset to transfer. tokenStandard must be set.
250
+ * @param options.amount Amount of asset to transfer. Not used for ERC721.
251
+ * @param options.fromAddress The address to transfer from
252
+ * @param options.toAddress The address to transfer to
253
+ * @param options.overrides Transaction overrides (gasLimit, maxFeePerGas, etc.).
254
+ */
255
+ async transfer(options) {
256
+ return this._assetsManager.transfer(options);
257
+ }
258
+ /** Bulk transfer multiple assets using OpenSea's TransferHelper contract. */
259
+ async bulkTransfer(options) {
260
+ return this._assetsManager.bulkTransfer(options);
261
+ }
262
+ /** Batch approve multiple assets for transfer to the OpenSea conduit. */
263
+ async batchApproveAssets(options) {
264
+ return this._assetsManager.batchApproveAssets(options);
265
+ }
266
+ // ─── Private Helpers ───────────────────────────────────────────────
267
+ /**
268
+ * Compute the `basePrice` parameter to be used to price an order.
269
+ */
270
+ async _getPriceParameters(orderSide, tokenAddress, amount) {
271
+ tokenAddress = tokenAddress.toLowerCase();
272
+ const isEther = tokenAddress === constants_1.ZERO_ADDRESS;
273
+ let decimals = 18;
274
+ if (!isEther) {
275
+ if (tokenAddress in this._cachedPaymentTokenDecimals) {
276
+ decimals = this._cachedPaymentTokenDecimals[tokenAddress];
277
+ }
278
+ else {
279
+ const paymentToken = await this.api.getPaymentToken(tokenAddress);
280
+ this._cachedPaymentTokenDecimals[tokenAddress] = paymentToken.decimals;
281
+ decimals = paymentToken.decimals;
282
+ }
283
+ }
284
+ const amountWei = (0, units_1.parseUnits)(amount.toString(), decimals);
285
+ const basePrice = amountWei;
286
+ if (amount == null || amountWei < 0) {
287
+ throw new Error("Starting price must be a number >= 0");
288
+ }
289
+ if (isEther && orderSide === types_1.OrderSide.OFFER) {
290
+ throw new Error("Offers must use wrapped ETH or an ERC-20 token.");
291
+ }
292
+ return { basePrice };
293
+ }
294
+ _dispatch(event, data) {
295
+ this._emitter.emit(event, data);
296
+ }
297
+ async _requireAccountIsAvailable(accountAddress) {
298
+ const checksummed = (0, address_1.checksumAddress)(accountAddress);
299
+ const availableAccounts = await this._getAvailableAccounts();
300
+ if (availableAccounts.includes(checksummed)) {
301
+ return;
302
+ }
303
+ throw new Error(`Specified accountAddress is not available through wallet or provider: ${checksummed}. Accounts available: ${availableAccounts.length > 0 ? availableAccounts.join(", ") : "none"}`);
304
+ }
305
+ async _confirmTransaction(transactionHash, event, description) {
306
+ const transactionEventData = { transactionHash, event };
307
+ this.logger(`Transaction started: ${description}`);
308
+ try {
309
+ this._dispatch(types_1.EventType.TransactionCreated, transactionEventData);
310
+ await this._wallet.provider.waitForTransaction(transactionHash);
311
+ this.logger(`Transaction succeeded: ${description}`);
312
+ this._dispatch(types_1.EventType.TransactionConfirmed, transactionEventData);
313
+ }
314
+ catch (error) {
315
+ this.logger(`Transaction failed: ${description}`);
316
+ this._dispatch(types_1.EventType.TransactionFailed, {
317
+ ...transactionEventData,
318
+ error,
319
+ });
320
+ throw error;
321
+ }
322
+ }
323
+ }
324
+ exports.BaseOpenSeaSDK = BaseOpenSeaSDK;
325
+ //# sourceMappingURL=base.js.map