@solana/connector 0.1.10 → 0.2.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.
Files changed (55) hide show
  1. package/README.md +344 -88
  2. package/dist/{chunk-MN7XNCYI.js → chunk-BJAVJQLK.js} +6 -6
  3. package/dist/{chunk-MN7XNCYI.js.map → chunk-BJAVJQLK.js.map} +1 -1
  4. package/dist/{chunk-6AJJJG5B.js → chunk-BZ2VBJCZ.js} +618 -415
  5. package/dist/chunk-BZ2VBJCZ.js.map +1 -0
  6. package/dist/{chunk-ATYK5OKR.js → chunk-EM4KNOKG.js} +614 -194
  7. package/dist/chunk-EM4KNOKG.js.map +1 -0
  8. package/dist/{chunk-4JT24DIX.js → chunk-HN5AJF7F.js} +61 -20
  9. package/dist/chunk-HN5AJF7F.js.map +1 -0
  10. package/dist/{chunk-FVA4TUI4.mjs → chunk-HPQ5T32K.mjs} +4 -4
  11. package/dist/{chunk-FVA4TUI4.mjs.map → chunk-HPQ5T32K.mjs.map} +1 -1
  12. package/dist/{chunk-QOIQBWMP.mjs → chunk-IDTUFDNB.mjs} +531 -339
  13. package/dist/chunk-IDTUFDNB.mjs.map +1 -0
  14. package/dist/{chunk-WGZYKDXF.mjs → chunk-RTXUS5KG.mjs} +529 -115
  15. package/dist/chunk-RTXUS5KG.mjs.map +1 -0
  16. package/dist/{chunk-64LV76OK.js → chunk-SITQ4JWM.js} +23 -2
  17. package/dist/chunk-SITQ4JWM.js.map +1 -0
  18. package/dist/{chunk-7XHVZW2L.mjs → chunk-UCISIAOG.mjs} +60 -19
  19. package/dist/chunk-UCISIAOG.mjs.map +1 -0
  20. package/dist/{chunk-DKCZA2QI.mjs → chunk-ZZTY3O4N.mjs} +21 -3
  21. package/dist/chunk-ZZTY3O4N.mjs.map +1 -0
  22. package/dist/compat.d.mts +1 -1
  23. package/dist/compat.d.ts +1 -1
  24. package/dist/compat.js +2 -2
  25. package/dist/compat.mjs +1 -1
  26. package/dist/headless.d.mts +25 -7
  27. package/dist/headless.d.ts +25 -7
  28. package/dist/headless.js +196 -132
  29. package/dist/headless.mjs +4 -4
  30. package/dist/index.d.mts +4 -4
  31. package/dist/index.d.ts +4 -4
  32. package/dist/index.js +255 -175
  33. package/dist/index.mjs +5 -5
  34. package/dist/react.d.mts +230 -8
  35. package/dist/react.d.ts +230 -8
  36. package/dist/react.js +78 -42
  37. package/dist/react.mjs +2 -2
  38. package/dist/{standard-shim-BTUm7cur.d.mts → standard-shim-CGB88PPO.d.mts} +396 -54
  39. package/dist/{standard-shim-LsQ97i9T.d.ts → standard-shim-tmnQelaJ.d.ts} +396 -54
  40. package/dist/{transaction-signer-T-KVQFi8.d.ts → transaction-signer-7NaYmP5w.d.mts} +1 -0
  41. package/dist/{transaction-signer-T-KVQFi8.d.mts → transaction-signer-7NaYmP5w.d.ts} +1 -0
  42. package/dist/{walletconnect-D4JN6H2O.js → walletconnect-447EY3OJ.js} +8 -8
  43. package/dist/{walletconnect-D4JN6H2O.js.map → walletconnect-447EY3OJ.js.map} +1 -1
  44. package/dist/walletconnect-U455PO4I.mjs +3 -0
  45. package/dist/{walletconnect-I3PZUBTA.mjs.map → walletconnect-U455PO4I.mjs.map} +1 -1
  46. package/package.json +1 -1
  47. package/dist/chunk-4JT24DIX.js.map +0 -1
  48. package/dist/chunk-64LV76OK.js.map +0 -1
  49. package/dist/chunk-6AJJJG5B.js.map +0 -1
  50. package/dist/chunk-7XHVZW2L.mjs.map +0 -1
  51. package/dist/chunk-ATYK5OKR.js.map +0 -1
  52. package/dist/chunk-DKCZA2QI.mjs.map +0 -1
  53. package/dist/chunk-QOIQBWMP.mjs.map +0 -1
  54. package/dist/chunk-WGZYKDXF.mjs.map +0 -1
  55. package/dist/walletconnect-I3PZUBTA.mjs +0 -3
