@solana/connector 0.0.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +1460 -0
  2. package/dist/chunk-52WUWW5R.mjs +2533 -0
  3. package/dist/chunk-52WUWW5R.mjs.map +1 -0
  4. package/dist/chunk-5NSUFMCB.js +393 -0
  5. package/dist/chunk-5NSUFMCB.js.map +1 -0
  6. package/dist/chunk-5ZUVZZWU.mjs +180 -0
  7. package/dist/chunk-5ZUVZZWU.mjs.map +1 -0
  8. package/dist/chunk-7TADXRFD.mjs +298 -0
  9. package/dist/chunk-7TADXRFD.mjs.map +1 -0
  10. package/dist/chunk-ACFSCMUI.mjs +359 -0
  11. package/dist/chunk-ACFSCMUI.mjs.map +1 -0
  12. package/dist/chunk-SGAIPK7Q.js +314 -0
  13. package/dist/chunk-SGAIPK7Q.js.map +1 -0
  14. package/dist/chunk-SMUUAKC3.js +186 -0
  15. package/dist/chunk-SMUUAKC3.js.map +1 -0
  16. package/dist/chunk-ZLPQUOFK.js +2594 -0
  17. package/dist/chunk-ZLPQUOFK.js.map +1 -0
  18. package/dist/compat.d.mts +106 -0
  19. package/dist/compat.d.ts +106 -0
  20. package/dist/compat.js +98 -0
  21. package/dist/compat.js.map +1 -0
  22. package/dist/compat.mjs +94 -0
  23. package/dist/compat.mjs.map +1 -0
  24. package/dist/headless.d.mts +400 -0
  25. package/dist/headless.d.ts +400 -0
  26. package/dist/headless.js +325 -0
  27. package/dist/headless.js.map +1 -0
  28. package/dist/headless.mjs +4 -0
  29. package/dist/headless.mjs.map +1 -0
  30. package/dist/index.d.mts +10 -0
  31. package/dist/index.d.ts +10 -0
  32. package/dist/index.js +382 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/index.mjs +5 -0
  35. package/dist/index.mjs.map +1 -0
  36. package/dist/react.d.mts +645 -0
  37. package/dist/react.d.ts +645 -0
  38. package/dist/react.js +65 -0
  39. package/dist/react.js.map +1 -0
  40. package/dist/react.mjs +4 -0
  41. package/dist/react.mjs.map +1 -0
  42. package/dist/transaction-signer-BtJPGXIg.d.mts +373 -0
  43. package/dist/transaction-signer-BtJPGXIg.d.ts +373 -0
  44. package/dist/wallet-standard-shim-Af7ejSld.d.mts +1090 -0
  45. package/dist/wallet-standard-shim-BGlvGRbB.d.ts +1090 -0
  46. package/package.json +87 -10
  47. package/index.js +0 -1
