@solana/connector 0.1.0 → 0.1.2

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 (41) hide show
  1. package/dist/{chunk-52WUWW5R.mjs → chunk-4K6QY4HR.mjs} +60 -174
  2. package/dist/chunk-4K6QY4HR.mjs.map +1 -0
  3. package/dist/{chunk-7TADXRFD.mjs → chunk-F2QJH5ED.mjs} +3 -3
  4. package/dist/chunk-F2QJH5ED.mjs.map +1 -0
  5. package/dist/chunk-JS4KJ2KK.js +706 -0
  6. package/dist/chunk-JS4KJ2KK.js.map +1 -0
  7. package/dist/{chunk-ZLPQUOFK.js → chunk-RIBOPAOD.js} +61 -173
  8. package/dist/chunk-RIBOPAOD.js.map +1 -0
  9. package/dist/{chunk-SGAIPK7Q.js → chunk-SJEZHNYF.js} +11 -11
  10. package/dist/chunk-SJEZHNYF.js.map +1 -0
  11. package/dist/chunk-WXYUUCSD.mjs +635 -0
  12. package/dist/chunk-WXYUUCSD.mjs.map +1 -0
  13. package/dist/compat.d.mts +1 -60
  14. package/dist/compat.d.ts +1 -60
  15. package/dist/compat.js.map +1 -1
  16. package/dist/compat.mjs.map +1 -1
  17. package/dist/headless.d.mts +222 -107
  18. package/dist/headless.d.ts +222 -107
  19. package/dist/headless.js +201 -81
  20. package/dist/headless.mjs +2 -2
  21. package/dist/index.d.mts +7 -3
  22. package/dist/index.d.ts +7 -3
  23. package/dist/index.js +216 -96
  24. package/dist/index.mjs +3 -3
  25. package/dist/react.d.mts +5 -154
  26. package/dist/react.d.ts +5 -154
  27. package/dist/react.js +16 -16
  28. package/dist/react.mjs +2 -2
  29. package/dist/{transaction-signer-BtJPGXIg.d.ts → transaction-signer-D3csM_Mf.d.mts} +1 -175
  30. package/dist/{transaction-signer-BtJPGXIg.d.mts → transaction-signer-D3csM_Mf.d.ts} +1 -175
  31. package/dist/{wallet-standard-shim-BGlvGRbB.d.ts → wallet-standard-shim-C1tisl9S.d.ts} +5 -169
  32. package/dist/{wallet-standard-shim-Af7ejSld.d.mts → wallet-standard-shim-Cg0GVGwu.d.mts} +5 -169
  33. package/package.json +7 -1
  34. package/dist/chunk-52WUWW5R.mjs.map +0 -1
  35. package/dist/chunk-5NSUFMCB.js +0 -393
  36. package/dist/chunk-5NSUFMCB.js.map +0 -1
  37. package/dist/chunk-7TADXRFD.mjs.map +0 -1
  38. package/dist/chunk-ACFSCMUI.mjs +0 -359
  39. package/dist/chunk-ACFSCMUI.mjs.map +0 -1
  40. package/dist/chunk-SGAIPK7Q.js.map +0 -1
  41. package/dist/chunk-ZLPQUOFK.js.map +0 -1