@@ -1,8 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import React, { ReactNode, Component, ErrorInfo } from 'react';
3
- import { w as TransactionActivity, x as TransactionActivityStatus } from './transaction-signer-T-KVQFi8.mjs';
4
- import { SolanaClusterId, SolanaCluster } from '@wallet-ui/core';
2
+ import React, { ReactNode } from 'react';
3
+ import * as _wallet_standard_base from '@wallet-standard/base';
5
4
  import { Wallet, WalletAccount, IdentifierArray } from '@wallet-standard/base';
5
+ import { w as TransactionActivity, x as TransactionActivityStatus } from './transaction-signer-7NaYmP5w.mjs';
6
+ import { SolanaClusterId, SolanaCluster } from '@wallet-ui/core';
6
7
  import { Address } from '@solana/addresses';
7
8
  import { Signature } from '@solana/keys';
8
9
  import { AuthorizationCache, ChainSelector, SolanaMobileWalletAdapterWallet } from '@solana-mobile/wallet-standard-mobile';
@@ -96,10 +97,33 @@ interface EnhancedStorageClusterOptions extends BaseEnhancedStorageOptions<Solan
96
97
  validClusters?: SolanaClusterId[];
97
98
  }
98
99
  /**
99
- * Options for wallet storage
100
+ * Options for wallet storage (legacy)
100
101
  */
101
102
  interface EnhancedStorageWalletOptions extends BaseEnhancedStorageOptions<string | undefined> {
102
103
  }
104
+ /**
105
+ * Persisted wallet state for vNext auto-connect.
106
+ * Stores connector ID instead of wallet name for stability.
107
+ */
108
+ interface PersistedWalletState {
109
+ /** Storage format version for future migrations */
110
+ version: number;
111
+ /** Stable connector ID (e.g., 'wallet-standard:phantom') */
112
+ connectorId: string;
113
+ /** Last selected account address */
114
+ lastAccount?: string;
115
+ /** Whether auto-connect is enabled for this wallet */
116
+ autoConnect: boolean;
117
+ /** Timestamp of last connection */
118
+ lastConnected?: string;
119
+ }
120
+ /**
121
+ * Options for vNext wallet state storage
122
+ */
123
+ interface EnhancedStorageWalletStateOptions extends BaseEnhancedStorageOptions<PersistedWalletState | null> {
124
+ /** Migration handler for legacy wallet name storage */
125
+ migrateLegacy?: (legacyWalletName: string) => string | null;
126
+ }
103
127
 
104
128
  /**
105
129
  * Account-related types
@@ -239,6 +263,14 @@ interface WalletConnectTransport {
239
263
  isConnected(): boolean;
240
264
  /** Get accounts from the current session namespaces (if available) */
241
265
  getSessionAccounts(): string[];
266
+ /**
267
+ * Subscribe to session changes (account changes, session updates).
268
+ * Returns an unsubscribe function.
269
+ *
270
+ * @param listener - Called when session changes (new accounts, etc.)
271
+ * @returns Unsubscribe function
272
+ */
273
+ onSessionChanged?(listener: (accounts: string[]) => void): () => void;
242
274
  }