@@ -0,0 +1,400 @@
1
+ import { B as StorageOptions, S as StorageAdapter, F as EnhancedStorageAccountOptions, G as EnhancedStorageClusterOptions, H as EnhancedStorageWalletOptions } from './wallet-standard-shim-Af7ejSld.mjs';
2
+ export { q as AccountAddress, A as AccountInfo, K as ClipboardErrorType, N as ClipboardResult, i as ClusterType, j as ConnectorClient, d as ConnectorConfig, v as ConnectorDebugMetrics, x as ConnectorDebugState, y as ConnectorEvent, z as ConnectorEventListener, t as ConnectorHealth, e as ConnectorState, O as CopyOptions, D as DefaultConfigOptions, E as ExtendedConnectorConfig, L as Listener, M as MobileWalletAdapterConfig, a7 as PUBLIC_RPC_ENDPOINTS, a6 as SolanaNetwork, h as UnifiedConfig, U as UnifiedConfigOptions, J as WalletError, I as WalletErrorType, W as WalletInfo, p as WalletName, g as WalletStandardAccount, f as WalletStandardWallet, R as copyAddressToClipboard, T as copySignatureToClipboard, Q as copyToClipboard, n as createConfig, Z as getAddressUrl, $ as getBlockUrl, X as getClusterExplorerUrl, a4 as getClusterName, V as getClusterRpcUrl, a5 as getClusterType, l as getDefaultConfig, m as getDefaultMobileConfig, aa as getDefaultRpcUrl, af as getNetworkDisplayName, _ as getTokenUrl, Y as getTransactionUrl, k as getWalletsRegistry, s as isAccountAddress, P as isClipboardAvailable, ac as isDevnet, a1 as isDevnetCluster, a3 as isLocalCluster, ae as isLocalnet, ab as isMainnet, a0 as isMainnetCluster, ad as isTestnet, a2 as isTestnetCluster, o as isUnifiedConfig, r as isWalletName, a8 as normalizeNetwork, a9 as toClusterId } from './wallet-standard-shim-Af7ejSld.mjs';
3
+ import { j as TransactionSigner } from './transaction-signer-BtJPGXIg.mjs';
4
+ export { l as ConfigurationError, x as ConfigurationErrorCode, k as ConnectionError, v as ConnectionErrorCode, C as ConnectorError, E as Errors, N as NetworkError, y as NetworkErrorCode, a as SignedTransaction, S as SolanaTransaction, c as TransactionActivity, d as TransactionActivityStatus, m as TransactionError, z as TransactionErrorCode, f as TransactionMetadata, e as TransactionMethod, b as TransactionSignerCapabilities, T as TransactionSignerConfig, h as TransactionSignerError, V as ValidationError, w as ValidationErrorCode, g as createTransactionSigner, u as getUserFriendlyMessage, q as isConfigurationError, o as isConnectionError, n as isConnectorError, r as isNetworkError, s as isTransactionError, i as isTransactionSignerError, p as isValidationError, t as toConnectorError } from './transaction-signer-BtJPGXIg.mjs';
5
+ import { TransactionModifyingSigner } from 'gill';
6
+ import { Storage, SolanaClusterId } from '@wallet-ui/core';
7
+ export { SolanaCluster, SolanaClusterId, createSolanaDevnet, createSolanaLocalnet, createSolanaMainnet, createSolanaTestnet } from '@wallet-ui/core';
8
+ export { Wallet, WalletAccount } from '@wallet-standard/base';
9
+ import 'react';
10
+ import 'react/jsx-runtime';
11
+ import '@solana/web3.js';
12
+
13
+ /**
14
+ * @solana/connector - Formatting utilities
15
+ *
16
+ * Unified utility functions for formatting addresses, amounts, and other display values
17
+ * Consolidates both fast (number-based) and precise (bigint-based) formatting options
18
+ */
19
+ /**
20
+ * Format a Solana address for display
21
+ *
22
+ * @example
23
+ * formatAddress('7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU')
24
+ * // Returns: '7xKX...gAsU'
25
+ *
26
+ * @example
27
+ * formatAddress('7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU', { length: 6 })
28
+ * // Returns: '7xKXtg...osgAsU'
29
+ */
30
+ declare function formatAddress(address: string, options?: {
31
+ length?: number;
32
+ separator?: string;
33
+ }): string;
34
+ /**
35
+ * Format SOL amount for display
36
+ * Supports both precise bigint and fast number arithmetic
37
+ *
38
+ * @param lamports - Amount in lamports (number or bigint)
39
+ * @param options - Formatting options
40
+ * @param options.decimals - Number of decimal places (default: 4)
41
+ * @param options.suffix - Add 'SOL' suffix (default: true)
42
+ * @param options.fast - Use fast number arithmetic for amounts < 9000 SOL (default: false)
43
+ *
44
+ * @example
45
+ * formatSOL(1000000000n) // Returns: '1.0000 SOL' (precise)
46
+ * formatSOL(1000000000, { fast: true }) // Returns: '1.0000 SOL' (fast)
47
+ * formatSOL(1500000000, { decimals: 2 }) // Returns: '1.50 SOL'
48
+ */
49
+ declare function formatSOL(lamports: number | bigint, options?: {
50
+ decimals?: number;
51
+ suffix?: boolean;
52
+ fast?: boolean;
53
+ }): string;
54
+ /**
55
+ * Format a number with thousands separators
56
+ *
57
+ * @example
58
+ * formatNumber(1234567.89) // Returns: '1,234,567.89'
59
+ */
60
+ declare function formatNumber(value: number, options?: {
61
+ decimals?: number;
62
+ locale?: string;
63
+ }): string;
64
+ /**
65
+ * Truncate text with ellipsis
66
+ *
67
+ * @param text - Text to truncate
68
+ * @param maxLength - Maximum length including ellipsis
69
+ * @param position - Where to truncate: 'middle' or 'end' (default: 'middle')
70
+ *
71
+ * @example
72
+ * truncate('Hello World', 8) // Returns: 'He...ld'
73
+ * truncate('Hello World', 8, 'end') // Returns: 'Hello...'
74
+ * truncate('Short', 10) // Returns: 'Short' (no truncation needed)
75
+ */
76
+ declare function truncate(text: string, maxLength: number, position?: 'middle' | 'end'): string;
77
+ /**
78
+ * Format token amount with proper decimals
79
+ *
80
+ * @example
81
+ * formatTokenAmount(1000000, 6) // Returns: '1.000000'
82
+ */
83
+ declare function formatTokenAmount(amount: number | bigint, decimals: number, options?: {
84
+ minimumDecimals?: number;
85
+ maximumDecimals?: number;
86
+ }): string;
87
+
88
+ /**
89
+ * @solana/connector - Gill/Kit Transaction Signer Adapter
90
+ *
91
+ * Adapter that wraps connector-kit's TransactionSigner to be compatible with
92
+ * gill (@solana/kit) TransactionModifyingSigner interface.
93
+ *
94
+ * This enables connector-kit to work seamlessly with modern Solana libraries
95
+ * that expect @solana/kit's signer interface.
96
+ *
97
+ * Uses TransactionModifyingSigner to return fully signed Transaction objects,
98
+ * ensuring the exact bytes the wallet signed are preserved without re-encoding.
99
+ */
100
+
101
+ /**
102
+ * Create a gill-compatible TransactionPartialSigner from connector-kit's TransactionSigner
103
+ *
104
+ * This adapter allows connector-kit to work with modern Solana libraries that use
105
+ * @solana/kit's signer interfaces (gill, etc.)
106
+ *
107
+ * @param connectorSigner - Connector-kit's TransactionSigner instance
108
+ * @returns Gill-compatible TransactionPartialSigner
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * import { createTransactionSigner } from '@solana/connector';
113
+ * import { createGillTransactionSigner } from '@solana/connector/gill';
114
+ *
115
+ * const connectorSigner = createTransactionSigner({ wallet, account });
116
+ * const gillSigner = createGillTransactionSigner(connectorSigner);
117
+ *
118
+ * // Now compatible with gill libraries
119
+ * const instruction = getTransferSolInstruction({
120
+ * source: gillSigner,
121
+ * destination: address('...'),
122
+ * amount: 1000000n
123
+ * });
124
+ * ```
125
+ */
126
+ declare function createGillTransactionSigner<TAddress extends string = string>(connectorSigner: TransactionSigner): TransactionModifyingSigner<TAddress>;
127
+
128
+ /**
129
+ * @solana/connector - Enhanced Storage
130
+ *
131
+ * Extended version of @wallet-ui/core Storage with additional features:
132
+ * - Validation hooks
133
+ * - Error handling and recovery
134
+ * - SSR/memory fallback
135
+ * - Transform utilities
136
+ * - Migration support
137
+ * - Storage availability checks
138
+ */
139
+
140
+ /**
141
+ * Enhanced version of wallet-ui's Storage class
142
+ * Extends the base Storage with validation, error handling, and SSR support
143
+ */
144
+ declare class EnhancedStorage<T> extends Storage<T> {
145
+ private options?;
146
+ private errorHandlers;
147
+ private validators;
148
+ private memoryFallback;
149
+ constructor(key: string, initial: T, options?: StorageOptions<T> | undefined);
150
+ /**
151
+ * Enhanced set with validation and error handling
152
+ * @returns boolean indicating success
153
+ */
154
+ set(value: T): boolean;
155
+ /**
156
+ * Enhanced get with error handling and fallback
157
+ */
158
+ get(): T;
159
+ /**
160
+ * Validate a value against all registered validators
161
+ */
162
+ validate(value: T): boolean;
163
+ /**
164
+ * Add a validation rule (chainable)
165
+ *
166
+ * @example
167
+ * ```ts
168
+ * storage
169
+ * .addValidator((addr) => addr?.length === 44)
170
+ * .addValidator((addr) => addr?.startsWith('5'))
171
+ * ```
172
+ */
173
+ addValidator(validator: (value: T) => boolean): this;
174
+ /**
175
+ * Add error handler (chainable)
176
+ */
177
+ onError(handler: (error: Error) => void): this;
178
+ /**
179
+ * Transform the stored value
180
+ *
181
+ * @example
182
+ * ```ts
183
+ * const formatted = storage.transform(
184
+ * (address) => address ? formatAddress(address) : ''
185
+ * )
186
+ * ```
187
+ */
188
+ transform<U>(transformer: (value: T) => U): U;
189
+ /**
190
+ * Reset to initial value
191
+ */
192
+ reset(): void;
193
+ /**
194
+ * Clear storage (remove from localStorage)
195
+ */
196
+ clear(): void;
197
+ /**
198
+ * Check if storage is available (not in private mode, quota not exceeded)
199
+ */
200
+ isAvailable(): boolean;
201
+ /**
202
+ * Migrate from old key to new key
203
+ *
204
+ * @example
205
+ * ```ts
206
+ * EnhancedStorage.migrate(
207
+ * 'old-connector:account',
208
+ * createEnhancedStorageAccount()
209
+ * )
210
+ * ```
211
+ */
212
+ static migrate<T>(oldKey: string, newStorage: EnhancedStorage<T>): boolean;
213
+ private handleError;
214
+ }
215
+ /**
216
+ * Create a storage instance for wallet account persistence
217
+ *
218
+ * @example
219
+ * ```ts
220
+ * const storage = createEnhancedStorageAccount({
221
+ * validator: (address) => {
222
+ * if (!address) return true
223
+ * return isAddress(address)
224
+ * }
225
+ * })
226
+ * ```
227
+ */
228
+ declare function createEnhancedStorageAccount(options?: EnhancedStorageAccountOptions): EnhancedStorage<string | undefined>;
229
+ /**
230
+ * Create a storage instance for cluster selection persistence
231
+ *
232
+ * @example
233
+ * ```ts
234
+ * const storage = createEnhancedStorageCluster({
235
+ * initial: 'solana:mainnet',
236
+ * validClusters: ['solana:mainnet', 'solana:devnet']
237
+ * })
238
+ * ```
239
+ */
240
+ declare function createEnhancedStorageCluster(options?: EnhancedStorageClusterOptions): EnhancedStorage<SolanaClusterId>;
241
+ /**
242
+ * Create a storage instance for wallet name persistence
243
+ *
244
+ * @example
245
+ * ```ts
246
+ * const storage = createEnhancedStorageWallet({
247
+ * onError: (error) => console.error('Wallet storage error:', error)
248
+ * })
249
+ * ```
250
+ */
251
+ declare function createEnhancedStorageWallet(options?: EnhancedStorageWalletOptions): EnhancedStorage<string | undefined>;
252
+ /**
253
+ * Adapter to make EnhancedStorage compatible with StorageAdapter interface
254
+ * Exposes both the basic interface and enhanced methods for advanced usage
255
+ */
256
+ declare class EnhancedStorageAdapter<T> implements StorageAdapter<T> {
257
+ private storage;
258
+ constructor(storage: EnhancedStorage<T>);
259
+ get(): T;
260
+ set(value: T): void;
261
+ subscribe(callback: (value: T) => void): () => void;
262
+ validate(value: T): boolean;
263
+ reset(): void;
264
+ clear(): void;
265
+ isAvailable(): boolean;
266
+ transform<U>(transformer: (value: T) => U): U;
267
+ addValidator(validator: (value: T) => boolean): this;
268
+ onError(handler: (error: Error) => void): this;
269
+ }
270
+
271
+ /**
272
+ * @solana/connector - Browser Compatibility Polyfills
273
+ *
274
+ * Ensures connector works across all browser environments including:
275
+ * - Mobile browsers (iOS Safari, Chrome Mobile, etc.)
276
+ * - Older desktop browsers
277
+ * - Environments with restricted crypto APIs
278
+ *
279
+ * Inspired by wallet-adapter-compat's polyfill strategy
280
+ */
281
+ /**
282
+ * Install browser compatibility polyfills
283
+ *
284
+ * This function:
285
+ * - Installs WebCrypto Ed25519 polyfill for signature operations
286
+ * - Is safe to call multiple times (idempotent)
287
+ * - Only runs in browser environments
288
+ * - Fails gracefully if installation errors occur
289
+ *
290
+ * @example
291
+ * ```ts
292
+ * // Automatically called when connector-provider is imported
293
+ * import { ConnectorProvider } from '@solana/connector'
294
+ *
295
+ * // Can also be called manually if needed
296
+ * import { installPolyfills } from '@solana/connector/headless'
297
+ * installPolyfills()
298
+ * ```
299
+ */
300
+ declare function installPolyfills(): void;
301
+ /**
302
+ * Check if polyfills have been installed
303
+ * Useful for debugging and health checks
304
+ *
305
+ * @returns True if polyfills are installed, false otherwise
306
+ *
307
+ * @example
308
+ * ```ts
309
+ * import { isPolyfillInstalled } from '@solana/connector/headless'
310
+ *
311
+ * if (!isPolyfillInstalled()) {
312
+ * console.warn('Polyfills not installed - may have issues on older browsers')
313
+ * }
314
+ * ```
315
+ */
316
+ declare function isPolyfillInstalled(): boolean;
317
+ /**
318
+ * Check if WebCrypto API is available
319
+ * Useful for detecting environments with restricted crypto capabilities
320
+ *
321
+ * @returns True if crypto.subtle is available, false otherwise
322
+ *
323
+ * @example
324
+ * ```ts
325
+ * import { isCryptoAvailable } from '@solana/connector/headless'
326
+ *
327
+ * if (!isCryptoAvailable()) {
328
+ * // Show warning to user about unsupported browser
329
+ * }
330
+ * ```
331
+ */
332
+ declare function isCryptoAvailable(): boolean;
333
+ /**
334
+ * Get polyfill status information
335
+ * Returns detailed information about polyfill and crypto availability
336
+ *
337
+ * @returns Object with polyfill status details
338
+ *
339
+ * @example
340
+ * ```ts
341
+ * import { getPolyfillStatus } from '@solana/connector/headless'
342
+ *
343
+ * const status = getPolyfillStatus()
344
+ * console.log('Polyfills:', status.installed ? 'installed' : 'not installed')
345
+ * console.log('WebCrypto:', status.cryptoAvailable ? 'available' : 'unavailable')
346
+ * ```
347
+ */
348
+ declare function getPolyfillStatus(): {
349
+ installed: boolean;
350
+ cryptoAvailable: boolean;
351
+ environment: 'browser' | 'server';
352
+ };
353
+
354
+ /**
355
+ * @solana/connector - Explorer URL Utilities
356
+ *
357
+ * Generate URLs for various Solana block explorers to view transactions,
358
+ * accounts, and other on-chain data.
359
+ */
360
+ type ExplorerType = 'solana-explorer' | 'solscan' | 'xray' | 'solana-fm';
361
+ interface ExplorerOptions {
362
+ /** Cluster to use for the explorer link */
363
+ cluster?: string;
364
+ /** Custom RPC URL for localnet */
365
+ customUrl?: string;
366
+ }
367
+ /**
368
+ * Generate Solana Explorer URL for a transaction signature
369
+ */
370
+ declare function getSolanaExplorerUrl(signature: string, options?: ExplorerOptions): string;
371
+ /**
372
+ * Generate Solscan URL for a transaction signature
373
+ */
374
+ declare function getSolscanUrl(signature: string, options?: ExplorerOptions): string;
375
+ /**
376
+ * Generate XRAY (Helius) URL for a transaction signature
377
+ * Note: XRAY works best with mainnet transactions
378
+ */
379
+ declare function getXrayUrl(signature: string): string;
380
+ /**
381
+ * Generate SolanaFM URL for a transaction signature
382
+ */
383
+ declare function getSolanaFmUrl(signature: string, options?: ExplorerOptions): string;
384
+ /**
385
+ * Get all explorer URLs for a transaction
386
+ */
387
+ declare function getAllExplorerUrls(signature: string, options?: ExplorerOptions): Record<ExplorerType, string>;
388
+ /**
389
+ * Format a transaction signature for display (truncated)
390
+ */
391
+ declare function formatSignature(signature: string, chars?: number): string;
392
+ /**
393
+ * Copy signature to clipboard with enhanced error handling
394
+ *
395
+ * @deprecated Use copySignatureToClipboard from utils/clipboard instead
396
+ * This is maintained for backwards compatibility but will be removed in a future version
397
+ */
398
+ declare function copySignature(signature: string): Promise<boolean>;
399
+
400
+ export { EnhancedStorage, EnhancedStorageAccountOptions, EnhancedStorageAdapter, EnhancedStorageClusterOptions, EnhancedStorageWalletOptions, type ExplorerOptions, type ExplorerType, StorageAdapter, StorageOptions, TransactionSigner, copySignature, createEnhancedStorageAccount, createEnhancedStorageCluster, createEnhancedStorageWallet, createGillTransactionSigner, formatAddress, formatNumber, formatSOL, formatSignature, formatTokenAmount, getAllExplorerUrls, getPolyfillStatus, getSolanaExplorerUrl, getSolanaFmUrl, getSolscanUrl, getXrayUrl, installPolyfills, isCryptoAvailable, isPolyfillInstalled, truncate };