@solana/connector 0.1.9 → 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 (62) hide show
  1. package/README.md +403 -50
  2. package/dist/chunk-4KD6HQQG.js +69 -0
  3. package/dist/chunk-4KD6HQQG.js.map +1 -0
  4. package/dist/chunk-BJAVJQLK.js +230 -0
  5. package/dist/chunk-BJAVJQLK.js.map +1 -0
  6. package/dist/{chunk-5HRJKCIL.js → chunk-BZ2VBJCZ.js} +1061 -424
  7. package/dist/chunk-BZ2VBJCZ.js.map +1 -0
  8. package/dist/{chunk-WDXEP4AJ.js → chunk-EM4KNOKG.js} +658 -190
  9. package/dist/chunk-EM4KNOKG.js.map +1 -0
  10. package/dist/chunk-HN5AJF7F.js +507 -0
  11. package/dist/chunk-HN5AJF7F.js.map +1 -0
  12. package/dist/chunk-HO6QNKFM.mjs +61 -0
  13. package/dist/chunk-HO6QNKFM.mjs.map +1 -0
  14. package/dist/chunk-HPQ5T32K.mjs +178 -0
  15. package/dist/chunk-HPQ5T32K.mjs.map +1 -0
  16. package/dist/{chunk-MAXA3HEP.mjs → chunk-IDTUFDNB.mjs} +962 -344
  17. package/dist/chunk-IDTUFDNB.mjs.map +1 -0
  18. package/dist/{chunk-P5LXUDP6.mjs → chunk-RTXUS5KG.mjs} +579 -119
  19. package/dist/chunk-RTXUS5KG.mjs.map +1 -0
  20. package/dist/{chunk-DSUCH44G.js → chunk-SITQ4JWM.js} +23 -67
  21. package/dist/chunk-SITQ4JWM.js.map +1 -0
  22. package/dist/chunk-UCISIAOG.mjs +501 -0
  23. package/dist/chunk-UCISIAOG.mjs.map +1 -0
  24. package/dist/{chunk-J7DHGLW6.mjs → chunk-ZZTY3O4N.mjs} +21 -61
  25. package/dist/chunk-ZZTY3O4N.mjs.map +1 -0
  26. package/dist/compat.d.mts +1 -1
  27. package/dist/compat.d.ts +1 -1
  28. package/dist/compat.js +10 -9
  29. package/dist/compat.js.map +1 -1
  30. package/dist/compat.mjs +2 -1
  31. package/dist/compat.mjs.map +1 -1
  32. package/dist/headless.d.mts +239 -104
  33. package/dist/headless.d.ts +239 -104
  34. package/dist/headless.js +255 -169
  35. package/dist/headless.mjs +5 -3
  36. package/dist/index.d.mts +4 -4
  37. package/dist/index.d.ts +4 -4
  38. package/dist/index.js +316 -206
  39. package/dist/index.mjs +6 -4
  40. package/dist/react.d.mts +299 -9
  41. package/dist/react.d.ts +299 -9
  42. package/dist/react.js +90 -38
  43. package/dist/react.mjs +2 -2
  44. package/dist/{standard-shim-CT49DM5l.d.mts → standard-shim-CGB88PPO.d.mts} +673 -52
  45. package/dist/{standard-shim-D9guL5fz.d.ts → standard-shim-tmnQelaJ.d.ts} +673 -52
  46. package/dist/{transaction-signer-T-KVQFi8.d.mts → transaction-signer-7NaYmP5w.d.mts} +1 -0
  47. package/dist/{transaction-signer-T-KVQFi8.d.ts → transaction-signer-7NaYmP5w.d.ts} +1 -0
  48. package/dist/walletconnect-447EY3OJ.js +28 -0
  49. package/dist/walletconnect-447EY3OJ.js.map +1 -0
  50. package/dist/walletconnect-U455PO4I.mjs +3 -0
  51. package/dist/walletconnect-U455PO4I.mjs.map +1 -0
  52. package/package.json +6 -2
  53. package/dist/chunk-5HRJKCIL.js.map +0 -1
  54. package/dist/chunk-DSUCH44G.js.map +0 -1
  55. package/dist/chunk-I6TJLYNA.js +0 -535
  56. package/dist/chunk-I6TJLYNA.js.map +0 -1
  57. package/dist/chunk-J7DHGLW6.mjs.map +0 -1
  58. package/dist/chunk-JOBLG62A.mjs +0 -476
  59. package/dist/chunk-JOBLG62A.mjs.map +0 -1
  60. package/dist/chunk-MAXA3HEP.mjs.map +0 -1
  61. package/dist/chunk-P5LXUDP6.mjs.map +0 -1
  62. package/dist/chunk-WDXEP4AJ.js.map +0 -1
