@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opensea/sdk",
3
- "version": "9.0.0",
3
+ "version": "10.0.0",
4
4
  "description": "TypeScript SDK for the OpenSea marketplace helps developers build new experiences using NFTs and our marketplace data",
5
5
  "license": "MIT",
6
6
  "author": "OpenSea Developers",
@@ -14,19 +14,28 @@
14
14
  },
15
15
  "type": "commonjs",
16
16
  "main": "lib/index.js",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./lib/index.d.ts",
20
+ "default": "./lib/index.js"
21
+ },
22
+ "./viem": {
23
+ "types": "./lib/viem.d.ts",
24
+ "default": "./lib/viem.js"
25
+ }
26
+ },
17
27
  "files": [
18
28
  "lib",
19
29
  "src"
20
30
  ],
21
31
  "scripts": {
22
- "abi-type-gen": "typechain --target=ethers-v6 src/abi/*.json --out-dir=src/typechain/contracts",
23
- "build": "npm run abi-type-gen && tsc -p tsconfig.build.json",
24
- "check-types": "tsc --noEmit --project tsconfig.json",
32
+ "build": "tsc",
33
+ "check-types": "tsc -p tsconfig.check.json",
25
34
  "docs-build": "typedoc",
26
35
  "docs-build-md": "typedoc --plugin typedoc-plugin-markdown",
27
36
  "format": "biome format --config-path ../.. --write .",
28
37
  "format:check": "biome format --config-path ../.. .",
29
- "lint": "concurrently \"npm run check-types\" \"biome check --config-path ../.. .\"",
38
+ "lint": "biome check --config-path ../.. .",
30
39
  "lint:fix": "biome check --config-path ../.. --write .",
31
40
  "test": "vitest run",
32
41
  "test:all": "concurrently \"npm run test\" \"npm run test:integration\"",
@@ -35,17 +44,25 @@
35
44
  },
36
45
  "types": "lib/index.d.ts",
37
46
  "dependencies": {
38
- "@opensea/api-types": "workspace:^",
47
+ "@noble/hashes": "^2.0.1",
48
+ "@opensea/api-types": "^0.2.0",
39
49
  "@opensea/seaport-js": "^4.0.7",
40
50
  "ethers": "^6.16.0"
41
51
  },