@@ -99,85 +99,40 @@ interface TransactionActivity {
99
99
 
100
100
  /**
101
101
  * @solana/connector - Unified Error System
102
- *
103
- * Provides consistent, structured error handling across the entire library.
104
- * All errors extend ConnectorError and include:
105
- * - Error codes for programmatic handling
106
- * - Optional context data
107
- * - Original error preservation
108
- * - Stack trace capture
109
- */
110
- /**
111
- * Base error class for all Connector errors
112
- * Provides common structure and metadata
113
102
  */
114
103
  declare abstract class ConnectorError extends Error {
115
- /**
116
- * Error code for programmatic handling
117
- */
118
104
  abstract readonly code: string;
119
- /**
120
- * Whether this error is recoverable (user can retry)
121
- */
122
105
  abstract readonly recoverable: boolean;
123
- /**
124
- * Additional context about the error
125
- */
126
106
  readonly context?: Record<string, unknown>;
127
- /**
128
- * The underlying error that caused this error
129
- */
130
107
  readonly originalError?: Error;
131
- /**
132
- * Timestamp when error occurred
133
- */
134
108
  readonly timestamp: string;
135
109
  constructor(message: string, context?: Record<string, unknown>, originalError?: Error);
136
- /**
137
- * Get a JSON representation of the error
138
- */
139
110
  toJSON(): Record<string, unknown>;
140
111
  }
141
- /**
142
- * Connection-related errors (wallet connection, disconnection)
143
- */
144
112
  declare class ConnectionError extends ConnectorError {
145
113
  readonly code: ConnectionErrorCode;
146
114
  readonly recoverable = true;
147
115
  constructor(code: ConnectionErrorCode, message: string, context?: Record<string, unknown>, originalError?: Error);
148
116
  }
149
117
  type ConnectionErrorCode = 'WALLET_NOT_CONNECTED' | 'WALLET_NOT_FOUND' | 'CONNECTION_FAILED' | 'CONNECTION_REJECTED' | 'DISCONNECTION_FAILED' | 'ACCOUNT_NOT_AVAILABLE' | 'RECONNECTION_FAILED';
150
- /**
151
- * Validation errors (invalid data, unsupported formats)
152
- */
153
118
  declare class ValidationError extends ConnectorError {
154
119
  readonly code: ValidationErrorCode;
155
120
  readonly recoverable = false;
156
121
  constructor(code: ValidationErrorCode, message: string, context?: Record<string, unknown>, originalError?: Error);
157
122
  }
158
123
  type ValidationErrorCode = 'INVALID_TRANSACTION' | 'INVALID_MESSAGE' | 'INVALID_ADDRESS' | 'INVALID_SIGNATURE' | 'INVALID_FORMAT' | 'UNSUPPORTED_FORMAT' | 'VALIDATION_FAILED';
159
- /**
160
- * Configuration errors (setup issues, missing required options)
161
- */
162
124
  declare class ConfigurationError extends ConnectorError {
163
125
  readonly code: ConfigurationErrorCode;
164
126
  readonly recoverable = false;
165
127
  constructor(code: ConfigurationErrorCode, message: string, context?: Record<string, unknown>, originalError?: Error);
166
128
  }
167
129
  type ConfigurationErrorCode = 'MISSING_PROVIDER' | 'INVALID_CLUSTER' | 'CLUSTER_NOT_FOUND' | 'INVALID_CONFIG' | 'INITIALIZATION_FAILED';
168
- /**
169
- * Network errors (RPC failures, timeout)
170
- */
171
130
  declare class NetworkError extends ConnectorError {
172
131
  readonly code: NetworkErrorCode;
173
132
  readonly recoverable = true;
174
133
  constructor(code: NetworkErrorCode, message: string, context?: Record<string, unknown>, originalError?: Error);
175
134
  }
176
135
  type NetworkErrorCode = 'RPC_ERROR' | 'NETWORK_TIMEOUT' | 'NETWORK_UNAVAILABLE' | 'TRANSACTION_SIMULATION_FAILED';
177
- /**
178
- * Transaction errors (signing, sending transactions)
179
- * Extends the existing TransactionSignerError pattern
180
- */
181
136
  declare class TransactionError extends ConnectorError {
182
137
  readonly code: TransactionErrorCode;
183
138
  readonly recoverable: boolean;
@@ -206,167 +161,38 @@ declare const Errors: {
206
161
  readonly featureNotSupported: (feature: string) => TransactionError;
207
162
  readonly userRejected: (operation: string) => TransactionError;
208
163
  };
209
- /**
210
- * Convert any error to a ConnectorError
211
- * Useful for wrapping unknown errors in a structured format
212
- */
213
164
  declare function toConnectorError(error: unknown, defaultMessage?: string): ConnectorError;
214
- /**
215
- * Get user-friendly error message
216
- * Converts technical errors into messages suitable for display
217
- */
218
165
  declare function getUserFriendlyMessage(error: unknown): string;
219
166
 
220
167
  /**
221
- * @solana/connector - Transaction Signing Abstraction Layer
222
- *
223
- * Provides a clean, unified interface for transaction operations that works
224
- * across both Wallet Standard and legacy wallet implementations.
225
- *
226
- * Inspired by wallet-adapter-compat's transaction signer pattern, this
227
- * abstraction layer makes it easy to integrate with transaction libraries
228
- * and provides consistent error handling and capability detection.
168
+ * Transaction signing abstraction layer
229
169
  */
230
170
 
231
- /**
232
- * Unified transaction signer interface
233
- *
234
- * This interface abstracts wallet-specific transaction signing methods
235
- * into a consistent API that works across all Wallet Standard wallets.
236
- *
237
- * @example
238
- * ```ts
239
- * const signer = createTransactionSigner({
240
- * wallet: connectedWallet,
241
- * account: selectedAccount,
242
- * cluster: currentCluster
243
- * })
244
- *
245
- * // Check capabilities before using
246
- * const caps = signer.getCapabilities()
247
- * if (!caps.canSend) {
248
- * console.warn('Wallet cannot send transactions directly')
249
- * }
250
- *
251
- * // Sign and send a transaction
252
- * const signature = await signer.signAndSendTransaction(transaction)
253
- * console.log('Transaction sent:', signature)
254
- * ```
255
- */
256
171
  interface TransactionSigner {
257
172
  /** The wallet address that will sign transactions */
258
173
  readonly address: string;
259
- /**
260
- * Sign a single transaction without sending it
261
- * The wallet prompts the user to approve the transaction
262
- *
263
- * @param transaction - The transaction to sign
264
- * @returns The signed transaction
265
- * @throws {TransactionSignerError} If wallet doesn't support signing or user rejects
266
- */
267
174
  signTransaction(transaction: SolanaTransaction): Promise<SolanaTransaction>;
268
- /**
269
- * Sign multiple transactions at once
270
- * More efficient than signing one-by-one for batch operations
271
- * Falls back to sequential signing if batch not supported
272
- *
273
- * @param transactions - Array of transactions to sign
274
- * @returns Array of signed transactions in the same order
275
- * @throws {TransactionSignerError} If signing fails for any transaction
276
- */
277
175
  signAllTransactions(transactions: SolanaTransaction[]): Promise<SolanaTransaction[]>;
278
- /**
279
- * Sign and send a transaction in one operation
280
- * The wallet handles both signing and broadcasting to the network
281
- *
282
- * @param transaction - The transaction to sign and send
283
- * @param options - Optional send options (e.g., skipPreflight)
284
- * @returns The transaction signature/hash
285
- * @throws {TransactionSignerError} If sending fails or user rejects
286
- */
287
176
  signAndSendTransaction(transaction: SolanaTransaction, options?: {
288
177
  skipPreflight?: boolean;
289
178
  maxRetries?: number;
290
179
  }): Promise<string>;
291
- /**
292
- * Sign and send multiple transactions sequentially
293
- * Waits for each transaction to be sent before sending the next
294
- *
295
- * @param transactions - Array of transactions to sign and send
296
- * @param options - Optional send options
297
- * @returns Array of transaction signatures in the same order
298
- * @throws {TransactionSignerError} If any transaction fails
299
- */
300
180
  signAndSendTransactions(transactions: SolanaTransaction[], options?: {
301
181
  skipPreflight?: boolean;
302
182
  maxRetries?: number;
303
183
  }): Promise<string[]>;
304
- /**
305
- * Sign an arbitrary message (for authentication, verification, etc.)
306
- * Optional: not all wallets support message signing
307
- *
308
- * @param message - The message to sign (as Uint8Array)
309
- * @returns The signature bytes
310
- * @throws {TransactionSignerError} If wallet doesn't support message signing
311
- */
312
184
  signMessage?(message: Uint8Array): Promise<Uint8Array>;
313
- /**
314
- * Get the signer's capabilities
315
- * Use this to conditionally enable/disable features in your UI
316
- *
317
- * @returns Object describing what this signer can do
318
- */
319
185
  getCapabilities(): TransactionSignerCapabilities;
320
186
  }
321
- /**
322
- * Create a transaction signer from a Wallet Standard wallet
323
- *
324
- * This factory function creates a TransactionSigner instance that bridges
325
- * Wallet Standard features to a clean, consistent API.
326
- *
327
- * @param config - Configuration including wallet, account, and optional cluster
328
- * @returns TransactionSigner instance, or null if wallet/account invalid
329
- *
330
- * @example
331
- * ```ts
332
- * // Basic usage
333
- * const signer = createTransactionSigner({
334
- * wallet: connectedWallet,
335
- * account: selectedAccount
336
- * })
337
- *
338
- * if (!signer) {
339
- * console.error('Failed to create signer - wallet or account missing')
340
- * return
341
- * }
342
- *
343
- * // Use the signer
344
- * try {
345
- * const sig = await signer.signAndSendTransaction(tx)
346
- * console.log('Success:', sig)
347
- * } catch (error) {
348
- * if (error instanceof TransactionSignerError) {
349
- * console.error('Signing error:', error.code, error.message)
350
- * }
351
- * }
352
- * ```
353
- */
354
187
  declare function createTransactionSigner(config: TransactionSignerConfig): TransactionSigner | null;
355
188
  /**
356
189
  * @deprecated Use TransactionError from '../errors' instead
357
- * Kept for backward compatibility
358
- *
359
- * Custom error class for transaction signer operations
360
- * Provides structured error information for better error handling
361
190
  */
362
191
  declare class TransactionSignerError extends TransactionError {
363
192
  constructor(message: string, code: 'WALLET_NOT_CONNECTED' | 'FEATURE_NOT_SUPPORTED' | 'SIGNING_FAILED' | 'SEND_FAILED', originalError?: Error);
364
193
  }
365
194
  /**
366
195
  * @deprecated Use isTransactionError from '../errors' instead
367
- * Kept for backward compatibility
368
- *
369
- * Type guard to check if an error is a TransactionSignerError
370
196
  */
371
197
  declare function isTransactionSignerError(error: unknown): error is TransactionSignerError;
372
198
 
@@ -99,85 +99,40 @@ interface TransactionActivity {
99
99
 
100
100
  /**
101
101
  * @solana/connector - Unified Error System
102
- *
103
- * Provides consistent, structured error handling across the entire library.
104
- * All errors extend ConnectorError and include:
105
- * - Error codes for programmatic handling
106
- * - Optional context data
107
- * - Original error preservation
108
- * - Stack trace capture
109
- */
110
- /**
111
- * Base error class for all Connector errors
112
- * Provides common structure and metadata
113
102
  */
114
103
  declare abstract class ConnectorError extends Error {
115
- /**
116
- * Error code for programmatic handling
117
- */
118
104
  abstract readonly code: string;
119
- /**
120
- * Whether this error is recoverable (user can retry)
121
- */
122
105
  abstract readonly recoverable: boolean;
123
- /**
124
- * Additional context about the error
125
- */
126
106
  readonly context?: Record<string, unknown>;
127
- /**
128
- * The underlying error that caused this error
129
- */
130
107
  readonly originalError?: Error;
131
- /**
132
- * Timestamp when error occurred
133
- */
134
108
  readonly timestamp: string;
135
109
  constructor(message: string, context?: Record<string, unknown>, originalError?: Error);
136
- /**
137
- * Get a JSON representation of the error
138
- */
139
110
  toJSON(): Record<string, unknown>;
140
111
  }
141
- /**
142
- * Connection-related errors (wallet connection, disconnection)
143
- */
144
112
  declare class ConnectionError extends ConnectorError {
145
113
  readonly code: ConnectionErrorCode;
146
114
  readonly recoverable = true;
147
115
  constructor(code: ConnectionErrorCode, message: string, context?: Record<string, unknown>, originalError?: Error);
148
116
  }
149
117
  type ConnectionErrorCode = 'WALLET_NOT_CONNECTED' | 'WALLET_NOT_FOUND' | 'CONNECTION_FAILED' | 'CONNECTION_REJECTED' | 'DISCONNECTION_FAILED' | 'ACCOUNT_NOT_AVAILABLE' | 'RECONNECTION_FAILED';
150
- /**
151
- * Validation errors (invalid data, unsupported formats)
152
- */
153
118
  declare class ValidationError extends ConnectorError {
154
119
  readonly code: ValidationErrorCode;
155
120
  readonly recoverable = false;
156
121
  constructor(code: ValidationErrorCode, message: string, context?: Record<string, unknown>, originalError?: Error);
157
122
  }
158
123
  type ValidationErrorCode = 'INVALID_TRANSACTION' | 'INVALID_MESSAGE' | 'INVALID_ADDRESS' | 'INVALID_SIGNATURE' | 'INVALID_FORMAT' | 'UNSUPPORTED_FORMAT' | 'VALIDATION_FAILED';
159
- /**
160
- * Configuration errors (setup issues, missing required options)
161
- */
162
124
  declare class ConfigurationError extends ConnectorError {
163
125
  readonly code: ConfigurationErrorCode;
164
126
  readonly recoverable = false;
165
127
  constructor(code: ConfigurationErrorCode, message: string, context?: Record<string, unknown>, originalError?: Error);
166
128
  }
167
129
  type ConfigurationErrorCode = 'MISSING_PROVIDER' | 'INVALID_CLUSTER' | 'CLUSTER_NOT_FOUND' | 'INVALID_CONFIG' | 'INITIALIZATION_FAILED';
168
- /**
169
- * Network errors (RPC failures, timeout)
170
- */
171
130
  declare class NetworkError extends ConnectorError {
172
131
  readonly code: NetworkErrorCode;
173
132
  readonly recoverable = true;
174
133
  constructor(code: NetworkErrorCode, message: string, context?: Record<string, unknown>, originalError?: Error);
175
134
  }
176
135
  type NetworkErrorCode = 'RPC_ERROR' | 'NETWORK_TIMEOUT' | 'NETWORK_UNAVAILABLE' | 'TRANSACTION_SIMULATION_FAILED';
177
- /**
178
- * Transaction errors (signing, sending transactions)
179
- * Extends the existing TransactionSignerError pattern
180
- */
181
136
  declare class TransactionError extends ConnectorError {
182
137
  readonly code: TransactionErrorCode;
183
138
  readonly recoverable: boolean;
@@ -206,167 +161,38 @@ declare const Errors: {
206
161
  readonly featureNotSupported: (feature: string) => TransactionError;
207
162
  readonly userRejected: (operation: string) => TransactionError;
208
163
  };
209
- /**
210
- * Convert any error to a ConnectorError
211
- * Useful for wrapping unknown errors in a structured format
212
- */
213
164
  declare function toConnectorError(error: unknown, defaultMessage?: string): ConnectorError;
214
- /**
215
- * Get user-friendly error message
216
- * Converts technical errors into messages suitable for display
217
- */
218
165
  declare function getUserFriendlyMessage(error: unknown): string;
219
166
 
220
167
  /**
221
- * @solana/connector - Transaction Signing Abstraction Layer
222
- *
223
- * Provides a clean, unified interface for transaction operations that works
224
- * across both Wallet Standard and legacy wallet implementations.
225
- *
226
- * Inspired by wallet-adapter-compat's transaction signer pattern, this
227
- * abstraction layer makes it easy to integrate with transaction libraries
228
- * and provides consistent error handling and capability detection.
168
+ * Transaction signing abstraction layer
229
169
  */
230
170
 
231
- /**
232
- * Unified transaction signer interface
233
- *
234
- * This interface abstracts wallet-specific transaction signing methods
235
- * into a consistent API that works across all Wallet Standard wallets.
236
- *
237
- * @example
238
- * ```ts
239
- * const signer = createTransactionSigner({
240
- * wallet: connectedWallet,
241
- * account: selectedAccount,
242
- * cluster: currentCluster
243
- * })
244
- *
245
- * // Check capabilities before using
246
- * const caps = signer.getCapabilities()
247
- * if (!caps.canSend) {
248
- * console.warn('Wallet cannot send transactions directly')
249
- * }
250
- *
251
- * // Sign and send a transaction
252
- * const signature = await signer.signAndSendTransaction(transaction)
253
- * console.log('Transaction sent:', signature)
254
- * ```
255
- */
256
171
  interface TransactionSigner {
257
172
  /** The wallet address that will sign transactions */
258
173
  readonly address: string;
259
- /**
260
- * Sign a single transaction without sending it
261
- * The wallet prompts the user to approve the transaction
262
- *
263
- * @param transaction - The transaction to sign
264
- * @returns The signed transaction
265
- * @throws {TransactionSignerError} If wallet doesn't support signing or user rejects
266
- */
267
174
  signTransaction(transaction: SolanaTransaction): Promise<SolanaTransaction>;
268
- /**
269
- * Sign multiple transactions at once
270
- * More efficient than signing one-by-one for batch operations
271
- * Falls back to sequential signing if batch not supported
272
- *
273
- * @param transactions - Array of transactions to sign
274
- * @returns Array of signed transactions in the same order
275
- * @throws {TransactionSignerError} If signing fails for any transaction
276
- */
277
175
  signAllTransactions(transactions: SolanaTransaction[]): Promise<SolanaTransaction[]>;
278
- /**
279
- * Sign and send a transaction in one operation
280
- * The wallet handles both signing and broadcasting to the network
281
- *
282
- * @param transaction - The transaction to sign and send
283
- * @param options - Optional send options (e.g., skipPreflight)
284
- * @returns The transaction signature/hash
285
- * @throws {TransactionSignerError} If sending fails or user rejects
286
- */
287
176
  signAndSendTransaction(transaction: SolanaTransaction, options?: {
288
177
  skipPreflight?: boolean;
289
178
  maxRetries?: number;
290
179
  }): Promise<string>;
291
- /**
292
- * Sign and send multiple transactions sequentially
293
- * Waits for each transaction to be sent before sending the next
294
- *
295
- * @param transactions - Array of transactions to sign and send
296
- * @param options - Optional send options
297
- * @returns Array of transaction signatures in the same order
298
- * @throws {TransactionSignerError} If any transaction fails
299
- */
300
180
  signAndSendTransactions(transactions: SolanaTransaction[], options?: {
301
181
  skipPreflight?: boolean;
302
182
  maxRetries?: number;
303
183
  }): Promise<string[]>;
304
- /**
305
- * Sign an arbitrary message (for authentication, verification, etc.)
306
- * Optional: not all wallets support message signing
307
- *
308
- * @param message - The message to sign (as Uint8Array)
309
- * @returns The signature bytes
310
- * @throws {TransactionSignerError} If wallet doesn't support message signing
311
- */
312
184
  signMessage?(message: Uint8Array): Promise<Uint8Array>;
313
- /**
314
- * Get the signer's capabilities
315
- * Use this to conditionally enable/disable features in your UI
316
- *
317
- * @returns Object describing what this signer can do
318
- */
319
185
  getCapabilities(): TransactionSignerCapabilities;
320
186
  }
321
- /**
322
- * Create a transaction signer from a Wallet Standard wallet
323
- *
324
- * This factory function creates a TransactionSigner instance that bridges
325
- * Wallet Standard features to a clean, consistent API.
326
- *
327
- * @param config - Configuration including wallet, account, and optional cluster
328
- * @returns TransactionSigner instance, or null if wallet/account invalid
329
- *
330
- * @example
331
- * ```ts
332
- * // Basic usage
333
- * const signer = createTransactionSigner({
334
- * wallet: connectedWallet,
335
- * account: selectedAccount
336
- * })
337
- *
338
- * if (!signer) {
339
- * console.error('Failed to create signer - wallet or account missing')
340
- * return
341
- * }
342
- *
343
- * // Use the signer
344
- * try {
345
- * const sig = await signer.signAndSendTransaction(tx)
346
- * console.log('Success:', sig)
347
- * } catch (error) {
348
- * if (error instanceof TransactionSignerError) {
349
- * console.error('Signing error:', error.code, error.message)
350
- * }
351
- * }
352
- * ```
353
- */
354
187
  declare function createTransactionSigner(config: TransactionSignerConfig): TransactionSigner | null;
355
188
  /**
356
189
  * @deprecated Use TransactionError from '../errors' instead
357
- * Kept for backward compatibility
358
- *
359
- * Custom error class for transaction signer operations
360
- * Provides structured error information for better error handling
361
190
  */
362
191
  declare class TransactionSignerError extends TransactionError {
363
192
  constructor(message: string, code: 'WALLET_NOT_CONNECTED' | 'FEATURE_NOT_SUPPORTED' | 'SIGNING_FAILED' | 'SEND_FAILED', originalError?: Error);
364
193
  }
365
194
  /**
366
195
  * @deprecated Use isTransactionError from '../errors' instead
367
- * Kept for backward compatibility
368
- *
369
- * Type guard to check if an error is a TransactionSignerError
370
196
  */
371
197
  declare function isTransactionSignerError(error: unknown): error is TransactionSignerError;
372
198