@@ -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.js';
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.js';
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
@@ -117,6 +141,429 @@ interface AccountInfo {
117
141
  raw: WalletAccount;
118
142
  }
119
143
 
144
+ /**
145
+ * WalletConnect configuration types
146
+ *
147
+ * Types for configuring WalletConnect integration with the connector.
148
+ * WalletConnect uses Solana JSON-RPC methods as documented at:
149
+ * https://docs.walletconnect.network/wallet-sdk/chain-support/solana
150
+ */
151
+ /**
152
+ * WalletConnect app metadata
153
+ * Required for session establishment with mobile/desktop wallets
154
+ */
155
+ interface WalletConnectMetadata {
156
+ /** Application name displayed to the user in the wallet */
157
+ name: string;
158
+ /** Brief description of the application */
159
+ description: string;
160
+ /** Application URL (used for verification) */
161
+ url: string;
162
+ /** Array of icon URLs for the application */
163
+ icons: string[];
164
+ }
165
+ /**
166
+ * Configuration for WalletConnect integration
167
+ *
168
+ * When enabled, ConnectorKit registers a virtual "WalletConnect" wallet
169
+ * into the Wallet Standard registry. This wallet proxies all signing
170
+ * operations through WalletConnect's Solana JSON-RPC methods.
171
+ *
172
+ * @example
173
+ * ```typescript
174
+ * const config = getDefaultConfig({
175
+ * appName: 'My App',
176
+ * walletConnect: {
177
+ * enabled: true,
178
+ * projectId: process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID!,
179
+ * metadata: {
180
+ * name: 'My App',
181
+ * description: 'My Solana Application',
182
+ * url: 'https://myapp.com',
183
+ * icons: ['https://myapp.com/icon.png'],
184
+ * },
185
+ * onDisplayUri: (uri) => {
186
+ * // Show QR code or deep link with this URI
187
+ * console.log('WalletConnect URI:', uri);
188
+ * },
189
+ * },
190
+ * });
191
+ * ```
192
+ */
193
+ interface WalletConnectConfig {
194
+ /**
195
+ * Enable WalletConnect integration.
196
+ * When true, a "WalletConnect" wallet is registered in the Wallet Standard registry.
197
+ * @default false
198
+ */
199
+ enabled?: boolean;
200
+ /**
201
+ * WalletConnect Cloud project ID.
202
+ * Get one at https://cloud.walletconnect.com/
203
+ */
204
+ projectId: string;
205
+ /**
206
+ * Application metadata shown to users during connection.
207
+ */
208
+ metadata: WalletConnectMetadata;
209
+ /**
210
+ * Default Solana chain/cluster for WalletConnect sessions.
211
+ * Used as fallback if getCurrentChain is not provided.
212
+ * Uses ConnectorKit's cluster ID format.
213
+ * @default 'solana:mainnet'
214
+ */
215
+ defaultChain?: 'solana:mainnet' | 'solana:devnet' | 'solana:testnet';
216
+ /**
217
+ * Callback to get the current chain/cluster dynamically.
218
+ * When provided, this is called before each request to determine the chain.
219
+ * This allows WalletConnect to follow the app's cluster selection.
220
+ *
221
+ * @returns The current chain ID (e.g., 'solana:mainnet', 'solana:devnet')
222
+ */
223
+ getCurrentChain?: () => 'solana:mainnet' | 'solana:devnet' | 'solana:testnet';
224
+ /**
225
+ * Callback invoked when WalletConnect needs to display a connection URI.
226
+ * The app should render this as a QR code or use it for deep linking.
227
+ *
228
+ * If not provided, the URI will be logged to console in development.
229
+ *
230
+ * @param uri - The WalletConnect pairing URI (starts with "wc:")
231
+ */
232
+ onDisplayUri?: (uri: string) => void;
233
+ /**
234
+ * Callback invoked when a WalletConnect session is established.
235
+ */
236
+ onSessionEstablished?: () => void;
237
+ /**
238
+ * Callback invoked when a WalletConnect session is disconnected.
239
+ */
240
+ onSessionDisconnected?: () => void;
241
+ /**
242
+ * Optional relay URL override.
243
+ * @default 'wss://relay.walletconnect.org'
244
+ */
245
+ relayUrl?: string;
246
+ }
247
+ /**
248
+ * Internal transport interface for WalletConnect provider
249
+ * Used by the shim wallet to communicate with WalletConnect
250
+ */
251
+ interface WalletConnectTransport {
252
+ /** Establish connection and create/restore session */
253
+ connect(): Promise<void>;
254
+ /** Disconnect the current session */
255
+ disconnect(): Promise<void>;
256
+ /** Send a JSON-RPC request to the connected wallet */
257
+ request<T = unknown>(args: {
258
+ method: string;
259
+ params: unknown;
260
+ chainId?: string;
261
+ }): Promise<T>;
262
+ /** Check if there's an active session */
263
+ isConnected(): boolean;
264
+ /** Get accounts from the current session namespaces (if available) */
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;
274
+ }
275
+ /**
276
+ * WalletConnect Solana account response
277
+ * Response format from solana_getAccounts and solana_requestAccounts
278
+ */
279
+ interface WalletConnectSolanaAccount {
280
+ /** Base58-encoded public key */
281
+ pubkey: string;
282
+ }
283
+ /**
284
+ * WalletConnect sign message params
285
+ * Parameters for solana_signMessage
286
+ */
287
+ interface WalletConnectSignMessageParams {
288
+ /** Base58-encoded message bytes */
289
+ message: string;
290
+ /** Base58-encoded public key of the signer */
291
+ pubkey: string;
292
+ }
293
+ /**
294
+ * WalletConnect sign message result
295
+ * Response from solana_signMessage
296
+ */
297
+ interface WalletConnectSignMessageResult {
298
+ /** Base58-encoded signature */
299
+ signature: string;
300
+ }
301
+ /**
302
+ * WalletConnect sign transaction params
303
+ * Parameters for solana_signTransaction
304
+ */
305
+ interface WalletConnectSignTransactionParams {
306
+ /** Base64-encoded serialized transaction */
307
+ transaction: string;
308
+ }
309
+ /**
310
+ * WalletConnect sign transaction result
311
+ * Response from solana_signTransaction
312
+ */
313
+ interface WalletConnectSignTransactionResult {
314
+ /** Base58-encoded signature */
315
+ signature: string;
316
+ /** Optional: Base64-encoded signed transaction (if wallet returns full tx) */
317
+ transaction?: string;
318
+ }
319
+ /**
320
+ * WalletConnect sign all transactions params
321
+ * Parameters for solana_signAllTransactions
322
+ */
323
+ interface WalletConnectSignAllTransactionsParams {
324
+ /** Array of Base64-encoded serialized transactions */
325
+ transactions: string[];
326
+ }
327
+ /**
328
+ * WalletConnect sign all transactions result
329
+ * Response from solana_signAllTransactions
330
+ */
331
+ interface WalletConnectSignAllTransactionsResult {
332
+ /** Array of Base64-encoded signed transactions */
333
+ transactions: string[];
334
+ }
335
+ /**
336
+ * WalletConnect sign and send transaction params
337
+ * Parameters for solana_signAndSendTransaction
338
+ */
339
+ interface WalletConnectSignAndSendTransactionParams {
340
+ /** Base64-encoded serialized transaction */
341
+ transaction: string;
342
+ /** Optional send options */
343
+ sendOptions?: {
344
+ skipPreflight?: boolean;
345
+ preflightCommitment?: 'processed' | 'confirmed' | 'finalized' | 'recent' | 'single' | 'singleGossip' | 'root' | 'max';
346
+ maxRetries?: number;
347
+ minContextSlot?: number;
348
+ };
349
+ }
350
+ /**
351
+ * WalletConnect sign and send transaction result
352
+ * Response from solana_signAndSendTransaction
353
+ */
354
+ interface WalletConnectSignAndSendTransactionResult {
355
+ /** Base58-encoded transaction signature (transaction ID) */
356
+ signature: string;
357
+ }
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
+
120
567
  /**
121
568
  * CoinGecko API configuration for price fetching.
122
569
  *
@@ -163,11 +610,46 @@ interface CoinGeckoConfig {
163
610
  * Core connector state
164
611
  */
