@opensea/sdk 11.1.1 → 11.3.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 (68) hide show
  1. package/lib/api/accounts.d.ts +13 -1
  2. package/lib/api/accounts.js +18 -0
  3. package/lib/api/accounts.js.map +1 -1
  4. package/lib/api/api.d.ts +14 -1
  5. package/lib/api/api.js +22 -0
  6. package/lib/api/api.js.map +1 -1
  7. package/lib/api/apiPaths.d.ts +3 -0
  8. package/lib/api/apiPaths.js +13 -1
  9. package/lib/api/apiPaths.js.map +1 -1
  10. package/lib/api/types.d.ts +31 -1
  11. package/lib/auth/index.d.ts +67 -0
  12. package/lib/auth/index.js +174 -0
  13. package/lib/auth/index.js.map +1 -0
  14. package/lib/auth/oauth-types.d.ts +69 -0
  15. package/lib/auth/oauth-types.js +3 -0
  16. package/lib/auth/oauth-types.js.map +1 -0
  17. package/lib/auth/oauth.d.ts +109 -0
  18. package/lib/auth/oauth.js +342 -0
  19. package/lib/auth/oauth.js.map +1 -0
  20. package/lib/auth/siwx.d.ts +63 -0
  21. package/lib/auth/siwx.js +276 -0
  22. package/lib/auth/siwx.js.map +1 -0
  23. package/lib/auth/types.d.ts +50 -0
  24. package/lib/auth/types.js +3 -0
  25. package/lib/auth/types.js.map +1 -0
  26. package/lib/index.d.ts +7 -1
  27. package/lib/index.js +9 -1
  28. package/lib/index.js.map +1 -1
  29. package/lib/scopes.d.ts +29 -0
  30. package/lib/scopes.js +27 -0
  31. package/lib/scopes.js.map +1 -0
  32. package/lib/sdk/base.d.ts +1 -0
  33. package/lib/sdk/base.js +6 -3
  34. package/lib/sdk/base.js.map +1 -1
  35. package/lib/sdk/cancellation.js +33 -23
  36. package/lib/sdk/cancellation.js.map +1 -1
  37. package/lib/types.d.ts +5 -1
  38. package/lib/types.js +1 -0
  39. package/lib/types.js.map +1 -1
  40. package/lib/utils/chain.d.ts +1 -1
  41. package/lib/utils/chain.js +30 -5
  42. package/lib/utils/chain.js.map +1 -1
  43. package/lib/utils/chainIds.generated.js +1 -0
  44. package/lib/utils/chainIds.generated.js.map +1 -1
  45. package/lib/utils/units.js +9 -5
  46. package/lib/utils/units.js.map +1 -1
  47. package/lib/viem.d.ts +1 -0
  48. package/lib/viem.js +1 -0
  49. package/lib/viem.js.map +1 -1
  50. package/package.json +7 -7
  51. package/src/api/accounts.ts +41 -0
  52. package/src/api/api.ts +36 -0
  53. package/src/api/apiPaths.ts +12 -0
  54. package/src/api/types.ts +36 -0
  55. package/src/auth/index.ts +244 -0
  56. package/src/auth/oauth-types.ts +73 -0
  57. package/src/auth/oauth.ts +428 -0
  58. package/src/auth/siwx.ts +400 -0
  59. package/src/auth/types.ts +55 -0
  60. package/src/index.ts +10 -0
  61. package/src/scopes.ts +39 -0
  62. package/src/sdk/base.ts +6 -4
  63. package/src/sdk/cancellation.ts +39 -25
  64. package/src/types.ts +4 -0
  65. package/src/utils/chain.ts +37 -5
  66. package/src/utils/chainIds.generated.ts +1 -0
  67. package/src/utils/units.ts +9 -5
  68. package/src/viem.ts +1 -0
@@ -38,7 +38,14 @@ export const usesAlternateProtocol = (chain: Chain): boolean =>
38
38
  */
39
39
  export const getChainId = (chain: Chain): string => {
40
40
  const id = CHAIN_ID_MAP[chain]
41
- if (id === undefined) throw new Error(`Unknown chainId for ${chain}`)
41
+ if (id === undefined) {
42
+ if (Object.values(Chain).includes(chain)) {
43
+ throw new Error(
44
+ `Chain ${chain} has no EVM chain ID for OpenSea Seaport operations`,
45
+ )
46
+ }
47
+ throw new Error(`Unknown chainId for ${chain}`)
48
+ }
42
49
  return id
43
50
  }
44
51
 