52
+ "peerDependencies": {
53
+ "viem": "^2.0.0"
54
+ },
55
+ "peerDependenciesMeta": {
56
+ "viem": {
57
+ "optional": true
58
+ }
59
+ },
42
60
  "devDependencies": {
43
- "@typechain/ethers-v6": "^0.5.1",
44
61
  "@types/node": "^25.4.0",
62
+ "viem": "2.23.2",
45
63
  "@vitest/coverage-v8": "^3.2.4",
46
64
  "concurrently": "^9.2.1",
47
65
  "dotenv": "^17.3.1",
48
- "typechain": "^8.0.0",
49
66
  "typedoc": "^0.28.17",
50
67
  "typedoc-plugin-markdown": "^4.10.0",
51
68
  "typescript": "^6.0.2",
@@ -0,0 +1,236 @@
1
+ /**
2
+ * Minimal ABI definitions for the contract calls the SDK makes.
3
+ * These replace the TypeChain-generated factories from v9.
4
+ */
5
+
6
+ export const ERC20_ABI = [
7
+ {
8
+ name: "balanceOf",
9
+ type: "function",
10
+ stateMutability: "view",
11
+ inputs: [{ name: "account", type: "address" }],
12
+ outputs: [{ name: "", type: "uint256" }],
13
+ },
14
+ {
15
+ name: "transfer",
16
+ type: "function",
17
+ stateMutability: "nonpayable",
18
+ inputs: [
19
+ { name: "to", type: "address" },
20
+ { name: "amount", type: "uint256" },
21
+ ],
22
+ outputs: [{ name: "", type: "bool" }],
23
+ },
24
+ {
25
+ name: "allowance",
26
+ type: "function",
27
+ stateMutability: "view",
28
+ inputs: [
29
+ { name: "owner", type: "address" },
30
+ { name: "spender", type: "address" },
31
+ ],
32
+ outputs: [{ name: "", type: "uint256" }],
33
+ },
34
+ {
35
+ name: "approve",
36
+ type: "function",
37
+ stateMutability: "nonpayable",
38
+ inputs: [
39
+ { name: "spender", type: "address" },
40
+ { name: "amount", type: "uint256" },
41
+ ],
42
+ outputs: [{ name: "", type: "bool" }],
43
+ },
44
+ ] as const
45
+
46
+ export const ERC721_ABI = [
47
+ {
48
+ name: "ownerOf",
49
+ type: "function",
50
+ stateMutability: "view",
51
+ inputs: [{ name: "tokenId", type: "uint256" }],
52
+ outputs: [{ name: "", type: "address" }],
53
+ },
54
+ {
55
+ name: "transferFrom",
56
+ type: "function",
57
+ stateMutability: "nonpayable",
58
+ inputs: [
59
+ { name: "from", type: "address" },
60
+ { name: "to", type: "address" },
61
+ { name: "tokenId", type: "uint256" },
62
+ ],
63
+ outputs: [],
64
+ },
65
+ {
66
+ name: "isApprovedForAll",
67
+ type: "function",
68
+ stateMutability: "view",
69
+ inputs: [
70
+ { name: "owner", type: "address" },
71
+ { name: "operator", type: "address" },
72
+ ],
73
+ outputs: [{ name: "", type: "bool" }],
74
+ },
75
+ {
76
+ name: "getApproved",
77
+ type: "function",
78
+ stateMutability: "view",
79
+ inputs: [{ name: "tokenId", type: "uint256" }],
80
+ outputs: [{ name: "", type: "address" }],
81
+ },
82
+ {
83
+ name: "setApprovalForAll",
84
+ type: "function",
85
+ stateMutability: "nonpayable",
86
+ inputs: [
87
+ { name: "operator", type: "address" },
88
+ { name: "approved", type: "bool" },
89
+ ],
90
+ outputs: [],
91
+ },
92
+ ] as const
93
+
94
+ export const ERC1155_ABI = [
95
+ {
96
+ name: "balanceOf",
97
+ type: "function",
98
+ stateMutability: "view",
99
+ inputs: [
100
+ { name: "account", type: "address" },
101
+ { name: "id", type: "uint256" },
102
+ ],
103
+ outputs: [{ name: "", type: "uint256" }],
104
+ },
105
+ {
106
+ name: "safeTransferFrom",
107
+ type: "function",
108
+ stateMutability: "nonpayable",
109
+ inputs: [
110
+ { name: "from", type: "address" },
111
+ { name: "to", type: "address" },
112
+ { name: "id", type: "uint256" },
113
+ { name: "amount", type: "uint256" },
114
+ { name: "data", type: "bytes" },
115
+ ],
116
+ outputs: [],
117
+ },
118
+ {
119
+ name: "isApprovedForAll",
120
+ type: "function",
121
+ stateMutability: "view",
122
+ inputs: [
123
+ { name: "owner", type: "address" },
124
+ { name: "operator", type: "address" },
125
+ ],
126
+ outputs: [{ name: "", type: "bool" }],
127
+ },
128
+ {
129
+ name: "setApprovalForAll",
130
+ type: "function",
131
+ stateMutability: "nonpayable",
132
+ inputs: [
133
+ { name: "operator", type: "address" },
134
+ { name: "approved", type: "bool" },
135
+ ],
136
+ outputs: [],
137
+ },
138
+ ] as const
139
+
140
+ export const WETH_DEPOSIT_ABI = [
141
+ {
142
+ name: "deposit",
143
+ type: "function",
144
+ stateMutability: "payable",
145
+ inputs: [],
146
+ outputs: [],
147
+ },
148
+ ] as const
149
+
150
+ export const WETH_WITHDRAW_ABI = [
151
+ {
152
+ name: "withdraw",
153
+ type: "function",
154
+ stateMutability: "nonpayable",
155
+ inputs: [{ name: "wad", type: "uint256" }],
156
+ outputs: [],
157
+ },
158
+ ] as const
159
+
160
+ export const TRANSFER_HELPER_ABI = [
161
+ {
162
+ name: "bulkTransfer",
163
+ type: "function",
164
+ stateMutability: "nonpayable",
165
+ inputs: [
166
+ {
167
+ name: "items",
168
+ type: "tuple[]",
169
+ components: [
170
+ { name: "itemType", type: "uint8" },
171
+ { name: "token", type: "address" },
172
+ { name: "identifier", type: "uint256" },
173
+ { name: "amount", type: "uint256" },
174
+ { name: "recipient", type: "address" },
175
+ ],
176
+ },
177
+ { name: "conduitKey", type: "bytes32" },
178
+ ],
179
+ outputs: [{ name: "", type: "bytes4" }],
180
+ },
181
+ ] as const
182
+
183
+ export const MULTICALL3_ABI = [
184
+ {
185
+ name: "aggregate3",
186
+ type: "function",
187
+ stateMutability: "payable",
188
+ inputs: [
189
+ {
190
+ name: "calls",
191
+ type: "tuple[]",
192
+ components: [
193
+ { name: "target", type: "address" },
194
+ { name: "allowFailure", type: "bool" },
195
+ { name: "callData", type: "bytes" },
196
+ ],
197
+ },
198
+ ],
199
+ outputs: [
200
+ {
201
+ name: "returnData",
202
+ type: "tuple[]",
203
+ components: [
204
+ { name: "success", type: "bool" },
205
+ { name: "returnData", type: "bytes" },
206
+ ],
207
+ },
208
+ ],
209
+ },
210
+ ] as const
211
+
212
+ export const SET_APPROVAL_FOR_ALL_ABI = [
213
+ {
214
+ name: "setApprovalForAll",
215
+ type: "function",
216
+ stateMutability: "nonpayable",
217
+ inputs: [
218
+ { name: "operator", type: "address" },
219
+ { name: "approved", type: "bool" },
220
+ ],
221
+ outputs: [],
222
+ },
223
+ ] as const
224
+
225
+ export const APPROVE_ABI = [
226
+ {
227
+ name: "approve",
228
+ type: "function",
229
+ stateMutability: "nonpayable",
230
+ inputs: [
231
+ { name: "spender", type: "address" },
232
+ { name: "amount", type: "uint256" },
233
+ ],
234
+ outputs: [{ name: "", type: "bool" }],
235
+ },
236
+ ] as const
package/src/api/api.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { ethers } from "ethers"
2
1
  import { API_BASE_MAINNET } from "../constants"
3
2
  import type {
4
3
  FulfillmentDataResponse,
@@ -999,7 +998,9 @@ export class OpenSeaAPI {
999
998
  * Fetch from an API Endpoint, sending auth token in headers
1000
999
  * @param url The URL to fetch
1001
1000
  * @param headers Additional headers to send with the request
1002
- * @param body Optional body to send. If set, will POST, otherwise GET
1001
+ * @param body Optional body to send. HTTP method is inferred: POST if body is
1002
+ * provided (non-nullish), GET otherwise. This covers all OpenSea API
1003
+ * endpoints which only use GET and POST.
1003
1004
  * @param options Request options like timeout and abort signal
1004
1005
  */
1005
1006
  private async _fetch(
@@ -1008,61 +1009,64 @@ export class OpenSeaAPI {
1008
1009
  body?: object,
1009
1010
  options?: RequestOptions,
1010
1011
  ) {
1011
- // Create the fetch request
1012
- const req = new ethers.FetchRequest(url)
1013
-
1014
- // Set the headers
1015
- headers = {
1012
+ const mergedHeaders: Record<string, string> = {
1013
+ // Kept as "opensea-js" for server-side analytics continuity after package rename
1016
1014
  "x-app-id": "opensea-js",
1017
1015
  ...(this.apiKey ? { "X-API-KEY": this.apiKey } : {}),
1016
+ ...(body != null ? { "Content-Type": "application/json" } : {}),
1018
1017
  ...headers,
1019
1018
  }
1020
- for (const [key, value] of Object.entries(headers)) {
1021
- req.setHeader(key, value)
1022
- }
1023
-
1024
- // Set the body if provided
1025
- if (body) {
1026
- req.body = body
1027
- }
1028
-
1029
- // Apply request options
1030
- if (options?.timeout !== undefined) {
1031
- req.timeout = options.timeout
1032
- }
1033
-
1034
- // Set up abort signal handling
1035
- let abortHandler: (() => void) | undefined
1036
- if (options?.signal) {
1037
- if (options.signal.aborted) {
1038
- throw new Error("Request aborted")
1039
- }
1040
- abortHandler = () => req.cancel()
1041
- options.signal.addEventListener("abort", abortHandler)
1042
- }
1043
-
1044
- // Set the throttle params
1045
- req.setThrottleParams({ slotInterval: 1000 })
1046
1019
 
1047
- const sanitizedHeaders = { ...req.headers }
1020
+ const sanitizedHeaders = { ...mergedHeaders }
1048
1021
  delete sanitizedHeaders["X-API-KEY"]
1049
1022
  this.logger(
1050
1023
  `Sending request: ${url} ${JSON.stringify({
1051
- method: body ? "POST" : "GET",
1024
+ method: body != null ? "POST" : "GET",
1052
1025
  headers: sanitizedHeaders,
1053
- body: body ? JSON.stringify(body, null, 2) : undefined,
1026
+ body: body != null ? JSON.stringify(body, null, 2) : undefined,
1054
1027
  })}`,
1055
1028
  )
1056
1029
 
1030
+ // Build abort signal (merge timeout + user-provided signal)
1031
+ let controller: AbortController | undefined
1032
+ let timeoutId: ReturnType<typeof setTimeout> | undefined
1033
+ let userAbortHandler: (() => void) | undefined
1034
+ let signal = options?.signal
1035
+ if (options?.timeout !== undefined) {
1036
+ controller = new AbortController()
1037
+ timeoutId = setTimeout(() => controller!.abort(), options.timeout)
1038
+ // If user provided their own signal, abort ours if theirs fires
1039
+ if (options.signal) {
1040
+ if (options.signal.aborted) {
1041
+ clearTimeout(timeoutId)
1042
+ throw new Error("Request aborted")
1043
+ }
1044
+ userAbortHandler = () => {
1045
+ controller!.abort()
1046
+ clearTimeout(timeoutId)
1047
+ }
1048
+ options.signal.addEventListener("abort", userAbortHandler)
1049
+ }
1050
+ signal = controller.signal
1051
+ } else if (options?.signal?.aborted) {
1052
+ throw new Error("Request aborted")
1053
+ }
1054
+
1057
1055
  try {
1058
- const response = await req.send()
1059
- if (!response.ok()) {
1056
+ const response = await fetch(url, {
1057
+ method: body != null ? "POST" : "GET",
1058
+ headers: mergedHeaders,
1059
+ body: body != null ? JSON.stringify(body) : undefined,
1060
+ signal,
1061
+ })
1062
+
1063
+ if (!response.ok) {
1060
1064
  // Handle rate limit errors (429 Too Many Requests and 599 custom rate limit)
1061
- if (response.statusCode === 599 || response.statusCode === 429) {
1062
- throw this._createRateLimitError(response)
1065
+ if (response.status === 599 || response.status === 429) {
1066
+ throw await this._createRateLimitError(response)
1063
1067
  }
1064
- // If an errors array is returned, throw with the error messages.
1065
- const errors = response.bodyJson?.errors
1068
+ const responseBody = await response.json().catch(() => ({}))
1069
+ const errors = responseBody?.errors
1066
1070
  if (errors?.length > 0) {
1067
1071
  let errorMessage = Array.isArray(errors)
1068
1072
  ? errors.join(", ")
@@ -1071,17 +1075,18 @@ export class OpenSeaAPI {
1071
1075
  errorMessage = JSON.stringify(errors)
1072
1076
  }
1073
1077
  throw new Error(`Server Error: ${errorMessage}`)
1074
- } else {
1075
- // Otherwise, let ethers throw a SERVER_ERROR since it will include
1076
- // more context about the request and response.
1077
- response.assertOk()
1078
1078
  }
1079
+ throw new Error(
1080
+ `Server Error (${response.status}): ${response.statusText}`,
1081
+ )
1079
1082
  }
1080
- return response.bodyJson
1083
+ return response.json()
1081
1084
  } finally {
1082
- // Clean up abort handler
1083
- if (abortHandler && options?.signal) {
1084
- options.signal.removeEventListener("abort", abortHandler)
1085
+ if (timeoutId !== undefined) {
1086
+ clearTimeout(timeoutId)
1087
+ }
1088
+ if (userAbortHandler && options?.signal) {
1089
+ options.signal.removeEventListener("abort", userAbortHandler)
1085
1090
  }
1086
1091
  }
1087
1092
  }
@@ -1097,9 +1102,8 @@ export class OpenSeaAPI {
1097
1102
  * @param response The HTTP response object from the API
1098
1103
  * @returns The retry-after value in seconds (capped at 5 minutes), or undefined if not present or invalid
1099
1104
  */
1100
- private _parseRetryAfter(response: ethers.FetchResponse): number | undefined {
1101
- const retryAfterHeader =
1102
- response.headers["retry-after"] || response.headers["Retry-After"]
1105
+ private _parseRetryAfter(response: Response): number | undefined {
1106
+ const retryAfterHeader = response.headers.get("retry-after")
1103
1107
  if (retryAfterHeader) {
1104
1108
  const trimmed = retryAfterHeader.trim()
1105
1109
 
@@ -1132,21 +1136,24 @@ export class OpenSeaAPI {
1132
1136
 
1133
1137
  /**
1134
1138
  * Creates a rate limit error with status code and retry-after information.
1139
+ * This is async because it attempts to parse the response body. If the body
1140
+ * is malformed JSON, responseBody will be undefined (intentional — the error
1141
+ * itself is more important than the body).
1135
1142
  * @param response The HTTP response object from the API
1136
1143
  * @returns An enhanced Error object with statusCode, retryAfter and responseBody properties
1137
1144
  */
1138
- private _createRateLimitError(
1139
- response: ethers.FetchResponse,
1140
- ): OpenSeaRateLimitError {
1145
+ private async _createRateLimitError(
1146
+ response: Response,
1147
+ ): Promise<OpenSeaRateLimitError> {
1141
1148
  const retryAfter = this._parseRetryAfter(response)
1142
1149
  const error = new Error(
1143
- `${response.statusCode} ${response.statusMessage}`,
1150
+ `${response.status} ${response.statusText}`,
1144
1151
  ) as OpenSeaRateLimitError
1145
1152
 
1146
1153
  // Add status code and retry-after information to the error object
1147
- error.statusCode = response.statusCode
1154
+ error.statusCode = response.status
1148
1155
  error.retryAfter = retryAfter
1149
- error.responseBody = response.bodyJson
1156
+ error.responseBody = await response.json().catch(() => undefined)
1150
1157
  return error
1151
1158
  }
1152
1159
  }
package/src/api/orders.ts CHANGED
@@ -207,8 +207,8 @@ export class OrdersAPI {
207
207
  }
208
208
 
209
209
  // Validate side value
210
- if (side !== "ask" && side !== "bid") {
211
- throw new Error("side must be either 'ask' or 'bid'")
210
+ if (side !== "listing" && side !== "offer") {
211
+ throw new Error("side must be either 'listing' or 'offer'")
212
212
  }
213
213
 
214
214
  // Validate protocolAddress format
package/src/constants.ts CHANGED
@@ -1,12 +1,16 @@
1
- import { FixedNumber } from "ethers"
2
-
3
1
  // =============================================================================
4
2
  // Math & Calculation Constants
5
3
  // =============================================================================
6
4
 
7
- export const FIXED_NUMBER_100 = FixedNumber.fromValue(100)
8
5
  export const INVERSE_BASIS_POINT = 10_000n // 100 basis points per 1%
9
6
 
7
+ // =============================================================================
8
+ // Ethereum Constants
9
+ // =============================================================================
10
+
11
+ export const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"
12
+ export const MAX_UINT256 = 2n ** 256n - 1n
13
+
10
14
  // =============================================================================
11
15
  // API Configuration
12
16
  // =============================================================================
package/src/index.ts CHANGED
@@ -1,7 +1,15 @@
1
1
  import { OpenSeaSDK } from "./sdk"
2
2
 
3
3
  export * from "./api/types"
4
+ export * from "./constants"
4
5
  export * from "./orders/types"
6
+ export type {
7
+ ContractCaller,
8
+ OpenSeaProvider,
9
+ OpenSeaSigner,
10
+ OpenSeaWallet,
11
+ TransactionResponse,
12
+ } from "./provider/types"
5
13
  export * from "./types"
6
14
  export * from "./utils"
7
15
  /**
@@ -8,7 +8,7 @@ import type {
8
8
  } from "@opensea/seaport-js/lib/types"
9
9
  import { isCurrencyItem } from "@opensea/seaport-js/lib/utils/item"
10
10
  import { generateRandomSalt } from "@opensea/seaport-js/lib/utils/order"
11
- import { ZeroAddress } from "ethers"
11
+ import { ZERO_ADDRESS } from "../constants"
12
12
 
13
13
  /**
14
14
  * Compute the native currency (ETH) value required to fulfill a private listing.
@@ -25,7 +25,7 @@ export const computePrivateListingValue = (
25
25
  .filter(
26
26
  item =>
27
27
  item.recipient.toLowerCase() !== takerAddress.toLowerCase() &&
28
- item.token.toLowerCase() === ZeroAddress.toLowerCase() &&
28
+ item.token.toLowerCase() === ZERO_ADDRESS.toLowerCase() &&
29
29
  item.itemType === ItemType.NATIVE,
30
30
  )
31
31
  .reduce((sum, item) => sum + BigInt(item.startAmount), 0n)
@@ -222,6 +222,13 @@ export const serializeOrdersQueryOptions = (
222
222
  }
223
223
  }
224
224
 
225
+ /** Map API side values ("ask"/"bid") to SDK OrderSide enum values */
226
+ const mapApiSide = (side: string): OrderSide => {
227
+ if (side === "ask" || side === OrderSide.LISTING) return OrderSide.LISTING
228
+ if (side === "bid" || side === OrderSide.OFFER) return OrderSide.OFFER
229
+ return side as OrderSide
230
+ }
231
+
225
232
  export const deserializeOrder = (order: SerializedOrderV2): OrderV2 => {
226
233
  return {
227
234
  createdDate: order.created_date,
@@ -242,7 +249,7 @@ export const deserializeOrder = (order: SerializedOrderV2): OrderV2 => {
242
249
  account: accountFromJSON(account),
243
250
  basisPoints: basis_points,
244
251
  })),
245
- side: order.side,
252
+ side: mapApiSide(order.side as string),
246
253
  orderType: order.order_type,
247
254
  cancelled: order.cancelled,
248
255
  finalized: order.finalized,