243
275
  /**
244
276
  * WalletConnect Solana account response
@@ -324,6 +356,214 @@ interface WalletConnectSignAndSendTransactionResult {
324
356
  signature: string;
325
357
  }
326
358
 
359
+ /**
360
+ * Wallet Session Types - Framework-kit-inspired connector/session abstraction
361
+ *
362
+ * Provides stable connector identity, explicit session management, and
363
+ * a clear status state machine for wallet connections.
364
+ */
365
+
366
+ /**
367
+ * Branded string type for stable wallet connector identification.
368
+ * Format: `wallet-standard:{kebab-cased-wallet-name}` or `walletconnect`
369
+ *
370
+ * @example
371
+ * - 'wallet-standard:phantom'
372
+ * - 'wallet-standard:solflare'
373
+ * - 'walletconnect'
374
+ */
375
+ type WalletConnectorId = string & {
376
+ readonly __brand: 'WalletConnectorId';
377
+ };
378
+ /**
379
+ * Create a connector ID from a wallet name
380
+ */
381
+ declare function createConnectorId(walletName: string): WalletConnectorId;
382
+ /**
383
+ * Check if a string is a valid WalletConnectorId
384
+ *
385
+ * Valid formats:
386
+ * - `wallet-standard:<adapter-name>` - Wallet Standard adapters (e.g., 'wallet-standard:phantom')
387
+ * - `walletconnect` - WalletConnect connector
388
+ * - `mwa:<adapter-name>` - Mobile Wallet Adapter (MWA) connectors for mobile wallets
389
+ * (e.g., 'mwa:phantom')
390
+ *
391
+ * The 'mwa:' prefix identifies connectors using the Solana Mobile Wallet Adapter protocol,
392
+ * which enables communication with mobile wallet apps on iOS and Android devices.
393
+ */
394
+ declare function isWalletConnectorId(value: string): value is WalletConnectorId;
395
+ /**
396
+ * Extract the wallet name from a connector ID (for display purposes)
397
+ */
398
+ declare function getWalletNameFromConnectorId(connectorId: WalletConnectorId): string;
399
+ /**
400
+ * Serializable metadata about a wallet connector.
401
+ * This is what gets stored in state (not the Wallet itself).
402
+ */
403
+ interface WalletConnectorMetadata {
404
+ /** Stable connector identifier */
405
+ id: WalletConnectorId;
406
+ /** Human-readable display name */
407
+ name: string;
408
+ /** Wallet icon (data URI or URL) */
409
+ icon: string;
410
+ /** Whether this connector is ready to connect */
411
+ ready: boolean;
412
+ /** Supported Solana chains (e.g., 'solana:mainnet', 'solana:devnet') */
413
+ chains: readonly string[];
414
+ /** Supported wallet standard features */
415
+ features: readonly string[];
416
+ }
417
+ /**
418
+ * Full wallet connector with methods (not stored in state, kept in registry)
419
+ */
420
+ interface WalletConnector extends WalletConnectorMetadata {
421
+ /** The underlying Wallet Standard wallet (reference, not serialized) */
422
+ readonly wallet: Wallet;
423
+ /**
424
+ * Connect to the wallet
425
+ * @param options Connection options
426
+ * @returns Session with accounts
427
+ */
428
+ connect(options?: ConnectOptions): Promise<WalletSession>;
429
+ /**
430
+ * Disconnect from the wallet
431
+ */
432
+ disconnect(): Promise<void>;
433
+ /**
434
+ * Check if this connector supports a specific feature
435
+ */
436
+ supportsFeature(feature: string): boolean;
437
+ }
438
+ /**
439
+ * Options for connecting to a wallet
440
+ */
441
+ interface ConnectOptions {
442
+ /**
443
+ * Attempt silent connection without user prompt.
444
+ * If the wallet has previously authorized this app, it may connect
445
+ * without showing a popup.
446
+ * @default false
447
+ */
448
+ silent?: boolean;
449
+ /**
450
+ * If silent connection fails, allow falling back to interactive connection.
451
+ * @default true (when silent is true)
452
+ */
453
+ allowInteractiveFallback?: boolean;
454
+ /**
455
+ * Preferred account address to select after connection.
456
+ * If not available, the first account will be selected.
457
+ */
458
+ preferredAccount?: Address;
459
+ }
460
+ /**
461
+ * Account information within a session
462
+ */
463
+ interface SessionAccount {
464
+ /** Account address */
465
+ address: Address;
466
+ /** Display label (if provided by wallet) */
467
+ label?: string;
468
+ /** Wallet standard account reference */
469
+ readonly account: WalletAccount;
470
+ }
471
+ /**
472
+ * Active wallet session with signing capabilities.
473
+ * Created after successful connection.
474
+ */
475
+ interface WalletSession {
476
+ /** Connector that created this session */
477
+ connectorId: WalletConnectorId;
478
+ /** All available accounts in this session */
479
+ accounts: SessionAccount[];
480
+ /** Currently selected account */
481
+ selectedAccount: SessionAccount;
482
+ /**
483
+ * Subscribe to account changes within the session.
484
+ * Returns unsubscribe function.
485
+ */
486
+ onAccountsChanged(listener: (accounts: SessionAccount[]) => void): () => void;
487
+ /**
488
+ * Select a different account within the session
489
+ */
490
+ selectAccount(address: Address): void;
491
+ }
492
+ /**
493
+ * Disconnected state - no wallet connected
494
+ */
495
+ interface WalletStatusDisconnected {
496
+ status: 'disconnected';
497
+ }
498
+ /**
499
+ * Connecting state - connection in progress
500
+ */
501
+ interface WalletStatusConnecting {
502
+ status: 'connecting';
503
+ /** Connector being connected to */
504
+ connectorId: WalletConnectorId;
505
+ }
506
+ /**
507
+ * Connected state - wallet successfully connected
508
+ */
509
+ interface WalletStatusConnected {
510
+ status: 'connected';
511
+ /** Active session */
512
+ session: WalletSession;
513
+ }
514
+ /**
515
+ * Error state - connection or session error
516
+ */
517
+ interface WalletStatusError {
518
+ status: 'error';
519
+ /** Error that occurred */
520
+ error: Error;
521
+ /** Connector that failed (if known) */
522
+ connectorId?: WalletConnectorId;
523
+ /** Whether this error is recoverable */
524
+ recoverable: boolean;
525
+ }
526
+ /**
527
+ * Union of all wallet status states.
528
+ * Use discriminated union pattern for type narrowing.
529
+ *
530
+ * @example
531
+ * ```ts
532
+ * if (wallet.status === 'connected') {
533
+ * // TypeScript knows wallet.session exists
534
+ * console.log(wallet.session.selectedAccount.address);
535
+ * }
536
+ * ```
537
+ */
538
+ type WalletStatus = WalletStatusDisconnected | WalletStatusConnecting | WalletStatusConnected | WalletStatusError;
539
+ declare function isDisconnected(status: WalletStatus): status is WalletStatusDisconnected;
540
+ declare function isConnecting(status: WalletStatus): status is WalletStatusConnecting;
541
+ declare function isConnected(status: WalletStatus): status is WalletStatusConnected;
542
+ declare function isStatusError(status: WalletStatus): status is WalletStatusError;
543
+ /**
544
+ * @deprecated Use isStatusError instead. This alias is kept for backward compatibility.
545
+ */
546
+ declare const isWalletStatusError: typeof isStatusError;
547
+ /**
548
+ * Initial disconnected wallet status
549
+ */
550
+ declare const INITIAL_WALLET_STATUS: WalletStatusDisconnected;
551
+ /**
552
+ * Extract legacy-style state from WalletStatus.
553
+ * Useful for backwards compatibility during migration.
554
+ *
555
+ * @deprecated Use the new WalletStatus discriminated union directly
556
+ */
557
+ declare function toLegacyWalletState(wallet: WalletStatus): {
558
+ connected: boolean;
559
+ connecting: boolean;
560
+ selectedAccount: Address | null;
561
+ accounts: Array<{
562
+ address: Address;
563
+ label?: string;
564
+ }>;
565
+ };
566
+
327
567
  /**
328
568
  * CoinGecko API configuration for price fetching.
329
569
  *
@@ -370,11 +610,46 @@ interface CoinGeckoConfig {
370
610
  * Core connector state
371
611
  */
