@opensea/cli 0.4.1 → 1.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.
- package/README.md +12 -1
- package/dist/cli.js +1484 -72
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +508 -183
- package/dist/index.js +1276 -36
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
package/dist/index.d.ts
CHANGED
|
@@ -1,161 +1,65 @@
|
|
|
1
|
-
|
|
1
|
+
import { components } from '@opensea/api-types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* API types for the OpenSea CLI.
|
|
5
|
+
*
|
|
6
|
+
* Types that match the OpenSea API spec are imported from @opensea/api-types.
|
|
7
|
+
* CLI-specific types (swap, search UI, token details) are defined locally.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
type Schemas = components["schemas"];
|
|
11
|
+
type Chain = Schemas["ChainIdentifier"];
|
|
12
|
+
type Fee = Schemas["Fee"];
|
|
13
|
+
type PaymentToken = Schemas["PaymentToken"];
|
|
14
|
+
type Price = Schemas["Price"];
|
|
15
|
+
type Trait = Schemas["Trait"];
|
|
16
|
+
type Contract = Schemas["Contract"];
|
|
17
|
+
type Nft = Schemas["Nft"];
|
|
18
|
+
type NftDetailed = Schemas["NftDetailed"];
|
|
19
|
+
type Owner = Schemas["Owner"];
|
|
20
|
+
type Rarity = Schemas["Rarity"];
|
|
21
|
+
type CollectionRarity = Schemas["CollectionRarity"];
|
|
22
|
+
type Order = Schemas["Order"];
|
|
23
|
+
type Offer = Schemas["Offer"];
|
|
24
|
+
type Listing = Schemas["Listing"];
|
|
25
|
+
type ListingPrice = Schemas["ListingPrice"];
|
|
26
|
+
type Payment = Schemas["Payment"];
|
|
27
|
+
type Event = Schemas["Event"];
|
|
28
|
+
type SaleEvent = Schemas["SaleEvent"];
|
|
29
|
+
type TransferEvent = Schemas["TransferEvent"];
|
|
30
|
+
type OrderEvent = Schemas["OrderEvent"];
|
|
31
|
+
type SimpleAccount = Schemas["SimpleAccount"];
|
|
32
|
+
type SocialMediaAccount = Schemas["SocialMediaAccount"];
|
|
33
|
+
type ProtocolData = Schemas["ProtocolData"];
|
|
34
|
+
type IntervalStat = Schemas["IntervalStat"];
|
|
35
|
+
type Total = Schemas["Total"];
|
|
36
|
+
type PricingCurrencies = Schemas["PricingCurrencies"];
|
|
37
|
+
type CollectionResponse = Schemas["CollectionResponse"];
|
|
38
|
+
type CollectionDetailedResponse = Schemas["CollectionDetailedResponse"];
|
|
39
|
+
type CollectionPaginatedResponse = Schemas["CollectionPaginatedResponse"];
|
|
40
|
+
type CollectionStatsResponse = Schemas["CollectionStatsResponse"];
|
|
41
|
+
type NftResponse = Schemas["NftResponse"];
|
|
42
|
+
type NftListResponse = Schemas["NftListResponse"];
|
|
43
|
+
type OrdersResponse = Schemas["OrdersResponse"];
|
|
44
|
+
type OffersResponse = Schemas["OffersResponse"];
|
|
45
|
+
type ListingsResponse = Schemas["ListingsResponse"];
|
|
46
|
+
type GetOrderResponse = Schemas["GetOrderResponse"];
|
|
47
|
+
type AssetEventsResponse = Schemas["AssetEventsResponse"];
|
|
48
|
+
type AccountResponse = Schemas["AccountResponse"];
|
|
49
|
+
type ContractResponse = Schemas["ContractResponse"];
|
|
50
|
+
type FulfillListingResponse = Schemas["FulfillListingResponse"];
|
|
51
|
+
type DropResponse = Schemas["DropResponse"];
|
|
52
|
+
type DropDetailedResponse = Schemas["DropDetailedResponse"];
|
|
53
|
+
type DropStageResponse = Schemas["DropStageResponse"];
|
|
54
|
+
type DropPaginatedResponse = Schemas["DropPaginatedResponse"];
|
|
55
|
+
type DropMintRequest = Schemas["DropMintRequest"];
|
|
56
|
+
type DropMintResponse = Schemas["DropMintResponse"];
|
|
57
|
+
type AccountResolveResponse = Schemas["AccountResolveResponse"];
|
|
2
58
|
type SafelistStatus = "not_requested" | "requested" | "approved" | "verified" | "disabled_top_trending";
|
|
3
59
|
type CollectionOrderBy = "created_date" | "one_day_change" | "seven_day_volume" | "seven_day_change" | "num_owners" | "market_cap";
|
|
4
60
|
type EventType = "sale" | "transfer" | "mint" | "listing" | "offer" | "trait_offer" | "collection_offer";
|
|
5
61
|
type OrderSide = "ask" | "bid";
|
|
6
|
-
|
|
7
|
-
fee: number;
|
|
8
|
-
recipient: string;
|
|
9
|
-
required: boolean;
|
|
10
|
-
}
|
|
11
|
-
interface PaymentToken {
|
|
12
|
-
name: string;
|
|
13
|
-
symbol: string;
|
|
14
|
-
decimals: number;
|
|
15
|
-
address: string;
|
|
16
|
-
chain: Chain;
|
|
17
|
-
image_url?: string;
|
|
18
|
-
eth_price?: string;
|
|
19
|
-
usd_price?: string;
|
|
20
|
-
}
|
|
21
|
-
interface Collection {
|
|
22
|
-
name: string;
|
|
23
|
-
collection: string;
|
|
24
|
-
description: string;
|
|
25
|
-
image_url: string;
|
|
26
|
-
banner_image_url: string;
|
|
27
|
-
owner: string;
|
|
28
|
-
safelist_status: SafelistStatus;
|
|
29
|
-
category: string;
|
|
30
|
-
is_disabled: boolean;
|
|
31
|
-
is_nsfw: boolean;
|
|
32
|
-
trait_offers_enabled: boolean;
|
|
33
|
-
collection_offers_enabled: boolean;
|
|
34
|
-
opensea_url: string;
|
|
35
|
-
project_url: string;
|
|
36
|
-
wiki_url: string;
|
|
37
|
-
discord_url: string;
|
|
38
|
-
telegram_url: string;
|
|
39
|
-
twitter_username: string;
|
|
40
|
-
instagram_username: string;
|
|
41
|
-
contracts: {
|
|
42
|
-
address: string;
|
|
43
|
-
chain: Chain;
|
|
44
|
-
}[];
|
|
45
|
-
editors: string[];
|
|
46
|
-
fees: Fee[];
|
|
47
|
-
rarity: {
|
|
48
|
-
strategy_id: string;
|
|
49
|
-
strategy_version: string;
|
|
50
|
-
calculated_at: string;
|
|
51
|
-
max_rank: number;
|
|
52
|
-
tokens_scored: number;
|
|
53
|
-
} | null;
|
|
54
|
-
payment_tokens: PaymentToken[];
|
|
55
|
-
total_supply: number;
|
|
56
|
-
created_date: string;
|
|
57
|
-
required_zone?: string;
|
|
58
|
-
}
|
|
59
|
-
interface CollectionStats {
|
|
60
|
-
total: {
|
|
61
|
-
volume: number;
|
|
62
|
-
sales: number;
|
|
63
|
-
average_price: number;
|
|
64
|
-
num_owners: number;
|
|
65
|
-
market_cap: number;
|
|
66
|
-
floor_price: number;
|
|
67
|
-
floor_price_symbol: string;
|
|
68
|
-
};
|
|
69
|
-
intervals: {
|
|
70
|
-
interval: "one_day" | "seven_day" | "thirty_day";
|
|
71
|
-
volume: number;
|
|
72
|
-
volume_diff: number;
|
|
73
|
-
volume_change: number;
|
|
74
|
-
sales: number;
|
|
75
|
-
sales_diff: number;
|
|
76
|
-
average_price: number;
|
|
77
|
-
}[];
|
|
78
|
-
}
|
|
79
|
-
interface NFT {
|
|
80
|
-
identifier: string;
|
|
81
|
-
collection: string;
|
|
82
|
-
contract: string;
|
|
83
|
-
token_standard: string;
|
|
84
|
-
name: string;
|
|
85
|
-
description: string;
|
|
86
|
-
image_url: string;
|
|
87
|
-
metadata_url: string;
|
|
88
|
-
opensea_url: string;
|
|
89
|
-
updated_at: string;
|
|
90
|
-
is_disabled: boolean;
|
|
91
|
-
is_nsfw: boolean;
|
|
92
|
-
traits: Trait[] | null;
|
|
93
|
-
creator: string;
|
|
94
|
-
owners: {
|
|
95
|
-
address: string;
|
|
96
|
-
quantity: number;
|
|
97
|
-
}[];
|
|
98
|
-
rarity: {
|
|
99
|
-
strategy_id: string | null;
|
|
100
|
-
strategy_version: string | null;
|
|
101
|
-
rank: number | null;
|
|
102
|
-
score: number | null;
|
|
103
|
-
calculated_at: string;
|
|
104
|
-
max_rank: number | null;
|
|
105
|
-
tokens_scored: number | null;
|
|
106
|
-
ranking_features: {
|
|
107
|
-
unique_attribute_count: number;
|
|
108
|
-
} | null;
|
|
109
|
-
} | null;
|
|
110
|
-
}
|
|
111
|
-
interface Trait {
|
|
112
|
-
trait_type: string;
|
|
113
|
-
display_type: string;
|
|
114
|
-
max_value: string;
|
|
115
|
-
value: string | number;
|
|
116
|
-
}
|
|
117
|
-
interface Price {
|
|
118
|
-
currency: string;
|
|
119
|
-
decimals: number;
|
|
120
|
-
value: string;
|
|
121
|
-
}
|
|
122
|
-
interface Order {
|
|
123
|
-
order_hash: string;
|
|
124
|
-
chain: string;
|
|
125
|
-
protocol_data: Record<string, unknown>;
|
|
126
|
-
protocol_address: string;
|
|
127
|
-
price: Price;
|
|
128
|
-
}
|
|
129
|
-
interface Offer extends Order {
|
|
130
|
-
criteria?: {
|
|
131
|
-
collection: {
|
|
132
|
-
slug: string;
|
|
133
|
-
};
|
|
134
|
-
contract: {
|
|
135
|
-
address: string;
|
|
136
|
-
};
|
|
137
|
-
encoded_token_ids?: string;
|
|
138
|
-
trait?: {
|
|
139
|
-
type: string;
|
|
140
|
-
value: string;
|
|
141
|
-
};
|
|
142
|
-
};
|
|
143
|
-
status: string;
|
|
144
|
-
}
|
|
145
|
-
interface Listing extends Omit<Order, "price"> {
|
|
146
|
-
type: string;
|
|
147
|
-
price: {
|
|
148
|
-
current: Price;
|
|
149
|
-
};
|
|
150
|
-
remaining_quantity: number;
|
|
151
|
-
status: string;
|
|
152
|
-
}
|
|
153
|
-
interface EventPayment {
|
|
154
|
-
quantity: string;
|
|
155
|
-
token_address: string;
|
|
156
|
-
decimals: number;
|
|
157
|
-
symbol: string;
|
|
158
|
-
}
|
|
62
|
+
|
|
159
63
|
interface EventAsset {
|
|
160
64
|
identifier: string;
|
|
161
65
|
collection: string;
|
|
@@ -177,26 +81,6 @@ interface AssetEvent {
|
|
|
177
81
|
quantity: number;
|
|
178
82
|
[key: string]: unknown;
|
|
179
83
|
}
|
|
180
|
-
interface Contract {
|
|
181
|
-
address: string;
|
|
182
|
-
chain: string;
|
|
183
|
-
collection: string | null;
|
|
184
|
-
name: string;
|
|
185
|
-
contract_standard: string;
|
|
186
|
-
}
|
|
187
|
-
interface Account {
|
|
188
|
-
address: string;
|
|
189
|
-
username: string;
|
|
190
|
-
profile_image_url: string;
|
|
191
|
-
banner_image_url: string;
|
|
192
|
-
website: string;
|
|
193
|
-
social_media_accounts: {
|
|
194
|
-
platform: string;
|
|
195
|
-
username: string;
|
|
196
|
-
}[];
|
|
197
|
-
bio: string;
|
|
198
|
-
joined_date: string;
|
|
199
|
-
}
|
|
200
84
|
interface TraitCategories {
|
|
201
85
|
[traitType: string]: "string" | "number" | "date";
|
|
202
86
|
}
|
|
@@ -312,6 +196,63 @@ interface SearchResult {
|
|
|
312
196
|
interface SearchResponse {
|
|
313
197
|
results: SearchResult[];
|
|
314
198
|
}
|
|
199
|
+
interface ChainInfo {
|
|
200
|
+
chain: string;
|
|
201
|
+
name: string;
|
|
202
|
+
symbol: string;
|
|
203
|
+
supports_swaps: boolean;
|
|
204
|
+
block_explorer: string;
|
|
205
|
+
block_explorer_url: string;
|
|
206
|
+
}
|
|
207
|
+
interface ChainListResponse {
|
|
208
|
+
chains: ChainInfo[];
|
|
209
|
+
}
|
|
210
|
+
interface TokenBalance {
|
|
211
|
+
address: string;
|
|
212
|
+
chain: string;
|
|
213
|
+
name: string;
|
|
214
|
+
symbol: string;
|
|
215
|
+
image_url?: string;
|
|
216
|
+
usd_price: string;
|
|
217
|
+
decimals: number;
|
|
218
|
+
quantity: string;
|
|
219
|
+
usd_value: string;
|
|
220
|
+
opensea_url: string;
|
|
221
|
+
}
|
|
222
|
+
interface TokenBalancePaginatedResponse {
|
|
223
|
+
token_balances: TokenBalance[];
|
|
224
|
+
next?: string;
|
|
225
|
+
}
|
|
226
|
+
type TokenBalanceSortBy = "USD_VALUE" | "MARKET_CAP" | "ONE_DAY_VOLUME" | "PRICE" | "ONE_DAY_PRICE_CHANGE" | "SEVEN_DAY_PRICE_CHANGE";
|
|
227
|
+
interface ValidateMetadataResponse {
|
|
228
|
+
assetIdentifier: {
|
|
229
|
+
chain: string;
|
|
230
|
+
contractAddress: string;
|
|
231
|
+
tokenId: string;
|
|
232
|
+
};
|
|
233
|
+
tokenUri?: string;
|
|
234
|
+
metadata?: {
|
|
235
|
+
name?: string;
|
|
236
|
+
description?: string;
|
|
237
|
+
originalImageUrl?: string;
|
|
238
|
+
processedImageUrl?: string;
|
|
239
|
+
originalAnimationUrl?: string;
|
|
240
|
+
processedAnimationUrl?: string;
|
|
241
|
+
externalUrl?: string;
|
|
242
|
+
backgroundColor?: string;
|
|
243
|
+
attributes: {
|
|
244
|
+
traitType: string;
|
|
245
|
+
value: string;
|
|
246
|
+
displayType?: string;
|
|
247
|
+
}[];
|
|
248
|
+
};
|
|
249
|
+
error?: {
|
|
250
|
+
errorType: string;
|
|
251
|
+
message: string;
|
|
252
|
+
url?: string;
|
|
253
|
+
statusCode?: number;
|
|
254
|
+
};
|
|
255
|
+
}
|
|
315
256
|
|
|
316
257
|
interface OpenSeaClientConfig {
|
|
317
258
|
apiKey: string;
|
|
@@ -319,6 +260,8 @@ interface OpenSeaClientConfig {
|
|
|
319
260
|
chain?: string;
|
|
320
261
|
timeout?: number;
|
|
321
262
|
verbose?: boolean;
|
|
263
|
+
maxRetries?: number;
|
|
264
|
+
retryBaseDelay?: number;
|
|
322
265
|
}
|
|
323
266
|
interface CommandOptions {
|
|
324
267
|
apiKey?: string;
|
|
@@ -326,6 +269,13 @@ interface CommandOptions {
|
|
|
326
269
|
format?: "json" | "table";
|
|
327
270
|
raw?: boolean;
|
|
328
271
|
}
|
|
272
|
+
interface HealthResult {
|
|
273
|
+
status: "ok" | "error";
|
|
274
|
+
key_prefix: string;
|
|
275
|
+
authenticated: boolean;
|
|
276
|
+
rate_limited: boolean;
|
|
277
|
+
message: string;
|
|
278
|
+
}
|
|
329
279
|
|
|
330
280
|
declare class OpenSeaClient {
|
|
331
281
|
private apiKey;
|
|
@@ -333,10 +283,15 @@ declare class OpenSeaClient {
|
|
|
333
283
|
private defaultChain;
|
|
334
284
|
private timeoutMs;
|
|
335
285
|
private verbose;
|
|
286
|
+
private maxRetries;
|
|
287
|
+
private retryBaseDelay;
|
|
336
288
|
constructor(config: OpenSeaClientConfig);
|
|
289
|
+
private get defaultHeaders();
|
|
337
290
|
get<T>(path: string, params?: Record<string, unknown>): Promise<T>;
|
|
338
291
|
post<T>(path: string, body?: Record<string, unknown>, params?: Record<string, unknown>): Promise<T>;
|
|
339
292
|
getDefaultChain(): string;
|
|
293
|
+
getApiKeyPrefix(): string;
|
|
294
|
+
private fetchWithRetry;
|
|
340
295
|
}
|
|
341
296
|
declare class OpenSeaAPIError extends Error {
|
|
342
297
|
statusCode: number;
|
|
@@ -345,12 +300,301 @@ declare class OpenSeaAPIError extends Error {
|
|
|
345
300
|
constructor(statusCode: number, responseBody: string, path: string);
|
|
346
301
|
}
|
|
347
302
|
|
|
303
|
+
declare function checkHealth(client: OpenSeaClient): Promise<HealthResult>;
|
|
304
|
+
|
|
348
305
|
type OutputFormat = "json" | "table" | "toon";
|
|
349
306
|
declare function formatOutput(data: unknown, format: OutputFormat): string;
|
|
350
307
|
|
|
308
|
+
/**
|
|
309
|
+
* Wallet adapter interface for signing and sending transactions.
|
|
310
|
+
*
|
|
311
|
+
* Abstracts away the signing backend so the CLI and SDK can work with
|
|
312
|
+
* any provider (Privy, Turnkey, Fireblocks, etc.) through a single API.
|
|
313
|
+
*/
|
|
314
|
+
interface TransactionRequest {
|
|
315
|
+
to: string;
|
|
316
|
+
data: string;
|
|
317
|
+
value: string;
|
|
318
|
+
chainId: number;
|
|
319
|
+
}
|
|
320
|
+
interface TransactionResult {
|
|
321
|
+
hash: string;
|
|
322
|
+
}
|
|
323
|
+
interface WalletAdapter {
|
|
324
|
+
/** Human-readable provider name for logging */
|
|
325
|
+
readonly name: string;
|
|
326
|
+
/** Get the wallet address */
|
|
327
|
+
getAddress(): Promise<string>;
|
|
328
|
+
/** Sign and send a transaction, returns the tx hash */
|
|
329
|
+
sendTransaction(tx: TransactionRequest): Promise<TransactionResult>;
|
|
330
|
+
/** Optional hook called before each adapter request (for metrics/logging) */
|
|
331
|
+
onRequest?: (method: string, params: unknown) => void;
|
|
332
|
+
/** Optional hook called after each adapter response (for metrics/logging) */
|
|
333
|
+
onResponse?: (method: string, result: unknown, durationMs: number) => void;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* AUTO-GENERATED by scripts/sync-chains.ts — DO NOT EDIT.
|
|
338
|
+
* Source of truth: OpenSea REST API + scripts/chain-data.json
|
|
339
|
+
* Run `pnpm sync-chains` to regenerate.
|
|
340
|
+
*/
|
|
341
|
+
declare const CHAIN_IDS: Record<string, number>;
|
|
342
|
+
/**
|
|
343
|
+
* Resolve a chain identifier to a numeric EVM chain ID.
|
|
344
|
+
* Accepts a known chain name (e.g. "base") or a numeric string / number.
|
|
345
|
+
*/
|
|
346
|
+
declare function resolveChainId(chain: string | number): number;
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Fireblocks wallet adapter.
|
|
350
|
+
*
|
|
351
|
+
* Uses Fireblocks' REST API to sign and send transactions through their
|
|
352
|
+
* enterprise-grade custody infrastructure. Fireblocks provides MPC-based
|
|
353
|
+
* key management, transaction policy engine, and multi-level approval
|
|
354
|
+
* workflows suitable for institutional use.
|
|
355
|
+
*
|
|
356
|
+
* Required environment variables:
|
|
357
|
+
* FIREBLOCKS_API_KEY — Fireblocks API key
|
|
358
|
+
* FIREBLOCKS_API_SECRET — Fireblocks API secret (RSA private key, PEM-encoded)
|
|
359
|
+
* FIREBLOCKS_VAULT_ID — Fireblocks vault account ID
|
|
360
|
+
*
|
|
361
|
+
* Optional:
|
|
362
|
+
* FIREBLOCKS_API_BASE_URL — Override the Fireblocks API base URL
|
|
363
|
+
* (default: https://api.fireblocks.io)
|
|
364
|
+
* FIREBLOCKS_ASSET_ID — Override the Fireblocks asset ID
|
|
365
|
+
* (default: ETH — for EVM chains Fireblocks uses
|
|
366
|
+
* asset IDs like ETH, ETH_TEST5, MATIC, etc.)
|
|
367
|
+
*
|
|
368
|
+
* @see https://developers.fireblocks.com/docs/introduction
|
|
369
|
+
* @see https://developers.fireblocks.com/reference/api-overview
|
|
370
|
+
*/
|
|
371
|
+
|
|
372
|
+
interface FireblocksConfig {
|
|
373
|
+
apiKey: string;
|
|
374
|
+
apiSecret: string;
|
|
375
|
+
vaultId: string;
|
|
376
|
+
assetId?: string;
|
|
377
|
+
baseUrl?: string;
|
|
378
|
+
}
|
|
379
|
+
declare class FireblocksAdapter implements WalletAdapter {
|
|
380
|
+
readonly name = "fireblocks";
|
|
381
|
+
onRequest?: (method: string, params: unknown) => void;
|
|
382
|
+
onResponse?: (method: string, result: unknown, durationMs: number) => void;
|
|
383
|
+
private config;
|
|
384
|
+
private cachedAddress?;
|
|
385
|
+
constructor(config: FireblocksConfig);
|
|
386
|
+
/**
|
|
387
|
+
* Create a FireblocksAdapter from environment variables.
|
|
388
|
+
* Throws if any required variable is missing.
|
|
389
|
+
*/
|
|
390
|
+
static fromEnv(): FireblocksAdapter;
|
|
391
|
+
private get baseUrl();
|
|
392
|
+
/**
|
|
393
|
+
* Create a JWT for Fireblocks API authentication.
|
|
394
|
+
*
|
|
395
|
+
* Fireblocks uses JWT tokens signed with the API secret (RSA private key).
|
|
396
|
+
* The JWT contains the API key as `sub`, a URI claim for the endpoint path,
|
|
397
|
+
* and a body hash for POST requests.
|
|
398
|
+
*
|
|
399
|
+
* @see https://developers.fireblocks.com/reference/signing-a-request-jwt-structure
|
|
400
|
+
*/
|
|
401
|
+
private createJwt;
|
|
402
|
+
private pemToBuffer;
|
|
403
|
+
private hashBody;
|
|
404
|
+
private resolveAssetId;
|
|
405
|
+
getAddress(): Promise<string>;
|
|
406
|
+
sendTransaction(tx: TransactionRequest): Promise<TransactionResult>;
|
|
407
|
+
/**
|
|
408
|
+
* Poll a Fireblocks transaction until it reaches a terminal status.
|
|
409
|
+
* Fireblocks MPC signing + broadcast is asynchronous, so the initial
|
|
410
|
+
* POST returns a transaction ID that must be polled for the final hash.
|
|
411
|
+
*/
|
|
412
|
+
private waitForTransaction;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Raw private key wallet adapter.
|
|
417
|
+
*
|
|
418
|
+
* WARNING: Using a raw private key is NOT recommended for production use.
|
|
419
|
+
* It provides no spending limits, no destination allowlists, and no
|
|
420
|
+
* human-in-the-loop approval. Prefer Privy, Turnkey, or Fireblocks
|
|
421
|
+
* for managed wallet security.
|
|
422
|
+
*
|
|
423
|
+
* This adapter sends transactions via eth_sendTransaction on the RPC node,
|
|
424
|
+
* which requires the node to manage the key (e.g. Hardhat, Anvil, Ganache).
|
|
425
|
+
* The PRIVATE_KEY env var is validated (format + address derivation) to
|
|
426
|
+
* confirm intent, but is NOT used for signing — the RPC node holds the key
|
|
427
|
+
* and signs server-side. This means this adapter only works with local dev
|
|
428
|
+
* nodes, not production RPC providers like Infura or Alchemy.
|
|
429
|
+
*
|
|
430
|
+
* Required environment variables:
|
|
431
|
+
* PRIVATE_KEY — Hex-encoded private key (validated for format;
|
|
432
|
+
* the RPC node must already have this key imported)
|
|
433
|
+
* RPC_URL — JSON-RPC endpoint URL (must be a local dev node)
|
|
434
|
+
* WALLET_ADDRESS — The wallet address corresponding to the private key
|
|
435
|
+
*/
|
|
436
|
+
|
|
437
|
+
interface PrivateKeyConfig {
|
|
438
|
+
/**
|
|
439
|
+
* The private key hex string. Validated at construction time to confirm
|
|
440
|
+
* the user intends to use raw key mode, but NOT used for signing.
|
|
441
|
+
* The RPC node (Hardhat/Anvil/Ganache) handles signing via eth_sendTransaction.
|
|
442
|
+
*/
|
|
443
|
+
privateKey: string;
|
|
444
|
+
rpcUrl: string;
|
|
445
|
+
walletAddress: string;
|
|
446
|
+
}
|
|
447
|
+
declare class PrivateKeyAdapter implements WalletAdapter {
|
|
448
|
+
readonly name = "private-key";
|
|
449
|
+
onRequest?: (method: string, params: unknown) => void;
|
|
450
|
+
onResponse?: (method: string, result: unknown, durationMs: number) => void;
|
|
451
|
+
private config;
|
|
452
|
+
private hasWarned;
|
|
453
|
+
constructor(config: PrivateKeyConfig);
|
|
454
|
+
/**
|
|
455
|
+
* Create a PrivateKeyAdapter from environment variables.
|
|
456
|
+
* Validates the private key format and warns if the RPC URL looks
|
|
457
|
+
* like a hosted provider (which won't support eth_sendTransaction).
|
|
458
|
+
*/
|
|
459
|
+
static fromEnv(): PrivateKeyAdapter;
|
|
460
|
+
getAddress(): Promise<string>;
|
|
461
|
+
sendTransaction(tx: TransactionRequest): Promise<TransactionResult>;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Privy wallet adapter.
|
|
466
|
+
*
|
|
467
|
+
* Uses Privy's server-side wallet API to sign and send transactions.
|
|
468
|
+
* Transactions are governed by Privy's programmable policy engine —
|
|
469
|
+
* policies (transaction limits, destination allowlists, chain restrictions)
|
|
470
|
+
* are evaluated in a trusted execution environment before any signing occurs.
|
|
471
|
+
*
|
|
472
|
+
* Required environment variables:
|
|
473
|
+
* PRIVY_APP_ID — Privy application ID
|
|
474
|
+
* PRIVY_APP_SECRET — Privy application secret
|
|
475
|
+
* PRIVY_WALLET_ID — Wallet ID to use for signing
|
|
476
|
+
*
|
|
477
|
+
* @see https://docs.privy.io/wallets/wallets/server-side-access
|
|
478
|
+
* @see https://docs.privy.io/controls/policies/overview
|
|
479
|
+
*/
|
|
480
|
+
|
|
481
|
+
interface PrivyConfig {
|
|
482
|
+
appId: string;
|
|
483
|
+
appSecret: string;
|
|
484
|
+
walletId: string;
|
|
485
|
+
baseUrl?: string;
|
|
486
|
+
}
|
|
487
|
+
declare class PrivyAdapter implements WalletAdapter {
|
|
488
|
+
readonly name = "privy";
|
|
489
|
+
onRequest?: (method: string, params: unknown) => void;
|
|
490
|
+
onResponse?: (method: string, result: unknown, durationMs: number) => void;
|
|
491
|
+
private config;
|
|
492
|
+
private cachedAddress?;
|
|
493
|
+
constructor(config: PrivyConfig);
|
|
494
|
+
/**
|
|
495
|
+
* Create a PrivyAdapter from environment variables.
|
|
496
|
+
* Throws if any required variable is missing.
|
|
497
|
+
*/
|
|
498
|
+
static fromEnv(): PrivyAdapter;
|
|
499
|
+
private get baseUrl();
|
|
500
|
+
private get authHeaders();
|
|
501
|
+
getAddress(): Promise<string>;
|
|
502
|
+
sendTransaction(tx: TransactionRequest): Promise<TransactionResult>;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Turnkey wallet adapter.
|
|
507
|
+
*
|
|
508
|
+
* Uses Turnkey's API to sign and send transactions via their HSM-backed
|
|
509
|
+
* signing infrastructure. Turnkey provides non-custodial key management
|
|
510
|
+
* with policy controls, audit logging, and multi-party approval workflows.
|
|
511
|
+
*
|
|
512
|
+
* Authentication uses Turnkey's stamp scheme: each request body is hashed
|
|
513
|
+
* and signed with a P-256 ECDSA key, then the signature + public key are
|
|
514
|
+
* sent in the X-Stamp header.
|
|
515
|
+
*
|
|
516
|
+
* Required environment variables:
|
|
517
|
+
* TURNKEY_API_PUBLIC_KEY — Turnkey API public key (hex-encoded, compressed or uncompressed)
|
|
518
|
+
* TURNKEY_API_PRIVATE_KEY — Turnkey API private key (hex-encoded P-256 private key)
|
|
519
|
+
* TURNKEY_ORGANIZATION_ID — Turnkey organization ID
|
|
520
|
+
* TURNKEY_WALLET_ADDRESS — Ethereum address managed by Turnkey
|
|
521
|
+
*
|
|
522
|
+
* Required:
|
|
523
|
+
* TURNKEY_RPC_URL — RPC endpoint for gas estimation and broadcast (must match target chain)
|
|
524
|
+
*
|
|
525
|
+
* Optional:
|
|
526
|
+
* TURNKEY_API_BASE_URL — Override the Turnkey API base URL (default: https://api.turnkey.com)
|
|
527
|
+
* TURNKEY_PRIVATE_KEY_ID — Turnkey private key ID (for signing with a specific key)
|
|
528
|
+
*
|
|
529
|
+
* @see https://docs.turnkey.com/
|
|
530
|
+
* @see https://docs.turnkey.com/developer-tools/api-overview/stamps
|
|
531
|
+
*/
|
|
532
|
+
|
|
533
|
+
interface TurnkeyConfig {
|
|
534
|
+
apiPublicKey: string;
|
|
535
|
+
apiPrivateKey: string;
|
|
536
|
+
organizationId: string;
|
|
537
|
+
walletAddress: string;
|
|
538
|
+
rpcUrl: string;
|
|
539
|
+
privateKeyId?: string;
|
|
540
|
+
baseUrl?: string;
|
|
541
|
+
}
|
|
542
|
+
declare class TurnkeyAdapter implements WalletAdapter {
|
|
543
|
+
readonly name = "turnkey";
|
|
544
|
+
onRequest?: (method: string, params: unknown) => void;
|
|
545
|
+
onResponse?: (method: string, result: unknown, durationMs: number) => void;
|
|
546
|
+
private config;
|
|
547
|
+
constructor(config: TurnkeyConfig);
|
|
548
|
+
/**
|
|
549
|
+
* Create a TurnkeyAdapter from environment variables.
|
|
550
|
+
* Throws if any required variable is missing.
|
|
551
|
+
*/
|
|
552
|
+
static fromEnv(): TurnkeyAdapter;
|
|
553
|
+
private get baseUrl();
|
|
554
|
+
/**
|
|
555
|
+
* Sign a Turnkey API request using the API key pair (P-256 ECDSA).
|
|
556
|
+
*
|
|
557
|
+
* Turnkey uses a stamp-based authentication scheme: the request body
|
|
558
|
+
* is hashed with SHA-256 and signed with the P-256 private key. The
|
|
559
|
+
* stamp JSON (publicKey + scheme + signature) is then base64url-encoded
|
|
560
|
+
* and sent in the X-Stamp header.
|
|
561
|
+
*
|
|
562
|
+
* @see https://docs.turnkey.com/developer-tools/api-overview/stamps
|
|
563
|
+
*/
|
|
564
|
+
private stamp;
|
|
565
|
+
private signedRequest;
|
|
566
|
+
getAddress(): Promise<string>;
|
|
567
|
+
sendTransaction(tx: TransactionRequest): Promise<TransactionResult>;
|
|
568
|
+
/**
|
|
569
|
+
* Populate gas parameters via JSON-RPC calls to the target chain.
|
|
570
|
+
* Mirrors what ethers.js provider.populateTransaction() does internally.
|
|
571
|
+
*
|
|
572
|
+
* Makes three parallel RPC calls:
|
|
573
|
+
* - eth_getTransactionCount (nonce)
|
|
574
|
+
* - eth_estimateGas (gasLimit)
|
|
575
|
+
* - eth_maxPriorityFeePerGas + eth_getBlockByNumber (fee data)
|
|
576
|
+
*/
|
|
577
|
+
private estimateGasParams;
|
|
578
|
+
/** Make a single JSON-RPC call */
|
|
579
|
+
private rpcCall;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
type WalletProvider = "privy" | "turnkey" | "fireblocks" | "private-key";
|
|
583
|
+
declare const WALLET_PROVIDERS: WalletProvider[];
|
|
584
|
+
/**
|
|
585
|
+
* Create a WalletAdapter from the current environment.
|
|
586
|
+
*
|
|
587
|
+
* When no provider is specified, auto-detects based on which
|
|
588
|
+
* environment variables are set. Priority: Turnkey > Fireblocks > PrivateKey > Privy.
|
|
589
|
+
* If no provider-specific vars are found, defaults to Privy.
|
|
590
|
+
*/
|
|
591
|
+
declare function createWalletFromEnv(provider?: WalletProvider): WalletAdapter;
|
|
592
|
+
|
|
351
593
|
declare class OpenSeaCLI {
|
|
352
594
|
private client;
|
|
595
|
+
readonly chains: ChainsAPI;
|
|
353
596
|
readonly collections: CollectionsAPI;
|
|
597
|
+
readonly drops: DropsAPI;
|
|
354
598
|
readonly nfts: NFTsAPI;
|
|
355
599
|
readonly listings: ListingsAPI;
|
|
356
600
|
readonly offers: OffersAPI;
|
|
@@ -359,12 +603,18 @@ declare class OpenSeaCLI {
|
|
|
359
603
|
readonly tokens: TokensAPI;
|
|
360
604
|
readonly search: SearchAPI;
|
|
361
605
|
readonly swaps: SwapsAPI;
|
|
606
|
+
readonly health: HealthAPI;
|
|
362
607
|
constructor(config: OpenSeaClientConfig);
|
|
363
608
|
}
|
|
609
|
+
declare class ChainsAPI {
|
|
610
|
+
private client;
|
|
611
|
+
constructor(client: OpenSeaClient);
|
|
612
|
+
list(): Promise<ChainListResponse>;
|
|
613
|
+
}
|
|
364
614
|
declare class CollectionsAPI {
|
|
365
615
|
private client;
|
|
366
616
|
constructor(client: OpenSeaClient);
|
|
367
|
-
get(slug: string): Promise<
|
|
617
|
+
get(slug: string): Promise<CollectionDetailedResponse>;
|
|
368
618
|
list(options?: {
|
|
369
619
|
chain?: Chain;
|
|
370
620
|
limit?: number;
|
|
@@ -373,41 +623,73 @@ declare class CollectionsAPI {
|
|
|
373
623
|
creatorUsername?: string;
|
|
374
624
|
includeHidden?: boolean;
|
|
375
625
|
}): Promise<{
|
|
376
|
-
collections:
|
|
626
|
+
collections: CollectionDetailedResponse[];
|
|
377
627
|
next?: string;
|
|
378
628
|
}>;
|
|
379
|
-
stats(slug: string): Promise<
|
|
629
|
+
stats(slug: string): Promise<CollectionStatsResponse>;
|
|
380
630
|
traits(slug: string): Promise<GetTraitsResponse>;
|
|
631
|
+
trending(options?: {
|
|
632
|
+
timeframe?: string;
|
|
633
|
+
chains?: string[];
|
|
634
|
+
category?: string;
|
|
635
|
+
limit?: number;
|
|
636
|
+
next?: string;
|
|
637
|
+
}): Promise<CollectionPaginatedResponse>;
|
|
638
|
+
top(options?: {
|
|
639
|
+
sortBy?: string;
|
|
640
|
+
chains?: string[];
|
|
641
|
+
category?: string;
|
|
642
|
+
limit?: number;
|
|
643
|
+
next?: string;
|
|
644
|
+
}): Promise<CollectionPaginatedResponse>;
|
|
645
|
+
}
|
|
646
|
+
declare class DropsAPI {
|
|
647
|
+
private client;
|
|
648
|
+
constructor(client: OpenSeaClient);
|
|
649
|
+
list(options?: {
|
|
650
|
+
type?: string;
|
|
651
|
+
chains?: string[];
|
|
652
|
+
limit?: number;
|
|
653
|
+
next?: string;
|
|
654
|
+
}): Promise<DropPaginatedResponse>;
|
|
655
|
+
get(slug: string): Promise<DropDetailedResponse>;
|
|
656
|
+
mint(slug: string, options: {
|
|
657
|
+
minter: string;
|
|
658
|
+
quantity?: number;
|
|
659
|
+
}): Promise<DropMintResponse>;
|
|
381
660
|
}
|
|
382
661
|
declare class NFTsAPI {
|
|
383
662
|
private client;
|
|
384
663
|
constructor(client: OpenSeaClient);
|
|
385
664
|
get(chain: Chain, address: string, identifier: string): Promise<{
|
|
386
|
-
nft:
|
|
665
|
+
nft: NftDetailed;
|
|
387
666
|
}>;
|
|
388
667
|
listByCollection(slug: string, options?: {
|
|
389
668
|
limit?: number;
|
|
390
669
|
next?: string;
|
|
391
670
|
}): Promise<{
|
|
392
|
-
nfts:
|
|
671
|
+
nfts: NftDetailed[];
|
|
393
672
|
next?: string;
|
|
394
673
|
}>;
|
|
395
674
|
listByContract(chain: Chain, address: string, options?: {
|
|
396
675
|
limit?: number;
|
|
397
676
|
next?: string;
|
|
398
677
|
}): Promise<{
|
|
399
|
-
nfts:
|
|
678
|
+
nfts: NftDetailed[];
|
|
400
679
|
next?: string;
|
|
401
680
|
}>;
|
|
402
681
|
listByAccount(chain: Chain, address: string, options?: {
|
|
403
682
|
limit?: number;
|
|
404
683
|
next?: string;
|
|
405
684
|
}): Promise<{
|
|
406
|
-
nfts:
|
|
685
|
+
nfts: NftDetailed[];
|
|
407
686
|
next?: string;
|
|
408
687
|
}>;
|
|
409
688
|
refresh(chain: Chain, address: string, identifier: string): Promise<void>;
|
|
410
689
|
getContract(chain: Chain, address: string): Promise<Contract>;
|
|
690
|
+
validateMetadata(chain: Chain, address: string, identifier: string, options?: {
|
|
691
|
+
ignoreCachedItemUrls?: boolean;
|
|
692
|
+
}): Promise<ValidateMetadataResponse>;
|
|
411
693
|
}
|
|
412
694
|
declare class ListingsAPI {
|
|
413
695
|
private client;
|
|
@@ -499,7 +781,16 @@ declare class EventsAPI {
|
|
|
499
781
|
declare class AccountsAPI {
|
|
500
782
|
private client;
|
|
501
783
|
constructor(client: OpenSeaClient);
|
|
502
|
-
get(address: string): Promise<
|
|
784
|
+
get(address: string): Promise<AccountResponse>;
|
|
785
|
+
tokens(address: string, options?: {
|
|
786
|
+
chains?: string[];
|
|
787
|
+
limit?: number;
|
|
788
|
+
sortBy?: TokenBalanceSortBy;
|
|
789
|
+
sortDirection?: "asc" | "desc";
|
|
790
|
+
disableSpamFiltering?: boolean;
|
|
791
|
+
next?: string;
|
|
792
|
+
}): Promise<TokenBalancePaginatedResponse>;
|
|
793
|
+
resolve(identifier: string): Promise<AccountResolveResponse>;
|
|
503
794
|
}
|
|
504
795
|
declare class TokensAPI {
|
|
505
796
|
private client;
|
|
@@ -544,8 +835,42 @@ declare class SwapsAPI {
|
|
|
544
835
|
slippage?: number;
|
|
545
836
|
recipient?: string;
|
|
546
837
|
}): Promise<SwapQuoteResponse>;
|
|
838
|
+
/**
|
|
839
|
+
* Get a swap quote and execute all transactions using the provided wallet adapter.
|
|
840
|
+
* Returns an array of transaction results (one per transaction in the quote).
|
|
841
|
+
*
|
|
842
|
+
* @param options - Swap parameters (chains, addresses, quantity, etc.)
|
|
843
|
+
* @param wallet - Wallet adapter to sign and send transactions
|
|
844
|
+
* @param callbacks - Optional callbacks for progress reporting and skipped txs
|
|
845
|
+
*/
|
|
846
|
+
execute(options: {
|
|
847
|
+
fromChain: string;
|
|
848
|
+
fromAddress: string;
|
|
849
|
+
toChain: string;
|
|
850
|
+
toAddress: string;
|
|
851
|
+
quantity: string;
|
|
852
|
+
slippage?: number;
|
|
853
|
+
recipient?: string;
|
|
854
|
+
address?: string;
|
|
855
|
+
}, wallet: WalletAdapter, callbacks?: {
|
|
856
|
+
onQuote?: (quote: SwapQuoteResponse) => void;
|
|
857
|
+
onSending?: (tx: {
|
|
858
|
+
to: string;
|
|
859
|
+
chain: string;
|
|
860
|
+
chainId: number;
|
|
861
|
+
}) => void;
|
|
862
|
+
onSkipped?: (tx: {
|
|
863
|
+
chain: string;
|
|
864
|
+
reason: string;
|
|
865
|
+
}) => void;
|
|
866
|
+
}): Promise<TransactionResult[]>;
|
|
867
|
+
}
|
|
868
|
+
declare class HealthAPI {
|
|
869
|
+
private client;
|
|
870
|
+
constructor(client: OpenSeaClient);
|
|
871
|
+
check(): Promise<HealthResult>;
|
|
547
872
|
}
|
|
548
873
|
|
|
549
874
|
declare function formatToon(data: unknown): string;
|
|
550
875
|
|
|
551
|
-
export { type Account, type AssetEvent, type Chain, type Collection, type CollectionOrderBy, type CollectionStats, type CommandOptions, type Contract, type EventAsset, type EventPayment, type EventType, type Fee, type GetTraitsResponse, type Listing, type NFT, type Offer, OpenSeaAPIError, OpenSeaCLI, OpenSeaClient, type OpenSeaClientConfig, type Order, type OrderSide, type OutputFormat, type PaymentToken, type Price, type SafelistStatus, type SearchAssetType, type SearchResponse, type SearchResult, type SearchResultAccount, type SearchResultCollection, type SearchResultNFT, type SearchResultToken, type SwapQuote, type SwapQuoteResponse, type SwapTransaction, type Token, type TokenDetails, type TokenSocials, type TokenStats, type Trait, type TraitCategories, type TraitCounts, formatOutput, formatToon };
|
|
876
|
+
export { type AccountResponse as Account, type AccountResolveResponse, type AccountResponse, type AssetEvent, type AssetEventsResponse, CHAIN_IDS, type Chain, type ChainInfo, type ChainListResponse, type CollectionDetailedResponse as Collection, type CollectionDetailedResponse, type CollectionOrderBy, type CollectionPaginatedResponse, type CollectionRarity, type CollectionResponse, type CollectionStatsResponse as CollectionStats, type CollectionStatsResponse, type CommandOptions, type Contract, type ContractResponse, type DropDetailedResponse, type DropMintRequest, type DropMintResponse, type DropPaginatedResponse, type DropResponse, type DropStageResponse, type Event, type EventAsset, type Payment as EventPayment, type EventType, type Fee, FireblocksAdapter, type FulfillListingResponse, type GetOrderResponse, type GetTraitsResponse, type HealthResult, type IntervalStat, type Listing, type ListingPrice, type ListingsResponse, type NftDetailed as NFT, type Nft, type NftDetailed, type NftListResponse, type NftResponse, type Offer, type OffersResponse, OpenSeaAPIError, OpenSeaCLI, OpenSeaClient, type OpenSeaClientConfig, type Order, type OrderEvent, type OrderSide, type OrdersResponse, type OutputFormat, type Owner, type Payment, type PaymentToken, type Price, type PricingCurrencies, PrivateKeyAdapter, PrivyAdapter, type ProtocolData, type Rarity, type SafelistStatus, type SaleEvent, type SearchAssetType, type SearchResponse, type SearchResult, type SearchResultAccount, type SearchResultCollection, type SearchResultNFT, type SearchResultToken, type SimpleAccount, type SocialMediaAccount, type SwapQuote, type SwapQuoteResponse, type SwapTransaction, SwapsAPI, type Token, type TokenBalance, type TokenBalancePaginatedResponse, type TokenBalanceSortBy, type TokenDetails, type TokenSocials, type TokenStats, type Total, type Trait, type TraitCategories, type TraitCounts, type TransactionRequest, type TransactionResult, type TransferEvent, TurnkeyAdapter, type ValidateMetadataResponse, WALLET_PROVIDERS, type WalletAdapter, type WalletProvider, checkHealth, createWalletFromEnv, formatOutput, formatToon, resolveChainId };
|