165
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
+ */
166
633
  wallets: WalletInfo[];
634
+ /**
635
+ * @deprecated Use `state.wallet.status === 'connected' && state.wallet.session` instead.
636
+ */
167
637
  selectedWallet: Wallet | null;
638
+ /**
639
+ * @deprecated Use `state.wallet.status === 'connected'` instead.
640
+ */
168
641
  connected: boolean;
642
+ /**
643
+ * @deprecated Use `state.wallet.status === 'connecting'` instead.
644
+ */
169
645
  connecting: boolean;
646
+ /**
647
+ * @deprecated Use `state.wallet.status === 'connected' && state.wallet.session.accounts` instead.
648
+ */
170
649
  accounts: AccountInfo[];
650
+ /**
651
+ * @deprecated Use `state.wallet.status === 'connected' && state.wallet.session.selectedAccount.address` instead.
652
+ */
171
653
  selectedAccount: Address | null;
172
654
  cluster: SolanaCluster | null;
173
655
  clusters: SolanaCluster[];
@@ -212,6 +694,12 @@ interface ConnectorConfig {
212
694
  * Configure API key for higher rate limits and retry behavior for 429 responses.
213
695
  */
214
696
  coingecko?: CoinGeckoConfig;
697
+ /**
698
+ * WalletConnect configuration for connecting via QR code / deep link.
699
+ * When enabled, a "WalletConnect" wallet is registered in the Wallet Standard registry.
700
+ * @see https://docs.walletconnect.network/wallet-sdk/chain-support/solana
701
+ */
702
+ walletConnect?: WalletConnectConfig;
215
703
  }
