@solana/connector 0.0.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +1460 -0
  2. package/dist/chunk-5ZUVZZWU.mjs +180 -0
  3. package/dist/chunk-5ZUVZZWU.mjs.map +1 -0
  4. package/dist/chunk-6PBQ5CXV.mjs +635 -0
  5. package/dist/chunk-6PBQ5CXV.mjs.map +1 -0
  6. package/dist/chunk-D4JGBIP7.js +314 -0
  7. package/dist/chunk-D4JGBIP7.js.map +1 -0
  8. package/dist/chunk-EGYXJT54.mjs +298 -0
  9. package/dist/chunk-EGYXJT54.mjs.map +1 -0
  10. package/dist/chunk-P4ZLJI4L.js +706 -0
  11. package/dist/chunk-P4ZLJI4L.js.map +1 -0
  12. package/dist/chunk-P5A3XNFF.js +2482 -0
  13. package/dist/chunk-P5A3XNFF.js.map +1 -0
  14. package/dist/chunk-SMUUAKC3.js +186 -0
  15. package/dist/chunk-SMUUAKC3.js.map +1 -0
  16. package/dist/chunk-TAAXHAV2.mjs +2419 -0
  17. package/dist/chunk-TAAXHAV2.mjs.map +1 -0
  18. package/dist/compat.d.mts +47 -0
  19. package/dist/compat.d.ts +47 -0
  20. package/dist/compat.js +98 -0
  21. package/dist/compat.js.map +1 -0
  22. package/dist/compat.mjs +94 -0
  23. package/dist/compat.mjs.map +1 -0
  24. package/dist/headless.d.mts +515 -0
  25. package/dist/headless.d.ts +515 -0
  26. package/dist/headless.js +445 -0
  27. package/dist/headless.js.map +1 -0
  28. package/dist/headless.mjs +4 -0
  29. package/dist/headless.mjs.map +1 -0
  30. package/dist/index.d.mts +14 -0
  31. package/dist/index.d.ts +14 -0
  32. package/dist/index.js +502 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/index.mjs +5 -0
  35. package/dist/index.mjs.map +1 -0
  36. package/dist/react.d.mts +496 -0
  37. package/dist/react.d.ts +496 -0
  38. package/dist/react.js +65 -0
  39. package/dist/react.js.map +1 -0
  40. package/dist/react.mjs +4 -0
  41. package/dist/react.mjs.map +1 -0
  42. package/dist/transaction-signer-D3csM_Mf.d.mts +199 -0
  43. package/dist/transaction-signer-D3csM_Mf.d.ts +199 -0
  44. package/dist/wallet-standard-shim-C1tisl9S.d.ts +926 -0
  45. package/dist/wallet-standard-shim-Cg0GVGwu.d.mts +926 -0
  46. package/package.json +93 -10
  47. package/index.js +0 -1
