@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.
- package/README.md +1460 -0
- package/dist/chunk-52WUWW5R.mjs +2533 -0
- package/dist/chunk-52WUWW5R.mjs.map +1 -0
- package/dist/chunk-5NSUFMCB.js +393 -0
- package/dist/chunk-5NSUFMCB.js.map +1 -0
- package/dist/chunk-5ZUVZZWU.mjs +180 -0
- package/dist/chunk-5ZUVZZWU.mjs.map +1 -0
- package/dist/chunk-7TADXRFD.mjs +298 -0
- package/dist/chunk-7TADXRFD.mjs.map +1 -0
- package/dist/chunk-ACFSCMUI.mjs +359 -0
- package/dist/chunk-ACFSCMUI.mjs.map +1 -0
- package/dist/chunk-SGAIPK7Q.js +314 -0
- package/dist/chunk-SGAIPK7Q.js.map +1 -0
- package/dist/chunk-SMUUAKC3.js +186 -0
- package/dist/chunk-SMUUAKC3.js.map +1 -0
- package/dist/chunk-ZLPQUOFK.js +2594 -0
- package/dist/chunk-ZLPQUOFK.js.map +1 -0
- package/dist/compat.d.mts +106 -0
- package/dist/compat.d.ts +106 -0
- package/dist/compat.js +98 -0
- package/dist/compat.js.map +1 -0
- package/dist/compat.mjs +94 -0
- package/dist/compat.mjs.map +1 -0
- package/dist/headless.d.mts +400 -0
- package/dist/headless.d.ts +400 -0
- package/dist/headless.js +325 -0
- package/dist/headless.js.map +1 -0
- package/dist/headless.mjs +4 -0
- package/dist/headless.mjs.map +1 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +382 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +5 -0
- package/dist/index.mjs.map +1 -0
- package/dist/react.d.mts +645 -0
- package/dist/react.d.ts +645 -0
- package/dist/react.js +65 -0
- package/dist/react.js.map +1 -0
- package/dist/react.mjs +4 -0
- package/dist/react.mjs.map +1 -0
- package/dist/transaction-signer-BtJPGXIg.d.mts +373 -0
- package/dist/transaction-signer-BtJPGXIg.d.ts +373 -0
- package/dist/wallet-standard-shim-Af7ejSld.d.mts +1090 -0
- package/dist/wallet-standard-shim-BGlvGRbB.d.ts +1090 -0
- package/package.json +87 -10
- package/index.js +0 -1
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import { DEFAULT_MAX_RETRIES, toClusterId, normalizeNetwork, getDefaultRpcUrl } from './chunk-52WUWW5R.mjs';
|
|
2
|
+
import { createLogger, __publicField } from './chunk-5ZUVZZWU.mjs';
|
|
3
|
+
import { Storage, createSolanaMainnet, createSolanaDevnet, createSolanaTestnet, createSolanaLocalnet } from '@wallet-ui/core';
|
|
4
|
+
export { createSolanaDevnet, createSolanaLocalnet, createSolanaMainnet, createSolanaTestnet } from '@wallet-ui/core';
|
|
5
|
+
import { isAddress, getExplorerLink } from 'gill';
|
|
6
|
+
|
|
7
|
+
var logger = createLogger("EnhancedStorage"), STORAGE_VERSION = "v1", EnhancedStorage = class extends Storage {
|
|
8
|
+
constructor(key, initial, options) {
|
|
9
|
+
super(key, initial);
|
|
10
|
+
this.options = options;
|
|
11
|
+
__publicField(this, "errorHandlers", /* @__PURE__ */ new Set());
|
|
12
|
+
__publicField(this, "validators", []);
|
|
13
|
+
__publicField(this, "memoryFallback");
|
|
14
|
+
this.memoryFallback = initial, options?.onError && this.errorHandlers.add(options.onError), options?.validator && this.validators.push(options.validator);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Enhanced set with validation and error handling
|
|
18
|
+
* @returns boolean indicating success
|
|
19
|
+
*/
|
|
20
|
+
set(value) {
|
|
21
|
+
try {
|
|
22
|
+
return this.validate(value) ? (super.set(value), this.memoryFallback = value, true) : (logger.warn("Validation failed", { key: this.key }), false);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
return this.handleError(error), this.options?.useMemoryFallback ? (this.memoryFallback = value, true) : false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Enhanced get with error handling and fallback
|
|
29
|
+
*/
|
|
30
|
+
get() {
|
|
31
|
+
try {
|
|
32
|
+
return super.get();
|
|
33
|
+
} catch (error) {
|
|
34
|
+
return this.handleError(error), this.options?.useMemoryFallback ? this.memoryFallback : this.initial;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Validate a value against all registered validators
|
|
39
|
+
*/
|
|
40
|
+
validate(value) {
|
|
41
|
+
return this.validators.every((validator) => validator(value));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Add a validation rule (chainable)
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* storage
|
|
49
|
+
* .addValidator((addr) => addr?.length === 44)
|
|
50
|
+
* .addValidator((addr) => addr?.startsWith('5'))
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
addValidator(validator) {
|
|
54
|
+
return this.validators.push(validator), this;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Add error handler (chainable)
|
|
58
|
+
*/
|
|
59
|
+
onError(handler) {
|
|
60
|
+
return this.errorHandlers.add(handler), this;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Transform the stored value
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* const formatted = storage.transform(
|
|
68
|
+
* (address) => address ? formatAddress(address) : ''
|
|
69
|
+
* )
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
transform(transformer) {
|
|
73
|
+
return transformer(this.get());
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Reset to initial value
|
|
77
|
+
*/
|
|
78
|
+
reset() {
|
|
79
|
+
this.set(this.initial);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Clear storage (remove from localStorage)
|
|
83
|
+
*/
|
|
84
|
+
clear() {
|
|
85
|
+
try {
|
|
86
|
+
typeof window < "u" && window.localStorage && window.localStorage.removeItem(this.key), this.reset();
|
|
87
|
+
} catch (error) {
|
|
88
|
+
this.handleError(error);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Check if storage is available (not in private mode, quota not exceeded)
|
|
93
|
+
*/
|
|
94
|
+
isAvailable() {
|
|
95
|
+
try {
|
|
96
|
+
if (typeof window > "u") return false;
|
|
97
|
+
let testKey = `__storage_test_${this.key}__`;
|
|
98
|
+
return window.localStorage.setItem(testKey, "test"), window.localStorage.removeItem(testKey), true;
|
|
99
|
+
} catch {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Migrate from old key to new key
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* EnhancedStorage.migrate(
|
|
109
|
+
* 'old-connector:account',
|
|
110
|
+
* createEnhancedStorageAccount()
|
|
111
|
+
* )
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
static migrate(oldKey, newStorage) {
|
|
115
|
+
try {
|
|
116
|
+
if (typeof window > "u") return false;
|
|
117
|
+
let oldValue = window.localStorage.getItem(oldKey);
|
|
118
|
+
if (oldValue) {
|
|
119
|
+
let parsed = JSON.parse(oldValue);
|
|
120
|
+
return newStorage.set(parsed), window.localStorage.removeItem(oldKey), true;
|
|
121
|
+
}
|
|
122
|
+
return false;
|
|
123
|
+
} catch {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
handleError(error) {
|
|
128
|
+
logger.error("Storage error", { key: this.key, error }), this.errorHandlers.forEach((handler) => {
|
|
129
|
+
try {
|
|
130
|
+
handler(error);
|
|
131
|
+
} catch (err) {
|
|
132
|
+
logger.error("Error in error handler", { error: err });
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
function createEnhancedStorageAccount(options) {
|
|
138
|
+
let key = options?.key ?? `connector-kit:${STORAGE_VERSION}:account`;
|
|
139
|
+
return new EnhancedStorage(key, options?.initial, {
|
|
140
|
+
validator: options?.validator,
|
|
141
|
+
onError: options?.onError,
|
|
142
|
+
useMemoryFallback: true
|
|
143
|
+
// Always fallback for SSR
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function createEnhancedStorageCluster(options) {
|
|
147
|
+
let key = options?.key ?? `connector-kit:${STORAGE_VERSION}:cluster`, storage = new EnhancedStorage(key, options?.initial ?? "solana:mainnet", {
|
|
148
|
+
onError: options?.onError,
|
|
149
|
+
useMemoryFallback: true
|
|
150
|
+
});
|
|
151
|
+
return options?.validClusters && storage.addValidator((clusterId) => options.validClusters.includes(clusterId)), storage;
|
|
152
|
+
}
|
|
153
|
+
function createEnhancedStorageWallet(options) {
|
|
154
|
+
let key = options?.key ?? `connector-kit:${STORAGE_VERSION}:wallet`;
|
|
155
|
+
return new EnhancedStorage(key, options?.initial, {
|
|
156
|
+
onError: options?.onError,
|
|
157
|
+
useMemoryFallback: true
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
var EnhancedStorageAdapter = class {
|
|
161
|
+
constructor(storage) {
|
|
162
|
+
this.storage = storage;
|
|
163
|
+
}
|
|
164
|
+
get() {
|
|
165
|
+
return this.storage.get();
|
|
166
|
+
}
|
|
167
|
+
set(value) {
|
|
168
|
+
this.storage.set(value);
|
|
169
|
+
}
|
|
170
|
+
subscribe(callback) {
|
|
171
|
+
return this.storage.value.subscribe(callback);
|
|
172
|
+
}
|
|
173
|
+
validate(value) {
|
|
174
|
+
return this.storage.validate(value);
|
|
175
|
+
}
|
|
176
|
+
reset() {
|
|
177
|
+
this.storage.reset();
|
|
178
|
+
}
|
|
179
|
+
clear() {
|
|
180
|
+
this.storage.clear();
|
|
181
|
+
}
|
|
182
|
+
isAvailable() {
|
|
183
|
+
return this.storage.isAvailable();
|
|
184
|
+
}
|
|
185
|
+
transform(transformer) {
|
|
186
|
+
return this.storage.transform(transformer);
|
|
187
|
+
}
|
|
188
|
+
addValidator(validator) {
|
|
189
|
+
return this.storage.addValidator(validator), this;
|
|
190
|
+
}
|
|
191
|
+
onError(handler) {
|
|
192
|
+
return this.storage.onError(handler), this;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
var logger2 = createLogger("DefaultConfig");
|
|
196
|
+
function getDefaultConfig(options) {
|
|
197
|
+
let {
|
|
198
|
+
appName,
|
|
199
|
+
appUrl,
|
|
200
|
+
autoConnect = true,
|
|
201
|
+
debug,
|
|
202
|
+
network = "mainnet-beta",
|
|
203
|
+
enableMobile = true,
|
|
204
|
+
storage,
|
|
205
|
+
clusters,
|
|
206
|
+
customClusters = [],
|
|
207
|
+
persistClusterSelection = true,
|
|
208
|
+
clusterStorageKey,
|
|
209
|
+
enableErrorBoundary = true,
|
|
210
|
+
maxRetries = DEFAULT_MAX_RETRIES,
|
|
211
|
+
onError
|
|
212
|
+
} = options, defaultClusters = clusters ?? [
|
|
213
|
+
createSolanaMainnet(),
|
|
214
|
+
createSolanaDevnet(),
|
|
215
|
+
createSolanaTestnet(),
|
|
216
|
+
...network === "localnet" ? [createSolanaLocalnet()] : [],
|
|
217
|
+
...customClusters || []
|
|
218
|
+
], validClusterIds = defaultClusters.map((c) => c.id), accountStorage = createEnhancedStorageAccount({
|
|
219
|
+
validator: (address) => address ? isAddress(address) : true,
|
|
220
|
+
onError: (error) => {
|
|
221
|
+
debug && logger2.error("Account Storage error", { error }), onError && onError(error, {
|
|
222
|
+
componentStack: "account-storage"
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}), clusterStorage = createEnhancedStorageCluster({
|
|
226
|
+
key: clusterStorageKey,
|
|
227
|
+
initial: getInitialCluster(network),
|
|
228
|
+
validClusters: persistClusterSelection ? validClusterIds : void 0,
|
|
229
|
+
onError: (error) => {
|
|
230
|
+
debug && logger2.error("Cluster Storage error", { error }), onError && onError(error, {
|
|
231
|
+
componentStack: "cluster-storage"
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}), walletStorage = createEnhancedStorageWallet({
|
|
235
|
+
onError: (error) => {
|
|
236
|
+
debug && logger2.error("Wallet Storage error", { error }), onError && onError(error, {
|
|
237
|
+
componentStack: "wallet-storage"
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
if (typeof window < "u") {
|
|
242
|
+
let oldAccountKey = "connector-kit:account", oldWalletKey = "connector-kit:wallet", oldClusterKey = clusterStorageKey || "connector-kit:cluster";
|
|
243
|
+
EnhancedStorage.migrate(oldAccountKey, accountStorage), EnhancedStorage.migrate(oldWalletKey, walletStorage), EnhancedStorage.migrate(oldClusterKey, clusterStorage);
|
|
244
|
+
}
|
|
245
|
+
let defaultStorage = storage ?? {
|
|
246
|
+
account: new EnhancedStorageAdapter(accountStorage),
|
|
247
|
+
cluster: new EnhancedStorageAdapter(clusterStorage),
|
|
248
|
+
wallet: new EnhancedStorageAdapter(walletStorage)
|
|
249
|
+
};
|
|
250
|
+
return {
|
|
251
|
+
autoConnect,
|
|
252
|
+
debug: debug ?? process.env.NODE_ENV === "development",
|
|
253
|
+
storage: defaultStorage,
|
|
254
|
+
appName,
|
|
255
|
+
appUrl,
|
|
256
|
+
enableMobile,
|
|
257
|
+
network,
|
|
258
|
+
cluster: {
|
|
259
|
+
clusters: defaultClusters,
|
|
260
|
+
persistSelection: persistClusterSelection,
|
|
261
|
+
initialCluster: getInitialCluster(network)
|
|
262
|
+
},
|
|
263
|
+
errorBoundary: {
|
|
264
|
+
enabled: enableErrorBoundary,
|
|
265
|
+
maxRetries,
|
|
266
|
+
onError
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
function getInitialCluster(network = "mainnet-beta") {
|
|
271
|
+
return toClusterId(network);
|
|
272
|
+
}
|
|
273
|
+
function getDefaultMobileConfig(options) {
|
|
274
|
+
let baseUrl = options.appUrl || (typeof window < "u" ? window.location.origin : "https://localhost:3000");
|
|
275
|
+
return {
|
|
276
|
+
appIdentity: {
|
|
277
|
+
name: options.appName,
|
|
278
|
+
uri: baseUrl,
|
|
279
|
+
icon: `${baseUrl}/favicon.ico`
|
|
280
|
+
},
|
|
281
|
+
cluster: options.network || "mainnet-beta"
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// src/config/unified-config.ts
|
|
286
|
+
function createConfig(options) {
|
|
287
|
+
let { network = "mainnet-beta", rpcUrl: customRpcUrl, ...connectorOptions } = options, normalizedNetwork = normalizeNetwork(typeof network == "string" ? network : "mainnet-beta"), rpcUrl = customRpcUrl || getDefaultRpcUrl(normalizedNetwork), rpcNetwork = normalizedNetwork === "mainnet" ? "mainnet-beta" : normalizedNetwork, connectorConfig = getDefaultConfig({
|
|
288
|
+
...connectorOptions,
|
|
289
|
+
network: rpcNetwork
|
|
290
|
+
}), mobile = options.enableMobile !== false && normalizedNetwork !== "localnet" ? getDefaultMobileConfig({
|
|
291
|
+
appName: options.appName,
|
|
292
|
+
appUrl: connectorConfig.appUrl,
|
|
293
|
+
network: rpcNetwork
|
|
294
|
+
}) : void 0;
|
|
295
|
+
return {
|
|
296
|
+
connectorConfig,
|
|
297
|
+
mobile,
|
|
298
|
+
network: normalizedNetwork,
|
|
299
|
+
rpcUrl,
|
|
300
|
+
app: {
|
|
301
|
+
name: options.appName,
|
|
302
|
+
url: connectorConfig.appUrl || (typeof window < "u" ? window.location.origin : "https://localhost:3000")
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
function isUnifiedConfig(config) {
|
|
307
|
+
return !!(config && typeof config == "object" && "connectorConfig" in config && "network" in config && "rpcUrl" in config && "app" in config);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// src/types/wallets.ts
|
|
311
|
+
function isWalletName(value) {
|
|
312
|
+
return typeof value == "string" && value.length > 0;
|
|
313
|
+
}
|
|
314
|
+
function isAccountAddress(value) {
|
|
315
|
+
return typeof value == "string" && value.length >= 32 && value.length <= 44;
|
|
316
|
+
}
|
|
317
|
+
function getSolanaExplorerUrl(signature, options = {}) {
|
|
318
|
+
let { cluster = "mainnet", customUrl } = options, normalizedCluster = cluster === "mainnet-beta" ? "mainnet" : cluster;
|
|
319
|
+
if (normalizedCluster === "localnet")
|
|
320
|
+
return `https://explorer.solana.com/tx/${signature}?cluster=custom&customUrl=${encodeURIComponent(customUrl || "http://localhost:8899")}`;
|
|
321
|
+
let explorerCluster = ["mainnet", "devnet", "testnet"].includes(normalizedCluster) ? normalizedCluster : "devnet";
|
|
322
|
+
return getExplorerLink({
|
|
323
|
+
transaction: signature,
|
|
324
|
+
cluster: explorerCluster
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
function getSolscanUrl(signature, options = {}) {
|
|
328
|
+
let { cluster = "mainnet" } = options, normalizedCluster = cluster === "mainnet-beta" ? "mainnet" : cluster;
|
|
329
|
+
return normalizedCluster === "mainnet" ? `https://solscan.io/tx/${signature}` : normalizedCluster === "localnet" ? `https://solscan.io/tx/${signature}?cluster=custom` : `https://solscan.io/tx/${signature}?cluster=${normalizedCluster}`;
|
|
330
|
+
}
|
|
331
|
+
function getXrayUrl(signature) {
|
|
332
|
+
return `https://xray.helius.xyz/tx/${signature}`;
|
|
333
|
+
}
|
|
334
|
+
function getSolanaFmUrl(signature, options = {}) {
|
|
335
|
+
let { cluster = "mainnet" } = options, normalizedCluster = cluster === "mainnet-beta" ? "mainnet" : cluster;
|
|
336
|
+
return normalizedCluster === "mainnet" ? `https://solana.fm/tx/${signature}` : `https://solana.fm/tx/${signature}?cluster=${normalizedCluster}`;
|
|
337
|
+
}
|
|
338
|
+
function getAllExplorerUrls(signature, options = {}) {
|
|
339
|
+
return {
|
|
340
|
+
"solana-explorer": getSolanaExplorerUrl(signature, options),
|
|
341
|
+
solscan: getSolscanUrl(signature, options),
|
|
342
|
+
xray: getXrayUrl(signature),
|
|
343
|
+
"solana-fm": getSolanaFmUrl(signature, options)
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
function formatSignature(signature, chars = 8) {
|
|
347
|
+
return signature.length <= chars * 2 ? signature : `${signature.slice(0, chars)}...${signature.slice(-chars)}`;
|
|
348
|
+
}
|
|
349
|
+
async function copySignature(signature) {
|
|
350
|
+
try {
|
|
351
|
+
return await navigator.clipboard.writeText(signature), true;
|
|
352
|
+
} catch {
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export { EnhancedStorage, EnhancedStorageAdapter, copySignature, createConfig, createEnhancedStorageAccount, createEnhancedStorageCluster, createEnhancedStorageWallet, formatSignature, getAllExplorerUrls, getDefaultConfig, getDefaultMobileConfig, getSolanaExplorerUrl, getSolanaFmUrl, getSolscanUrl, getXrayUrl, isAccountAddress, isUnifiedConfig, isWalletName };
|
|
358
|
+
//# sourceMappingURL=chunk-ACFSCMUI.mjs.map
|
|
359
|
+
//# sourceMappingURL=chunk-ACFSCMUI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/adapters/enhanced-storage.ts","../src/config/default-config.ts","../src/config/unified-config.ts","../src/types/wallets.ts","../src/lib/utils/explorer-urls.ts"],"names":["WalletUiStorage","logger"],"mappings":";;;;;;AAuBA,IAAM,MAAA,GAAS,aAAa,iBAAiB,CAAA,CAAA,CAMhC,kBAAkB,IAAA,CAAA,CAMlB,eAAA,GAAN,cAAiCA,OAAA,CAAmB;AAAA,EAKvD,WAAA,CACI,GAAA,EACA,OAAA,EACQ,OAAA,EACV;AACE,IAAA,KAAA,CAAM,KAAK,OAAO,CAAA;AAFV,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAPZ,IAAA,aAAA,CAAA,IAAA,EAAQ,eAAA,sBAAiD,GAAA,EAAI,CAAA;AAC7D,IAAA,aAAA,CAAA,IAAA,EAAQ,cAAwC,EAAC,CAAA;AACjD,IAAA,aAAA,CAAA,IAAA,EAAQ,gBAAA,CAAA;AAQJ,IAAA,IAAA,CAAK,iBAAiB,OAA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AAA,MAAM,SAAA,CAAU,SAAA,CAAU,SAAA,CAAU,SAAS,CAAA,EACtC,IAAA;AAAA,EACX,CAAA,CAAA,MAAQ;AACJ,IAAA,OAAO,KAAA;AAAA,EACX;AACJ","file":"chunk-ACFSCMUI.mjs","sourcesContent":["/**\n * @solana/connector - Enhanced Storage\n *\n * Extended version of @wallet-ui/core Storage with additional features:\n * - Validation hooks\n * - Error handling and recovery\n * - SSR/memory fallback\n * - Transform utilities\n * - Migration support\n * - Storage availability checks\n */\n\nimport { Storage as WalletUiStorage } from '@wallet-ui/core';\nimport type { SolanaClusterId } from '@wallet-ui/core';\nimport type {\n StorageOptions,\n StorageAdapter,\n EnhancedStorageAccountOptions,\n EnhancedStorageClusterOptions,\n EnhancedStorageWalletOptions,\n} from '../../types/storage';\nimport { createLogger } from '../utils/secure-logger';\n\nconst logger = createLogger('EnhancedStorage');\n\n/**\n * Storage version for migration support\n * Increment when making breaking changes to storage format\n */\nexport const STORAGE_VERSION = 'v1';\n\n/**\n * Enhanced version of wallet-ui's Storage class\n * Extends the base Storage with validation, error handling, and SSR support\n */\nexport class EnhancedStorage<T> extends WalletUiStorage<T> {\n private errorHandlers: Set<(error: Error) => void> = new Set();\n private validators: ((value: T) => boolean)[] = [];\n private memoryFallback: T;\n\n constructor(\n key: string,\n initial: T,\n private options?: StorageOptions<T>,\n ) {\n super(key, initial);\n this.memoryFallback = initial;\n\n if (options?.onError) {\n this.errorHandlers.add(options.onError);\n }\n if (options?.validator) {\n this.validators.push(options.validator);\n }\n }\n\n /**\n * Enhanced set with validation and error handling\n * @returns boolean indicating success\n */\n override set(value: T): boolean {\n try {\n if (!this.validate(value)) {\n logger.warn('Validation failed', { key: this.key });\n return false;\n }\n\n super.set(value);\n\n this.memoryFallback = value;\n return true;\n } catch (error) {\n this.handleError(error as Error);\n\n if (this.options?.useMemoryFallback) {\n this.memoryFallback = value;\n return true;\n }\n\n return false;\n }\n }\n\n /**\n * Enhanced get with error handling and fallback\n */\n override get(): T {\n try {\n return super.get();\n } catch (error) {\n this.handleError(error as Error);\n\n if (this.options?.useMemoryFallback) {\n return this.memoryFallback;\n }\n\n return this.initial;\n }\n }\n\n /**\n * Validate a value against all registered validators\n */\n validate(value: T): boolean {\n return this.validators.every(validator => validator(value));\n }\n\n /**\n * Add a validation rule (chainable)\n *\n * @example\n * ```ts\n * storage\n * .addValidator((addr) => addr?.length === 44)\n * .addValidator((addr) => addr?.startsWith('5'))\n * ```\n */\n addValidator(validator: (value: T) => boolean): this {\n this.validators.push(validator);\n return this;\n }\n\n /**\n * Add error handler (chainable)\n */\n onError(handler: (error: Error) => void): this {\n this.errorHandlers.add(handler);\n return this;\n }\n\n /**\n * Transform the stored value\n *\n * @example\n * ```ts\n * const formatted = storage.transform(\n * (address) => address ? formatAddress(address) : ''\n * )\n * ```\n */\n transform<U>(transformer: (value: T) => U): U {\n return transformer(this.get());\n }\n\n /**\n * Reset to initial value\n */\n reset(): void {\n this.set(this.initial);\n }\n\n /**\n * Clear storage (remove from localStorage)\n */\n clear(): void {\n try {\n if (typeof window !== 'undefined' && window.localStorage) {\n window.localStorage.removeItem(this.key);\n }\n this.reset();\n } catch (error) {\n this.handleError(error as Error);\n }\n }\n\n /**\n * Check if storage is available (not in private mode, quota not exceeded)\n */\n isAvailable(): boolean {\n try {\n if (typeof window === 'undefined') return false;\n const testKey = `__storage_test_${this.key}__`;\n window.localStorage.setItem(testKey, 'test');\n window.localStorage.removeItem(testKey);\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * Migrate from old key to new key\n *\n * @example\n * ```ts\n * EnhancedStorage.migrate(\n * 'old-connector:account',\n * createEnhancedStorageAccount()\n * )\n * ```\n */\n static migrate<T>(oldKey: string, newStorage: EnhancedStorage<T>): boolean {\n try {\n if (typeof window === 'undefined') return false;\n\n const oldValue = window.localStorage.getItem(oldKey);\n if (oldValue) {\n const parsed = JSON.parse(oldValue) as T;\n newStorage.set(parsed);\n window.localStorage.removeItem(oldKey);\n return true;\n }\n return false;\n } catch {\n return false;\n }\n }\n\n private handleError(error: Error): void {\n logger.error('Storage error', { key: this.key, error });\n this.errorHandlers.forEach(handler => {\n try {\n handler(error);\n } catch (err) {\n logger.error('Error in error handler', { error: err });\n }\n });\n }\n}\n\n// ============================================================================\n// Factory Functions\n// ============================================================================\n\n/**\n * Create a storage instance for wallet account persistence\n *\n * @example\n * ```ts\n * const storage = createEnhancedStorageAccount({\n * validator: (address) => {\n * if (!address) return true\n * return isAddress(address)\n * }\n * })\n * ```\n */\nexport function createEnhancedStorageAccount(\n options?: EnhancedStorageAccountOptions,\n): EnhancedStorage<string | undefined> {\n const key = options?.key ?? `connector-kit:${STORAGE_VERSION}:account`;\n return new EnhancedStorage(key, options?.initial, {\n validator: options?.validator,\n onError: options?.onError,\n useMemoryFallback: true, // Always fallback for SSR\n });\n}\n\n/**\n * Create a storage instance for cluster selection persistence\n *\n * @example\n * ```ts\n * const storage = createEnhancedStorageCluster({\n * initial: 'solana:mainnet',\n * validClusters: ['solana:mainnet', 'solana:devnet']\n * })\n * ```\n */\nexport function createEnhancedStorageCluster(\n options?: EnhancedStorageClusterOptions,\n): EnhancedStorage<SolanaClusterId> {\n const key = options?.key ?? `connector-kit:${STORAGE_VERSION}:cluster`;\n const storage = new EnhancedStorage(key, options?.initial ?? 'solana:mainnet', {\n onError: options?.onError,\n useMemoryFallback: true,\n });\n\n if (options?.validClusters) {\n storage.addValidator(clusterId => options.validClusters!.includes(clusterId));\n }\n\n return storage;\n}\n\n/**\n * Create a storage instance for wallet name persistence\n *\n * @example\n * ```ts\n * const storage = createEnhancedStorageWallet({\n * onError: (error) => console.error('Wallet storage error:', error)\n * })\n * ```\n */\nexport function createEnhancedStorageWallet(\n options?: EnhancedStorageWalletOptions,\n): EnhancedStorage<string | undefined> {\n const key = options?.key ?? `connector-kit:${STORAGE_VERSION}:wallet`;\n return new EnhancedStorage(key, options?.initial, {\n onError: options?.onError,\n useMemoryFallback: true,\n });\n}\n\n// ============================================================================\n// Storage Adapter Interface\n// ============================================================================\n\n/**\n * Adapter to make EnhancedStorage compatible with StorageAdapter interface\n * Exposes both the basic interface and enhanced methods for advanced usage\n */\nexport class EnhancedStorageAdapter<T> implements StorageAdapter<T> {\n constructor(private storage: EnhancedStorage<T>) {}\n\n get(): T {\n return this.storage.get();\n }\n\n set(value: T): void {\n this.storage.set(value);\n }\n\n subscribe(callback: (value: T) => void): () => void {\n return this.storage.value.subscribe(callback);\n }\n\n validate(value: T): boolean {\n return this.storage.validate(value);\n }\n\n reset(): void {\n this.storage.reset();\n }\n\n clear(): void {\n this.storage.clear();\n }\n\n isAvailable(): boolean {\n return this.storage.isAvailable();\n }\n\n transform<U>(transformer: (value: T) => U): U {\n return this.storage.transform(transformer);\n }\n\n addValidator(validator: (value: T) => boolean): this {\n this.storage.addValidator(validator);\n return this;\n }\n\n onError(handler: (error: Error) => void): this {\n this.storage.onError(handler);\n return this;\n }\n}\n","import type { ConnectorConfig } from '../types/connector';\nimport type { SolanaCluster, SolanaClusterId } from '@wallet-ui/core';\nimport { createSolanaMainnet, createSolanaDevnet, createSolanaTestnet, createSolanaLocalnet } from '@wallet-ui/core';\nimport {\n createEnhancedStorageAccount,\n createEnhancedStorageCluster,\n createEnhancedStorageWallet,\n EnhancedStorageAdapter,\n EnhancedStorage,\n} from '../lib/adapters/enhanced-storage';\nimport { toClusterId } from '../utils/network';\nimport type React from 'react';\nimport { isAddress } from 'gill';\nimport { DEFAULT_MAX_RETRIES } from '../lib/constants';\nimport { createLogger } from '../lib/utils/secure-logger';\n\nconst logger = createLogger('DefaultConfig');\n\nexport interface DefaultConfigOptions {\n /** Application name shown in wallet connection prompts */\n appName: string;\n /** Application URL for wallet connection metadata */\n appUrl?: string;\n /** Enable automatic wallet reconnection on page load */\n autoConnect?: boolean;\n /** Enable debug logging */\n debug?: boolean;\n /** Solana network to connect to (accepts both 'mainnet' and 'mainnet-beta' conventions) */\n network?: 'mainnet' | 'mainnet-beta' | 'devnet' | 'testnet' | 'localnet';\n /** Enable Mobile Wallet Adapter support */\n enableMobile?: boolean;\n /** Custom storage implementation */\n storage?: ConnectorConfig['storage'];\n /** Custom cluster configuration - overrides network if provided */\n clusters?: SolanaCluster[];\n /** Additional custom clusters to add to the default list */\n customClusters?: SolanaCluster[];\n /** Persist cluster selection across sessions */\n persistClusterSelection?: boolean;\n /** Custom storage key for cluster persistence */\n clusterStorageKey?: string;\n /** Enable error boundaries for automatic error handling (default: true) */\n enableErrorBoundary?: boolean;\n /** Maximum retry attempts for error recovery (default: 3) */\n maxRetries?: number;\n /** Custom error handler */\n onError?: (error: Error, errorInfo: React.ErrorInfo) => void;\n}\n\n/** Extended ConnectorConfig with app metadata */\nexport interface ExtendedConnectorConfig extends ConnectorConfig {\n /** Application name for display and metadata */\n appName?: string;\n /** Application URL for metadata */\n appUrl?: string;\n /** Whether mobile wallet adapter is enabled */\n enableMobile?: boolean;\n /** Selected network for convenience (accepts both 'mainnet' and 'mainnet-beta' conventions) */\n network?: 'mainnet' | 'mainnet-beta' | 'devnet' | 'testnet' | 'localnet';\n /** Error boundary configuration */\n errorBoundary?: {\n /** Enable error boundaries (default: true) */\n enabled?: boolean;\n /** Maximum retry attempts (default: 3) */\n maxRetries?: number;\n /** Custom error handler */\n onError?: (error: Error, errorInfo: React.ErrorInfo) => void;\n /** Custom fallback component */\n fallback?: (error: Error, retry: () => void) => React.ReactNode;\n };\n}\n\n/**\n * Creates a default connector configuration with sensible defaults for Solana applications\n */\nexport function getDefaultConfig(options: DefaultConfigOptions): ExtendedConnectorConfig {\n const {\n appName,\n appUrl,\n autoConnect = true,\n debug,\n network = 'mainnet-beta',\n enableMobile = true,\n storage,\n clusters,\n customClusters = [],\n persistClusterSelection = true,\n clusterStorageKey,\n enableErrorBoundary = true,\n maxRetries = DEFAULT_MAX_RETRIES,\n onError,\n } = options;\n\n const defaultClusters: SolanaCluster[] = clusters ?? [\n createSolanaMainnet(),\n createSolanaDevnet(),\n createSolanaTestnet(),\n ...(network === 'localnet' ? [createSolanaLocalnet()] : []),\n ...(customClusters || []),\n ];\n\n const validClusterIds = defaultClusters.map(c => c.id);\n\n const accountStorage = createEnhancedStorageAccount({\n validator: address => {\n if (!address) return true;\n return isAddress(address);\n },\n onError: error => {\n if (debug) {\n logger.error('Account Storage error', { error });\n }\n if (onError) {\n onError(error, {\n componentStack: 'account-storage',\n });\n }\n },\n });\n\n const clusterStorage = createEnhancedStorageCluster({\n key: clusterStorageKey,\n initial: getInitialCluster(network),\n validClusters: persistClusterSelection ? validClusterIds : undefined,\n onError: error => {\n if (debug) {\n logger.error('Cluster Storage error', { error });\n }\n if (onError) {\n onError(error, {\n componentStack: 'cluster-storage',\n });\n }\n },\n });\n\n const walletStorage = createEnhancedStorageWallet({\n onError: error => {\n if (debug) {\n logger.error('Wallet Storage error', { error });\n }\n if (onError) {\n onError(error, {\n componentStack: 'wallet-storage',\n });\n }\n },\n });\n\n // Migrate old storage keys to new versioned format (v1)\n // This allows seamless upgrades from old versions without losing user data\n if (typeof window !== 'undefined') {\n // Old keys (pre-v1): 'connector-kit:account', 'connector-kit:wallet', 'connector-kit:cluster'\n // New keys (v1): 'connector-kit:v1:account', 'connector-kit:v1:wallet', 'connector-kit:v1:cluster'\n const oldAccountKey = 'connector-kit:account';\n const oldWalletKey = 'connector-kit:wallet';\n const oldClusterKey = clusterStorageKey || 'connector-kit:cluster';\n\n EnhancedStorage.migrate(oldAccountKey, accountStorage);\n EnhancedStorage.migrate(oldWalletKey, walletStorage);\n EnhancedStorage.migrate(oldClusterKey, clusterStorage);\n }\n\n const defaultStorage: ConnectorConfig['storage'] = storage ?? {\n account: new EnhancedStorageAdapter(accountStorage),\n cluster: new EnhancedStorageAdapter(clusterStorage),\n wallet: new EnhancedStorageAdapter(walletStorage),\n };\n\n const config: ExtendedConnectorConfig = {\n autoConnect,\n debug: debug ?? process.env.NODE_ENV === 'development',\n storage: defaultStorage,\n appName,\n appUrl,\n enableMobile,\n network,\n cluster: {\n clusters: defaultClusters,\n persistSelection: persistClusterSelection,\n initialCluster: getInitialCluster(network),\n },\n errorBoundary: {\n enabled: enableErrorBoundary,\n maxRetries,\n onError,\n },\n };\n\n return config;\n}\n\n/**\n * Helper to convert network string to cluster ID\n * Uses network utility for consistent translation\n */\nfunction getInitialCluster(\n network: 'mainnet' | 'mainnet-beta' | 'devnet' | 'testnet' | 'localnet' = 'mainnet-beta',\n): SolanaClusterId {\n return toClusterId(network);\n}\n\n/**\n * Default Mobile Wallet Adapter configuration for Solana applications\n */\nexport function getDefaultMobileConfig(options: {\n appName: string;\n appUrl?: string;\n network?: 'mainnet' | 'mainnet-beta' | 'devnet' | 'testnet';\n}) {\n const baseUrl =\n options.appUrl || (typeof window !== 'undefined' ? window.location.origin : 'https://localhost:3000');\n\n return {\n appIdentity: {\n name: options.appName,\n uri: baseUrl,\n icon: `${baseUrl}/favicon.ico`,\n },\n cluster: options.network || 'mainnet-beta',\n };\n}\n","/**\n * @solana/connector - Unified configuration\n *\n * Simplified configuration for apps using ConnectorKit\n * Eliminates config duplication and provides a single source of truth\n */\n\nimport type { ExtendedConnectorConfig, DefaultConfigOptions } from './default-config';\nimport type { MobileWalletAdapterConfig } from '../ui/connector-provider';\nimport { getDefaultConfig, getDefaultMobileConfig } from './default-config';\nimport { normalizeNetwork, getDefaultRpcUrl, type SolanaNetwork } from '../utils/network';\n\n/**\n * Options for creating a unified configuration\n * Maintains type safety while providing flexibility\n */\nexport interface UnifiedConfigOptions extends DefaultConfigOptions {\n /**\n * Custom RPC URL (optional - overrides default for network)\n * Note: For production apps, use environment variables to avoid exposing API keys\n * @see packages/connector/src/utils/cluster.ts for secure RPC URL patterns\n */\n rpcUrl?: string;\n}\n\n/**\n * Unified configuration output\n * Contains all configs needed for ConnectorKit and integrations\n *\n * Important: The `rpcUrl` property is intended for:\n * 1. Server-side rendering (SSR) setup\n * 2. Passing to external libraries that need RPC configuration\n * 3. Development/testing environments\n *\n * For production client-side code, use the connector client's `getRpcUrl()` method\n * which supports environment variable patterns and proxy configurations.\n */\nexport interface UnifiedConfig {\n /** ConnectorKit configuration */\n connectorConfig: ExtendedConnectorConfig;\n /** Mobile Wallet Adapter configuration (optional) */\n mobile?: MobileWalletAdapterConfig;\n /** Normalized network name ('mainnet', 'devnet', 'testnet', 'localnet') */\n network: SolanaNetwork;\n /**\n * RPC endpoint URL\n * For external library integration only - client code should use connector client\n * @deprecated in client components - use `useConnectorClient().getRpcUrl()` instead\n */\n rpcUrl: string;\n /** Application metadata */\n app: {\n name: string;\n url: string;\n };\n}\n\n/**\n * Create a unified configuration for ConnectorKit\n *\n * This helper eliminates configuration duplication by creating all necessary\n * configs from a single source of truth. It automatically handles network\n * name translation between different conventions.\n *\n * @example Basic usage\n * ```tsx\n * import { createConfig, AppProvider } from '@solana/connector';\n *\n * const config = createConfig({\n * appName: 'My App',\n * network: 'mainnet', // Works with 'mainnet' or 'mainnet-beta'\n * enableMobile: true\n * });\n *\n * <AppProvider config={config}>\n * {children}\n * </AppProvider>\n * ```\n *\n * @example Integration with external libraries\n * ```tsx\n * import { createConfig, AppProvider } from '@solana/connector';\n * import { ArmaProvider } from '@armadura/sdk';\n *\n * const config = createConfig({\n * appName: 'My App',\n * network: 'mainnet',\n * });\n *\n * <AppProvider config={config}>\n * <ArmaProvider\n * config={{\n * network: config.network,\n * rpcUrl: config.rpcUrl, // Safe - for external library initialization\n * providers: [...]\n * }}\n * useConnector=\"auto\"\n * >\n * {children}\n * </ArmaProvider>\n * </AppProvider>\n * ```\n *\n * @example Production with environment variables\n * ```tsx\n * // Use environment variables to avoid exposing API keys\n * const config = createConfig({\n * appName: 'My App',\n * network: 'mainnet',\n * // RPC URL comes from process.env on server\n * // Client-side code should use connector client's getRpcUrl()\n * });\n * ```\n *\n * @example Custom clusters\n * ```tsx\n * const config = createConfig({\n * appName: 'My App',\n * network: 'mainnet',\n * customClusters: [\n * {\n * id: 'solana:custom',\n * label: 'Custom RPC',\n * url: process.env.CUSTOM_RPC_URL || 'https://...'\n * }\n * ]\n * });\n * ```\n */\nexport function createConfig(options: UnifiedConfigOptions): UnifiedConfig {\n // Extract network and rpcUrl, use remaining options for connector config\n const { network = 'mainnet-beta', rpcUrl: customRpcUrl, ...connectorOptions } = options;\n\n // Normalize network name for consistency\n const normalizedNetwork = normalizeNetwork(typeof network === 'string' ? network : 'mainnet-beta');\n\n // Get RPC URL (custom or default)\n const rpcUrl = customRpcUrl || getDefaultRpcUrl(normalizedNetwork);\n\n // Convert normalized network to RPC format (mainnet -> mainnet-beta)\n const rpcNetwork = normalizedNetwork === 'mainnet' ? 'mainnet-beta' : normalizedNetwork;\n\n // Create connector configuration\n const connectorConfig = getDefaultConfig({\n ...connectorOptions,\n network: rpcNetwork,\n });\n\n // Create mobile configuration (if enabled)\n const mobile =\n options.enableMobile !== false && normalizedNetwork !== 'localnet'\n ? getDefaultMobileConfig({\n appName: options.appName,\n appUrl: connectorConfig.appUrl,\n network: rpcNetwork as 'mainnet-beta' | 'devnet' | 'testnet',\n })\n : undefined;\n\n return {\n connectorConfig,\n mobile,\n network: normalizedNetwork,\n rpcUrl,\n app: {\n name: options.appName,\n url:\n connectorConfig.appUrl ||\n (typeof window !== 'undefined' ? window.location.origin : 'https://localhost:3000'),\n },\n };\n}\n\n/**\n * Type guard to check if a config is a unified config\n *\n * @example\n * ```ts\n * if (isUnifiedConfig(someConfig)) {\n * // TypeScript knows this is UnifiedConfig\n * console.log(someConfig.network, someConfig.rpcUrl);\n * }\n * ```\n */\nexport function isUnifiedConfig(config: unknown): config is UnifiedConfig {\n return Boolean(\n config &&\n typeof config === 'object' &&\n 'connectorConfig' in config &&\n 'network' in config &&\n 'rpcUrl' in config &&\n 'app' in config,\n );\n}\n","/**\n * Wallet-related types\n * Re-exports from @wallet-standard/base and custom wallet types\n */\n\nimport type { Wallet, WalletAccount } from '@wallet-standard/base';\n\n// Re-export standard types\nexport type { Wallet, WalletAccount };\n\n/**\n * Wallet name as a branded string for type safety\n * Represents the unique identifier for a wallet (e.g., \"Phantom\", \"Solflare\")\n */\nexport type WalletName = string & { readonly __brand: 'WalletName' };\n\n/**\n * Account address as a branded string for type safety\n * Represents a Solana address (base58-encoded public key)\n *\n * @deprecated Use `Address` from 'gill' instead for consistent address typing\n */\nexport type AccountAddress = string & { readonly __brand: 'AccountAddress' };\n\n/**\n * Type guard to check if a string is a valid wallet name\n */\nexport function isWalletName(value: string): value is WalletName {\n return typeof value === 'string' && value.length > 0;\n}\n\n/**\n * Type guard to check if a string is a valid account address\n *\n * @deprecated Use `isAddress` from 'gill' instead for proper address validation\n */\nexport function isAccountAddress(value: string): value is AccountAddress {\n // Basic validation: Solana addresses are typically 32-44 characters\n return typeof value === 'string' && value.length >= 32 && value.length <= 44;\n}\n\n/**\n * Extended wallet information with capability metadata\n */\nexport interface WalletInfo {\n /** The Wallet Standard wallet object */\n wallet: Wallet;\n /** Whether the wallet extension is installed */\n installed: boolean;\n /** Precomputed capability flag for UI convenience */\n connectable?: boolean;\n}\n","/**\n * @solana/connector - Explorer URL Utilities\n *\n * Generate URLs for various Solana block explorers to view transactions,\n * accounts, and other on-chain data.\n */\n\nimport { getExplorerLink } from 'gill';\n\nexport type ExplorerType = 'solana-explorer' | 'solscan' | 'xray' | 'solana-fm';\n\nexport interface ExplorerOptions {\n /** Cluster to use for the explorer link */\n cluster?: string;\n /** Custom RPC URL for localnet */\n customUrl?: string;\n}\n\n/**\n * Generate Solana Explorer URL for a transaction signature\n */\nexport function getSolanaExplorerUrl(signature: string, options: ExplorerOptions = {}): string {\n const { cluster = 'mainnet', customUrl } = options;\n const normalizedCluster = cluster === 'mainnet-beta' ? 'mainnet' : cluster;\n\n // Handle localnet with custom URL - gill doesn't support this specific case\n if (normalizedCluster === 'localnet') {\n const url = customUrl || 'http://localhost:8899';\n return `https://explorer.solana.com/tx/${signature}?cluster=custom&customUrl=${encodeURIComponent(url)}`;\n }\n\n // Map to valid gill cluster types (custom clusters default to devnet)\n const validClusters = ['mainnet', 'devnet', 'testnet'] as const;\n const explorerCluster = validClusters.includes(normalizedCluster as 'mainnet' | 'devnet' | 'testnet')\n ? (normalizedCluster as 'mainnet' | 'devnet' | 'testnet')\n : 'devnet';\n\n // Use gill's getExplorerLink for standard clusters\n return getExplorerLink({\n transaction: signature,\n cluster: explorerCluster,\n });\n}\n\n/**\n * Generate Solscan URL for a transaction signature\n */\nexport function getSolscanUrl(signature: string, options: ExplorerOptions = {}): string {\n const { cluster = 'mainnet' } = options;\n const normalizedCluster = cluster === 'mainnet-beta' ? 'mainnet' : cluster;\n\n if (normalizedCluster === 'mainnet') {\n return `https://solscan.io/tx/${signature}`;\n }\n\n if (normalizedCluster === 'localnet') {\n return `https://solscan.io/tx/${signature}?cluster=custom`;\n }\n\n return `https://solscan.io/tx/${signature}?cluster=${normalizedCluster}`;\n}\n\n/**\n * Generate XRAY (Helius) URL for a transaction signature\n * Note: XRAY works best with mainnet transactions\n */\nexport function getXrayUrl(signature: string): string {\n return `https://xray.helius.xyz/tx/${signature}`;\n}\n\n/**\n * Generate SolanaFM URL for a transaction signature\n */\nexport function getSolanaFmUrl(signature: string, options: ExplorerOptions = {}): string {\n const { cluster = 'mainnet' } = options;\n const normalizedCluster = cluster === 'mainnet-beta' ? 'mainnet' : cluster;\n\n if (normalizedCluster === 'mainnet') {\n return `https://solana.fm/tx/${signature}`;\n }\n\n return `https://solana.fm/tx/${signature}?cluster=${normalizedCluster}`;\n}\n\n/**\n * Get all explorer URLs for a transaction\n */\nexport function getAllExplorerUrls(signature: string, options: ExplorerOptions = {}): Record<ExplorerType, string> {\n return {\n 'solana-explorer': getSolanaExplorerUrl(signature, options),\n solscan: getSolscanUrl(signature, options),\n xray: getXrayUrl(signature),\n 'solana-fm': getSolanaFmUrl(signature, options),\n };\n}\n\n/**\n * Format a transaction signature for display (truncated)\n */\nexport function formatSignature(signature: string, chars = 8): string {\n if (signature.length <= chars * 2) return signature;\n return `${signature.slice(0, chars)}...${signature.slice(-chars)}`;\n}\n\n/**\n * Copy signature to clipboard with enhanced error handling\n *\n * @deprecated Use copySignatureToClipboard from utils/clipboard instead\n * This is maintained for backwards compatibility but will be removed in a future version\n */\nexport async function copySignature(signature: string): Promise<boolean> {\n try {\n await navigator.clipboard.writeText(signature);\n return true;\n } catch {\n return false;\n }\n}\n"]}
|