@solana/connector 0.0.0 → 0.1.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 +1460 -0
- package/dist/chunk-52WUWW5R.mjs +2533 -0
- package/dist/chunk-52WUWW5R.mjs.map +1 -0
- package/dist/chunk-5NSUFMCB.js +393 -0
- package/dist/chunk-5NSUFMCB.js.map +1 -0
- package/dist/chunk-5ZUVZZWU.mjs +180 -0
- package/dist/chunk-5ZUVZZWU.mjs.map +1 -0
- package/dist/chunk-7TADXRFD.mjs +298 -0
- package/dist/chunk-7TADXRFD.mjs.map +1 -0
- package/dist/chunk-ACFSCMUI.mjs +359 -0
- package/dist/chunk-ACFSCMUI.mjs.map +1 -0
- package/dist/chunk-SGAIPK7Q.js +314 -0
- package/dist/chunk-SGAIPK7Q.js.map +1 -0
- package/dist/chunk-SMUUAKC3.js +186 -0
- package/dist/chunk-SMUUAKC3.js.map +1 -0
- package/dist/chunk-ZLPQUOFK.js +2594 -0
- package/dist/chunk-ZLPQUOFK.js.map +1 -0
- package/dist/compat.d.mts +106 -0
- package/dist/compat.d.ts +106 -0
- package/dist/compat.js +98 -0
- package/dist/compat.js.map +1 -0
- package/dist/compat.mjs +94 -0
- package/dist/compat.mjs.map +1 -0
- package/dist/headless.d.mts +400 -0
- package/dist/headless.d.ts +400 -0
- package/dist/headless.js +325 -0
- package/dist/headless.js.map +1 -0
- package/dist/headless.mjs +4 -0
- package/dist/headless.mjs.map +1 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +382 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +5 -0
- package/dist/index.mjs.map +1 -0
- package/dist/react.d.mts +645 -0
- package/dist/react.d.ts +645 -0
- package/dist/react.js +65 -0
- package/dist/react.js.map +1 -0
- package/dist/react.mjs +4 -0
- package/dist/react.mjs.map +1 -0
- package/dist/transaction-signer-BtJPGXIg.d.mts +373 -0
- package/dist/transaction-signer-BtJPGXIg.d.ts +373 -0
- package/dist/wallet-standard-shim-Af7ejSld.d.mts +1090 -0
- package/dist/wallet-standard-shim-BGlvGRbB.d.ts +1090 -0
- package/package.json +87 -10
- package/index.js +0 -1
|
@@ -0,0 +1,1090 @@
|
|
|
1
|
+
import { c as TransactionActivity, d as TransactionActivityStatus } from './transaction-signer-BtJPGXIg.mjs';
|
|
2
|
+
import { SolanaClusterId, SolanaCluster } from '@wallet-ui/core';
|
|
3
|
+
import { Wallet, WalletAccount } from '@wallet-standard/base';
|
|
4
|
+
import { Address, Signature } from 'gill';
|
|
5
|
+
import React, { ReactNode, Component, ErrorInfo } from 'react';
|
|
6
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Wallet-related types
|
|
10
|
+
* Re-exports from @wallet-standard/base and custom wallet types
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Wallet name as a branded string for type safety
|
|
15
|
+
* Represents the unique identifier for a wallet (e.g., "Phantom", "Solflare")
|
|
16
|
+
*/
|
|
17
|
+
type WalletName = string & {
|
|
18
|
+
readonly __brand: 'WalletName';
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Account address as a branded string for type safety
|
|
22
|
+
* Represents a Solana address (base58-encoded public key)
|
|
23
|
+
*
|
|
24
|
+
* @deprecated Use `Address` from 'gill' instead for consistent address typing
|
|
25
|
+
*/
|
|
26
|
+
type AccountAddress = string & {
|
|
27
|
+
readonly __brand: 'AccountAddress';
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Type guard to check if a string is a valid wallet name
|
|
31
|
+
*/
|
|
32
|
+
declare function isWalletName(value: string): value is WalletName;
|
|
33
|
+
/**
|
|
34
|
+
* Type guard to check if a string is a valid account address
|
|
35
|
+
*
|
|
36
|
+
* @deprecated Use `isAddress` from 'gill' instead for proper address validation
|
|
37
|
+
*/
|
|
38
|
+
declare function isAccountAddress(value: string): value is AccountAddress;
|
|
39
|
+
/**
|
|
40
|
+
* Extended wallet information with capability metadata
|
|
41
|
+
*/
|
|
42
|
+
interface WalletInfo {
|
|
43
|
+
/** The Wallet Standard wallet object */
|
|
44
|
+
wallet: Wallet;
|
|
45
|
+
/** Whether the wallet extension is installed */
|
|
46
|
+
installed: boolean;
|
|
47
|
+
/** Precomputed capability flag for UI convenience */
|
|
48
|
+
connectable?: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Storage-related types
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Storage adapter interface for connector persistence
|
|
57
|
+
*/
|
|
58
|
+
interface StorageAdapter<T> {
|
|
59
|
+
get(): T;
|
|
60
|
+
set(value: T): void;
|
|
61
|
+
subscribe?(callback: (value: T) => void): () => void;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Base options for enhanced storage instances
|
|
65
|
+
*/
|
|
66
|
+
interface BaseEnhancedStorageOptions<T> {
|
|
67
|
+
/** Storage key */
|
|
68
|
+
key?: string;
|
|
69
|
+
/** Initial value */
|
|
70
|
+
initial?: T;
|
|
71
|
+
/** Custom error handler for storage failures */
|
|
72
|
+
onError?: (error: Error) => void;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Options for creating enhanced storage instances with validation
|
|
76
|
+
*/
|
|
77
|
+
interface StorageOptions<T> extends BaseEnhancedStorageOptions<T> {
|
|
78
|
+
/** Validate before setting values */
|
|
79
|
+
validator?: (value: T) => boolean;
|
|
80
|
+
/** Use memory storage if localStorage unavailable (SSR) */
|
|
81
|
+
useMemoryFallback?: boolean;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Options for account storage
|
|
85
|
+
*/
|
|
86
|
+
interface EnhancedStorageAccountOptions extends BaseEnhancedStorageOptions<string | undefined> {
|
|
87
|
+
validator?: (value: string | undefined) => boolean;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Options for cluster storage
|
|
91
|
+
*/
|
|
92
|
+
interface EnhancedStorageClusterOptions extends BaseEnhancedStorageOptions<SolanaClusterId> {
|
|
93
|
+
validClusters?: SolanaClusterId[];
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Options for wallet storage
|
|
97
|
+
*/
|
|
98
|
+
interface EnhancedStorageWalletOptions extends BaseEnhancedStorageOptions<string | undefined> {
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Account-related types
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Extended account information with formatted address
|
|
107
|
+
*/
|
|
108
|
+
interface AccountInfo {
|
|
109
|
+
/** Formatted Solana address */
|
|
110
|
+
address: Address;
|
|
111
|
+
/** Optional account icon/avatar URL */
|
|
112
|
+
icon?: string;
|
|
113
|
+
/** Raw wallet account object from Wallet Standard */
|
|
114
|
+
raw: WalletAccount;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Core connector state
|
|
119
|
+
*/
|
|
120
|
+
interface ConnectorState {
|
|
121
|
+
wallets: WalletInfo[];
|
|
122
|
+
selectedWallet: Wallet | null;
|
|
123
|
+
connected: boolean;
|
|
124
|
+
connecting: boolean;
|
|
125
|
+
accounts: AccountInfo[];
|
|
126
|
+
selectedAccount: Address | null;
|
|
127
|
+
cluster: SolanaCluster | null;
|
|
128
|
+
clusters: SolanaCluster[];
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* State change listener function type
|
|
132
|
+
*/
|
|
133
|
+
type Listener = (s: ConnectorState) => void;
|
|
134
|
+
/**
|
|
135
|
+
* Connector configuration options
|
|
136
|
+
*/
|
|
137
|
+
interface ConnectorConfig {
|
|
138
|
+
autoConnect?: boolean;
|
|
139
|
+
debug?: boolean;
|
|
140
|
+
/** Storage configuration using enhanced storage adapters */
|
|
141
|
+
storage?: {
|
|
142
|
+
account: StorageAdapter<string | undefined>;
|
|
143
|
+
cluster: StorageAdapter<SolanaClusterId>;
|
|
144
|
+
wallet: StorageAdapter<string | undefined>;
|
|
145
|
+
};
|
|
146
|
+
/** Enhanced cluster configuration using wallet-ui */
|
|
147
|
+
cluster?: {
|
|
148
|
+
clusters?: SolanaCluster[];
|
|
149
|
+
persistSelection?: boolean;
|
|
150
|
+
initialCluster?: SolanaClusterId;
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Health check information for connector diagnostics
|
|
155
|
+
* Useful for debugging, monitoring, and support
|
|
156
|
+
*/
|
|
157
|
+
interface ConnectorHealth {
|
|
158
|
+
/** Whether the connector has been initialized */
|
|
159
|
+
initialized: boolean;
|
|
160
|
+
/** Whether Wallet Standard registry is available */
|
|
161
|
+
walletStandardAvailable: boolean;
|
|
162
|
+
/** Whether localStorage/storage is available */
|
|
163
|
+
storageAvailable: boolean;
|
|
164
|
+
/** Number of wallets currently detected */
|
|
165
|
+
walletsDetected: number;
|
|
166
|
+
/** List of errors encountered during initialization or operation */
|
|
167
|
+
errors: string[];
|
|
168
|
+
/** Current connection state */
|
|
169
|
+
connectionState: {
|
|
170
|
+
connected: boolean;
|
|
171
|
+
connecting: boolean;
|
|
172
|
+
hasSelectedWallet: boolean;
|
|
173
|
+
hasSelectedAccount: boolean;
|
|
174
|
+
};
|
|
175
|
+
/** Timestamp of health check */
|
|
176
|
+
timestamp: string;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Performance and debug metrics for monitoring
|
|
180
|
+
* Useful for identifying performance issues and optimization opportunities
|
|
181
|
+
*/
|
|
182
|
+
interface ConnectorDebugMetrics {
|
|
183
|
+
/** Total number of state updates that resulted in actual changes */
|
|
184
|
+
stateUpdates: number;
|
|
185
|
+
/** Number of state updates that were skipped (no changes detected) */
|
|
186
|
+
noopUpdates: number;
|
|
187
|
+
/** Percentage of updates that were optimized away */
|
|
188
|
+
optimizationRate: number;
|
|
189
|
+
/** Number of active event listeners */
|
|
190
|
+
eventListenerCount: number;
|
|
191
|
+
/** Number of state subscribers */
|
|
192
|
+
subscriptionCount: number;
|
|
193
|
+
/** Average time taken for state updates (in milliseconds) */
|
|
194
|
+
avgUpdateTimeMs: number;
|
|
195
|
+
/** Timestamp of last state update */
|
|
196
|
+
lastUpdateTime: number;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Debug state with transaction history
|
|
200
|
+
*/
|
|
201
|
+
interface ConnectorDebugState extends ConnectorDebugMetrics {
|
|
202
|
+
/** Recent transaction activity (limited by maxTransactions) */
|
|
203
|
+
transactions: TransactionActivity[];
|
|
204
|
+
/** Total transactions tracked in this session */
|
|
205
|
+
totalTransactions: number;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Event system types for connector
|
|
210
|
+
*/
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Event types emitted by the connector
|
|
214
|
+
* Use these for analytics, logging, and custom behavior
|
|
215
|
+
*/
|
|
216
|
+
type ConnectorEvent = {
|
|
217
|
+
type: 'wallet:connected';
|
|
218
|
+
wallet: WalletName;
|
|
219
|
+
account: Address;
|
|
220
|
+
timestamp: string;
|
|
221
|
+
} | {
|
|
222
|
+
type: 'wallet:disconnected';
|
|
223
|
+
timestamp: string;
|
|
224
|
+
} | {
|
|
225
|
+
type: 'wallet:changed';
|
|
226
|
+
wallet: WalletName;
|
|
227
|
+
timestamp: string;
|
|
228
|
+
} | {
|
|
229
|
+
type: 'account:changed';
|
|
230
|
+
account: Address;
|
|
231
|
+
timestamp: string;
|
|
232
|
+
} | {
|
|
233
|
+
type: 'cluster:changed';
|
|
234
|
+
cluster: SolanaClusterId;
|
|
235
|
+
previousCluster: SolanaClusterId | null;
|
|
236
|
+
timestamp: string;
|
|
237
|
+
} | {
|
|
238
|
+
type: 'wallets:detected';
|
|
239
|
+
count: number;
|
|
240
|
+
timestamp: string;
|
|
241
|
+
} | {
|
|
242
|
+
type: 'error';
|
|
243
|
+
error: Error;
|
|
244
|
+
context: string;
|
|
245
|
+
timestamp: string;
|
|
246
|
+
} | {
|
|
247
|
+
type: 'connecting';
|
|
248
|
+
wallet: WalletName;
|
|
249
|
+
timestamp: string;
|
|
250
|
+
} | {
|
|
251
|
+
type: 'connection:failed';
|
|
252
|
+
wallet: WalletName;
|
|
253
|
+
error: string;
|
|
254
|
+
timestamp: string;
|
|
255
|
+
} | {
|
|
256
|
+
type: 'transaction:tracked';
|
|
257
|
+
signature: Signature;
|
|
258
|
+
status: TransactionActivityStatus;
|
|
259
|
+
timestamp: string;
|
|
260
|
+
} | {
|
|
261
|
+
type: 'transaction:updated';
|
|
262
|
+
signature: Signature;
|
|
263
|
+
status: TransactionActivityStatus;
|
|
264
|
+
timestamp: string;
|
|
265
|
+
} | {
|
|
266
|
+
type: 'transaction:preparing';
|
|
267
|
+
transaction: Uint8Array;
|
|
268
|
+
size: number;
|
|
269
|
+
timestamp: string;
|
|
270
|
+
} | {
|
|
271
|
+
type: 'transaction:simulated';
|
|
272
|
+
success: boolean;
|
|
273
|
+
computeUnits: number | null;
|
|
274
|
+
timestamp: string;
|
|
275
|
+
} | {
|
|
276
|
+
type: 'transaction:signing';
|
|
277
|
+
timestamp: string;
|
|
278
|
+
} | {
|
|
279
|
+
type: 'transaction:sent';
|
|
280
|
+
signature: Signature;
|
|
281
|
+
timestamp: string;
|
|
282
|
+
} | {
|
|
283
|
+
type: 'storage:reset';
|
|
284
|
+
timestamp: string;
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* Event listener function type
|
|
288
|
+
*/
|
|
289
|
+
type ConnectorEventListener = (event: ConnectorEvent) => void;
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* ConnectorClient - Lean coordinator that delegates to specialized collaborators
|
|
293
|
+
*
|
|
294
|
+
* Orchestrates wallet connection, state management, and event handling by wiring
|
|
295
|
+
* together focused collaborators, each with a single responsibility.
|
|
296
|
+
*/
|
|
297
|
+
declare class ConnectorClient {
|
|
298
|
+
private stateManager;
|
|
299
|
+
private eventEmitter;
|
|
300
|
+
private walletDetector;
|
|
301
|
+
private connectionManager;
|
|
302
|
+
private autoConnector;
|
|
303
|
+
private clusterManager;
|
|
304
|
+
private transactionTracker;
|
|
305
|
+
private debugMetrics;
|
|
306
|
+
private healthMonitor;
|
|
307
|
+
private initialized;
|
|
308
|
+
private config;
|
|
309
|
+
constructor(config?: ConnectorConfig);
|
|
310
|
+
/**
|
|
311
|
+
* Initialize the connector
|
|
312
|
+
*/
|
|
313
|
+
private initialize;
|
|
314
|
+
/**
|
|
315
|
+
* Connect to a wallet by name
|
|
316
|
+
*/
|
|
317
|
+
select(walletName: string): Promise<void>;
|
|
318
|
+
/**
|
|
319
|
+
* Disconnect from the current wallet
|
|
320
|
+
*/
|
|
321
|
+
disconnect(): Promise<void>;
|
|
322
|
+
/**
|
|
323
|
+
* Select a different account
|
|
324
|
+
*/
|
|
325
|
+
selectAccount(address: string): Promise<void>;
|
|
326
|
+
/**
|
|
327
|
+
* Set the active cluster (network)
|
|
328
|
+
*/
|
|
329
|
+
setCluster(clusterId: SolanaClusterId): Promise<void>;
|
|
330
|
+
/**
|
|
331
|
+
* Get the currently active cluster
|
|
332
|
+
*/
|
|
333
|
+
getCluster(): SolanaCluster | null;
|
|
334
|
+
/**
|
|
335
|
+
* Get all available clusters
|
|
336
|
+
*/
|
|
337
|
+
getClusters(): SolanaCluster[];
|
|
338
|
+
/**
|
|
339
|
+
* Get the RPC URL for the current cluster
|
|
340
|
+
* @returns RPC URL or null if no cluster is selected
|
|
341
|
+
*/
|
|
342
|
+
getRpcUrl(): string | null;
|
|
343
|
+
/**
|
|
344
|
+
* Subscribe to state changes
|
|
345
|
+
*/
|
|
346
|
+
subscribe(listener: Listener): () => void;
|
|
347
|
+
/**
|
|
348
|
+
* Get current state snapshot
|
|
349
|
+
*/
|
|
350
|
+
getSnapshot(): ConnectorState;
|
|
351
|
+
/**
|
|
352
|
+
* Reset all storage to initial values
|
|
353
|
+
* Useful for "logout", "forget this device", or clearing user data
|
|
354
|
+
*
|
|
355
|
+
* This will:
|
|
356
|
+
* - Clear saved wallet name
|
|
357
|
+
* - Clear saved account address
|
|
358
|
+
* - Reset cluster to initial value (does not clear)
|
|
359
|
+
*
|
|
360
|
+
* Note: This does NOT disconnect the wallet. Call disconnect() separately if needed.
|
|
361
|
+
*
|
|
362
|
+
* @example
|
|
363
|
+
* ```ts
|
|
364
|
+
* // Complete logout flow
|
|
365
|
+
* await client.disconnect();
|
|
366
|
+
* client.resetStorage();
|
|
367
|
+
* ```
|
|
368
|
+
*/
|
|
369
|
+
resetStorage(): void;
|
|
370
|
+
/**
|
|
371
|
+
* Subscribe to connector events
|
|
372
|
+
*/
|
|
373
|
+
on(listener: ConnectorEventListener): () => void;
|
|
374
|
+
/**
|
|
375
|
+
* Remove a specific event listener
|
|
376
|
+
*/
|
|
377
|
+
off(listener: ConnectorEventListener): void;
|
|
378
|
+
/**
|
|
379
|
+
* Remove all event listeners
|
|
380
|
+
*/
|
|
381
|
+
offAll(): void;
|
|
382
|
+
/**
|
|
383
|
+
* Emit a connector event
|
|
384
|
+
* Internal method used by transaction signer and other components
|
|
385
|
+
* @internal
|
|
386
|
+
*/
|
|
387
|
+
emitEvent(event: ConnectorEvent): void;
|
|
388
|
+
/**
|
|
389
|
+
* Track a transaction for debugging and monitoring
|
|
390
|
+
*/
|
|
391
|
+
trackTransaction(activity: Omit<TransactionActivity, 'timestamp' | 'cluster'>): void;
|
|
392
|
+
/**
|
|
393
|
+
* Update transaction status
|
|
394
|
+
*/
|
|
395
|
+
updateTransactionStatus(signature: string, status: TransactionActivity['status'], error?: string): void;
|
|
396
|
+
/**
|
|
397
|
+
* Clear transaction history
|
|
398
|
+
*/
|
|
399
|
+
clearTransactionHistory(): void;
|
|
400
|
+
/**
|
|
401
|
+
* Get connector health and diagnostics
|
|
402
|
+
*/
|
|
403
|
+
getHealth(): ConnectorHealth;
|
|
404
|
+
/**
|
|
405
|
+
* Get performance and debug metrics
|
|
406
|
+
*/
|
|
407
|
+
getDebugMetrics(): ConnectorDebugMetrics;
|
|
408
|
+
/**
|
|
409
|
+
* Get debug state including transactions
|
|
410
|
+
*/
|
|
411
|
+
getDebugState(): ConnectorDebugState;
|
|
412
|
+
/**
|
|
413
|
+
* Reset debug metrics
|
|
414
|
+
*/
|
|
415
|
+
resetDebugMetrics(): void;
|
|
416
|
+
/**
|
|
417
|
+
* Cleanup resources
|
|
418
|
+
*/
|
|
419
|
+
destroy(): void;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
interface DefaultConfigOptions {
|
|
423
|
+
/** Application name shown in wallet connection prompts */
|
|
424
|
+
appName: string;
|
|
425
|
+
/** Application URL for wallet connection metadata */
|
|
426
|
+
appUrl?: string;
|
|
427
|
+
/** Enable automatic wallet reconnection on page load */
|
|
428
|
+
autoConnect?: boolean;
|
|
429
|
+
/** Enable debug logging */
|
|
430
|
+
debug?: boolean;
|
|
431
|
+
/** Solana network to connect to (accepts both 'mainnet' and 'mainnet-beta' conventions) */
|
|
432
|
+
network?: 'mainnet' | 'mainnet-beta' | 'devnet' | 'testnet' | 'localnet';
|
|
433
|
+
/** Enable Mobile Wallet Adapter support */
|
|
434
|
+
enableMobile?: boolean;
|
|
435
|
+
/** Custom storage implementation */
|
|
436
|
+
storage?: ConnectorConfig['storage'];
|
|
437
|
+
/** Custom cluster configuration - overrides network if provided */
|
|
438
|
+
clusters?: SolanaCluster[];
|
|
439
|
+
/** Additional custom clusters to add to the default list */
|
|
440
|
+
customClusters?: SolanaCluster[];
|
|
441
|
+
/** Persist cluster selection across sessions */
|
|
442
|
+
persistClusterSelection?: boolean;
|
|
443
|
+
/** Custom storage key for cluster persistence */
|
|
444
|
+
clusterStorageKey?: string;
|
|
445
|
+
/** Enable error boundaries for automatic error handling (default: true) */
|
|
446
|
+
enableErrorBoundary?: boolean;
|
|
447
|
+
/** Maximum retry attempts for error recovery (default: 3) */
|
|
448
|
+
maxRetries?: number;
|
|
449
|
+
/** Custom error handler */
|
|
450
|
+
onError?: (error: Error, errorInfo: React.ErrorInfo) => void;
|
|
451
|
+
}
|
|
452
|
+
/** Extended ConnectorConfig with app metadata */
|
|
453
|
+
interface ExtendedConnectorConfig extends ConnectorConfig {
|
|
454
|
+
/** Application name for display and metadata */
|
|
455
|
+
appName?: string;
|
|
456
|
+
/** Application URL for metadata */
|
|
457
|
+
appUrl?: string;
|
|
458
|
+
/** Whether mobile wallet adapter is enabled */
|
|
459
|
+
enableMobile?: boolean;
|
|
460
|
+
/** Selected network for convenience (accepts both 'mainnet' and 'mainnet-beta' conventions) */
|
|
461
|
+
network?: 'mainnet' | 'mainnet-beta' | 'devnet' | 'testnet' | 'localnet';
|
|
462
|
+
/** Error boundary configuration */
|
|
463
|
+
errorBoundary?: {
|
|
464
|
+
/** Enable error boundaries (default: true) */
|
|
465
|
+
enabled?: boolean;
|
|
466
|
+
/** Maximum retry attempts (default: 3) */
|
|
467
|
+
maxRetries?: number;
|
|
468
|
+
/** Custom error handler */
|
|
469
|
+
onError?: (error: Error, errorInfo: React.ErrorInfo) => void;
|
|
470
|
+
/** Custom fallback component */
|
|
471
|
+
fallback?: (error: Error, retry: () => void) => React.ReactNode;
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Creates a default connector configuration with sensible defaults for Solana applications
|
|
476
|
+
*/
|
|
477
|
+
declare function getDefaultConfig(options: DefaultConfigOptions): ExtendedConnectorConfig;
|
|
478
|
+
/**
|
|
479
|
+
* Default Mobile Wallet Adapter configuration for Solana applications
|
|
480
|
+
*/
|
|
481
|
+
declare function getDefaultMobileConfig(options: {
|
|
482
|
+
appName: string;
|
|
483
|
+
appUrl?: string;
|
|
484
|
+
network?: 'mainnet' | 'mainnet-beta' | 'devnet' | 'testnet';
|
|
485
|
+
}): {
|
|
486
|
+
appIdentity: {
|
|
487
|
+
name: string;
|
|
488
|
+
uri: string;
|
|
489
|
+
icon: string;
|
|
490
|
+
};
|
|
491
|
+
cluster: "mainnet" | "devnet" | "testnet" | "mainnet-beta";
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
declare global {
|
|
495
|
+
interface Window {
|
|
496
|
+
__connectorClient?: ConnectorClient;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
type ConnectorSnapshot = ReturnType<ConnectorClient['getSnapshot']> & {
|
|
500
|
+
select: (walletName: string) => Promise<void>;
|
|
501
|
+
disconnect: () => Promise<void>;
|
|
502
|
+
selectAccount: (address: string) => Promise<void>;
|
|
503
|
+
};
|
|
504
|
+
interface MobileWalletAdapterConfig {
|
|
505
|
+
appIdentity: {
|
|
506
|
+
name: string;
|
|
507
|
+
uri?: string;
|
|
508
|
+
icon?: string;
|
|
509
|
+
};
|
|
510
|
+
remoteHostAuthority?: string;
|
|
511
|
+
chains?: readonly string[];
|
|
512
|
+
authorizationCache?: unknown;
|
|
513
|
+
chainSelector?: unknown;
|
|
514
|
+
onWalletNotFound?: (wallet: unknown) => Promise<void>;
|
|
515
|
+
}
|
|
516
|
+
declare function ConnectorProvider({ children, config, mobile, }: {
|
|
517
|
+
children: ReactNode;
|
|
518
|
+
config?: ExtendedConnectorConfig;
|
|
519
|
+
mobile?: MobileWalletAdapterConfig;
|
|
520
|
+
}): react_jsx_runtime.JSX.Element;
|
|
521
|
+
declare function useConnector(): ConnectorSnapshot;
|
|
522
|
+
/**
|
|
523
|
+
* Get the connector client instance
|
|
524
|
+
* Returns null if not within ConnectorProvider or if initialization failed
|
|
525
|
+
*
|
|
526
|
+
* @example
|
|
527
|
+
* ```tsx
|
|
528
|
+
* function MyComponent() {
|
|
529
|
+
* const client = useConnectorClient()
|
|
530
|
+
*
|
|
531
|
+
* if (!client) {
|
|
532
|
+
* return <div>Connector not available</div>
|
|
533
|
+
* }
|
|
534
|
+
*
|
|
535
|
+
* // Use client methods directly
|
|
536
|
+
* const health = client.getHealth()
|
|
537
|
+
* }
|
|
538
|
+
* ```
|
|
539
|
+
*/
|
|
540
|
+
declare function useConnectorClient(): ConnectorClient | null;
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* @solana/connector - Network utilities
|
|
544
|
+
*
|
|
545
|
+
* Utilities for translating between different Solana network naming conventions.
|
|
546
|
+
* Ensures compatibility with WalletUI (SolanaClusterId) and Gill types.
|
|
547
|
+
*
|
|
548
|
+
* Primary type: SolanaNetwork - normalized network names
|
|
549
|
+
* External integration: Use WalletUI's SolanaClusterId for cluster operations
|
|
550
|
+
*/
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Normalized Solana network names
|
|
554
|
+
*
|
|
555
|
+
* This is the canonical network type used throughout the connector.
|
|
556
|
+
* Use `toClusterId()` to convert to WalletUI's SolanaClusterId format.
|
|
557
|
+
* Aligned with Gill's SolanaClusterMoniker type.
|
|
558
|
+
*/
|
|
559
|
+
type SolanaNetwork = 'mainnet' | 'devnet' | 'testnet' | 'localnet';
|
|
560
|
+
/**
|
|
561
|
+
* Public RPC endpoints for each Solana network
|
|
562
|
+
*
|
|
563
|
+
* ⚠️ WARNING: These are public, rate-limited endpoints provided by Solana Labs.
|
|
564
|
+
* For production applications, use a dedicated RPC provider like:
|
|
565
|
+
* - Triton (https://triton.one)
|
|
566
|
+
* - Helius (https://helius.dev)
|
|
567
|
+
* - QuickNode (https://quicknode.com)
|
|
568
|
+
* - Alchemy (https://alchemy.com)
|
|
569
|
+
*
|
|
570
|
+
* Note: These values are now sourced from Gill's getPublicSolanaRpcUrl for consistency.
|
|
571
|
+
* Kept here for reference and backward compatibility.
|
|
572
|
+
*/
|
|
573
|
+
declare const PUBLIC_RPC_ENDPOINTS: Record<SolanaNetwork, string>;
|
|
574
|
+
/**
|
|
575
|
+
* Normalize network name to standard format
|
|
576
|
+
* Accepts various naming conventions and returns the canonical SolanaNetwork format
|
|
577
|
+
*
|
|
578
|
+
* @example
|
|
579
|
+
* normalizeNetwork('mainnet-beta') // Returns: 'mainnet'
|
|
580
|
+
* normalizeNetwork('mainnet') // Returns: 'mainnet'
|
|
581
|
+
* normalizeNetwork('MAINNET') // Returns: 'mainnet'
|
|
582
|
+
*/
|
|
583
|
+
declare function normalizeNetwork(network: string): SolanaNetwork;
|
|
584
|
+
/**
|
|
585
|
+
* Convert network name to WalletUI cluster ID format
|
|
586
|
+
*
|
|
587
|
+
* WalletUI uses the 'solana:network' format for cluster identification.
|
|
588
|
+
*
|
|
589
|
+
* @example
|
|
590
|
+
* toClusterId('mainnet') // Returns: 'solana:mainnet'
|
|
591
|
+
* toClusterId('mainnet-beta') // Returns: 'solana:mainnet' (normalized)
|
|
592
|
+
*/
|
|
593
|
+
declare function toClusterId(network: string): SolanaClusterId;
|
|
594
|
+
/**
|
|
595
|
+
* Get the public RPC URL for a network
|
|
596
|
+
*
|
|
597
|
+
* ⚠️ Returns public, rate-limited endpoints. For production, use a dedicated RPC provider.
|
|
598
|
+
*
|
|
599
|
+
* Now uses Gill's getPublicSolanaRpcUrl for consistency with the Gill ecosystem.
|
|
600
|
+
* Falls back to localnet URL for unknown networks.
|
|
601
|
+
*
|
|
602
|
+
* @example
|
|
603
|
+
* getDefaultRpcUrl('mainnet') // Returns: 'https://api.mainnet-beta.solana.com'
|
|
604
|
+
* getDefaultRpcUrl('devnet') // Returns: 'https://api.devnet.solana.com'
|
|
605
|
+
*/
|
|
606
|
+
declare function getDefaultRpcUrl(network: string): string;
|
|
607
|
+
/**
|
|
608
|
+
* Check if a network is mainnet
|
|
609
|
+
*
|
|
610
|
+
* @example
|
|
611
|
+
* isMainnet('mainnet') // Returns: true
|
|
612
|
+
* isMainnet('mainnet-beta') // Returns: true
|
|
613
|
+
* isMainnet('devnet') // Returns: false
|
|
614
|
+
*/
|
|
615
|
+
declare function isMainnet(network: string): boolean;
|
|
616
|
+
/**
|
|
617
|
+
* Check if a network is devnet
|
|
618
|
+
*
|
|
619
|
+
* @example
|
|
620
|
+
* isDevnet('devnet') // Returns: true
|
|
621
|
+
* isDevnet('mainnet') // Returns: false
|
|
622
|
+
*/
|
|
623
|
+
declare function isDevnet(network: string): boolean;
|
|
624
|
+
/**
|
|
625
|
+
* Check if a network is testnet
|
|
626
|
+
*
|
|
627
|
+
* @example
|
|
628
|
+
* isTestnet('testnet') // Returns: true
|
|
629
|
+
* isTestnet('mainnet') // Returns: false
|
|
630
|
+
*/
|
|
631
|
+
declare function isTestnet(network: string): boolean;
|
|
632
|
+
/**
|
|
633
|
+
* Check if a network is localnet
|
|
634
|
+
*
|
|
635
|
+
* @example
|
|
636
|
+
* isLocalnet('localnet') // Returns: true
|
|
637
|
+
* isLocalnet('mainnet') // Returns: false
|
|
638
|
+
*/
|
|
639
|
+
declare function isLocalnet(network: string): boolean;
|
|
640
|
+
/**
|
|
641
|
+
* Get a user-friendly display name for a network
|
|
642
|
+
*
|
|
643
|
+
* @example
|
|
644
|
+
* getNetworkDisplayName('mainnet-beta') // Returns: 'Mainnet'
|
|
645
|
+
* getNetworkDisplayName('devnet') // Returns: 'Devnet'
|
|
646
|
+
*/
|
|
647
|
+
declare function getNetworkDisplayName(network: string): string;
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* @solana/connector - Unified configuration
|
|
651
|
+
*
|
|
652
|
+
* Simplified configuration for apps using ConnectorKit
|
|
653
|
+
* Eliminates config duplication and provides a single source of truth
|
|
654
|
+
*/
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* Options for creating a unified configuration
|
|
658
|
+
* Maintains type safety while providing flexibility
|
|
659
|
+
*/
|
|
660
|
+
interface UnifiedConfigOptions extends DefaultConfigOptions {
|
|
661
|
+
/**
|
|
662
|
+
* Custom RPC URL (optional - overrides default for network)
|
|
663
|
+
* Note: For production apps, use environment variables to avoid exposing API keys
|
|
664
|
+
* @see packages/connector/src/utils/cluster.ts for secure RPC URL patterns
|
|
665
|
+
*/
|
|
666
|
+
rpcUrl?: string;
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Unified configuration output
|
|
670
|
+
* Contains all configs needed for ConnectorKit and integrations
|
|
671
|
+
*
|
|
672
|
+
* Important: The `rpcUrl` property is intended for:
|
|
673
|
+
* 1. Server-side rendering (SSR) setup
|
|
674
|
+
* 2. Passing to external libraries that need RPC configuration
|
|
675
|
+
* 3. Development/testing environments
|
|
676
|
+
*
|
|
677
|
+
* For production client-side code, use the connector client's `getRpcUrl()` method
|
|
678
|
+
* which supports environment variable patterns and proxy configurations.
|
|
679
|
+
*/
|
|
680
|
+
interface UnifiedConfig {
|
|
681
|
+
/** ConnectorKit configuration */
|
|
682
|
+
connectorConfig: ExtendedConnectorConfig;
|
|
683
|
+
/** Mobile Wallet Adapter configuration (optional) */
|
|
684
|
+
mobile?: MobileWalletAdapterConfig;
|
|
685
|
+
/** Normalized network name ('mainnet', 'devnet', 'testnet', 'localnet') */
|
|
686
|
+
network: SolanaNetwork;
|
|
687
|
+
/**
|
|
688
|
+
* RPC endpoint URL
|
|
689
|
+
* For external library integration only - client code should use connector client
|
|
690
|
+
* @deprecated in client components - use `useConnectorClient().getRpcUrl()` instead
|
|
691
|
+
*/
|
|
692
|
+
rpcUrl: string;
|
|
693
|
+
/** Application metadata */
|
|
694
|
+
app: {
|
|
695
|
+
name: string;
|
|
696
|
+
url: string;
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Create a unified configuration for ConnectorKit
|
|
701
|
+
*
|
|
702
|
+
* This helper eliminates configuration duplication by creating all necessary
|
|
703
|
+
* configs from a single source of truth. It automatically handles network
|
|
704
|
+
* name translation between different conventions.
|
|
705
|
+
*
|
|
706
|
+
* @example Basic usage
|
|
707
|
+
* ```tsx
|
|
708
|
+
* import { createConfig, AppProvider } from '@solana/connector';
|
|
709
|
+
*
|
|
710
|
+
* const config = createConfig({
|
|
711
|
+
* appName: 'My App',
|
|
712
|
+
* network: 'mainnet', // Works with 'mainnet' or 'mainnet-beta'
|
|
713
|
+
* enableMobile: true
|
|
714
|
+
* });
|
|
715
|
+
*
|
|
716
|
+
* <AppProvider config={config}>
|
|
717
|
+
* {children}
|
|
718
|
+
* </AppProvider>
|
|
719
|
+
* ```
|
|
720
|
+
*
|
|
721
|
+
* @example Integration with external libraries
|
|
722
|
+
* ```tsx
|
|
723
|
+
* import { createConfig, AppProvider } from '@solana/connector';
|
|
724
|
+
* import { ArmaProvider } from '@armadura/sdk';
|
|
725
|
+
*
|
|
726
|
+
* const config = createConfig({
|
|
727
|
+
* appName: 'My App',
|
|
728
|
+
* network: 'mainnet',
|
|
729
|
+
* });
|
|
730
|
+
*
|
|
731
|
+
* <AppProvider config={config}>
|
|
732
|
+
* <ArmaProvider
|
|
733
|
+
* config={{
|
|
734
|
+
* network: config.network,
|
|
735
|
+
* rpcUrl: config.rpcUrl, // Safe - for external library initialization
|
|
736
|
+
* providers: [...]
|
|
737
|
+
* }}
|
|
738
|
+
* useConnector="auto"
|
|
739
|
+
* >
|
|
740
|
+
* {children}
|
|
741
|
+
* </ArmaProvider>
|
|
742
|
+
* </AppProvider>
|
|
743
|
+
* ```
|
|
744
|
+
*
|
|
745
|
+
* @example Production with environment variables
|
|
746
|
+
* ```tsx
|
|
747
|
+
* // Use environment variables to avoid exposing API keys
|
|
748
|
+
* const config = createConfig({
|
|
749
|
+
* appName: 'My App',
|
|
750
|
+
* network: 'mainnet',
|
|
751
|
+
* // RPC URL comes from process.env on server
|
|
752
|
+
* // Client-side code should use connector client's getRpcUrl()
|
|
753
|
+
* });
|
|
754
|
+
* ```
|
|
755
|
+
*
|
|
756
|
+
* @example Custom clusters
|
|
757
|
+
* ```tsx
|
|
758
|
+
* const config = createConfig({
|
|
759
|
+
* appName: 'My App',
|
|
760
|
+
* network: 'mainnet',
|
|
761
|
+
* customClusters: [
|
|
762
|
+
* {
|
|
763
|
+
* id: 'solana:custom',
|
|
764
|
+
* label: 'Custom RPC',
|
|
765
|
+
* url: process.env.CUSTOM_RPC_URL || 'https://...'
|
|
766
|
+
* }
|
|
767
|
+
* ]
|
|
768
|
+
* });
|
|
769
|
+
* ```
|
|
770
|
+
*/
|
|
771
|
+
declare function createConfig(options: UnifiedConfigOptions): UnifiedConfig;
|
|
772
|
+
/**
|
|
773
|
+
* Type guard to check if a config is a unified config
|
|
774
|
+
*
|
|
775
|
+
* @example
|
|
776
|
+
* ```ts
|
|
777
|
+
* if (isUnifiedConfig(someConfig)) {
|
|
778
|
+
* // TypeScript knows this is UnifiedConfig
|
|
779
|
+
* console.log(someConfig.network, someConfig.rpcUrl);
|
|
780
|
+
* }
|
|
781
|
+
* ```
|
|
782
|
+
*/
|
|
783
|
+
declare function isUnifiedConfig(config: unknown): config is UnifiedConfig;
|
|
784
|
+
|
|
785
|
+
declare enum WalletErrorType {
|
|
786
|
+
CONNECTION_FAILED = "CONNECTION_FAILED",
|
|
787
|
+
TRANSACTION_FAILED = "TRANSACTION_FAILED",
|
|
788
|
+
NETWORK_ERROR = "NETWORK_ERROR",
|
|
789
|
+
WALLET_NOT_FOUND = "WALLET_NOT_FOUND",
|
|
790
|
+
USER_REJECTED = "USER_REJECTED",
|
|
791
|
+
INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS",
|
|
792
|
+
UNKNOWN_ERROR = "UNKNOWN_ERROR"
|
|
793
|
+
}
|
|
794
|
+
interface WalletError extends Error {
|
|
795
|
+
type: WalletErrorType;
|
|
796
|
+
recoverable: boolean;
|
|
797
|
+
context?: Record<string, unknown>;
|
|
798
|
+
retryAction?: () => Promise<void>;
|
|
799
|
+
}
|
|
800
|
+
interface ErrorBoundaryState {
|
|
801
|
+
hasError: boolean;
|
|
802
|
+
error: Error | null;
|
|
803
|
+
errorInfo: ErrorInfo | null;
|
|
804
|
+
errorId: string;
|
|
805
|
+
retryCount: number;
|
|
806
|
+
}
|
|
807
|
+
interface ErrorBoundaryProps {
|
|
808
|
+
children: ReactNode;
|
|
809
|
+
fallback?: (error: WalletError, retry: () => void) => ReactNode;
|
|
810
|
+
onError?: (error: Error, errorInfo: ErrorInfo) => void;
|
|
811
|
+
maxRetries?: number;
|
|
812
|
+
enableRecovery?: boolean;
|
|
813
|
+
}
|
|
814
|
+
declare class ConnectorErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
815
|
+
private retryTimeouts;
|
|
816
|
+
constructor(props: ErrorBoundaryProps);
|
|
817
|
+
static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState>;
|
|
818
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
819
|
+
componentWillUnmount(): void;
|
|
820
|
+
retry: () => void;
|
|
821
|
+
render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
822
|
+
}
|
|
823
|
+
declare function withErrorBoundary<P extends object>(Component: React.ComponentType<P>, errorBoundaryProps?: Omit<ErrorBoundaryProps, 'children'>): {
|
|
824
|
+
(props: P): react_jsx_runtime.JSX.Element;
|
|
825
|
+
displayName: string;
|
|
826
|
+
};
|
|
827
|
+
|
|
828
|
+
/**
|
|
829
|
+
* @solana/connector - Cluster utilities
|
|
830
|
+
*
|
|
831
|
+
* Utility functions for working with Solana clusters (networks)
|
|
832
|
+
*/
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
* Cluster type enum for all supported Solana cluster types
|
|
836
|
+
*/
|
|
837
|
+
type ClusterType = 'mainnet' | 'devnet' | 'testnet' | 'localnet' | 'custom';
|
|
838
|
+
/**
|
|
839
|
+
* Get the RPC endpoint URL for a cluster
|
|
840
|
+
* Handles both string cluster names and full URLs
|
|
841
|
+
*
|
|
842
|
+
* @example
|
|
843
|
+
* getClusterRpcUrl(devnetCluster) // Returns: 'https://api.devnet.solana.com'
|
|
844
|
+
*/
|
|
845
|
+
declare function getClusterRpcUrl(cluster: SolanaCluster): string;
|
|
846
|
+
/**
|
|
847
|
+
* Get the base Solana Explorer URL for a cluster
|
|
848
|
+
*
|
|
849
|
+
* @example
|
|
850
|
+
* getClusterExplorerUrl(mainnetCluster) // Returns: 'https://explorer.solana.com'
|
|
851
|
+
*/
|
|
852
|
+
declare function getClusterExplorerUrl(cluster: SolanaCluster, path?: string): string;
|
|
853
|
+
/**
|
|
854
|
+
* Get the Solana Explorer URL for a transaction signature
|
|
855
|
+
*
|
|
856
|
+
* @example
|
|
857
|
+
* getTransactionUrl('5VERv8...', devnetCluster)
|
|
858
|
+
* // Returns: 'https://explorer.solana.com/tx/5VERv8...?cluster=devnet'
|
|
859
|
+
*/
|
|
860
|
+
declare function getTransactionUrl(signature: string, cluster: SolanaCluster): string;
|
|
861
|
+
/**
|
|
862
|
+
* Get the Solana Explorer URL for an address
|
|
863
|
+
* Works for wallet addresses, token accounts, and programs
|
|
864
|
+
*
|
|
865
|
+
* @example
|
|
866
|
+
* getAddressUrl('7xKXtg2C...', mainnetCluster)
|
|
867
|
+
* // Returns: 'https://explorer.solana.com/address/7xKXtg2C...'
|
|
868
|
+
*/
|
|
869
|
+
declare function getAddressUrl(address: string, cluster: SolanaCluster): string;
|
|
870
|
+
/**
|
|
871
|
+
* Get the Solana Explorer URL for a token
|
|
872
|
+
*
|
|
873
|
+
* @example
|
|
874
|
+
* getTokenUrl('EPjFWdd5...', mainnetCluster)
|
|
875
|
+
*/
|
|
876
|
+
declare function getTokenUrl(tokenAddress: string, cluster: SolanaCluster): string;
|
|
877
|
+
/**
|
|
878
|
+
* Get the Solana Explorer URL for a block
|
|
879
|
+
*/
|
|
880
|
+
declare function getBlockUrl(slot: number, cluster: SolanaCluster): string;
|
|
881
|
+
/**
|
|
882
|
+
* Check if a cluster is production (mainnet)
|
|
883
|
+
*/
|
|
884
|
+
declare function isMainnetCluster(cluster: SolanaCluster): boolean;
|
|
885
|
+
/**
|
|
886
|
+
* Check if a cluster is devnet
|
|
887
|
+
*/
|
|
888
|
+
declare function isDevnetCluster(cluster: SolanaCluster): boolean;
|
|
889
|
+
/**
|
|
890
|
+
* Check if a cluster is testnet
|
|
891
|
+
*/
|
|
892
|
+
declare function isTestnetCluster(cluster: SolanaCluster): boolean;
|
|
893
|
+
/**
|
|
894
|
+
* Check if a cluster is running locally
|
|
895
|
+
*/
|
|
896
|
+
declare function isLocalCluster(cluster: SolanaCluster): boolean;
|
|
897
|
+
/**
|
|
898
|
+
* Get a user-friendly name for the cluster
|
|
899
|
+
*/
|
|
900
|
+
declare function getClusterName(cluster: SolanaCluster): string;
|
|
901
|
+
/**
|
|
902
|
+
* Get the cluster type (mainnet, devnet, testnet, localnet, custom)
|
|
903
|
+
*/
|
|
904
|
+
declare function getClusterType(cluster: SolanaCluster): ClusterType;
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* @solana/connector - Enhanced Clipboard Utilities
|
|
908
|
+
*
|
|
909
|
+
* Comprehensive clipboard functionality with validation, formatting, fallbacks,
|
|
910
|
+
* and detailed error reporting for Solana addresses and transaction signatures.
|
|
911
|
+
*/
|
|
912
|
+
/**
|
|
913
|
+
* Types of errors that can occur during clipboard operations
|
|
914
|
+
*/
|
|
915
|
+
declare enum ClipboardErrorType {
|
|
916
|
+
/** Browser doesn't support clipboard API (neither modern nor legacy) */
|
|
917
|
+
NOT_SUPPORTED = "not_supported",
|
|
918
|
+
/** User denied clipboard permission or browser blocked the operation */
|
|
919
|
+
PERMISSION_DENIED = "permission_denied",
|
|
920
|
+
/** Running in server-side rendering context (no window/navigator) */
|
|
921
|
+
SSR = "ssr",
|
|
922
|
+
/** Empty or null value provided */
|
|
923
|
+
EMPTY_VALUE = "empty_value",
|
|
924
|
+
/** Value failed validation (invalid address/signature format) */
|
|
925
|
+
INVALID_VALUE = "invalid_value",
|
|
926
|
+
/** Unknown error occurred during copy operation */
|
|
927
|
+
UNKNOWN = "unknown"
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* Detailed result from clipboard operation
|
|
931
|
+
*/
|
|
932
|
+
interface ClipboardResult {
|
|
933
|
+
/** Whether the copy operation succeeded */
|
|
934
|
+
success: boolean;
|
|
935
|
+
/** Type of error if operation failed */
|
|
936
|
+
error?: ClipboardErrorType;
|
|
937
|
+
/** Human-readable error message */
|
|
938
|
+
errorMessage?: string;
|
|
939
|
+
/** Whether fallback method (execCommand) was used instead of modern API */
|
|
940
|
+
usedFallback?: boolean;
|
|
941
|
+
/** The actual value that was copied (after formatting) */
|
|
942
|
+
copiedValue?: string;
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* Options for clipboard copy operations
|
|
946
|
+
*/
|
|
947
|
+
interface CopyOptions {
|
|
948
|
+
/** Callback invoked on successful copy */
|
|
949
|
+
onSuccess?: () => void;
|
|
950
|
+
/** Callback invoked on copy failure */
|
|
951
|
+
onError?: (error: ClipboardErrorType, message: string) => void;
|
|
952
|
+
/** Format to use when copying ('full' = original, 'short' = truncated) */
|
|
953
|
+
format?: 'full' | 'short' | 'custom';
|
|
954
|
+
/** Custom formatter function (only used when format='custom') */
|
|
955
|
+
customFormatter?: (value: string) => string;
|
|
956
|
+
/** Custom validation function */
|
|
957
|
+
validate?: (value: string) => boolean;
|
|
958
|
+
/** Type of value being copied (enables built-in validation) */
|
|
959
|
+
validateType?: 'address' | 'signature' | 'none';
|
|
960
|
+
/** Whether to attempt fallback using execCommand for older browsers */
|
|
961
|
+
useFallback?: boolean;
|
|
962
|
+
/** Number of characters to show on each side when format='short' */
|
|
963
|
+
shortFormatChars?: number;
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* Check clipboard API availability
|
|
967
|
+
*
|
|
968
|
+
* @returns Object indicating which clipboard methods are available
|
|
969
|
+
*
|
|
970
|
+
* @example
|
|
971
|
+
* ```ts
|
|
972
|
+
* const { modern, fallback, available } = isClipboardAvailable();
|
|
973
|
+
* if (!available) {
|
|
974
|
+
* console.warn('Clipboard not supported in this browser');
|
|
975
|
+
* }
|
|
976
|
+
* ```
|
|
977
|
+
*/
|
|
978
|
+
declare function isClipboardAvailable(): {
|
|
979
|
+
/** Modern Clipboard API (navigator.clipboard) is available */
|
|
980
|
+
modern: boolean;
|
|
981
|
+
/** Legacy execCommand fallback is available */
|
|
982
|
+
fallback: boolean;
|
|
983
|
+
/** At least one method is available */
|
|
984
|
+
available: boolean;
|
|
985
|
+
};
|
|
986
|
+
/**
|
|
987
|
+
* Copy text to clipboard with comprehensive error handling and features
|
|
988
|
+
*
|
|
989
|
+
* @param text - Text to copy to clipboard
|
|
990
|
+
* @param options - Configuration options for copy operation
|
|
991
|
+
* @returns Promise resolving to detailed result object
|
|
992
|
+
*
|
|
993
|
+
* @example Basic usage
|
|
994
|
+
* ```ts
|
|
995
|
+
* const result = await copyToClipboard('5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp...');
|
|
996
|
+
* if (result.success) {
|
|
997
|
+
* console.log('Copied!');
|
|
998
|
+
* }
|
|
999
|
+
* ```
|
|
1000
|
+
*
|
|
1001
|
+
* @example With validation and formatting
|
|
1002
|
+
* ```ts
|
|
1003
|
+
* const result = await copyToClipboard(address, {
|
|
1004
|
+
* validateType: 'address',
|
|
1005
|
+
* format: 'short',
|
|
1006
|
+
* onSuccess: () => toast.success('Address copied!'),
|
|
1007
|
+
* onError: (type, msg) => toast.error(msg)
|
|
1008
|
+
* });
|
|
1009
|
+
* ```
|
|
1010
|
+
*
|
|
1011
|
+
* @example Custom formatting
|
|
1012
|
+
* ```ts
|
|
1013
|
+
* const result = await copyToClipboard(signature, {
|
|
1014
|
+
* format: 'custom',
|
|
1015
|
+
* customFormatter: (sig) => `Signature: ${sig}`,
|
|
1016
|
+
* onSuccess: () => setCopied(true)
|
|
1017
|
+
* });
|
|
1018
|
+
* ```
|
|
1019
|
+
*/
|
|
1020
|
+
declare function copyToClipboard(text: string, options?: CopyOptions): Promise<ClipboardResult>;
|
|
1021
|
+
/**
|
|
1022
|
+
* Copy a Solana wallet address to clipboard with automatic validation
|
|
1023
|
+
*
|
|
1024
|
+
* @param address - Solana wallet address (base58 encoded public key)
|
|
1025
|
+
* @param options - Copy options (validateType will be set to 'address' automatically)
|
|
1026
|
+
* @returns Promise resolving to result object
|
|
1027
|
+
*
|
|
1028
|
+
* @example
|
|
1029
|
+
* ```tsx
|
|
1030
|
+
* function AddressButton({ address }: { address: string }) {
|
|
1031
|
+
* const [copied, setCopied] = useState(false);
|
|
1032
|
+
*
|
|
1033
|
+
* const handleCopy = async () => {
|
|
1034
|
+
* const result = await copyAddressToClipboard(address, {
|
|
1035
|
+
* format: 'short',
|
|
1036
|
+
* onSuccess: () => {
|
|
1037
|
+
* setCopied(true);
|
|
1038
|
+
* setTimeout(() => setCopied(false), 2000);
|
|
1039
|
+
* }
|
|
1040
|
+
* });
|
|
1041
|
+
* };
|
|
1042
|
+
*
|
|
1043
|
+
* return (
|
|
1044
|
+
* <button onClick={handleCopy}>
|
|
1045
|
+
* {formatAddress(address)} {copied && '✓'}
|
|
1046
|
+
* </button>
|
|
1047
|
+
* );
|
|
1048
|
+
* }
|
|
1049
|
+
* ```
|
|
1050
|
+
*/
|
|
1051
|
+
declare function copyAddressToClipboard(address: string, options?: Omit<CopyOptions, 'validateType'>): Promise<ClipboardResult>;
|
|
1052
|
+
/**
|
|
1053
|
+
* Copy a transaction signature to clipboard with automatic validation
|
|
1054
|
+
*
|
|
1055
|
+
* @param signature - Solana transaction signature (base58 encoded, 64 bytes)
|
|
1056
|
+
* @param options - Copy options (validateType will be set to 'signature' automatically)
|
|
1057
|
+
* @returns Promise resolving to result object
|
|
1058
|
+
*
|
|
1059
|
+
* @example
|
|
1060
|
+
* ```tsx
|
|
1061
|
+
* function TransactionRow({ signature }: { signature: string }) {
|
|
1062
|
+
* return (
|
|
1063
|
+
* <button
|
|
1064
|
+
* onClick={async () => {
|
|
1065
|
+
* const result = await copySignatureToClipboard(signature, {
|
|
1066
|
+
* onSuccess: () => toast.success('Signature copied!'),
|
|
1067
|
+
* onError: (type, msg) => toast.error(msg)
|
|
1068
|
+
* });
|
|
1069
|
+
* }}
|
|
1070
|
+
* >
|
|
1071
|
+
* Copy Signature
|
|
1072
|
+
* </button>
|
|
1073
|
+
* );
|
|
1074
|
+
* }
|
|
1075
|
+
* ```
|
|
1076
|
+
*/
|
|
1077
|
+
declare function copySignatureToClipboard(signature: string, options?: Omit<CopyOptions, 'validateType'>): Promise<ClipboardResult>;
|
|
1078
|
+
|
|
1079
|
+
interface WalletsRegistry {
|
|
1080
|
+
get(): readonly Wallet[];
|
|
1081
|
+
on(event: 'register' | 'unregister', callback: (wallet: Wallet) => void): () => void;
|
|
1082
|
+
}
|
|
1083
|
+
type WalletStandardWallet = Wallet;
|
|
1084
|
+
type WalletStandardAccount = WalletAccount;
|
|
1085
|
+
/**
|
|
1086
|
+
* Get the wallets registry - simplified approach
|
|
1087
|
+
*/
|
|
1088
|
+
declare function getWalletsRegistry(): WalletsRegistry;
|
|
1089
|
+
|
|
1090
|
+
export { getBlockUrl as $, type AccountInfo as A, type StorageOptions as B, ConnectorProvider as C, type DefaultConfigOptions as D, type ExtendedConnectorConfig as E, type EnhancedStorageAccountOptions as F, type EnhancedStorageClusterOptions as G, type EnhancedStorageWalletOptions as H, WalletErrorType as I, type WalletError as J, ClipboardErrorType as K, type Listener as L, type MobileWalletAdapterConfig as M, type ClipboardResult as N, type CopyOptions as O, isClipboardAvailable as P, copyToClipboard as Q, copyAddressToClipboard as R, type StorageAdapter as S, copySignatureToClipboard as T, type UnifiedConfigOptions as U, getClusterRpcUrl as V, type WalletInfo as W, getClusterExplorerUrl as X, getTransactionUrl as Y, getAddressUrl as Z, getTokenUrl as _, useConnectorClient as a, isMainnetCluster as a0, isDevnetCluster as a1, isTestnetCluster as a2, isLocalCluster as a3, getClusterName as a4, getClusterType as a5, type SolanaNetwork as a6, PUBLIC_RPC_ENDPOINTS as a7, normalizeNetwork as a8, toClusterId as a9, getDefaultRpcUrl as aa, isMainnet as ab, isDevnet as ac, isTestnet as ad, isLocalnet as ae, getNetworkDisplayName as af, ConnectorErrorBoundary as b, type ConnectorSnapshot as c, type ConnectorConfig as d, type ConnectorState as e, type WalletStandardWallet as f, type WalletStandardAccount as g, type UnifiedConfig as h, type ClusterType as i, ConnectorClient as j, getWalletsRegistry as k, getDefaultConfig as l, getDefaultMobileConfig as m, createConfig as n, isUnifiedConfig as o, type WalletName as p, type AccountAddress as q, isWalletName as r, isAccountAddress as s, type ConnectorHealth as t, useConnector as u, type ConnectorDebugMetrics as v, withErrorBoundary as w, type ConnectorDebugState as x, type ConnectorEvent as y, type ConnectorEventListener as z };
|