@@ -48,6 +55,11 @@ export const getChainId = (chain: Chain): string => {
48
55
  * @returns The token address for offers
49
56
  */
50
57
  export const getOfferPaymentToken = (chain: Chain) => {
58
+ if (chain === Chain.Solana || chain === Chain.Hyperliquid) {
59
+ throw new Error(
60
+ `Chain ${chain} is not supported for OpenSea Seaport offers`,
61
+ )
62
+ }
51
63
  switch (chain) {
52
64
  case Chain.Mainnet:
53
65
  return "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" // WETH
@@ -68,7 +80,10 @@ export const getOfferPaymentToken = (chain: Chain) => {
68
80
  case Chain.Shape:
69
81
  case Chain.Unichain:
70
82
  case Chain.Ink:
83
+ case Chain.Soneium:
71
84
  return "0x4200000000000000000000000000000000000006" // WETH
85
+ case Chain.AnimeChain:
86
+ return "0x164906a76f1a2ea933366c446ae0ec6a37062c42" // WANIME
72
87
  case Chain.BeraChain:
73
88
  return "0x6969696969696969696969696969696969696969" // WBERA
74
89
  case Chain.Sei:
@@ -89,8 +104,12 @@ export const getOfferPaymentToken = (chain: Chain) => {
89
104
  return "0x046ede9564a72571df6f5e44d0405360c0f4dcab" // WSOMI
90
105
  case Chain.Monad:
91
106
  return "0x3bd359c1119da7da1d913d1c4d2b7c461115433a" // WMON
92
- default:
93
- throw new Error(`Unknown offer currency for ${chain}`)
107
+ case Chain.Robinhood:
108
+ return "0x0bd7d308f8e1639fab988df18a8011f41eacad73" // WETH
109
+ default: {
110
+ const exhaustiveChain: never = chain
111
+ throw new Error(`Unknown offer currency for ${exhaustiveChain}`)
112
+ }
94
113
  }
95
114
  }
96
115
 
@@ -100,8 +119,14 @@ export const getOfferPaymentToken = (chain: Chain) => {
100
119
  * @returns The token address for listings
101
120
  */
102
121
  export const getListingPaymentToken = (chain: Chain) => {
122
+ if (chain === Chain.Solana || chain === Chain.Hyperliquid) {
123
+ throw new Error(
124
+ `Chain ${chain} is not supported for OpenSea Seaport listings`,
125
+ )
126
+ }
103
127
  switch (chain) {
104
128
  case Chain.Mainnet:
129
+ case Chain.Soneium:
105
130
  case Chain.Somnia:
106
131
  case Chain.HyperEVM:
107
132
  case Chain.Arbitrum:
@@ -133,8 +158,14 @@ export const getListingPaymentToken = (chain: Chain) => {
133
158
  return "0xe514d9deb7966c8be0ca922de8a064264ea6bcd4" // WETH
134
159
  case Chain.Gunzilla:
135
160
  return "0x0000000000000000000000000000000000000000" // GUN
136
- default:
137
- throw new Error(`Unknown listing currency for ${chain}`)
161
+ case Chain.AnimeChain:
162
+ return "0x0000000000000000000000000000000000000000" // ANIME
163
+ case Chain.Robinhood:
164
+ return "0x0000000000000000000000000000000000000000" // ETH
165
+ default: {
166
+ const exhaustiveChain: never = chain
167
+ throw new Error(`Unknown listing currency for ${exhaustiveChain}`)
168
+ }
138
169
  }
139
170
  }
140
171
 
@@ -150,6 +181,7 @@ export const getDefaultConduit = (
150
181
  case Chain.Abstract:
151
182
  case Chain.HyperEVM:
152
183
  case Chain.Monad:
184
+ case Chain.Robinhood:
153
185
  return {
154
186
  key: OPENSEA_CONDUIT_KEY_2,
155
187
  address: OPENSEA_CONDUIT_ADDRESS_2,
@@ -19,6 +19,7 @@ export const CHAIN_ID_MAP: Record<string, string> = {
19
19
  ronin: "2020",
20
20
  abstract: "2741",
21
21
  megaeth: "4326",
22
+ robinhood: "4663",
22
23
  somnia: "5031",
23
24
  b3: "8333",
24
25
  base: "8453",
@@ -10,11 +10,15 @@ export function parseUnits(
10
10
  ): bigint {
11
11
  let str = value.toString()
12
12
 
13
- // Handle JavaScript scientific notation (e.g. 1e-8 → "0.00000001").
14
- // Note: toFixed has precision limits for very large numbers, but this is
15
- // sufficient for realistic token amounts (up to ~2^53).
16
- if (typeof value === "number" && str.includes("e")) {
17
- str = value.toFixed(decimals)
13
+ // Handle scientific notation (e.g. 1e-8 → "0.00000001") for both
14
+ // number and string inputs. Note: toFixed has precision limits for very
15
+ // large numbers, but this is sufficient for realistic token amounts.
16
+ if (str.includes("e") || str.includes("E")) {
17
+ const num = Number(str)
18
+ if (isNaN(num)) {
19
+ throw new Error(`Invalid numeric value: ${str}`)
20
+ }
21
+ str = num.toFixed(decimals)
18
22
  }
19
23
 
20
24
  // Handle negative values
package/src/viem.ts CHANGED
@@ -40,6 +40,7 @@ import {
40
40
  // Re-export everything from the main entry point
41
41
  export { OpenSeaAPI } from "./api/api"
42
42
  export * from "./api/types"
43
+ export * from "./auth"
43
44
  export * from "./constants"
44
45
  export * from "./orders/types"
45
46
  export type {