@@ -0,0 +1,926 @@
1
+ import { c as TransactionActivity, d as TransactionActivityStatus } from './transaction-signer-D3csM_Mf.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
+ declare class ConnectorClient {
292
+ private stateManager;
293
+ private eventEmitter;
294
+ private walletDetector;
295
+ private connectionManager;
296
+ private autoConnector;
297
+ private clusterManager;
298
+ private transactionTracker;
299
+ private debugMetrics;
300
+ private healthMonitor;
301
+ private initialized;
302
+ private config;
303
+ constructor(config?: ConnectorConfig);
304
+ private initialize;
305
+ select(walletName: string): Promise<void>;
306
+ disconnect(): Promise<void>;
307
+ selectAccount(address: string): Promise<void>;
308
+ setCluster(clusterId: SolanaClusterId): Promise<void>;
309
+ getCluster(): SolanaCluster | null;
310
+ getClusters(): SolanaCluster[];
311
+ getRpcUrl(): string | null;
312
+ subscribe(listener: Listener): () => void;
313
+ getSnapshot(): ConnectorState;
314
+ resetStorage(): void;
315
+ on(listener: ConnectorEventListener): () => void;
316
+ off(listener: ConnectorEventListener): void;
317
+ offAll(): void;
318
+ emitEvent(event: ConnectorEvent): void;
319
+ trackTransaction(activity: Omit<TransactionActivity, 'timestamp' | 'cluster'>): void;
320
+ updateTransactionStatus(signature: string, status: TransactionActivity['status'], error?: string): void;
321
+ clearTransactionHistory(): void;
322
+ getHealth(): ConnectorHealth;
323
+ getDebugMetrics(): ConnectorDebugMetrics;
324
+ getDebugState(): ConnectorDebugState;
325
+ resetDebugMetrics(): void;
326
+ destroy(): void;
327
+ }
328
+
329
+ interface DefaultConfigOptions {
330
+ /** Application name shown in wallet connection prompts */
331
+ appName: string;
332
+ /** Application URL for wallet connection metadata */
333
+ appUrl?: string;
334
+ /** Enable automatic wallet reconnection on page load */
335
+ autoConnect?: boolean;
336
+ /** Enable debug logging */
337
+ debug?: boolean;
338
+ /** Solana network to connect to (accepts both 'mainnet' and 'mainnet-beta' conventions) */
339
+ network?: 'mainnet' | 'mainnet-beta' | 'devnet' | 'testnet' | 'localnet';
340
+ /** Enable Mobile Wallet Adapter support */
341
+ enableMobile?: boolean;
342
+ /** Custom storage implementation */
343
+ storage?: ConnectorConfig['storage'];
344
+ /** Custom cluster configuration - overrides network if provided */
345
+ clusters?: SolanaCluster[];
346
+ /** Additional custom clusters to add to the default list */
347
+ customClusters?: SolanaCluster[];
348
+ /** Persist cluster selection across sessions */
349
+ persistClusterSelection?: boolean;
350
+ /** Custom storage key for cluster persistence */
351
+ clusterStorageKey?: string;
352
+ /** Enable error boundaries for automatic error handling (default: true) */
353
+ enableErrorBoundary?: boolean;
354
+ /** Maximum retry attempts for error recovery (default: 3) */
355
+ maxRetries?: number;
356
+ /** Custom error handler */
357
+ onError?: (error: Error, errorInfo: React.ErrorInfo) => void;
358
+ }
359
+ /** Extended ConnectorConfig with app metadata */
360
+ interface ExtendedConnectorConfig extends ConnectorConfig {
361
+ /** Application name for display and metadata */
362
+ appName?: string;
363
+ /** Application URL for metadata */
364
+ appUrl?: string;
365
+ /** Whether mobile wallet adapter is enabled */
366
+ enableMobile?: boolean;
367
+ /** Selected network for convenience (accepts both 'mainnet' and 'mainnet-beta' conventions) */
368
+ network?: 'mainnet' | 'mainnet-beta' | 'devnet' | 'testnet' | 'localnet';
369
+ /** Error boundary configuration */
370
+ errorBoundary?: {
371
+ /** Enable error boundaries (default: true) */
372
+ enabled?: boolean;
373
+ /** Maximum retry attempts (default: 3) */
374
+ maxRetries?: number;
375
+ /** Custom error handler */
376
+ onError?: (error: Error, errorInfo: React.ErrorInfo) => void;
377
+ /** Custom fallback component */
378
+ fallback?: (error: Error, retry: () => void) => React.ReactNode;
379
+ };
380
+ }
381
+ /**
382
+ * Creates a default connector configuration with sensible defaults for Solana applications
383
+ */
384
+ declare function getDefaultConfig(options: DefaultConfigOptions): ExtendedConnectorConfig;
385
+ /**
386
+ * Default Mobile Wallet Adapter configuration for Solana applications
387
+ */
388
+ declare function getDefaultMobileConfig(options: {
389
+ appName: string;
390
+ appUrl?: string;
391
+ network?: 'mainnet' | 'mainnet-beta' | 'devnet' | 'testnet';
392
+ }): {
393
+ appIdentity: {
394
+ name: string;
395
+ uri: string;
396
+ icon: string;
397
+ };
398
+ cluster: "mainnet" | "devnet" | "testnet" | "mainnet-beta";
399
+ };
400
+
401
+ declare global {
402
+ interface Window {
403
+ __connectorClient?: ConnectorClient;
404
+ }
405
+ }
406
+ type ConnectorSnapshot = ReturnType<ConnectorClient['getSnapshot']> & {
407
+ select: (walletName: string) => Promise<void>;
408
+ disconnect: () => Promise<void>;
409
+ selectAccount: (address: string) => Promise<void>;
410
+ };
411
+ interface MobileWalletAdapterConfig {
412
+ appIdentity: {
413
+ name: string;
414
+ uri?: string;
415
+ icon?: string;
416
+ };
417
+ remoteHostAuthority?: string;
418
+ chains?: readonly string[];
419
+ authorizationCache?: unknown;
420
+ chainSelector?: unknown;
421
+ onWalletNotFound?: (wallet: unknown) => Promise<void>;
422
+ }
423
+ declare function ConnectorProvider({ children, config, mobile, }: {
424
+ children: ReactNode;
425
+ config?: ExtendedConnectorConfig;
426
+ mobile?: MobileWalletAdapterConfig;
427
+ }): react_jsx_runtime.JSX.Element;
428
+ declare function useConnector(): ConnectorSnapshot;
429
+ declare function useConnectorClient(): ConnectorClient | null;
430
+
431
+ /**
432
+ * @solana/connector - Network utilities
433
+ *
434
+ * Utilities for translating between different Solana network naming conventions.
435
+ * Ensures compatibility with WalletUI (SolanaClusterId) and Gill types.
436
+ *
437
+ * Primary type: SolanaNetwork - normalized network names
438
+ * External integration: Use WalletUI's SolanaClusterId for cluster operations
439
+ */
440
+
441
+ /**
442
+ * Normalized Solana network names
443
+ *
444
+ * This is the canonical network type used throughout the connector.
445
+ * Use `toClusterId()` to convert to WalletUI's SolanaClusterId format.
446
+ * Aligned with Gill's SolanaClusterMoniker type.
447
+ */
448
+ type SolanaNetwork = 'mainnet' | 'devnet' | 'testnet' | 'localnet';
449
+ /**
450
+ * Public RPC endpoints for each Solana network
451
+ *
452
+ * ⚠️ WARNING: These are public, rate-limited endpoints provided by Solana Labs.
453
+ * For production applications, use a dedicated RPC provider like:
454
+ * - Triton (https://triton.one)
455
+ * - Helius (https://helius.dev)
456
+ * - QuickNode (https://quicknode.com)
457
+ * - Alchemy (https://alchemy.com)
458
+ *
459
+ * Note: These values are now sourced from Gill's getPublicSolanaRpcUrl for consistency.
460
+ * Kept here for reference and backward compatibility.
461
+ */
462
+ declare const PUBLIC_RPC_ENDPOINTS: Record<SolanaNetwork, string>;
463
+ /**
464
+ * Normalize network name to standard format
465
+ * Accepts various naming conventions and returns the canonical SolanaNetwork format
466
+ *
467
+ * @example
468
+ * normalizeNetwork('mainnet-beta') // Returns: 'mainnet'
469
+ * normalizeNetwork('mainnet') // Returns: 'mainnet'
470
+ * normalizeNetwork('MAINNET') // Returns: 'mainnet'
471
+ */
472
+ declare function normalizeNetwork(network: string): SolanaNetwork;
473
+ /**
474
+ * Convert network name to WalletUI cluster ID format
475
+ *
476
+ * WalletUI uses the 'solana:network' format for cluster identification.
477
+ *
478
+ * @example
479
+ * toClusterId('mainnet') // Returns: 'solana:mainnet'
480
+ * toClusterId('mainnet-beta') // Returns: 'solana:mainnet' (normalized)
481
+ */
482
+ declare function toClusterId(network: string): SolanaClusterId;
483
+ /**
484
+ * Get the public RPC URL for a network
485
+ *
486
+ * ⚠️ Returns public, rate-limited endpoints. For production, use a dedicated RPC provider.
487
+ *
488
+ * Now uses Gill's getPublicSolanaRpcUrl for consistency with the Gill ecosystem.
489
+ * Falls back to localnet URL for unknown networks.
490
+ *
491
+ * @example
492
+ * getDefaultRpcUrl('mainnet') // Returns: 'https://api.mainnet-beta.solana.com'
493
+ * getDefaultRpcUrl('devnet') // Returns: 'https://api.devnet.solana.com'
494
+ */
495
+ declare function getDefaultRpcUrl(network: string): string;
496
+ /**
497
+ * Check if a network is mainnet
498
+ *
499
+ * @example
500
+ * isMainnet('mainnet') // Returns: true
501
+ * isMainnet('mainnet-beta') // Returns: true
502
+ * isMainnet('devnet') // Returns: false
503
+ */
504
+ declare function isMainnet(network: string): boolean;
505
+ /**
506
+ * Check if a network is devnet
507
+ *
508
+ * @example
509
+ * isDevnet('devnet') // Returns: true
510
+ * isDevnet('mainnet') // Returns: false
511
+ */
512
+ declare function isDevnet(network: string): boolean;
513
+ /**
514
+ * Check if a network is testnet
515
+ *
516
+ * @example
517
+ * isTestnet('testnet') // Returns: true
518
+ * isTestnet('mainnet') // Returns: false
519
+ */
520
+ declare function isTestnet(network: string): boolean;
521
+ /**
522
+ * Check if a network is localnet
523
+ *
524
+ * @example
525
+ * isLocalnet('localnet') // Returns: true
526
+ * isLocalnet('mainnet') // Returns: false
527
+ */
528
+ declare function isLocalnet(network: string): boolean;
529
+ /**
530
+ * Get a user-friendly display name for a network
531
+ *
532
+ * @example
533
+ * getNetworkDisplayName('mainnet-beta') // Returns: 'Mainnet'
534
+ * getNetworkDisplayName('devnet') // Returns: 'Devnet'
535
+ */
536
+ declare function getNetworkDisplayName(network: string): string;
537
+
538
+ /**
539
+ * @solana/connector - Unified configuration
540
+ *
541
+ * Simplified configuration for apps using ConnectorKit
542
+ * Eliminates config duplication and provides a single source of truth
543
+ */
544
+
545
+ /**
546
+ * Options for creating a unified configuration
547
+ * Maintains type safety while providing flexibility
548
+ */
549
+ interface UnifiedConfigOptions extends DefaultConfigOptions {
550
+ /**
551
+ * Custom RPC URL (optional - overrides default for network)
552
+ * Note: For production apps, use environment variables to avoid exposing API keys
553
+ * @see packages/connector/src/utils/cluster.ts for secure RPC URL patterns
554
+ */
555
+ rpcUrl?: string;
556
+ }
557
+ /**
558
+ * Unified configuration output
559
+ * Contains all configs needed for ConnectorKit and integrations
560
+ *
561
+ * Important: The `rpcUrl` property is intended for:
562
+ * 1. Server-side rendering (SSR) setup
563
+ * 2. Passing to external libraries that need RPC configuration
564
+ * 3. Development/testing environments
565
+ *
566
+ * For production client-side code, use the connector client's `getRpcUrl()` method
567
+ * which supports environment variable patterns and proxy configurations.
568
+ */
569
+ interface UnifiedConfig {
570
+ /** ConnectorKit configuration */
571
+ connectorConfig: ExtendedConnectorConfig;
572
+ /** Mobile Wallet Adapter configuration (optional) */
573
+ mobile?: MobileWalletAdapterConfig;
574
+ /** Normalized network name ('mainnet', 'devnet', 'testnet', 'localnet') */
575
+ network: SolanaNetwork;
576
+ /**
577
+ * RPC endpoint URL
578
+ * For external library integration only - client code should use connector client
579
+ * @deprecated in client components - use `useConnectorClient().getRpcUrl()` instead
580
+ */
581
+ rpcUrl: string;
582
+ /** Application metadata */
583
+ app: {
584
+ name: string;
585
+ url: string;
586
+ };
587
+ }
588
+ /**
589
+ * Create a unified configuration for ConnectorKit
590
+ *
591
+ * This helper eliminates configuration duplication by creating all necessary
592
+ * configs from a single source of truth. It automatically handles network
593
+ * name translation between different conventions.
594
+ *
595
+ * @example Basic usage
596
+ * ```tsx
597
+ * import { createConfig, AppProvider } from '@solana/connector';
598
+ *
599
+ * const config = createConfig({
600
+ * appName: 'My App',
601
+ * network: 'mainnet', // Works with 'mainnet' or 'mainnet-beta'
602
+ * enableMobile: true
603
+ * });
604
+ *
605
+ * <AppProvider config={config}>
606
+ * {children}
607
+ * </AppProvider>
608
+ * ```
609
+ *
610
+ * @example Integration with external libraries
611
+ * ```tsx
612
+ * import { createConfig, AppProvider } from '@solana/connector';
613
+ * import { ArmaProvider } from '@armadura/sdk';
614
+ *
615
+ * const config = createConfig({
616
+ * appName: 'My App',
617
+ * network: 'mainnet',
618
+ * });
619
+ *
620
+ * <AppProvider config={config}>
621
+ * <ArmaProvider
622
+ * config={{
623
+ * network: config.network,
624
+ * rpcUrl: config.rpcUrl, // Safe - for external library initialization
625
+ * providers: [...]
626
+ * }}
627
+ * useConnector="auto"
628
+ * >
629
+ * {children}
630
+ * </ArmaProvider>
631
+ * </AppProvider>
632
+ * ```
633
+ *
634
+ * @example Production with environment variables
635
+ * ```tsx
636
+ * // Use environment variables to avoid exposing API keys
637
+ * const config = createConfig({
638
+ * appName: 'My App',
639
+ * network: 'mainnet',
640
+ * // RPC URL comes from process.env on server
641
+ * // Client-side code should use connector client's getRpcUrl()
642
+ * });
643
+ * ```
644
+ *
645
+ * @example Custom clusters
646
+ * ```tsx
647
+ * const config = createConfig({
648
+ * appName: 'My App',
649
+ * network: 'mainnet',
650
+ * customClusters: [
651
+ * {
652
+ * id: 'solana:custom',
653
+ * label: 'Custom RPC',
654
+ * url: process.env.CUSTOM_RPC_URL || 'https://...'
655
+ * }
656
+ * ]
657
+ * });
658
+ * ```
659
+ */
660
+ declare function createConfig(options: UnifiedConfigOptions): UnifiedConfig;
661
+ /**
662
+ * Type guard to check if a config is a unified config
663
+ *
664
+ * @example
665
+ * ```ts
666
+ * if (isUnifiedConfig(someConfig)) {
667
+ * // TypeScript knows this is UnifiedConfig
668
+ * console.log(someConfig.network, someConfig.rpcUrl);
669
+ * }
670
+ * ```
671
+ */
672
+ declare function isUnifiedConfig(config: unknown): config is UnifiedConfig;
673
+
674
+ declare enum WalletErrorType {
675
+ CONNECTION_FAILED = "CONNECTION_FAILED",
676
+ TRANSACTION_FAILED = "TRANSACTION_FAILED",
677
+ NETWORK_ERROR = "NETWORK_ERROR",
678
+ WALLET_NOT_FOUND = "WALLET_NOT_FOUND",
679
+ USER_REJECTED = "USER_REJECTED",
680
+ INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS",
681
+ UNKNOWN_ERROR = "UNKNOWN_ERROR"
682
+ }
683
+ interface WalletError extends Error {
684
+ type: WalletErrorType;
685
+ recoverable: boolean;
686
+ context?: Record<string, unknown>;
687
+ retryAction?: () => Promise<void>;
688
+ }
689
+ interface ErrorBoundaryState {
690
+ hasError: boolean;
691
+ error: Error | null;
692
+ errorInfo: ErrorInfo | null;
693
+ errorId: string;
694
+ retryCount: number;
695
+ }
696
+ interface ErrorBoundaryProps {
697
+ children: ReactNode;
698
+ fallback?: (error: WalletError, retry: () => void) => ReactNode;
699
+ onError?: (error: Error, errorInfo: ErrorInfo) => void;
700
+ maxRetries?: number;
701
+ enableRecovery?: boolean;
702
+ }
703
+ declare class ConnectorErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
704
+ private retryTimeouts;
705
+ constructor(props: ErrorBoundaryProps);
706
+ static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState>;
707
+ componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
708
+ componentWillUnmount(): void;
709
+ retry: () => void;
710
+ 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;
711
+ }
712
+ declare function withErrorBoundary<P extends object>(Component: React.ComponentType<P>, errorBoundaryProps?: Omit<ErrorBoundaryProps, 'children'>): {
713
+ (props: P): react_jsx_runtime.JSX.Element;
714
+ displayName: string;
715
+ };
716
+
717
+ /**
718
+ * @solana/connector - Cluster utilities
719
+ *
720
+ * Utility functions for working with Solana clusters (networks)
721
+ */
722
+
723
+ /**
724
+ * Cluster type enum for all supported Solana cluster types
725
+ */
726
+ type ClusterType = 'mainnet' | 'devnet' | 'testnet' | 'localnet' | 'custom';
727
+ declare function getClusterRpcUrl(cluster: SolanaCluster | string): string;
728
+ declare function getClusterExplorerUrl(cluster: SolanaCluster, path?: string): string;
729
+ declare function getTransactionUrl(signature: string, cluster: SolanaCluster): string;
730
+ declare function getAddressUrl(address: string, cluster: SolanaCluster): string;
731
+ declare function getTokenUrl(tokenAddress: string, cluster: SolanaCluster): string;
732
+ declare function getBlockUrl(slot: number, cluster: SolanaCluster): string;
733
+ declare function isMainnetCluster(cluster: SolanaCluster): boolean;
734
+ declare function isDevnetCluster(cluster: SolanaCluster): boolean;
735
+ declare function isTestnetCluster(cluster: SolanaCluster): boolean;
736
+ declare function isLocalCluster(cluster: SolanaCluster): boolean;
737
+ declare function getClusterName(cluster: SolanaCluster): string;
738
+ declare function getClusterType(cluster: SolanaCluster): ClusterType;
739
+ declare function getClusterChainId(cluster: SolanaCluster): `solana:${string}` | null;
740
+ declare function getChainIdForWalletStandard(cluster: SolanaCluster): `solana:${string}` | null;
741
+
742
+ /**
743
+ * @solana/connector - Enhanced Clipboard Utilities
744
+ *
745
+ * Comprehensive clipboard functionality with validation, formatting, fallbacks,
746
+ * and detailed error reporting for Solana addresses and transaction signatures.
747
+ */
748
+ /**
749
+ * Types of errors that can occur during clipboard operations
750
+ */
751
+ declare enum ClipboardErrorType {
752
+ /** Browser doesn't support clipboard API (neither modern nor legacy) */
753
+ NOT_SUPPORTED = "not_supported",
754
+ /** User denied clipboard permission or browser blocked the operation */
755
+ PERMISSION_DENIED = "permission_denied",
756
+ /** Running in server-side rendering context (no window/navigator) */
757
+ SSR = "ssr",
758
+ /** Empty or null value provided */
759
+ EMPTY_VALUE = "empty_value",
760
+ /** Value failed validation (invalid address/signature format) */
761
+ INVALID_VALUE = "invalid_value",
762
+ /** Unknown error occurred during copy operation */
763
+ UNKNOWN = "unknown"
764
+ }
765
+ /**
766
+ * Detailed result from clipboard operation
767
+ */
768
+ interface ClipboardResult {
769
+ /** Whether the copy operation succeeded */
770
+ success: boolean;
771
+ /** Type of error if operation failed */
772
+ error?: ClipboardErrorType;
773
+ /** Human-readable error message */
774
+ errorMessage?: string;
775
+ /** Whether fallback method (execCommand) was used instead of modern API */
776
+ usedFallback?: boolean;
777
+ /** The actual value that was copied (after formatting) */
778
+ copiedValue?: string;
779
+ }
780
+ /**
781
+ * Options for clipboard copy operations
782
+ */
783
+ interface CopyOptions {
784
+ /** Callback invoked on successful copy */
785
+ onSuccess?: () => void;
786
+ /** Callback invoked on copy failure */
787
+ onError?: (error: ClipboardErrorType, message: string) => void;
788
+ /** Format to use when copying ('full' = original, 'short' = truncated) */
789
+ format?: 'full' | 'short' | 'custom';
790
+ /** Custom formatter function (only used when format='custom') */
791
+ customFormatter?: (value: string) => string;
792
+ /** Custom validation function */
793
+ validate?: (value: string) => boolean;
794
+ /** Type of value being copied (enables built-in validation) */
795
+ validateType?: 'address' | 'signature' | 'none';
796
+ /** Whether to attempt fallback using execCommand for older browsers */
797
+ useFallback?: boolean;
798
+ /** Number of characters to show on each side when format='short' */
799
+ shortFormatChars?: number;
800
+ }
801
+ /**
802
+ * Check clipboard API availability
803
+ *
804
+ * @returns Object indicating which clipboard methods are available
805
+ *
806
+ * @example
807
+ * ```ts
808
+ * const { modern, fallback, available } = isClipboardAvailable();
809
+ * if (!available) {
810
+ * console.warn('Clipboard not supported in this browser');
811
+ * }
812
+ * ```
813
+ */
814
+ declare function isClipboardAvailable(): {
815
+ /** Modern Clipboard API (navigator.clipboard) is available */
816
+ modern: boolean;
817
+ /** Legacy execCommand fallback is available */
818
+ fallback: boolean;
819
+ /** At least one method is available */
820
+ available: boolean;
821
+ };
822
+ /**
823
+ * Copy text to clipboard with comprehensive error handling and features
824
+ *
825
+ * @param text - Text to copy to clipboard
826
+ * @param options - Configuration options for copy operation
827
+ * @returns Promise resolving to detailed result object
828
+ *
829
+ * @example Basic usage
830
+ * ```ts
831
+ * const result = await copyToClipboard('5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp...');
832
+ * if (result.success) {
833
+ * console.log('Copied!');
834
+ * }
835
+ * ```
836
+ *
837
+ * @example With validation and formatting
838
+ * ```ts
839
+ * const result = await copyToClipboard(address, {
840
+ * validateType: 'address',
841
+ * format: 'short',
842
+ * onSuccess: () => toast.success('Address copied!'),
843
+ * onError: (type, msg) => toast.error(msg)
844
+ * });
845
+ * ```
846
+ *
847
+ * @example Custom formatting
848
+ * ```ts
849
+ * const result = await copyToClipboard(signature, {
850
+ * format: 'custom',
851
+ * customFormatter: (sig) => `Signature: ${sig}`,
852
+ * onSuccess: () => setCopied(true)
853
+ * });
854
+ * ```
855
+ */
856
+ declare function copyToClipboard(text: string, options?: CopyOptions): Promise<ClipboardResult>;
857
+ /**
858
+ * Copy a Solana wallet address to clipboard with automatic validation
859
+ *
860
+ * @param address - Solana wallet address (base58 encoded public key)
861
+ * @param options - Copy options (validateType will be set to 'address' automatically)
862
+ * @returns Promise resolving to result object
863
+ *
864
+ * @example
865
+ * ```tsx
866
+ * function AddressButton({ address }: { address: string }) {
867
+ * const [copied, setCopied] = useState(false);
868
+ *
869
+ * const handleCopy = async () => {
870
+ * const result = await copyAddressToClipboard(address, {
871
+ * format: 'short',
872
+ * onSuccess: () => {
873
+ * setCopied(true);
874
+ * setTimeout(() => setCopied(false), 2000);
875
+ * }
876
+ * });
877
+ * };
878
+ *
879
+ * return (
880
+ * <button onClick={handleCopy}>
881
+ * {formatAddress(address)} {copied && '✓'}
882
+ * </button>
883
+ * );
884
+ * }
885
+ * ```
886
+ */
887
+ declare function copyAddressToClipboard(address: string, options?: Omit<CopyOptions, 'validateType'>): Promise<ClipboardResult>;
888
+ /**
889
+ * Copy a transaction signature to clipboard with automatic validation
890
+ *
891
+ * @param signature - Solana transaction signature (base58 encoded, 64 bytes)
892
+ * @param options - Copy options (validateType will be set to 'signature' automatically)
893
+ * @returns Promise resolving to result object
894
+ *
895
+ * @example
896
+ * ```tsx
897
+ * function TransactionRow({ signature }: { signature: string }) {
898
+ * return (
899
+ * <button
900
+ * onClick={async () => {
901
+ * const result = await copySignatureToClipboard(signature, {
902
+ * onSuccess: () => toast.success('Signature copied!'),
903
+ * onError: (type, msg) => toast.error(msg)
904
+ * });
905
+ * }}
906
+ * >
907
+ * Copy Signature
908
+ * </button>
909
+ * );
910
+ * }
911
+ * ```
912
+ */
913
+ declare function copySignatureToClipboard(signature: string, options?: Omit<CopyOptions, 'validateType'>): Promise<ClipboardResult>;
914
+
915
+ interface WalletsRegistry {
916
+ get(): readonly Wallet[];
917
+ on(event: 'register' | 'unregister', callback: (wallet: Wallet) => void): () => void;
918
+ }
919
+ type WalletStandardWallet = Wallet;
920
+ type WalletStandardAccount = WalletAccount;
921
+ /**
922
+ * Get the wallets registry - simplified approach
923
+ */
924
+ declare function getWalletsRegistry(): WalletsRegistry;
925
+
926
+ 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, getClusterChainId as a6, getChainIdForWalletStandard as a7, type SolanaNetwork as a8, PUBLIC_RPC_ENDPOINTS as a9, normalizeNetwork as aa, toClusterId as ab, getDefaultRpcUrl as ac, isMainnet as ad, isDevnet as ae, isTestnet as af, isLocalnet as ag, getNetworkDisplayName as ah, 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 };