@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.
- package/lib/api/accounts.d.ts +13 -1
- package/lib/api/accounts.js +18 -0
- package/lib/api/accounts.js.map +1 -1
- package/lib/api/api.d.ts +14 -1
- package/lib/api/api.js +22 -0
- package/lib/api/api.js.map +1 -1
- package/lib/api/apiPaths.d.ts +3 -0
- package/lib/api/apiPaths.js +13 -1
- package/lib/api/apiPaths.js.map +1 -1
- package/lib/api/types.d.ts +31 -1
- package/lib/auth/index.d.ts +67 -0
- package/lib/auth/index.js +174 -0
- package/lib/auth/index.js.map +1 -0
- package/lib/auth/oauth-types.d.ts +69 -0
- package/lib/auth/oauth-types.js +3 -0
- package/lib/auth/oauth-types.js.map +1 -0
- package/lib/auth/oauth.d.ts +109 -0
- package/lib/auth/oauth.js +342 -0
- package/lib/auth/oauth.js.map +1 -0
- package/lib/auth/siwx.d.ts +63 -0
- package/lib/auth/siwx.js +276 -0
- package/lib/auth/siwx.js.map +1 -0
- package/lib/auth/types.d.ts +50 -0
- package/lib/auth/types.js +3 -0
- package/lib/auth/types.js.map +1 -0
- package/lib/index.d.ts +7 -1
- package/lib/index.js +9 -1
- package/lib/index.js.map +1 -1
- package/lib/scopes.d.ts +29 -0
- package/lib/scopes.js +27 -0
- package/lib/scopes.js.map +1 -0
- package/lib/sdk/base.d.ts +1 -0
- package/lib/sdk/base.js +6 -3
- package/lib/sdk/base.js.map +1 -1
- package/lib/sdk/cancellation.js +33 -23
- package/lib/sdk/cancellation.js.map +1 -1
- package/lib/types.d.ts +5 -1
- package/lib/types.js +1 -0
- package/lib/types.js.map +1 -1
- package/lib/utils/chain.d.ts +1 -1
- package/lib/utils/chain.js +30 -5
- package/lib/utils/chain.js.map +1 -1
- package/lib/utils/chainIds.generated.js +1 -0
- package/lib/utils/chainIds.generated.js.map +1 -1
- package/lib/utils/units.js +9 -5
- package/lib/utils/units.js.map +1 -1
- package/lib/viem.d.ts +1 -0
- package/lib/viem.js +1 -0
- package/lib/viem.js.map +1 -1
- package/package.json +7 -7
- package/src/api/accounts.ts +41 -0
- package/src/api/api.ts +36 -0
- package/src/api/apiPaths.ts +12 -0
- package/src/api/types.ts +36 -0
- package/src/auth/index.ts +244 -0
- package/src/auth/oauth-types.ts +73 -0
- package/src/auth/oauth.ts +428 -0
- package/src/auth/siwx.ts +400 -0
- package/src/auth/types.ts +55 -0
- package/src/index.ts +10 -0
- package/src/scopes.ts +39 -0
- package/src/sdk/base.ts +6 -4
- package/src/sdk/cancellation.ts +39 -25
- package/src/types.ts +4 -0
- package/src/utils/chain.ts +37 -5
- package/src/utils/chainIds.generated.ts +1 -0
- package/src/utils/units.ts +9 -5
- package/src/viem.ts +1 -0
package/src/utils/chain.ts
CHANGED
|
@@ -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)
|
|
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
|
-
|
|
93
|
-
|
|
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
|
-
|
|
137
|
-
|
|
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,
|
package/src/utils/units.ts
CHANGED
|
@@ -10,11 +10,15 @@ export function parseUnits(
|
|
|
10
10
|
): bigint {
|
|
11
11
|
let str = value.toString()
|
|
12
12
|
|
|
13
|
-
// Handle
|
|
14
|
-
// Note: toFixed has precision limits for very
|
|
15
|
-
// sufficient for realistic token amounts
|
|
16
|
-
if (
|
|
17
|
-
|
|
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