@solana/connector 0.1.6 → 0.1.8
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 +122 -44
- package/dist/{chunk-VMSZJPR5.mjs → chunk-6F6M6L7R.mjs} +152 -173
- package/dist/chunk-6F6M6L7R.mjs.map +1 -0
- package/dist/{chunk-NQXK7PGX.js → chunk-AOIXHVRH.js} +82 -235
- package/dist/chunk-AOIXHVRH.js.map +1 -0
- package/dist/chunk-DSUCH44G.js +678 -0
- package/dist/chunk-DSUCH44G.js.map +1 -0
- package/dist/{chunk-JUZVCBAI.js → chunk-FTXIXM43.js} +240 -271
- package/dist/chunk-FTXIXM43.js.map +1 -0
- package/dist/{chunk-QKVL45F6.mjs → chunk-G575OAT4.mjs} +73 -218
- package/dist/chunk-G575OAT4.mjs.map +1 -0
- package/dist/chunk-J7DHGLW6.mjs +638 -0
- package/dist/chunk-J7DHGLW6.mjs.map +1 -0
- package/dist/{chunk-ULUYX23Q.js → chunk-K3BNIGPX.js} +1023 -404
- package/dist/chunk-K3BNIGPX.js.map +1 -0
- package/dist/{chunk-3STZXVXD.mjs → chunk-TTOKQAPX.mjs} +998 -388
- package/dist/chunk-TTOKQAPX.mjs.map +1 -0
- package/dist/compat.d.mts +1 -1
- package/dist/compat.d.ts +1 -1
- package/dist/compat.js +40 -39
- package/dist/compat.js.map +1 -1
- package/dist/compat.mjs +39 -38
- package/dist/compat.mjs.map +1 -1
- package/dist/headless.d.mts +540 -152
- package/dist/headless.d.ts +540 -152
- package/dist/headless.js +226 -190
- package/dist/headless.mjs +3 -3
- package/dist/index.d.mts +8 -6
- package/dist/index.d.ts +8 -6
- package/dist/index.js +286 -218
- package/dist/index.mjs +4 -4
- package/dist/react.d.mts +283 -16
- package/dist/react.d.ts +283 -16
- package/dist/react.js +60 -28
- package/dist/react.mjs +2 -2
- package/dist/{wallet-standard-shim--YcrQNRt.d.ts → standard-shim-CT49DM5l.d.mts} +72 -252
- package/dist/{wallet-standard-shim-Dx7H8Ctf.d.mts → standard-shim-D9guL5fz.d.ts} +72 -252
- package/dist/{transaction-signer-D9d8nxwb.d.mts → transaction-signer-T-KVQFi8.d.mts} +2 -2
- package/dist/{transaction-signer-D9d8nxwb.d.ts → transaction-signer-T-KVQFi8.d.ts} +2 -2
- package/package.json +3 -3
- package/dist/chunk-3STZXVXD.mjs.map +0 -1
- package/dist/chunk-I64FD2EH.js +0 -312
- package/dist/chunk-I64FD2EH.js.map +0 -1
- package/dist/chunk-JUZVCBAI.js.map +0 -1
- package/dist/chunk-NQXK7PGX.js.map +0 -1
- package/dist/chunk-QKVL45F6.mjs.map +0 -1
- package/dist/chunk-QL3IT3TS.mjs +0 -299
- package/dist/chunk-QL3IT3TS.mjs.map +0 -1
- package/dist/chunk-ULUYX23Q.js.map +0 -1
- package/dist/chunk-VMSZJPR5.mjs.map +0 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkFTXIXM43_js = require('./chunk-FTXIXM43.js');
|
|
4
|
+
var chunkDSUCH44G_js = require('./chunk-DSUCH44G.js');
|
|
5
5
|
var core = require('@wallet-ui/core');
|
|
6
6
|
var addresses = require('@solana/addresses');
|
|
7
|
-
var
|
|
7
|
+
var v4 = require('zod/v4');
|
|
8
8
|
var signers = require('@solana/signers');
|
|
9
9
|
|
|
10
|
-
var logger =
|
|
10
|
+
var logger = chunkDSUCH44G_js.createLogger("EnhancedStorage"), STORAGE_VERSION = "v1", EnhancedStorage = class extends core.Storage {
|
|
11
11
|
constructor(key, initial, options) {
|
|
12
12
|
super(key, initial);
|
|
13
13
|
this.options = options;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
chunkDSUCH44G_js.__publicField(this, "errorHandlers", /* @__PURE__ */ new Set());
|
|
15
|
+
chunkDSUCH44G_js.__publicField(this, "validators", []);
|
|
16
|
+
chunkDSUCH44G_js.__publicField(this, "memoryFallback");
|
|
17
17
|
this.memoryFallback = initial, options?.onError && this.errorHandlers.add(options.onError), options?.validator && this.validators.push(options.validator);
|
|
18
18
|
}
|
|
19
19
|
set(value) {
|
|
@@ -142,7 +142,7 @@ var EnhancedStorageAdapter = class {
|
|
|
142
142
|
return this.storage.onError(handler), this;
|
|
143
143
|
}
|
|
144
144
|
};
|
|
145
|
-
var logger2 =
|
|
145
|
+
var logger2 = chunkDSUCH44G_js.createLogger("DefaultConfig");
|
|
146
146
|
function getDefaultConfig(options) {
|
|
147
147
|
let {
|
|
148
148
|
appName,
|
|
@@ -157,9 +157,10 @@ function getDefaultConfig(options) {
|
|
|
157
157
|
persistClusterSelection = true,
|
|
158
158
|
clusterStorageKey,
|
|
159
159
|
enableErrorBoundary = true,
|
|
160
|
-
maxRetries =
|
|
160
|
+
maxRetries = chunkFTXIXM43_js.DEFAULT_MAX_RETRIES,
|
|
161
161
|
onError,
|
|
162
162
|
imageProxy,
|
|
163
|
+
programLabels,
|
|
163
164
|
coingecko
|
|
164
165
|
} = options, defaultClusters = clusters ?? [
|
|
165
166
|
core.createSolanaMainnet(),
|
|
@@ -168,7 +169,7 @@ function getDefaultConfig(options) {
|
|
|
168
169
|
...network === "localnet" ? [core.createSolanaLocalnet()] : [],
|
|
169
170
|
...customClusters || []
|
|
170
171
|
], validClusterIds = defaultClusters.map((c) => c.id), accountStorage = createEnhancedStorageAccount({
|
|
171
|
-
validator: (
|
|
172
|
+
validator: (address2) => address2 ? addresses.isAddress(address2) : true,
|
|
172
173
|
onError: (error) => {
|
|
173
174
|
debug && logger2.error("Account Storage error", { error }), onError && onError(error, {
|
|
174
175
|
componentStack: "account-storage"
|
|
@@ -218,11 +219,12 @@ function getDefaultConfig(options) {
|
|
|
218
219
|
onError
|
|
219
220
|
},
|
|
220
221
|
imageProxy,
|
|
222
|
+
programLabels,
|
|
221
223
|
coingecko
|
|
222
224
|
};
|
|
223
225
|
}
|
|
224
226
|
function getInitialCluster(network = "mainnet-beta") {
|
|
225
|
-
return
|
|
227
|
+
return chunkFTXIXM43_js.toClusterId(network);
|
|
226
228
|
}
|
|
227
229
|
function getDefaultMobileConfig(options) {
|
|
228
230
|
let baseUrl = options.appUrl || (typeof window < "u" ? window.location.origin : "https://localhost:3000");
|
|
@@ -235,30 +237,69 @@ function getDefaultMobileConfig(options) {
|
|
|
235
237
|
cluster: options.network || "mainnet-beta"
|
|
236
238
|
};
|
|
237
239
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
240
|
+
var solanaNetworkSchema = v4.z.enum(["mainnet", "mainnet-beta", "devnet", "testnet", "localnet"]), solanaClusterIdSchema = v4.z.string().regex(/^solana:(mainnet|devnet|testnet|localnet|[a-zA-Z0-9-]+)$/, {
|
|
241
|
+
message: 'Cluster ID must be in format "solana:<network>" (e.g., "solana:mainnet")'
|
|
242
|
+
}), urlSchema = v4.z.string().url("Invalid URL format"), optionalUrlSchema = urlSchema.optional(), coinGeckoConfigSchema = v4.z.strictObject({
|
|
243
|
+
apiKey: v4.z.string().optional(),
|
|
244
|
+
isPro: v4.z.boolean().optional(),
|
|
245
|
+
maxRetries: v4.z.number().int().positive().max(10).optional(),
|
|
246
|
+
baseDelay: v4.z.number().int().positive().max(3e4).optional(),
|
|
247
|
+
maxTimeout: v4.z.number().int().positive().max(12e4).optional()
|
|
248
|
+
}).optional(), storageAdapterSchema = v4.z.looseObject({
|
|
249
|
+
get: v4.z.custom((val) => typeof val == "function"),
|
|
250
|
+
set: v4.z.custom((val) => typeof val == "function")
|
|
251
|
+
}), storageConfigSchema = v4.z.object({
|
|
252
|
+
account: storageAdapterSchema,
|
|
253
|
+
cluster: storageAdapterSchema,
|
|
254
|
+
wallet: storageAdapterSchema
|
|
255
|
+
}).optional(), solanaClusterSchema = v4.z.object({
|
|
256
|
+
id: solanaClusterIdSchema,
|
|
257
|
+
label: v4.z.string().min(1, "Cluster label cannot be empty"),
|
|
258
|
+
url: urlSchema,
|
|
259
|
+
urlWs: urlSchema.optional()
|
|
260
|
+
}), clusterConfigSchema = v4.z.object({
|
|
261
|
+
clusters: v4.z.array(solanaClusterSchema).optional(),
|
|
262
|
+
persistSelection: v4.z.boolean().optional(),
|
|
263
|
+
initialCluster: solanaClusterIdSchema.optional()
|
|
264
|
+
}).optional(), defaultConfigOptionsSchema = v4.z.object({
|
|
265
|
+
// Required
|
|
266
|
+
appName: v4.z.string().min(1, "Application name is required"),
|
|
267
|
+
// Optional strings
|
|
268
|
+
appUrl: optionalUrlSchema,
|
|
269
|
+
imageProxy: v4.z.string().optional(),
|
|
270
|
+
clusterStorageKey: v4.z.string().optional(),
|
|
271
|
+
// Optional booleans
|
|
272
|
+
autoConnect: v4.z.boolean().optional(),
|
|
273
|
+
debug: v4.z.boolean().optional(),
|
|
274
|
+
enableMobile: v4.z.boolean().optional(),
|
|
275
|
+
persistClusterSelection: v4.z.boolean().optional(),
|
|
276
|
+
enableErrorBoundary: v4.z.boolean().optional(),
|
|
277
|
+
// Network
|
|
278
|
+
network: solanaNetworkSchema.optional(),
|
|
279
|
+
// Numbers
|
|
280
|
+
maxRetries: v4.z.number().int().positive().max(10).optional(),
|
|
281
|
+
// Complex types
|
|
282
|
+
storage: storageConfigSchema,
|
|
283
|
+
clusters: v4.z.array(solanaClusterSchema).optional(),
|
|
284
|
+
customClusters: v4.z.array(solanaClusterSchema).optional(),
|
|
285
|
+
programLabels: v4.z.record(v4.z.string(), v4.z.string()).optional(),
|
|
286
|
+
coingecko: coinGeckoConfigSchema,
|
|
287
|
+
// Functions (can't validate implementation, just existence)
|
|
288
|
+
onError: v4.z.custom((val) => typeof val == "function").optional()
|
|
289
|
+
}); v4.z.strictObject({
|
|
290
|
+
autoConnect: v4.z.boolean().optional(),
|
|
291
|
+
debug: v4.z.boolean().optional(),
|
|
292
|
+
storage: storageConfigSchema,
|
|
293
|
+
cluster: clusterConfigSchema,
|
|
294
|
+
imageProxy: v4.z.string().optional(),
|
|
295
|
+
programLabels: v4.z.record(v4.z.string(), v4.z.string()).optional(),
|
|
296
|
+
coingecko: coinGeckoConfigSchema
|
|
297
|
+
}).optional();
|
|
298
|
+
function validateConfigOptions(options) {
|
|
299
|
+
return defaultConfigOptionsSchema.safeParse(options);
|
|
300
|
+
}
|
|
301
|
+
function parseConfigOptions(options) {
|
|
302
|
+
return defaultConfigOptionsSchema.parse(options);
|
|
262
303
|
}
|
|
263
304
|
|
|
264
305
|
// src/types/wallets.ts
|
|
@@ -268,192 +309,6 @@ function isWalletName(value) {
|
|
|
268
309
|
function isAccountAddress(value) {
|
|
269
310
|
return typeof value == "string" && value.length >= 32 && value.length <= 44;
|
|
270
311
|
}
|
|
271
|
-
function detectMessageModification(original, modified) {
|
|
272
|
-
if (original.length !== modified.length)
|
|
273
|
-
return true;
|
|
274
|
-
for (let i = 0; i < original.length; i++)
|
|
275
|
-
if (original[i] !== modified[i])
|
|
276
|
-
return true;
|
|
277
|
-
return false;
|
|
278
|
-
}
|
|
279
|
-
function updateSignatureDictionary(original, signed, originalSignatures, address3, signature) {
|
|
280
|
-
let wasModified = detectMessageModification(original, signed), signatureBytes = signature, newSignatures = {};
|
|
281
|
-
return newSignatures[address3] = signatureBytes, wasModified ? newSignatures : {
|
|
282
|
-
...originalSignatures,
|
|
283
|
-
...newSignatures
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
function freezeSigner(signer) {
|
|
287
|
-
return Object.freeze(signer);
|
|
288
|
-
}
|
|
289
|
-
function base58ToSignatureBytes(signature) {
|
|
290
|
-
try {
|
|
291
|
-
let bytes = codecs.getBase58Encoder().encode(signature);
|
|
292
|
-
if (bytes.length !== 64)
|
|
293
|
-
throw new Error(`Invalid signature length: expected 64 bytes, got ${bytes.length}`);
|
|
294
|
-
return bytes;
|
|
295
|
-
} catch (error) {
|
|
296
|
-
throw new Error(`Failed to decode base58 signature: ${error instanceof Error ? error.message : String(error)}`);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
function signatureBytesToBase58(bytes) {
|
|
300
|
-
try {
|
|
301
|
-
if (bytes.length !== 64)
|
|
302
|
-
throw new Error(`Invalid signature length: expected 64 bytes, got ${bytes.length}`);
|
|
303
|
-
return codecs.getBase58Decoder().decode(bytes);
|
|
304
|
-
} catch (error) {
|
|
305
|
-
throw new Error(
|
|
306
|
-
`Failed to encode signature to base58: ${error instanceof Error ? error.message : String(error)}`
|
|
307
|
-
);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
// src/lib/kit-signers/factories.ts
|
|
312
|
-
function createMessageSignerFromWallet(walletAddress, signMessageFn) {
|
|
313
|
-
return freezeSigner({
|
|
314
|
-
address: walletAddress,
|
|
315
|
-
async modifyAndSignMessages(messages, config) {
|
|
316
|
-
if (messages.length !== 1)
|
|
317
|
-
throw new chunkJUZVCBAI_js.ValidationError("INVALID_FORMAT", "Wallets only support signing one message at a time", {
|
|
318
|
-
receivedCount: messages.length,
|
|
319
|
-
expectedCount: 1
|
|
320
|
-
});
|
|
321
|
-
let [message] = messages, { content, signatures: originalSignatures } = message;
|
|
322
|
-
if (config?.abortSignal?.aborted)
|
|
323
|
-
throw chunkJUZVCBAI_js.Errors.userRejected("message signing");
|
|
324
|
-
try {
|
|
325
|
-
let signature = await signMessageFn(content), signatures = updateSignatureDictionary(
|
|
326
|
-
content,
|
|
327
|
-
content,
|
|
328
|
-
// Message content doesn't change in signMessage
|
|
329
|
-
originalSignatures,
|
|
330
|
-
walletAddress,
|
|
331
|
-
signature
|
|
332
|
-
);
|
|
333
|
-
return [
|
|
334
|
-
{
|
|
335
|
-
content,
|
|
336
|
-
signatures
|
|
337
|
-
}
|
|
338
|
-
];
|
|
339
|
-
} catch (error) {
|
|
340
|
-
if (error instanceof Error) {
|
|
341
|
-
let message2 = error.message.toLowerCase();
|
|
342
|
-
throw message2.includes("user rejected") || message2.includes("user denied") ? chunkJUZVCBAI_js.Errors.userRejected("message signing") : new chunkJUZVCBAI_js.TransactionError("SIGNING_FAILED", "Failed to sign message", void 0, error);
|
|
343
|
-
}
|
|
344
|
-
throw new chunkJUZVCBAI_js.TransactionError("SIGNING_FAILED", "Failed to sign message", {
|
|
345
|
-
originalError: String(error)
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
function createTransactionSendingSignerFromWallet(walletAddress, chain, sendTransactionFn) {
|
|
352
|
-
return freezeSigner({
|
|
353
|
-
address: walletAddress,
|
|
354
|
-
async signAndSendTransactions(transactions, config) {
|
|
355
|
-
if (transactions.length !== 1)
|
|
356
|
-
throw new chunkJUZVCBAI_js.ValidationError("INVALID_FORMAT", "Wallets only support sending one transaction at a time", {
|
|
357
|
-
receivedCount: transactions.length,
|
|
358
|
-
expectedCount: 1
|
|
359
|
-
});
|
|
360
|
-
let [transaction] = transactions;
|
|
361
|
-
if (config?.abortSignal?.aborted)
|
|
362
|
-
throw chunkJUZVCBAI_js.Errors.userRejected("transaction sending");
|
|
363
|
-
try {
|
|
364
|
-
let signatureString = await sendTransactionFn(transaction);
|
|
365
|
-
return [base58ToSignatureBytes(signatureString)];
|
|
366
|
-
} catch (error) {
|
|
367
|
-
if (error instanceof Error) {
|
|
368
|
-
let message = error.message.toLowerCase();
|
|
369
|
-
throw message.includes("user rejected") || message.includes("user denied") ? chunkJUZVCBAI_js.Errors.userRejected("transaction sending") : message.includes("network") || message.includes("rpc") ? new chunkJUZVCBAI_js.TransactionError("SEND_FAILED", "Failed to send transaction", void 0, error) : new chunkJUZVCBAI_js.TransactionError("SEND_FAILED", "Failed to send transaction", void 0, error);
|
|
370
|
-
}
|
|
371
|
-
throw new chunkJUZVCBAI_js.TransactionError("SEND_FAILED", "Failed to send transaction", {
|
|
372
|
-
originalError: String(error)
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
function createKitSignersFromWallet(wallet, account, connection, network) {
|
|
379
|
-
if (!wallet || !account)
|
|
380
|
-
return {
|
|
381
|
-
address: null,
|
|
382
|
-
addressString: null,
|
|
383
|
-
messageSigner: null,
|
|
384
|
-
transactionSigner: null
|
|
385
|
-
};
|
|
386
|
-
let walletAddress = null, walletAddressString = null;
|
|
387
|
-
try {
|
|
388
|
-
walletAddress = addresses.address(account.address), walletAddressString = account.address;
|
|
389
|
-
} catch {
|
|
390
|
-
return {
|
|
391
|
-
address: null,
|
|
392
|
-
addressString: null,
|
|
393
|
-
messageSigner: null,
|
|
394
|
-
transactionSigner: null
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
let chain = "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1";
|
|
398
|
-
if (network)
|
|
399
|
-
chain = {
|
|
400
|
-
mainnet: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
|
|
401
|
-
devnet: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
|
|
402
|
-
testnet: "solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z"
|
|
403
|
-
}[network] || chain;
|
|
404
|
-
else if (connection) {
|
|
405
|
-
let rpcUrl = connection.rpcEndpoint || "";
|
|
406
|
-
rpcUrl.includes("mainnet") || rpcUrl.includes("api.mainnet-beta") ? chain = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp" : rpcUrl.includes("testnet") ? chain = "solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z" : chain = "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1";
|
|
407
|
-
}
|
|
408
|
-
let features = wallet.features, hasSignMessage = !!features["solana:signMessage"], hasSignAndSendTransaction = !!features["solana:signAndSendTransaction"], hasSendTransaction = !!features["solana:sendTransaction"], messageSigner = hasSignMessage ? createMessageSignerFromWallet(walletAddress, async (message) => {
|
|
409
|
-
if (!hasSignMessage)
|
|
410
|
-
throw chunkJUZVCBAI_js.Errors.featureNotSupported("message signing");
|
|
411
|
-
try {
|
|
412
|
-
let signFeature = features["solana:signMessage"], messageBytes = message instanceof Uint8Array ? message : new Uint8Array(message), results = await signFeature.signMessage({
|
|
413
|
-
account,
|
|
414
|
-
message: messageBytes,
|
|
415
|
-
...chain ? { chain } : {}
|
|
416
|
-
});
|
|
417
|
-
if (!Array.isArray(results) || results.length === 0)
|
|
418
|
-
throw new Error("Wallet returned empty results array");
|
|
419
|
-
let firstResult = results[0];
|
|
420
|
-
if (!firstResult?.signature)
|
|
421
|
-
throw new Error("Wallet returned no signature in first result");
|
|
422
|
-
return firstResult.signature;
|
|
423
|
-
} catch (error) {
|
|
424
|
-
throw console.error("signMessage error:", error), error instanceof Error ? error : new Error(String(error));
|
|
425
|
-
}
|
|
426
|
-
}) : null, transactionSigner = hasSignAndSendTransaction || hasSendTransaction ? createTransactionSendingSignerFromWallet(walletAddress, chain, async (transaction) => {
|
|
427
|
-
if (hasSignAndSendTransaction)
|
|
428
|
-
try {
|
|
429
|
-
return (await features["solana:signAndSendTransaction"].signAndSendTransaction({
|
|
430
|
-
account,
|
|
431
|
-
transactions: [transaction],
|
|
432
|
-
...chain ? { chain } : {},
|
|
433
|
-
...connection ? { connection } : {}
|
|
434
|
-
})).signatures[0] || "";
|
|
435
|
-
} catch (error) {
|
|
436
|
-
throw error instanceof Error ? error : new Error(String(error));
|
|
437
|
-
}
|
|
438
|
-
if (hasSendTransaction)
|
|
439
|
-
try {
|
|
440
|
-
return (await features["solana:sendTransaction"].sendTransaction({
|
|
441
|
-
account,
|
|
442
|
-
transactions: [transaction],
|
|
443
|
-
...chain ? { chain } : {}
|
|
444
|
-
})).signatures[0] || "";
|
|
445
|
-
} catch (error) {
|
|
446
|
-
throw error instanceof Error ? error : new Error(String(error));
|
|
447
|
-
}
|
|
448
|
-
throw chunkJUZVCBAI_js.Errors.featureNotSupported("transaction sending");
|
|
449
|
-
}) : null;
|
|
450
|
-
return {
|
|
451
|
-
address: walletAddress,
|
|
452
|
-
addressString: walletAddressString,
|
|
453
|
-
messageSigner,
|
|
454
|
-
transactionSigner
|
|
455
|
-
};
|
|
456
|
-
}
|
|
457
312
|
|
|
458
313
|
// src/lib/connection/types.ts
|
|
459
314
|
function isLegacyConnection(conn) {
|
|
@@ -504,7 +359,7 @@ var SOLANA_CHAIN_IDS = {
|
|
|
504
359
|
"solana:testnet": SOLANA_CHAIN_IDS.testnet
|
|
505
360
|
};
|
|
506
361
|
function getChainIdFromCluster(cluster) {
|
|
507
|
-
let clusterType =
|
|
362
|
+
let clusterType = chunkFTXIXM43_js.getClusterType(cluster);
|
|
508
363
|
return clusterType === "localnet" || clusterType === "custom" ? null : getChainIdFromClusterType(clusterType);
|
|
509
364
|
}
|
|
510
365
|
function getChainIdFromClusterId(clusterId) {
|
|
@@ -581,7 +436,7 @@ function getSolanaExplorerUrl(signature, options = {}) {
|
|
|
581
436
|
if (normalizedCluster === "localnet")
|
|
582
437
|
return `https://explorer.solana.com/tx/${signature}?cluster=custom&customUrl=${encodeURIComponent(customUrl || "http://localhost:8899")}`;
|
|
583
438
|
let explorerCluster = ["mainnet", "devnet", "testnet"].includes(normalizedCluster) ? normalizedCluster : "devnet";
|
|
584
|
-
return
|
|
439
|
+
return chunkDSUCH44G_js.getExplorerLink({
|
|
585
440
|
transaction: signature,
|
|
586
441
|
cluster: explorerCluster
|
|
587
442
|
});
|
|
@@ -643,21 +498,14 @@ Object.defineProperty(exports, "createSignableMessage", {
|
|
|
643
498
|
exports.EnhancedStorage = EnhancedStorage;
|
|
644
499
|
exports.EnhancedStorageAdapter = EnhancedStorageAdapter;
|
|
645
500
|
exports.SOLANA_CHAIN_IDS = SOLANA_CHAIN_IDS;
|
|
646
|
-
exports.base58ToSignatureBytes = base58ToSignatureBytes;
|
|
647
501
|
exports.chainIdToClusterId = chainIdToClusterId;
|
|
648
502
|
exports.chainIdToClusterType = chainIdToClusterType;
|
|
649
503
|
exports.clusterToChainId = clusterToChainId;
|
|
650
504
|
exports.copySignature = copySignature;
|
|
651
|
-
exports.createConfig = createConfig;
|
|
652
505
|
exports.createEnhancedStorageAccount = createEnhancedStorageAccount;
|
|
653
506
|
exports.createEnhancedStorageCluster = createEnhancedStorageCluster;
|
|
654
507
|
exports.createEnhancedStorageWallet = createEnhancedStorageWallet;
|
|
655
|
-
exports.createKitSignersFromWallet = createKitSignersFromWallet;
|
|
656
|
-
exports.createMessageSignerFromWallet = createMessageSignerFromWallet;
|
|
657
|
-
exports.createTransactionSendingSignerFromWallet = createTransactionSendingSignerFromWallet;
|
|
658
|
-
exports.detectMessageModification = detectMessageModification;
|
|
659
508
|
exports.formatSignature = formatSignature;
|
|
660
|
-
exports.freezeSigner = freezeSigner;
|
|
661
509
|
exports.getAllExplorerUrls = getAllExplorerUrls;
|
|
662
510
|
exports.getChainIdFromCluster = getChainIdFromCluster;
|
|
663
511
|
exports.getChainIdFromClusterId = getChainIdFromClusterId;
|
|
@@ -678,11 +526,10 @@ exports.isKitConnection = isKitConnection;
|
|
|
678
526
|
exports.isKnownSolanaChain = isKnownSolanaChain;
|
|
679
527
|
exports.isLegacyConnection = isLegacyConnection;
|
|
680
528
|
exports.isSolanaChain = isSolanaChain;
|
|
681
|
-
exports.isUnifiedConfig = isUnifiedConfig;
|
|
682
529
|
exports.isWalletName = isWalletName;
|
|
530
|
+
exports.parseConfigOptions = parseConfigOptions;
|
|
683
531
|
exports.sendRawTransaction = sendRawTransaction;
|
|
684
|
-
exports.
|
|
685
|
-
exports.updateSignatureDictionary = updateSignatureDictionary;
|
|
532
|
+
exports.validateConfigOptions = validateConfigOptions;
|
|
686
533
|
exports.validateKnownSolanaChain = validateKnownSolanaChain;
|
|
687
|
-
//# sourceMappingURL=chunk-
|
|
688
|
-
//# sourceMappingURL=chunk-
|
|
534
|
+
//# sourceMappingURL=chunk-AOIXHVRH.js.map
|
|
535
|
+
//# sourceMappingURL=chunk-AOIXHVRH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/wallet/enhanced-storage.ts","../src/config/default-config.ts","../src/config/schemas.ts","../src/types/wallets.ts","../src/lib/connection/types.ts","../src/lib/connection/helpers.ts","../src/utils/chain.ts","../src/lib/utils/explorer-urls.ts"],"names":["createLogger","WalletUiStorage","__publicField","logger","DEFAULT_MAX_RETRIES","createSolanaMainnet","createSolanaDevnet","createSolanaTestnet","createSolanaLocalnet","address","isAddress","toClusterId","z","getClusterType","getExplorerLink"],"mappings":";;;;;;;;;AAeA,IAAM,MAAA,GAASA,8BAAa,iBAAiB,CAAA,CAAA,CAMhC,kBAAkB,IAAA,CAAA,CAMlB,eAAA,GAAN,cAAiCC,YAAA,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,IAAAC,8BAAA,CAAA,IAAA,EAAQ,eAAA,sBAAiD,GAAA,EAAI,CAAA;AAC7D,IAAAA,8BAAA,CAAA,IAAA,EAAQ,cAAwC,EAAC,CAAA;AACjD,IAAAA,8BAAA,CAAA,IAAA,EAAQ,gBAAA,CAAA;AAQJ,IAAA,IAAA,CAAK,iBAAiB,OAAA,EAElB,OAAA,EAAS,OAAA,IACT,IAAA,CAAK,cAAc,GAAA,CAAI,OAAA,CAAQ,OAAO,CAAA,EAEtC,SAAS,SAAA,IACT,IAAA,CAAK,UAAA,CAAW,IAAA,CAAK,QAAQ,SAAS,CAAA;AAAA,EAE9C;AAAA,EAES,IAAI,KAAA,EAAmB;AAC5B,IAAA,IAAI;AACA,MAAA,OAAK,IAAA,CAAK,SAAS,KA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AS,YAAY,iBAAiB,CAAA,CAAA;AACzE;AAKO,SAAS,kBAAA,CAAmB,SAAA,EAAmB,OAAA,GAA2B,EAAC,EAAiC;AAC/G,EAAA,OAAO;AAAA,IACH,iBAAA,EAAmB,oBAAA,CAAqB,SAAA,EAAW,OAAO,CAAA;AAAA,IAC1D,OAAA,EAAS,aAAA,CAAc,SAAA,EAAW,OAAO,CAAA;AAAA,IACzC,IAAA,EAAM,WAAW,SAAS,CAAA;AAAA,IAC1B,WAAA,EAAa,cAAA,CAAe,SAAA,EAAW,OAAO;AAAA,GAClD;AACJ;AAKO,SAAS,eAAA,CAAgB,SAAA,EAAmB,KAAA,GAAQ,CAAA,EAAW;AAClE,EAAA,OAAI,UAAU,MAAA,IAAU,KAAA,GAAQ,CAAA,GAAU,SAAA,GACnC,GAAG,SAAA,CAAU,KAAA,CAAM,CAAA,EAAG,KAAK,CAAC,CAAA,GAAA,EAAM,SAAA,CAAU,KAAA,CAAM,CAAC,KAAK,CAAC,CAAA,CAAA;AACpE;AAQA,eAAsB,cAAc,SAAA,EAAqC;AACrE,EAAA,IAAI;AACA,IAAA,OAAA,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-AOIXHVRH.js","sourcesContent":["/**\n * Enhanced Storage\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 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 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 validate(value: T): boolean {\n return this.validators.every(validator => validator(value));\n }\n\n addValidator(validator: (value: T) => boolean): this {\n this.validators.push(validator);\n return this;\n }\n\n onError(handler: (error: Error) => void): this {\n this.errorHandlers.add(handler);\n return this;\n }\n\n transform<U>(transformer: (value: T) => U): U {\n return transformer(this.get());\n }\n\n reset(): void {\n this.set(this.initial);\n }\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 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 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\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\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\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\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, CoinGeckoConfig } 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/wallet/enhanced-storage';\nimport { toClusterId } from '../utils/network';\nimport type React from 'react';\nimport { isAddress } from '@solana/addresses';\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 * Image proxy URL prefix for token images.\n * When set, token image URLs will be transformed to: `${imageProxy}${encodeURIComponent(originalUrl)}`\n * This prevents direct image fetching which can leak user IPs to untrusted hosts.\n * @example '/_next/image?w=64&q=75&url=' // Next.js Image Optimization\n * @example '/cdn-cgi/image/width=64,quality=75/' // Cloudflare Image Resizing\n */\n imageProxy?: string;\n /**\n * Optional mapping from program IDs to human-readable program names.\n * Used to enrich transaction history (e.g. showing `Jupiter` instead of a raw program address).\n */\n programLabels?: Record<string, string>;\n /**\n * CoinGecko API configuration for token price fetching.\n * Configure API key for higher rate limits and retry behavior for 429 responses.\n * @see https://docs.coingecko.com/reference/introduction for rate limit details\n */\n coingecko?: CoinGeckoConfig;\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 * Image proxy URL prefix for token images.\n * When set, token image URLs will be transformed to: `${imageProxy}${encodeURIComponent(originalUrl)}`\n * This prevents direct image fetching which can leak user IPs to untrusted hosts.\n */\n imageProxy?: string;\n /**\n * Optional mapping from program IDs to human-readable program names.\n * Used to enrich transaction history (e.g. showing `Jupiter` instead of a raw program address).\n */\n programLabels?: Record<string, string>;\n /**\n * CoinGecko API configuration for token price fetching.\n */\n coingecko?: CoinGeckoConfig;\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 imageProxy,\n programLabels,\n coingecko,\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 imageProxy,\n programLabels,\n coingecko,\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 - Configuration Schemas\n *\n * Zod schemas for runtime validation of configuration options.\n * These schemas provide type-safe validation with helpful error messages.\n */\n\nimport { z } from 'zod/v4';\n\n// ============================================================================\n// Primitive Schemas\n// ============================================================================\n\n/**\n * Valid Solana network values\n */\nexport const solanaNetworkSchema = z.enum(['mainnet', 'mainnet-beta', 'devnet', 'testnet', 'localnet']);\n\n/**\n * Solana cluster ID format (e.g., 'solana:mainnet', 'solana:devnet')\n */\nexport const solanaClusterIdSchema = z.string().regex(/^solana:(mainnet|devnet|testnet|localnet|[a-zA-Z0-9-]+)$/, {\n message: 'Cluster ID must be in format \"solana:<network>\" (e.g., \"solana:mainnet\")',\n});\n\n/**\n * URL validation with protocol check\n */\nexport const urlSchema = z.string().url('Invalid URL format');\n\n/**\n * Optional URL that allows undefined\n */\nexport const optionalUrlSchema = urlSchema.optional();\n\n// ============================================================================\n// CoinGecko Configuration\n// ============================================================================\n\nexport const coinGeckoConfigSchema = z\n .strictObject({\n apiKey: z.string().optional(),\n isPro: z.boolean().optional(),\n maxRetries: z.number().int().positive().max(10).optional(),\n baseDelay: z.number().int().positive().max(30000).optional(),\n maxTimeout: z.number().int().positive().max(120000).optional(),\n })\n .optional();\n\n// ============================================================================\n// Storage Configuration\n// ============================================================================\n\n/**\n * Storage adapter interface schema (validates shape, not implementation)\n */\nexport const storageAdapterSchema = z.looseObject({\n get: z.custom<(...args: unknown[]) => unknown>(val => typeof val === 'function'),\n set: z.custom<(...args: unknown[]) => unknown>(val => typeof val === 'function'),\n});\n\nexport const storageConfigSchema = z\n .object({\n account: storageAdapterSchema,\n cluster: storageAdapterSchema,\n wallet: storageAdapterSchema,\n })\n .optional();\n\n// ============================================================================\n// Cluster Configuration\n// ============================================================================\n\n/**\n * SolanaCluster object schema\n */\nexport const solanaClusterSchema = z.object({\n id: solanaClusterIdSchema,\n label: z.string().min(1, 'Cluster label cannot be empty'),\n url: urlSchema,\n urlWs: urlSchema.optional(),\n});\n\nexport const clusterConfigSchema = z\n .object({\n clusters: z.array(solanaClusterSchema).optional(),\n persistSelection: z.boolean().optional(),\n initialCluster: solanaClusterIdSchema.optional(),\n })\n .optional();\n\n// ============================================================================\n// Default Config Options\n// ============================================================================\n\nexport const defaultConfigOptionsSchema = z.object({\n // Required\n appName: z.string().min(1, 'Application name is required'),\n\n // Optional strings\n appUrl: optionalUrlSchema,\n imageProxy: z.string().optional(),\n clusterStorageKey: z.string().optional(),\n\n // Optional booleans\n autoConnect: z.boolean().optional(),\n debug: z.boolean().optional(),\n enableMobile: z.boolean().optional(),\n persistClusterSelection: z.boolean().optional(),\n enableErrorBoundary: z.boolean().optional(),\n\n // Network\n network: solanaNetworkSchema.optional(),\n\n // Numbers\n maxRetries: z.number().int().positive().max(10).optional(),\n\n // Complex types\n storage: storageConfigSchema,\n clusters: z.array(solanaClusterSchema).optional(),\n customClusters: z.array(solanaClusterSchema).optional(),\n programLabels: z.record(z.string(), z.string()).optional(),\n coingecko: coinGeckoConfigSchema,\n\n // Functions (can't validate implementation, just existence)\n onError: z.custom<(...args: unknown[]) => unknown>(val => typeof val === 'function').optional(),\n});\n\n// ============================================================================\n// Connector Config (for ConnectorClient)\n// ============================================================================\n\nexport const connectorConfigSchema = z\n .strictObject({\n autoConnect: z.boolean().optional(),\n debug: z.boolean().optional(),\n storage: storageConfigSchema,\n cluster: clusterConfigSchema,\n imageProxy: z.string().optional(),\n programLabels: z.record(z.string(), z.string()).optional(),\n coingecko: coinGeckoConfigSchema,\n })\n .optional();\n\n// ============================================================================\n// Type Exports (inferred from schemas)\n// ============================================================================\n\nexport type SolanaNetworkInput = z.input<typeof solanaNetworkSchema>;\nexport type SolanaClusterIdInput = z.input<typeof solanaClusterIdSchema>;\nexport type CoinGeckoConfigInput = z.input<typeof coinGeckoConfigSchema>;\nexport type DefaultConfigOptionsInput = z.input<typeof defaultConfigOptionsSchema>;\n\n// ============================================================================\n// Validation Helpers\n// ============================================================================\n\n/**\n * Validate configuration options and return a result with helpful errors\n *\n * @example\n * ```ts\n * const result = validateConfigOptions({\n * appName: 'My App',\n * network: 'mainnet',\n * });\n *\n * if (!result.success) {\n * console.error('Config validation failed:', result.error.format());\n * }\n * ```\n */\nexport function validateConfigOptions(options: unknown): z.ZodSafeParseResult<DefaultConfigOptionsInput> {\n return defaultConfigOptionsSchema.safeParse(options);\n}\n\n/**\n * Parse and validate config options, throwing on error with formatted message\n *\n * @throws {z.ZodError} If validation fails\n *\n * @example\n * ```ts\n * try {\n * const validOptions = parseConfigOptions(userInput);\n * // validOptions is typed and validated\n * } catch (error) {\n * if (error instanceof z.ZodError) {\n * console.error(error.format());\n * }\n * }\n * ```\n */\nexport function parseConfigOptions(options: unknown): DefaultConfigOptionsInput {\n return defaultConfigOptionsSchema.parse(options);\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 '@solana/addresses' 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 '@solana/addresses' 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","import type { Connection } from '@solana/web3.js';\n\nexport type Commitment = 'processed' | 'confirmed' | 'finalized';\n\nexport interface KitSendTransactionOptions {\n commitment?: Commitment;\n skipPreflight?: boolean;\n maxRetries?: number;\n}\n\nexport type KitRpc = {\n getLatestBlockhash(options?: { commitment?: Commitment }): {\n send(): Promise<{ value: { blockhash: string; lastValidBlockHeight: number } }>;\n };\n sendTransaction(\n bytes: Uint8Array | string,\n options?: KitSendTransactionOptions,\n ): {\n send(): Promise<string>;\n };\n send?: () => unknown;\n};\n\nexport type DualConnection = Connection | KitRpc;\n\nexport function isLegacyConnection(conn: DualConnection): conn is Connection {\n return 'rpcEndpoint' in conn && typeof (conn as Connection).rpcEndpoint === 'string';\n}\n\nexport function isKitConnection(conn: DualConnection): conn is KitRpc {\n if ('rpcEndpoint' in conn) {\n return false;\n }\n\n const asKitRpc = conn as KitRpc;\n return typeof asKitRpc.getLatestBlockhash === 'function' && typeof asKitRpc.sendTransaction === 'function';\n}\n","/**\n * @solana/connector - Connection Helpers\n *\n * Abstraction layer for working with both legacy @solana/web3.js Connection\n * and modern Kit/gill Rpc objects.\n */\n\nimport type { SendOptions } from '@solana/web3.js';\nimport type { DualConnection, Commitment, KitRpc } from './types';\nimport { isLegacyConnection, isKitConnection } from './types';\n\n/**\n * Get latest blockhash from either legacy Connection or Kit Rpc\n *\n * Abstracts the differences between web3.js 1.x and Kit/gill APIs.\n *\n * @param connection - Legacy Connection or Kit Rpc\n * @param commitment - Optional commitment level (default: 'confirmed')\n * @returns Latest blockhash and last valid block height\n *\n * @example\n * ```typescript\n * // Works with both Connection and Rpc\n * const { blockhash, lastValidBlockHeight } = await getLatestBlockhash(connection);\n * ```\n */\nexport async function getLatestBlockhash(\n connection: DualConnection,\n commitment: Commitment = 'confirmed',\n): Promise<{ blockhash: string; lastValidBlockHeight: number }> {\n if (isLegacyConnection(connection)) {\n // Legacy Connection API\n return await connection.getLatestBlockhash(commitment);\n }\n\n if (isKitConnection(connection)) {\n // Kit/gill Rpc API - returns { value: { blockhash, lastValidBlockHeight } }\n const rpc = connection as KitRpc;\n const result = await rpc.getLatestBlockhash({ commitment }).send();\n return result.value;\n }\n\n throw new Error('Unsupported connection type');\n}\n\n/**\n * Send raw transaction bytes to either legacy Connection or Kit Rpc\n *\n * Abstracts the differences between web3.js 1.x and Kit/gill APIs.\n *\n * @param connection - Legacy Connection or Kit Rpc\n * @param bytes - Raw transaction bytes\n * @param options - Optional send options (skipPreflight, maxRetries, etc.)\n * @returns Transaction signature string\n *\n * @example\n * ```typescript\n * // Works with both Connection and Rpc\n * const signature = await sendRawTransaction(connection, transactionBytes, {\n * skipPreflight: false,\n * maxRetries: 3\n * });\n * ```\n */\nexport async function sendRawTransaction(\n connection: DualConnection,\n bytes: Uint8Array,\n options?: SendOptions & { commitment?: Commitment },\n): Promise<string> {\n if (isLegacyConnection(connection)) {\n // Legacy Connection API\n return await connection.sendRawTransaction(bytes, options);\n }\n\n if (isKitConnection(connection)) {\n // Kit/gill Rpc API\n // Note: gill's sendTransaction expects different options format\n const rpc = connection as KitRpc;\n // Convert Uint8Array to base64 string\n const base64String = Buffer.from(bytes).toString('base64');\n const result = await rpc\n .sendTransaction(base64String as Uint8Array | string, {\n ...(options?.commitment ? { commitment: options.commitment } : {}),\n ...(options?.skipPreflight !== undefined ? { skipPreflight: options.skipPreflight } : {}),\n ...(options?.maxRetries !== undefined ? { maxRetries: options.maxRetries } : {}),\n })\n .send();\n\n // Kit Rpc returns signature string directly\n return result;\n }\n\n throw new Error('Unsupported connection type');\n}\n","import type { SolanaCluster, SolanaClusterId } from '@wallet-ui/core';\nimport type { Connection } from '@solana/web3.js';\nimport type { ClusterType } from './cluster';\nimport { getClusterType, isMainnetCluster, isDevnetCluster, isTestnetCluster } from './cluster';\n\nexport const SOLANA_CHAIN_IDS = {\n mainnet: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',\n devnet: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1',\n testnet: 'solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z',\n} as const;\n\nconst CHAIN_ID_TO_CLUSTER_TYPE: Record<string, ClusterType> = {\n [SOLANA_CHAIN_IDS.mainnet]: 'mainnet',\n [SOLANA_CHAIN_IDS.devnet]: 'devnet',\n [SOLANA_CHAIN_IDS.testnet]: 'testnet',\n};\n\nconst CLUSTER_ID_TO_CHAIN_ID: Partial<Record<SolanaClusterId, string>> = {\n 'solana:mainnet': SOLANA_CHAIN_IDS.mainnet,\n 'solana:mainnet-beta': SOLANA_CHAIN_IDS.mainnet,\n 'solana:devnet': SOLANA_CHAIN_IDS.devnet,\n 'solana:testnet': SOLANA_CHAIN_IDS.testnet,\n};\n\nexport function getChainIdFromCluster(cluster: SolanaCluster): `solana:${string}` | null {\n const clusterType = getClusterType(cluster);\n\n if (clusterType === 'localnet' || clusterType === 'custom') {\n return null;\n }\n\n return getChainIdFromClusterType(clusterType);\n}\n\nexport function getChainIdFromClusterId(clusterId: SolanaClusterId): `solana:${string}` | null {\n return (CLUSTER_ID_TO_CHAIN_ID[clusterId] as `solana:${string}` | undefined) || null;\n}\n\nexport function getChainIdFromClusterType(type: ClusterType): `solana:${string}` | null {\n switch (type) {\n case 'mainnet':\n return SOLANA_CHAIN_IDS.mainnet;\n case 'devnet':\n return SOLANA_CHAIN_IDS.devnet;\n case 'testnet':\n return SOLANA_CHAIN_IDS.testnet;\n case 'localnet':\n case 'custom':\n return null;\n }\n}\n\nexport function getClusterTypeFromChainId(chainId: string): ClusterType | null {\n return CHAIN_ID_TO_CLUSTER_TYPE[chainId] || null;\n}\n\nexport function getClusterIdFromChainId(chainId: string): SolanaClusterId | null {\n const clusterType = getClusterTypeFromChainId(chainId);\n if (!clusterType) {\n return null;\n }\n\n switch (clusterType) {\n case 'mainnet':\n return 'solana:mainnet';\n case 'devnet':\n return 'solana:devnet';\n case 'testnet':\n return 'solana:testnet';\n default:\n return null;\n }\n}\n\nexport function isSolanaChain(chain: string): chain is `solana:${string}` {\n return chain.startsWith('solana:');\n}\n\nexport function isKnownSolanaChain(chain: string): boolean {\n return (\n chain === SOLANA_CHAIN_IDS.mainnet || chain === SOLANA_CHAIN_IDS.devnet || chain === SOLANA_CHAIN_IDS.testnet\n );\n}\n\nexport function validateKnownSolanaChain(chain: string): asserts chain is `solana:${string}` {\n if (!isSolanaChain(chain)) {\n throw new Error(`Invalid chain format: expected 'solana:...', got '${chain}'`);\n }\n\n if (!isKnownSolanaChain(chain)) {\n throw new Error(`Unknown Solana chain: ${chain}. Known chains: ${Object.values(SOLANA_CHAIN_IDS).join(', ')}`);\n }\n}\n\nexport function getClusterTypeFromConnection(connection: Connection | null): ClusterType | null {\n if (!connection) {\n return null;\n }\n\n const rpcUrl = connection.rpcEndpoint || '';\n\n if (rpcUrl.includes('mainnet') || rpcUrl.includes('api.mainnet-beta')) {\n return 'mainnet';\n }\n\n if (rpcUrl.includes('testnet')) {\n return 'testnet';\n }\n\n if (rpcUrl.includes('devnet')) {\n return 'devnet';\n }\n\n if (rpcUrl.includes('localhost') || rpcUrl.includes('127.0.0.1')) {\n return 'localnet';\n }\n\n return 'custom';\n}\n\nexport function getChainIdFromConnection(\n connection: Connection | null,\n network?: 'mainnet' | 'devnet' | 'testnet',\n): `solana:${string}` | null {\n if (network) {\n return getChainIdFromClusterType(network);\n }\n\n const clusterType = getClusterTypeFromConnection(connection);\n if (!clusterType) {\n return null;\n }\n\n return getChainIdFromClusterType(clusterType);\n}\n\nexport function clusterToChainId(cluster: SolanaCluster): `solana:${string}` | null {\n return getChainIdFromCluster(cluster);\n}\n\nexport function chainIdToClusterType(chainId: string): ClusterType | null {\n return getClusterTypeFromChainId(chainId);\n}\n\nexport function chainIdToClusterId(chainId: string): SolanaClusterId | null {\n return getClusterIdFromChainId(chainId);\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 '../kit';\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"]}
|