@opensea/sdk 12.7.0 → 12.9.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/README.md +34 -6
- package/lib/api/api.d.ts +36 -2
- package/lib/api/api.js +4 -20
- package/lib/api/api.js.map +1 -1
- package/lib/api/events.js +4 -10
- package/lib/api/events.js.map +1 -1
- package/lib/api/fetcher.d.ts +36 -2
- package/lib/api/walletAuth.d.ts +5 -14
- package/lib/api/walletAuth.js +6 -4
- package/lib/api/walletAuth.js.map +1 -1
- package/lib/sdk/orders.d.ts +1 -0
- package/lib/sdk/orders.js +11 -6
- package/lib/sdk/orders.js.map +1 -1
- package/lib/types.d.ts +36 -7
- 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 +11 -4
- 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/package.json +2 -2
- package/src/api/api.ts +75 -7
- package/src/api/events.ts +7 -11
- package/src/api/fetcher.ts +51 -2
- package/src/api/walletAuth.ts +5 -5
- package/src/sdk/orders.ts +15 -9
- package/src/types.ts +37 -6
- package/src/utils/chain.ts +14 -8
- package/src/utils/chainIds.generated.ts +1 -0
package/src/types.ts
CHANGED
|
@@ -211,6 +211,7 @@ export enum Chain {
|
|
|
211
211
|
Ink = "ink",
|
|
212
212
|
Robinhood = "robinhood",
|
|
213
213
|
StableChain = "stablechain",
|
|
214
|
+
Arc = "arc",
|
|
214
215
|
}
|
|
215
216
|
|
|
216
217
|
// Compile-time check: every ChainIdentifier from the API spec must be assignable to Chain.
|
|
@@ -388,12 +389,42 @@ export interface RequestOptions {
|
|
|
388
389
|
* names and trait values, so the default rewrite reports a `dark_brown` trait
|
|
389
390
|
* as `darkBrown` and merges two traits that differ only in casing.
|
|
390
391
|
*
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
392
|
+
* Write it as the literal `false` at the call site. `get`, `post` and
|
|
393
|
+
* `request` overload on that literal and return the raw `T` instead of
|
|
394
|
+
* `Camelize<T>`, so a snake_case `T` stays snake_case in the type as well as
|
|
395
|
+
* at runtime. A `boolean` whose value the compiler cannot see (a variable, or
|
|
396
|
+
* a property widened by a `const` declaration without `as const`) selects the
|
|
397
|
+
* camelized signature. That is accurate when the value turns out to be
|
|
398
|
+
* `true`, and wrong when it is `false`, because the runtime skips the rewrite
|
|
399
|
+
* and the declared type still claims camelCase properties the response does
|
|
400
|
+
* not have. See {@link RawResponseOptions}.
|
|
397
401
|
*/
|
|
398
402
|
camelizeResponse?: boolean
|
|
399
403
|
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* The options shape that selects the un-camelized overload of `get`, `post`
|
|
407
|
+
* and `request`.
|
|
408
|
+
*
|
|
409
|
+
* `camelizeResponse` is the literal `false` rather than `boolean`, which is
|
|
410
|
+
* what lets the overload fire: TypeScript keeps the literal when the property
|
|
411
|
+
* is written inline at the call site or the object is declared `as const`, and
|
|
412
|
+
* widens it to `boolean` otherwise.
|
|
413
|
+
*
|
|
414
|
+
* @example
|
|
415
|
+
* ```ts
|
|
416
|
+
* type UploadPolicy = { upload_url: string; success_action_status: string }
|
|
417
|
+
*
|
|
418
|
+
* // Selects the raw overload. `policy.success_action_status` is typed and
|
|
419
|
+
* // present; `policy.successActionStatus` is a compile error.
|
|
420
|
+
* const policy = await api.get<UploadPolicy>(path, undefined, {
|
|
421
|
+
* camelizeResponse: false,
|
|
422
|
+
* })
|
|
423
|
+
* ```
|
|
424
|
+
*
|
|
425
|
+
* @category API Models
|
|
426
|
+
*/
|
|
427
|
+
export type RawResponseOptions<O extends RequestOptions = RequestOptions> =
|
|
428
|
+
O & {
|
|
429
|
+
camelizeResponse: false
|
|
430
|
+
}
|
package/src/utils/chain.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
OPENSEA_SIGNED_ZONE_V2,
|
|
15
15
|
SOMNIA_FEE_RECIPIENT,
|
|
16
16
|
WPOL_ADDRESS,
|
|
17
|
+
ZERO_ADDRESS,
|
|
17
18
|
} from "../constants"
|
|
18
19
|
import { Chain } from "../types"
|
|
19
20
|
import { CHAIN_ID_MAP } from "./chainIds.generated"
|
|
@@ -106,11 +107,10 @@ export const getOfferPaymentToken = (chain: Chain) => {
|
|
|
106
107
|
return "0x3bd359c1119da7da1d913d1c4d2b7c461115433a" // WMON
|
|
107
108
|
case Chain.Robinhood:
|
|
108
109
|
return "0x0bd7d308f8e1639fab988df18a8011f41eacad73" // WETH
|
|
109
|
-
|
|
110
|
+
case Chain.Arc:
|
|
111
|
+
return "0x3600000000000000000000000000000000000000" // USDC (6-decimal ERC20 mirror of native USDC)
|
|
110
112
|
case Chain.StableChain:
|
|
111
|
-
|
|
112
|
-
`Chain ${chain} is not supported for OpenSea Seaport offers`,
|
|
113
|
-
)
|
|
113
|
+
return "0x779ded0c9e1022225f8e0630b35a9b54be713736" // USDT0 (6-decimal ERC20 mirror of native gUSDT0)
|
|
114
114
|
default: {
|
|
115
115
|
const exhaustiveChain: never = chain
|
|
116
116
|
throw new Error(`Unknown offer currency for ${exhaustiveChain}`)
|
|
@@ -167,11 +167,10 @@ export const getListingPaymentToken = (chain: Chain) => {
|
|
|
167
167
|
return "0x0000000000000000000000000000000000000000" // ANIME
|
|
168
168
|
case Chain.Robinhood:
|
|
169
169
|
return "0x0000000000000000000000000000000000000000" // ETH
|
|
170
|
-
|
|
170
|
+
case Chain.Arc:
|
|
171
|
+
return ZERO_ADDRESS
|
|
171
172
|
case Chain.StableChain:
|
|
172
|
-
|
|
173
|
-
`Chain ${chain} is not supported for OpenSea Seaport listings`,
|
|
174
|
-
)
|
|
173
|
+
return ZERO_ADDRESS
|
|
175
174
|
default: {
|
|
176
175
|
const exhaustiveChain: never = chain
|
|
177
176
|
throw new Error(`Unknown listing currency for ${exhaustiveChain}`)
|
|
@@ -192,6 +191,8 @@ export const getDefaultConduit = (
|
|
|
192
191
|
case Chain.HyperEVM:
|
|
193
192
|
case Chain.Monad:
|
|
194
193
|
case Chain.Robinhood:
|
|
194
|
+
case Chain.Arc:
|
|
195
|
+
case Chain.StableChain:
|
|
195
196
|
return {
|
|
196
197
|
key: OPENSEA_CONDUIT_KEY_2,
|
|
197
198
|
address: OPENSEA_CONDUIT_ADDRESS_2,
|
|
@@ -260,6 +261,11 @@ export const getNativeWrapTokenAddress = (chain: Chain): string => {
|
|
|
260
261
|
switch (chain) {
|
|
261
262
|
case Chain.Polygon:
|
|
262
263
|
return WPOL_ADDRESS
|
|
264
|
+
case Chain.Arc:
|
|
265
|
+
case Chain.StableChain:
|
|
266
|
+
throw new Error(
|
|
267
|
+
`Chain ${chain} has no wrapped native token; offers spend the native balance directly through ${getOfferPaymentToken(chain)}`,
|
|
268
|
+
)
|
|
263
269
|
default:
|
|
264
270
|
return getOfferPaymentToken(chain)
|
|
265
271
|
}
|