216
704
  /**
217
705
  * Health check information for connector diagnostics
@@ -363,9 +851,38 @@ declare class ConnectorClient {
363
851
  private healthMonitor;
364
852
  private initialized;
365
853
  private config;
854
+ private walletConnectRegistration;
366
855
  constructor(config?: ConnectorConfig);
367
856
  private initialize;
857
+ /**
858
+ * Initialize WalletConnect integration
859
+ * Dynamically imports and registers the WalletConnect wallet
860
+ */
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
+ */
368
882
  select(walletName: string): Promise<void>;
883
+ /**
884
+ * @deprecated Use `disconnectWallet()` instead.
885
+ */
369
886
  disconnect(): Promise<void>;
370
887
  selectAccount(address: string): Promise<void>;
371
888
  setCluster(clusterId: SolanaClusterId): Promise<void>;
@@ -441,6 +958,62 @@ interface DefaultConfigOptions {
441
958
  * @see https://docs.coingecko.com/reference/introduction for rate limit details
442
959
  */
443
960
  coingecko?: CoinGeckoConfig;
961
+ /**
962
+ * WalletConnect configuration for connecting via QR code / deep link.
963
+ * When enabled, a "WalletConnect" wallet appears in the wallet list.
964
+ *
965
+ * Can be:
966
+ * - `true` to enable with auto-detected project ID from NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID env var
967
+ * - An object with optional overrides (projectId, metadata, etc.)
968
+ * - `undefined` or `false` to disable
969
+ *
970
+ * When using `true` or minimal config, the following are auto-configured:
971
+ * - `projectId`: Read from NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID
972
+ * - `metadata.name`: Uses appName
973
+ * - `metadata.url`: Uses appUrl or window.location.origin
974
+ * - `metadata.description`: Auto-generated from appName
975
+ * - `metadata.icons`: Uses appUrl/icon.svg
976
+ * - `getCurrentChain`: Auto-reads from cluster storage
977
+ * - `onDisplayUri/onSessionEstablished/onSessionDisconnected`: Auto-wired by AppProvider
978
+ *
979
+ * @example
980
+ * ```ts
981
+ * // Simplest - just enable it (reads project ID from env)
982
+ * getDefaultConfig({ appName: 'My App', walletConnect: true })
983
+ *
984
+ * // With explicit project ID
985
+ * getDefaultConfig({
986
+ * appName: 'My App',
987
+ * walletConnect: { projectId: 'my-project-id' }
988
+ * })
989
+ * ```
990
+ *
991
+ * @see https://docs.walletconnect.network/wallet-sdk/chain-support/solana
992
+ */
993
+ walletConnect?: boolean | SimplifiedWalletConnectConfig;
994
+ }
995
+ /**
996
+ * Simplified WalletConnect configuration
997
+ * Most fields are auto-generated from appName/appUrl if not provided
998
+ */
999
+ interface SimplifiedWalletConnectConfig {
1000
+ /**
1001
+ * WalletConnect Cloud project ID.
1002
+ * If not provided, reads from NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID env var.
1003
+ */
1004
+ projectId?: string;
1005
+ /**
1006
+ * Optional metadata overrides. Merged with auto-generated metadata.
1007
+ */
1008
+ metadata?: Partial<WalletConnectConfig['metadata']>;
1009
+ /**
1010
+ * Default chain. Defaults to 'solana:mainnet'.
1011
+ */
1012
+ defaultChain?: WalletConnectConfig['defaultChain'];
1013
+ /**
1014
+ * Optional relay URL override.
1015
+ */
1016
+ relayUrl?: string;
444
1017
  }