372
612
  interface ConnectorState {
613
+ /**
614
+ * Wallet connection status using state machine pattern.
615
+ * This is the primary way to check wallet state in vNext.
616
+ *
617
+ * @example
618
+ * ```ts
619
+ * if (state.wallet.status === 'connected') {
620
+ * console.log(state.wallet.session.selectedAccount.address);
621
+ * }
622
+ * ```
623
+ */
624
+ wallet: WalletStatus;
625
+ /**
626
+ * Available wallet connectors with metadata (serializable).
627
+ * Use ConnectorClient methods to actually connect.
628
+ */
629
+ connectors: WalletConnectorMetadata[];
630
+ /**
631
+ * @deprecated Use `state.connectors` instead. This includes legacy WalletInfo.
632
+ */
373
633
  wallets: WalletInfo[];
634
+ /**
635
+ * @deprecated Use `state.wallet.status === 'connected' && state.wallet.session` instead.
636
+ */
374
637
  selectedWallet: Wallet | null;
638
+ /**
639
+ * @deprecated Use `state.wallet.status === 'connected'` instead.
640
+ */
375
641
  connected: boolean;
642
+ /**
643
+ * @deprecated Use `state.wallet.status === 'connecting'` instead.
644
+ */
376
645
  connecting: boolean;
646
+ /**
647
+ * @deprecated Use `state.wallet.status === 'connected' && state.wallet.session.accounts` instead.
648
+ */
377
649
  accounts: AccountInfo[];
650
+ /**
651
+ * @deprecated Use `state.wallet.status === 'connected' && state.wallet.session.selectedAccount.address` instead.
652
+ */
378
653
  selectedAccount: Address | null;
379
654
  cluster: SolanaCluster | null;
380
655
  clusters: SolanaCluster[];
@@ -584,7 +859,30 @@ declare class ConnectorClient {
584
859
  * Dynamically imports and registers the WalletConnect wallet
585
860
  */
586
861
  private initializeWalletConnect;
862
+ /**
863
+ * Connect to a wallet using its stable connector ID.
864
+ * This is the recommended way to connect in vNext.
865
+ *
866
+ * @param connectorId - Stable connector identifier
867
+ * @param options - Connection options (silent mode, preferred account, etc.)
868
+ */
869
+ connectWallet(connectorId: WalletConnectorId, options?: ConnectOptions): Promise<void>;
870
+ /**
871
+ * Disconnect the current wallet session.
872
+ * This is the vNext equivalent of disconnect().
873
+ */
874
+ disconnectWallet(): Promise<void>;
875
+ /**
876
+ * Get a connector by its ID (for advanced use cases).
877
+ */
878
+ getConnector(connectorId: WalletConnectorId): _wallet_standard_base.Wallet | undefined;
879
+ /**
880
+ * @deprecated Use `connectWallet(connectorId)` instead.
881
+ */
587
882
  select(walletName: string): Promise<void>;
883
+ /**
884
+ * @deprecated Use `disconnectWallet()` instead.
885
+ */
588
886
  disconnect(): Promise<void>;
589
887
  selectAccount(address: string): Promise<void>;
590
888
  setCluster(clusterId: SolanaClusterId): Promise<void>;
@@ -774,7 +1072,17 @@ declare function getDefaultMobileConfig(options: {
774
1072
  cluster: "devnet" | "mainnet" | "testnet" | "mainnet-beta";
775
1073
  };
776
1074
 
777
- /** Configuration for registerMwa - defined locally as the package doesn't export this type */
1075
+ /**
1076
+ * Mobile Wallet Adapter Configuration Types
1077
+ *
1078
+ * These types are shared between headless and React implementations.
1079
+ * They do NOT import React or any TSX modules.
1080
+ */
1081
+
1082
+ /**
1083
+ * Internal configuration used by registerMwa.
1084
+ * Defined here as the package doesn't export this type.
1085
+ */
778
1086
  interface RegisterMwaConfig {
779
1087
  appIdentity: {
780
1088
  name: string;
@@ -787,32 +1095,70 @@ interface RegisterMwaConfig {
787
1095
  remoteHostAuthority?: string;
788
1096
  onWalletNotFound: (mobileWalletAdapter: SolanaMobileWalletAdapterWallet) => Promise<void>;
789
1097
  }
1098
+ /**
1099
+ * Configuration options for Mobile Wallet Adapter integration.
1100
+ * Used to configure mobile wallet support in ConnectorProvider.
1101
+ */
1102
+ interface MobileWalletAdapterConfig {
1103
+ /** Application identity shown to users during authorization */
1104
+ appIdentity: {
1105
+ /** Display name of the application */
1106
+ name: string;
1107
+ /** URI of the application (optional) */
1108
+ uri?: string;
1109
+ /** Icon URL of the application (optional) */
1110
+ icon?: string;
1111
+ };
1112
+ /** Remote host authority for remote connections (optional) */
1113
+ remoteHostAuthority?: string;
1114
+ /** Solana chains to support (defaults to mainnet, devnet, testnet) */
1115
+ chains?: RegisterMwaConfig['chains'];
1116
+ /** Authorization cache implementation (optional, uses default if not provided) */
1117
+ authorizationCache?: AuthorizationCache;
1118
+ /** Chain selector implementation (optional, uses default if not provided) */
1119
+ chainSelector?: ChainSelector;
1120
+ /** Handler called when wallet app is not found (optional, uses default if not provided) */
1121
+ onWalletNotFound?: (wallet: SolanaMobileWalletAdapterWallet) => Promise<void>;
1122
+ }
1123
+
790
1124
  declare global {
791
1125
  interface Window {
792
1126
  __connectorClient?: ConnectorClient;
793
1127
  }
794
1128
  }
795
1129
  type ConnectorSnapshot = ReturnType<ConnectorClient['getSnapshot']> & {
1130
+ /** @deprecated Use `connectWallet(connectorId)` instead */
796
1131
  select: (walletName: string) => Promise<void>;
1132
+ /** @deprecated Use `disconnectWallet()` instead */
797
1133
  disconnect: () => Promise<void>;
798
1134
  selectAccount: (address: string) => Promise<void>;
799
1135
  /** WalletConnect URI for QR code display (null when not connecting via WalletConnect) */
800
1136
  walletConnectUri: string | null;
801
1137
  /** Clear the WalletConnect URI (call when modal closes or connection completes) */
802
1138
  clearWalletConnectUri: () => void;
1139
+ /** Connect to a wallet by connector ID (vNext) */
1140
+ connectWallet: (connectorId: WalletConnectorId, options?: ConnectOptions) => Promise<void>;
1141
+ /** Disconnect the current wallet session (vNext) */
1142
+ disconnectWallet: () => Promise<void>;
1143
+ /** Full wallet status object (discriminated union) */
1144
+ walletStatus: WalletStatus;
1145
+ /** Whether a wallet is connected */
1146
+ isConnected: boolean;
1147
+ /** Whether a wallet connection is in progress */
1148
+ isConnecting: boolean;
1149
+ /** Whether an error occurred */
1150
+ isError: boolean;
1151
+ /** Error object if status is 'error', otherwise null */
1152
+ walletError: Error | null;
1153
+ /** Currently selected account address (null if not connected) */
1154
+ account: Address | null;
1155
+ /** All available accounts in the session (empty if not connected) */
1156
+ sessionAccounts: SessionAccount[];
1157
+ /** Connected connector ID (null if not connected) */
1158
+ connectorId: WalletConnectorId | null;
1159
+ /** Resolved connector metadata for the connected wallet (null if not connected) */
1160
+ connector: WalletConnectorMetadata | null;
803
1161
  };
804
- interface MobileWalletAdapterConfig {
805
- appIdentity: {
806
- name: string;
807
- uri?: string;
808
- icon?: string;
809
- };
810
- remoteHostAuthority?: string;
811
- chains?: RegisterMwaConfig['chains'];
812
- authorizationCache?: AuthorizationCache;
813
- chainSelector?: ChainSelector;
814
- onWalletNotFound?: (wallet: SolanaMobileWalletAdapterWallet) => Promise<void>;
815
- }
816
1162
  declare function ConnectorProvider({ children, config, mobile, }: {
817
1163
  children: ReactNode;
818
1164
  config?: ExtendedConnectorConfig;
@@ -821,48 +1167,44 @@ declare function ConnectorProvider({ children, config, mobile, }: {
821
1167
  declare function useConnector(): ConnectorSnapshot;
822
1168
  declare function useConnectorClient(): ConnectorClient | null;
823
1169
 
824
- declare enum WalletErrorType {
825
- CONNECTION_FAILED = "CONNECTION_FAILED",
826
- TRANSACTION_FAILED = "TRANSACTION_FAILED",
827
- NETWORK_ERROR = "NETWORK_ERROR",
828
- WALLET_NOT_FOUND = "WALLET_NOT_FOUND",
829
- USER_REJECTED = "USER_REJECTED",
830
- INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS",
831
- UNKNOWN_ERROR = "UNKNOWN_ERROR"
832
- }
1170
+ /**
1171
+ * Wallet Error Types - Framework-agnostic error definitions
1172
+ *
1173
+ * These types are shared between headless and React implementations.
1174
+ * They do NOT import React or any TSX modules.
1175
+ */
1176
+ /**
1177
+ * Error types specific to wallet connections.
1178
+ * Used by error boundaries and headless error handling.
1179
+ */
1180
+ declare const WalletErrorType: {
1181
+ readonly CONNECTION_FAILED: "CONNECTION_FAILED";
1182
+ readonly TRANSACTION_FAILED: "TRANSACTION_FAILED";
1183
+ readonly NETWORK_ERROR: "NETWORK_ERROR";
1184
+ readonly WALLET_NOT_FOUND: "WALLET_NOT_FOUND";
1185
+ readonly USER_REJECTED: "USER_REJECTED";
1186
+ readonly INSUFFICIENT_FUNDS: "INSUFFICIENT_FUNDS";
1187
+ readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
1188
+ };
1189
+ type WalletErrorType = (typeof WalletErrorType)[keyof typeof WalletErrorType];
1190
+ /**
1191
+ * Extended error interface for wallet-specific errors.
1192
+ * Extends the standard Error with wallet context.
1193
+ */
833
1194
  interface WalletError extends Error {
834
1195
  type: WalletErrorType;
835
1196
  recoverable: boolean;
836
1197
  context?: Record<string, unknown>;
837
1198
  retryAction?: () => Promise<void>;
838
1199
  }
839
- interface ErrorBoundaryState {
840
- hasError: boolean;
841
- error: Error | null;
842
- errorInfo: ErrorInfo | null;
843
- errorId: string;
844
- retryCount: number;
845
- }
846
- interface ErrorBoundaryProps {
847
- children: ReactNode;
848
- fallback?: (error: WalletError, retry: () => void) => ReactNode;
849
- onError?: (error: Error, errorInfo: ErrorInfo) => void;
850
- maxRetries?: number;
851
- enableRecovery?: boolean;
852
- }
853
- declare class ConnectorErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
854
- private retryTimeouts;
855
- constructor(props: ErrorBoundaryProps);
856
- static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState>;
857
- componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
858
- componentWillUnmount(): void;
859
- retry: () => void;
860
- 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;
861
- }
862
- declare function withErrorBoundary<P extends object>(Component: React.ComponentType<P>, errorBoundaryProps?: Omit<ErrorBoundaryProps, 'children'>): {
863
- (props: P): react_jsx_runtime.JSX.Element;
864
- displayName: string;
865
- };
1200
+ /**
1201
+ * Type guard to check if an error is a WalletError
1202
+ */
1203
+ declare function isWalletError(error: unknown): error is WalletError;
1204
+ /**
1205
+ * Create a WalletError from a standard Error
1206
+ */
1207
+ declare function createWalletError(error: Error, type: WalletErrorType, recoverable: boolean, context?: Record<string, unknown>): WalletError;
866
1208
 
867
1209
  /**
868
1210
  * @solana/connector - Cluster utilities
@@ -1232,4 +1574,4 @@ declare const ready: Promise<void>;
1232
1574
  */
1233
1575
  declare function getWalletsRegistry(): WalletsRegistry;
1234
1576
 
1235
- export { type WalletConnectSignTransactionResult as $, type AccountInfo as A, type WalletName as B, ConnectorProvider as C, type DefaultConfigOptions as D, type ExtendedConnectorConfig as E, type AccountAddress as F, isWalletName as G, isAccountAddress as H, type CoinGeckoConfig as I, type ConnectorHealth as J, type ConnectorDebugMetrics as K, type ConnectorDebugState as L, type MobileWalletAdapterConfig as M, type Listener as N, type ConnectorEvent as O, type ConnectorEventListener as P, type StorageAdapter as Q, type StorageOptions as R, type SimplifiedWalletConnectConfig as S, type EnhancedStorageAccountOptions as T, type EnhancedStorageClusterOptions as U, type EnhancedStorageWalletOptions as V, type WalletInfo as W, type WalletConnectSolanaAccount as X, type WalletConnectSignMessageParams as Y, type WalletConnectSignMessageResult as Z, type WalletConnectSignTransactionParams as _, useConnectorClient as a, type WalletConnectSignAllTransactionsParams as a0, type WalletConnectSignAllTransactionsResult as a1, type WalletConnectSignAndSendTransactionParams as a2, type WalletConnectSignAndSendTransactionResult as a3, ClipboardErrorType as a4, type ClipboardResult as a5, type CopyOptions as a6, isClipboardAvailable as a7, copyToClipboard as a8, copyAddressToClipboard as a9, copySignatureToClipboard as aa, getClusterRpcUrl as ab, getClusterExplorerUrl as ac, getTransactionUrl as ad, getAddressUrl as ae, getTokenUrl as af, getBlockUrl as ag, isMainnetCluster as ah, isDevnetCluster as ai, isTestnetCluster as aj, isLocalCluster as ak, getClusterName as al, getClusterType as am, getClusterChainId as an, getChainIdForWalletStandard as ao, getDefaultMobileConfig as b, ConnectorErrorBoundary as c, type ConnectorSnapshot as d, type ConnectorConfig as e, type ConnectorState as f, getDefaultConfig as g, type WalletStandardWallet as h, type WalletStandardAccount as i, type ClusterType as j, ConnectorClient as k, getWalletsRegistry as l, WalletErrorType as m, type WalletError as n, getPublicSolanaRpcUrl as o, createSolanaClient as p, type SolanaClusterMoniker as q, ready as r, type ModifiedClusterUrl as s, type SolanaClient as t, useConnector as u, type CreateSolanaClientArgs as v, withErrorBoundary as w, type WalletConnectConfig as x, type WalletConnectMetadata as y, type WalletConnectTransport as z };
1577
+ export { type WalletConnectMetadata as $, type AccountInfo as A, isWalletStatusError as B, ConnectorProvider as C, type DefaultConfigOptions as D, type ExtendedConnectorConfig as E, toLegacyWalletState as F, type WalletConnector as G, type WalletStatusDisconnected as H, INITIAL_WALLET_STATUS as I, type WalletStatusConnecting as J, type WalletStatusConnected as K, type WalletStatusError as L, type MobileWalletAdapterConfig as M, WalletErrorType as N, isWalletError as O, createWalletError as P, type WalletError as Q, type RegisterMwaConfig as R, type SimplifiedWalletConnectConfig as S, getPublicSolanaRpcUrl as T, createSolanaClient as U, type SolanaClusterMoniker as V, type WalletInfo as W, type ModifiedClusterUrl as X, type SolanaClient as Y, type CreateSolanaClientArgs as Z, type WalletConnectConfig as _, useConnectorClient as a, type WalletConnectTransport as a0, type WalletName as a1, type AccountAddress as a2, isWalletName as a3, isAccountAddress as a4, type CoinGeckoConfig as a5, type ConnectorHealth as a6, type ConnectorDebugMetrics as a7, type ConnectorDebugState as a8, type Listener as a9, getClusterExplorerUrl as aA, getTransactionUrl as aB, getAddressUrl as aC, getTokenUrl as aD, getBlockUrl as aE, isMainnetCluster as aF, isDevnetCluster as aG, isTestnetCluster as aH, isLocalCluster as aI, getClusterName as aJ, getClusterType as aK, getClusterChainId as aL, getChainIdForWalletStandard as aM, type ConnectorEvent as aa, type ConnectorEventListener as ab, type StorageAdapter as ac, type StorageOptions as ad, type EnhancedStorageAccountOptions as ae, type EnhancedStorageClusterOptions as af, type EnhancedStorageWalletOptions as ag, type EnhancedStorageWalletStateOptions as ah, type PersistedWalletState as ai, type WalletConnectSolanaAccount as aj, type WalletConnectSignMessageParams as ak, type WalletConnectSignMessageResult as al, type WalletConnectSignTransactionParams as am, type WalletConnectSignTransactionResult as an, type WalletConnectSignAllTransactionsParams as ao, type WalletConnectSignAllTransactionsResult as ap, type WalletConnectSignAndSendTransactionParams as aq, type WalletConnectSignAndSendTransactionResult as ar, ClipboardErrorType as as, type ClipboardResult as at, type CopyOptions as au, isClipboardAvailable as av, copyToClipboard as aw, copyAddressToClipboard as ax, copySignatureToClipboard as ay, getClusterRpcUrl as az, getDefaultMobileConfig as b, type ConnectorSnapshot as c, type ConnectorConfig as d, type ConnectorState as e, type WalletStandardWallet as f, getDefaultConfig as g, type WalletStandardAccount as h, type WalletConnectorId as i, type WalletConnectorMetadata as j, type WalletSession as k, type WalletStatus as l, type SessionAccount as m, type ConnectOptions as n, createConnectorId as o, isWalletConnectorId as p, isConnected as q, isConnecting as r, isDisconnected as s, type ClusterType as t, useConnector as u, ConnectorClient as v, getWalletsRegistry as w, ready as x, getWalletNameFromConnectorId as y, isStatusError as z };