445
1018
  /** Extended ConnectorConfig with app metadata */
446
1019
  interface ExtendedConnectorConfig extends ConnectorConfig {
@@ -499,7 +1072,17 @@ declare function getDefaultMobileConfig(options: {
499
1072
  cluster: "devnet" | "mainnet" | "testnet" | "mainnet-beta";
500
1073
  };
501
1074
 
502
- /** 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
+ */
503
1086
  interface RegisterMwaConfig {
504
1087
  appIdentity: {
505
1088
  name: string;
@@ -512,28 +1095,70 @@ interface RegisterMwaConfig {
512
1095
  remoteHostAuthority?: string;
513
1096
  onWalletNotFound: (mobileWalletAdapter: SolanaMobileWalletAdapterWallet) => Promise<void>;
514
1097
  }
515
- declare global {
516
- interface Window {
517
- __connectorClient?: ConnectorClient;
518
- }
519
- }
520
- type ConnectorSnapshot = ReturnType<ConnectorClient['getSnapshot']> & {
521
- select: (walletName: string) => Promise<void>;
522
- disconnect: () => Promise<void>;
523
- selectAccount: (address: string) => Promise<void>;
524
- };
1098
+ /**
1099
+ * Configuration options for Mobile Wallet Adapter integration.
1100
+ * Used to configure mobile wallet support in ConnectorProvider.
1101
+ */
525
1102
  interface MobileWalletAdapterConfig {
1103
+ /** Application identity shown to users during authorization */
526
1104
  appIdentity: {
1105
+ /** Display name of the application */
527
1106
  name: string;
1107
+ /** URI of the application (optional) */
528
1108
  uri?: string;
1109
+ /** Icon URL of the application (optional) */
529
1110
  icon?: string;
530
1111
  };
1112
+ /** Remote host authority for remote connections (optional) */
531
1113
  remoteHostAuthority?: string;
1114
+ /** Solana chains to support (defaults to mainnet, devnet, testnet) */
532
1115
  chains?: RegisterMwaConfig['chains'];
1116
+ /** Authorization cache implementation (optional, uses default if not provided) */
533
1117
  authorizationCache?: AuthorizationCache;
1118
+ /** Chain selector implementation (optional, uses default if not provided) */
534
1119
  chainSelector?: ChainSelector;
1120
+ /** Handler called when wallet app is not found (optional, uses default if not provided) */
535
1121
  onWalletNotFound?: (wallet: SolanaMobileWalletAdapterWallet) => Promise<void>;
536
1122
  }
1123
+
1124
+ declare global {
1125
+ interface Window {
1126
+ __connectorClient?: ConnectorClient;
1127
+ }
1128
+ }
1129
+ type ConnectorSnapshot = ReturnType<ConnectorClient['getSnapshot']> & {
1130
+ /** @deprecated Use `connectWallet(connectorId)` instead */
1131
+ select: (walletName: string) => Promise<void>;
1132
+ /** @deprecated Use `disconnectWallet()` instead */
1133
+ disconnect: () => Promise<void>;
1134
+ selectAccount: (address: string) => Promise<void>;
1135
+ /** WalletConnect URI for QR code display (null when not connecting via WalletConnect) */
1136
+ walletConnectUri: string | null;
1137
+ /** Clear the WalletConnect URI (call when modal closes or connection completes) */
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;
1161
+ };
537
1162
  declare function ConnectorProvider({ children, config, mobile, }: {
538
1163
  children: ReactNode;
539
1164
  config?: ExtendedConnectorConfig;
@@ -542,48 +1167,44 @@ declare function ConnectorProvider({ children, config, mobile, }: {
542
1167
  declare function useConnector(): ConnectorSnapshot;
543
1168
  declare function useConnectorClient(): ConnectorClient | null;
544
1169
 
545
- declare enum WalletErrorType {
546
- CONNECTION_FAILED = "CONNECTION_FAILED",
547
- TRANSACTION_FAILED = "TRANSACTION_FAILED",
548
- NETWORK_ERROR = "NETWORK_ERROR",
549
- WALLET_NOT_FOUND = "WALLET_NOT_FOUND",
550
- USER_REJECTED = "USER_REJECTED",
551
- INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS",
552
- UNKNOWN_ERROR = "UNKNOWN_ERROR"
553
- }
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
+ */
554
1194
  interface WalletError extends Error {
555
1195
  type: WalletErrorType;
556
1196
  recoverable: boolean;
557
1197
  context?: Record<string, unknown>;
558
1198
  retryAction?: () => Promise<void>;
559
1199
  }
560
- interface ErrorBoundaryState {
561
- hasError: boolean;
562
- error: Error | null;
563
- errorInfo: ErrorInfo | null;
564
- errorId: string;
565
- retryCount: number;
566
- }
567
- interface ErrorBoundaryProps {
568
- children: ReactNode;
569
- fallback?: (error: WalletError, retry: () => void) => ReactNode;
570
- onError?: (error: Error, errorInfo: ErrorInfo) => void;
571
- maxRetries?: number;
572
- enableRecovery?: boolean;
573
- }
574
- declare class ConnectorErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
575
- private retryTimeouts;
576
- constructor(props: ErrorBoundaryProps);
577
- static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState>;
578
- componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
579
- componentWillUnmount(): void;
580
- retry: () => void;
581
- 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;
582
- }
583
- declare function withErrorBoundary<P extends object>(Component: React.ComponentType<P>, errorBoundaryProps?: Omit<ErrorBoundaryProps, 'children'>): {
584
- (props: P): react_jsx_runtime.JSX.Element;
585
- displayName: string;
586
- };
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;
587
1208
 
588
1209
  /**
589
1210
  * @solana/connector - Cluster utilities
@@ -953,4 +1574,4 @@ declare const ready: Promise<void>;
953
1574
  */
954
1575
  declare function getWalletsRegistry(): WalletsRegistry;
955
1576
 
956
- export { getClusterExplorerUrl as $, type AccountInfo as A, type CoinGeckoConfig as B, ConnectorProvider as C, type DefaultConfigOptions as D, type ExtendedConnectorConfig as E, type ConnectorHealth as F, type ConnectorDebugMetrics as G, type ConnectorDebugState as H, type ConnectorEvent as I, type ConnectorEventListener as J, type StorageAdapter as K, type Listener as L, type MobileWalletAdapterConfig as M, type StorageOptions as N, type EnhancedStorageAccountOptions as O, type EnhancedStorageClusterOptions as P, type EnhancedStorageWalletOptions as Q, ClipboardErrorType as R, type SolanaClusterMoniker as S, type ClipboardResult as T, type CopyOptions as U, isClipboardAvailable as V, type WalletInfo as W, copyToClipboard as X, copyAddressToClipboard as Y, copySignatureToClipboard as Z, getClusterRpcUrl as _, useConnectorClient as a, getTransactionUrl as a0, getAddressUrl as a1, getTokenUrl as a2, getBlockUrl as a3, isMainnetCluster as a4, isDevnetCluster as a5, isTestnetCluster as a6, isLocalCluster as a7, getClusterName as a8, getClusterType as a9, getClusterChainId as aa, getChainIdForWalletStandard as ab, ConnectorErrorBoundary as b, type ConnectorSnapshot as c, type ConnectorConfig as d, type ConnectorState as e, type WalletStandardWallet as f, type WalletStandardAccount as g, type ClusterType as h, ConnectorClient as i, getDefaultConfig as j, getDefaultMobileConfig as k, getWalletsRegistry as l, WalletErrorType as m, type WalletError as n, getPublicSolanaRpcUrl as o, createSolanaClient as p, type ModifiedClusterUrl as q, ready as r, type SolanaClient as s, type CreateSolanaClientArgs as t, useConnector as u, type WalletName as v, withErrorBoundary as w, type AccountAddress as x, isWalletName as y, isAccountAddress 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 };