@solana/connector 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-52WUWW5R.mjs → chunk-4K6QY4HR.mjs} +60 -174
- package/dist/chunk-4K6QY4HR.mjs.map +1 -0
- package/dist/{chunk-7TADXRFD.mjs → chunk-F2QJH5ED.mjs} +3 -3
- package/dist/chunk-F2QJH5ED.mjs.map +1 -0
- package/dist/chunk-JS4KJ2KK.js +706 -0
- package/dist/chunk-JS4KJ2KK.js.map +1 -0
- package/dist/{chunk-ZLPQUOFK.js → chunk-RIBOPAOD.js} +61 -173
- package/dist/chunk-RIBOPAOD.js.map +1 -0
- package/dist/{chunk-SGAIPK7Q.js → chunk-SJEZHNYF.js} +11 -11
- package/dist/chunk-SJEZHNYF.js.map +1 -0
- package/dist/chunk-WXYUUCSD.mjs +635 -0
- package/dist/chunk-WXYUUCSD.mjs.map +1 -0
- package/dist/compat.d.mts +1 -60
- package/dist/compat.d.ts +1 -60
- package/dist/compat.js.map +1 -1
- package/dist/compat.mjs.map +1 -1
- package/dist/headless.d.mts +222 -107
- package/dist/headless.d.ts +222 -107
- package/dist/headless.js +201 -81
- package/dist/headless.mjs +2 -2
- package/dist/index.d.mts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +216 -96
- package/dist/index.mjs +3 -3
- package/dist/react.d.mts +5 -154
- package/dist/react.d.ts +5 -154
- package/dist/react.js +16 -16
- package/dist/react.mjs +2 -2
- package/dist/{transaction-signer-BtJPGXIg.d.ts → transaction-signer-D3csM_Mf.d.mts} +1 -175
- package/dist/{transaction-signer-BtJPGXIg.d.mts → transaction-signer-D3csM_Mf.d.ts} +1 -175
- package/dist/{wallet-standard-shim-BGlvGRbB.d.ts → wallet-standard-shim-C1tisl9S.d.ts} +5 -169
- package/dist/{wallet-standard-shim-Af7ejSld.d.mts → wallet-standard-shim-Cg0GVGwu.d.mts} +5 -169
- package/package.json +7 -1
- package/dist/chunk-52WUWW5R.mjs.map +0 -1
- package/dist/chunk-5NSUFMCB.js +0 -393
- package/dist/chunk-5NSUFMCB.js.map +0 -1
- package/dist/chunk-7TADXRFD.mjs.map +0 -1
- package/dist/chunk-ACFSCMUI.mjs +0 -359
- package/dist/chunk-ACFSCMUI.mjs.map +0 -1
- package/dist/chunk-SGAIPK7Q.js.map +0 -1
- package/dist/chunk-ZLPQUOFK.js.map +0 -1
|
@@ -53,23 +53,11 @@ function getWalletsRegistry() {
|
|
|
53
53
|
var ConnectorError = class extends Error {
|
|
54
54
|
constructor(message, context, originalError) {
|
|
55
55
|
super(message);
|
|
56
|
-
/**
|
|
57
|
-
* Additional context about the error
|
|
58
|
-
*/
|
|
59
56
|
chunkSMUUAKC3_js.__publicField(this, "context");
|
|
60
|
-
/**
|
|
61
|
-
* The underlying error that caused this error
|
|
62
|
-
*/
|
|
63
57
|
chunkSMUUAKC3_js.__publicField(this, "originalError");
|
|
64
|
-
/**
|
|
65
|
-
* Timestamp when error occurred
|
|
66
|
-
*/
|
|
67
58
|
chunkSMUUAKC3_js.__publicField(this, "timestamp");
|
|
68
59
|
this.name = this.constructor.name, this.context = context, this.originalError = originalError, this.timestamp = (/* @__PURE__ */ new Date()).toISOString(), Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
69
60
|
}
|
|
70
|
-
/**
|
|
71
|
-
* Get a JSON representation of the error
|
|
72
|
-
*/
|
|
73
61
|
toJSON() {
|
|
74
62
|
return {
|
|
75
63
|
name: this.name,
|
|
@@ -136,21 +124,13 @@ function isTransactionError(error) {
|
|
|
136
124
|
return error instanceof TransactionError;
|
|
137
125
|
}
|
|
138
126
|
var Errors = {
|
|
139
|
-
// Connection errors
|
|
140
127
|
walletNotConnected: (context) => new ConnectionError("WALLET_NOT_CONNECTED", "No wallet connected", context),
|
|
141
|
-
walletNotFound: (walletName) => new ConnectionError("WALLET_NOT_FOUND", `Wallet not found${walletName ? `: ${walletName}` : ""}`, {
|
|
142
|
-
walletName
|
|
143
|
-
}),
|
|
128
|
+
walletNotFound: (walletName) => new ConnectionError("WALLET_NOT_FOUND", `Wallet not found${walletName ? `: ${walletName}` : ""}`, { walletName }),
|
|
144
129
|
connectionFailed: (originalError) => new ConnectionError("CONNECTION_FAILED", "Failed to connect to wallet", void 0, originalError),
|
|
145
130
|
accountNotAvailable: (address) => new ConnectionError("ACCOUNT_NOT_AVAILABLE", "Requested account not available", { address }),
|
|
146
|
-
// Validation errors
|
|
147
131
|
invalidTransaction: (reason, context) => new ValidationError("INVALID_TRANSACTION", `Invalid transaction: ${reason}`, context),
|
|
148
|
-
invalidFormat: (expectedFormat, actualFormat) => new ValidationError("INVALID_FORMAT", `Invalid format: expected ${expectedFormat}`, {
|
|
149
|
-
expectedFormat,
|
|
150
|
-
actualFormat
|
|
151
|
-
}),
|
|
132
|
+
invalidFormat: (expectedFormat, actualFormat) => new ValidationError("INVALID_FORMAT", `Invalid format: expected ${expectedFormat}`, { expectedFormat, actualFormat }),
|
|
152
133
|
unsupportedFormat: (format) => new ValidationError("UNSUPPORTED_FORMAT", `Unsupported format: ${format}`, { format }),
|
|
153
|
-
// Configuration errors
|
|
154
134
|
missingProvider: (hookName) => new ConfigurationError(
|
|
155
135
|
"MISSING_PROVIDER",
|
|
156
136
|
`${hookName} must be used within ConnectorProvider. Wrap your app with <ConnectorProvider> or <UnifiedProvider>.`,
|
|
@@ -161,10 +141,8 @@ var Errors = {
|
|
|
161
141
|
`Cluster ${clusterId} not found. Available clusters: ${availableClusters.join(", ")}`,
|
|
162
142
|
{ clusterId, availableClusters }
|
|
163
143
|
),
|
|
164
|
-
// Network errors
|
|
165
144
|
rpcError: (message, originalError) => new NetworkError("RPC_ERROR", message, void 0, originalError),
|
|
166
145
|
networkTimeout: () => new NetworkError("NETWORK_TIMEOUT", "Network request timed out"),
|
|
167
|
-
// Transaction errors
|
|
168
146
|
signingFailed: (originalError) => new TransactionError("SIGNING_FAILED", "Failed to sign transaction", void 0, originalError),
|
|
169
147
|
featureNotSupported: (feature) => new TransactionError("FEATURE_NOT_SUPPORTED", `Wallet does not support ${feature}`, { feature }),
|
|
170
148
|
userRejected: (operation) => new TransactionError("USER_REJECTED", `User rejected ${operation}`, { operation })
|
|
@@ -242,27 +220,28 @@ function getNetworkDisplayName(network) {
|
|
|
242
220
|
return normalized.charAt(0).toUpperCase() + normalized.slice(1);
|
|
243
221
|
}
|
|
244
222
|
function getClusterRpcUrl(cluster) {
|
|
245
|
-
if (
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
223
|
+
if (typeof cluster == "string") {
|
|
224
|
+
let presets2 = {
|
|
225
|
+
...PUBLIC_RPC_ENDPOINTS,
|
|
226
|
+
"mainnet-beta": PUBLIC_RPC_ENDPOINTS.mainnet
|
|
227
|
+
};
|
|
228
|
+
if (presets2[cluster])
|
|
229
|
+
return presets2[cluster];
|
|
230
|
+
throw new Error(`Unknown cluster: ${cluster}`);
|
|
231
|
+
}
|
|
232
|
+
let url = cluster.url || cluster.rpcUrl;
|
|
233
|
+
if (!url)
|
|
234
|
+
throw new Error("Cluster URL is required");
|
|
235
|
+
if (url.startsWith("http://") || url.startsWith("https://"))
|
|
249
236
|
return url;
|
|
250
237
|
let presets = {
|
|
251
238
|
...PUBLIC_RPC_ENDPOINTS,
|
|
252
239
|
"mainnet-beta": PUBLIC_RPC_ENDPOINTS.mainnet
|
|
253
240
|
};
|
|
254
|
-
|
|
255
|
-
return presets[url];
|
|
256
|
-
if (!url || url === "[object Object]")
|
|
257
|
-
throw new Error(
|
|
258
|
-
`Invalid cluster configuration: unable to determine RPC URL for cluster ${cluster?.id ?? "unknown"}`
|
|
259
|
-
);
|
|
260
|
-
return url;
|
|
241
|
+
return presets[url] ? presets[url] : url;
|
|
261
242
|
}
|
|
262
243
|
function getClusterExplorerUrl(cluster, path) {
|
|
263
|
-
|
|
264
|
-
return path ? `https://explorer.solana.com/${path}?cluster=devnet` : "https://explorer.solana.com?cluster=devnet";
|
|
265
|
-
let parts = cluster.id.split(":"), clusterSegment = parts.length >= 2 && parts[1] ? parts[1] : "devnet", isMainnet2 = cluster.id === "solana:mainnet" || cluster.id === "solana:mainnet-beta" || clusterSegment === "mainnet" || clusterSegment === "mainnet-beta", base = isMainnet2 ? "https://explorer.solana.com" : `https://explorer.solana.com?cluster=${clusterSegment}`;
|
|
244
|
+
let clusterSegment = cluster.id.split(":")[1] || "devnet", isMainnet2 = cluster.id === "solana:mainnet" || cluster.id === "solana:mainnet-beta", base = isMainnet2 ? "https://explorer.solana.com" : `https://explorer.solana.com?cluster=${clusterSegment}`;
|
|
266
245
|
return path ? isMainnet2 ? `https://explorer.solana.com/${path}` : `https://explorer.solana.com/${path}?cluster=${clusterSegment}` : base;
|
|
267
246
|
}
|
|
268
247
|
function getTransactionUrl(signature, cluster) {
|
|
@@ -295,19 +274,40 @@ function isTestnetCluster(cluster) {
|
|
|
295
274
|
return cluster.id === "solana:testnet";
|
|
296
275
|
}
|
|
297
276
|
function isLocalCluster(cluster) {
|
|
298
|
-
let url =
|
|
299
|
-
return
|
|
277
|
+
let url = cluster.url || cluster.rpcUrl;
|
|
278
|
+
return url ? cluster.id === "solana:localnet" || url.includes("localhost") || url.includes("127.0.0.1") : cluster.id === "solana:localnet";
|
|
300
279
|
}
|
|
301
280
|
function getClusterName(cluster) {
|
|
302
281
|
if (cluster.label) return cluster.label;
|
|
303
|
-
if (
|
|
304
|
-
return cluster.name;
|
|
282
|
+
if (cluster.name) return cluster.name;
|
|
305
283
|
let parts = cluster.id.split(":");
|
|
306
|
-
|
|
284
|
+
if (parts.length >= 2 && parts[1]) {
|
|
285
|
+
let name = parts.slice(1).join(":");
|
|
286
|
+
return name.charAt(0).toUpperCase() + name.slice(1).replace(/-/g, " ");
|
|
287
|
+
}
|
|
288
|
+
return "Unknown";
|
|
307
289
|
}
|
|
308
290
|
function getClusterType(cluster) {
|
|
309
291
|
return isMainnetCluster(cluster) ? "mainnet" : isDevnetCluster(cluster) ? "devnet" : isTestnetCluster(cluster) ? "testnet" : isLocalCluster(cluster) ? "localnet" : "custom";
|
|
310
292
|
}
|
|
293
|
+
function getClusterChainId(cluster) {
|
|
294
|
+
let clusterType = getClusterType(cluster);
|
|
295
|
+
if (clusterType === "localnet" || clusterType === "custom")
|
|
296
|
+
return null;
|
|
297
|
+
switch (clusterType) {
|
|
298
|
+
case "mainnet":
|
|
299
|
+
return "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
300
|
+
case "devnet":
|
|
301
|
+
return "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1";
|
|
302
|
+
case "testnet":
|
|
303
|
+
return "solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z";
|
|
304
|
+
default:
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
function getChainIdForWalletStandard(cluster) {
|
|
309
|
+
return getClusterChainId(cluster);
|
|
310
|
+
}
|
|
311
311
|
|
|
312
312
|
// src/lib/constants.ts
|
|
313
313
|
var POLL_INTERVALS_MS = [1e3, 2e3, 3e3, 5e3, 5e3], DEFAULT_MAX_RETRIES = 3, DEFAULT_MAX_TRACKED_TRANSACTIONS = 20;
|
|
@@ -844,7 +844,8 @@ var WalletDetector = class extends BaseCollaborator {
|
|
|
844
844
|
for (let unsubscribe of this.unsubscribers)
|
|
845
845
|
try {
|
|
846
846
|
unsubscribe();
|
|
847
|
-
} catch {
|
|
847
|
+
} catch (error) {
|
|
848
|
+
logger3.warn("Error during unsubscribe cleanup", { error });
|
|
848
849
|
}
|
|
849
850
|
this.unsubscribers = [];
|
|
850
851
|
}
|
|
@@ -900,11 +901,14 @@ var ConnectionManager = class extends BaseCollaborator {
|
|
|
900
901
|
selectedWallet: wallet.name,
|
|
901
902
|
selectedAccount: selected,
|
|
902
903
|
accountsCount: accounts.length
|
|
903
|
-
}), this.eventEmitter.emit({
|
|
904
|
+
}), selected ? this.eventEmitter.emit({
|
|
904
905
|
type: "wallet:connected",
|
|
905
906
|
wallet: name,
|
|
906
|
-
account: selected
|
|
907
|
+
account: selected,
|
|
907
908
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
909
|
+
}) : this.log("\u26A0\uFE0F Connection succeeded but no account available", {
|
|
910
|
+
wallet: wallet.name,
|
|
911
|
+
accountsCount: accounts.length
|
|
908
912
|
}), this.walletStorage && (!("isAvailable" in this.walletStorage) || typeof this.walletStorage.isAvailable != "function" || this.walletStorage.isAvailable() ? this.walletStorage.set(name) : this.log("Storage not available (private browsing?), skipping wallet persistence")), this.subscribeToWalletEvents();
|
|
909
913
|
} catch (e) {
|
|
910
914
|
let errorMessage = e instanceof Error ? e.message : String(e);
|
|
@@ -934,22 +938,11 @@ var ConnectionManager = class extends BaseCollaborator {
|
|
|
934
938
|
* Disconnect from wallet
|
|
935
939
|
*/
|
|
936
940
|
async disconnect() {
|
|
937
|
-
|
|
938
|
-
try {
|
|
939
|
-
this.walletChangeUnsub();
|
|
940
|
-
} catch {
|
|
941
|
-
}
|
|
942
|
-
this.walletChangeUnsub = null;
|
|
943
|
-
}
|
|
944
|
-
this.stopPollingWalletAccounts();
|
|
941
|
+
this.walletChangeUnsub && (this.walletChangeUnsub(), this.walletChangeUnsub = null), this.stopPollingWalletAccounts();
|
|
945
942
|
let wallet = this.getState().selectedWallet;
|
|
946
943
|
if (wallet) {
|
|
947
944
|
let disconnect = getDisconnectFeature(wallet);
|
|
948
|
-
|
|
949
|
-
try {
|
|
950
|
-
await disconnect();
|
|
951
|
-
} catch {
|
|
952
|
-
}
|
|
945
|
+
disconnect && await disconnect();
|
|
953
946
|
}
|
|
954
947
|
this.stateManager.updateState(
|
|
955
948
|
{
|
|
@@ -1004,14 +997,7 @@ var ConnectionManager = class extends BaseCollaborator {
|
|
|
1004
997
|
* Subscribe to wallet change events
|
|
1005
998
|
*/
|
|
1006
999
|
subscribeToWalletEvents() {
|
|
1007
|
-
|
|
1008
|
-
try {
|
|
1009
|
-
this.walletChangeUnsub();
|
|
1010
|
-
} catch {
|
|
1011
|
-
}
|
|
1012
|
-
this.walletChangeUnsub = null;
|
|
1013
|
-
}
|
|
1014
|
-
this.stopPollingWalletAccounts();
|
|
1000
|
+
this.walletChangeUnsub && (this.walletChangeUnsub(), this.walletChangeUnsub = null), this.stopPollingWalletAccounts();
|
|
1015
1001
|
let wallet = this.getState().selectedWallet;
|
|
1016
1002
|
if (!wallet) return;
|
|
1017
1003
|
let eventsOn = getEventsFeature(wallet);
|
|
@@ -1085,16 +1071,9 @@ var logger4 = chunkSMUUAKC3_js.createLogger("AutoConnector"), MIN_ADDRESS_LENGTH
|
|
|
1085
1071
|
chunkSMUUAKC3_js.__publicField(this, "debug");
|
|
1086
1072
|
this.walletDetector = walletDetector, this.connectionManager = connectionManager, this.stateManager = stateManager, this.walletStorage = walletStorage, this.debug = debug;
|
|
1087
1073
|
}
|
|
1088
|
-
/**
|
|
1089
|
-
* Attempt auto-connection using both instant and fallback strategies
|
|
1090
|
-
*/
|
|
1091
1074
|
async attemptAutoConnect() {
|
|
1092
1075
|
return await this.attemptInstantConnect() ? true : (await this.attemptStandardConnect(), this.stateManager.getSnapshot().connected);
|
|
1093
1076
|
}
|
|
1094
|
-
/**
|
|
1095
|
-
* Attempt instant auto-connection using direct wallet detection
|
|
1096
|
-
* Bypasses wallet standard initialization for maximum speed
|
|
1097
|
-
*/
|
|
1098
1077
|
async attemptInstantConnect() {
|
|
1099
1078
|
let storedWalletName = this.walletStorage?.get();
|
|
1100
1079
|
if (!storedWalletName) return false;
|
|
@@ -1153,13 +1132,13 @@ var logger4 = chunkSMUUAKC3_js.createLogger("AutoConnector"), MIN_ADDRESS_LENGTH
|
|
|
1153
1132
|
}
|
|
1154
1133
|
if (directWallet.signTransaction) {
|
|
1155
1134
|
let signTransactionFn = directWallet.signTransaction;
|
|
1156
|
-
features["
|
|
1135
|
+
features["solana:signTransaction"] = {
|
|
1157
1136
|
signTransaction: (tx) => signTransactionFn.call(directWallet, tx)
|
|
1158
1137
|
};
|
|
1159
1138
|
}
|
|
1160
1139
|
if (directWallet.signMessage) {
|
|
1161
1140
|
let signMessageFn = directWallet.signMessage;
|
|
1162
|
-
features["
|
|
1141
|
+
features["solana:signMessage"] = {
|
|
1163
1142
|
signMessage: (...args) => {
|
|
1164
1143
|
let msg = args[0];
|
|
1165
1144
|
return signMessageFn.call(directWallet, msg);
|
|
@@ -1205,9 +1184,6 @@ var logger4 = chunkSMUUAKC3_js.createLogger("AutoConnector"), MIN_ADDRESS_LENGTH
|
|
|
1205
1184
|
}), false;
|
|
1206
1185
|
}
|
|
1207
1186
|
}
|
|
1208
|
-
/**
|
|
1209
|
-
* Attempt auto-connection via standard wallet detection (fallback)
|
|
1210
|
-
*/
|
|
1211
1187
|
async attemptStandardConnect() {
|
|
1212
1188
|
try {
|
|
1213
1189
|
if (this.stateManager.getSnapshot().connected) {
|
|
@@ -1288,10 +1264,10 @@ var TransactionTracker = class extends BaseCollaborator {
|
|
|
1288
1264
|
* Track a transaction for debugging and monitoring
|
|
1289
1265
|
*/
|
|
1290
1266
|
trackTransaction(activity) {
|
|
1291
|
-
let
|
|
1267
|
+
let clusterId = this.getState().cluster?.id || "solana:devnet", fullActivity = {
|
|
1292
1268
|
...activity,
|
|
1293
1269
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1294
|
-
cluster:
|
|
1270
|
+
cluster: clusterId
|
|
1295
1271
|
};
|
|
1296
1272
|
this.transactions.unshift(fullActivity), this.transactions.length > this.maxTransactions && this.transactions.pop(), this.totalTransactions++, this.eventEmitter.emit({
|
|
1297
1273
|
type: "transaction:tracked",
|
|
@@ -1443,9 +1419,6 @@ var logger5 = chunkSMUUAKC3_js.createLogger("ConnectorClient"), ConnectorClient
|
|
|
1443
1419
|
() => this.initialized
|
|
1444
1420
|
), this.initialize();
|
|
1445
1421
|
}
|
|
1446
|
-
/**
|
|
1447
|
-
* Initialize the connector
|
|
1448
|
-
*/
|
|
1449
1422
|
initialize() {
|
|
1450
1423
|
if (!(typeof window > "u") && !this.initialized)
|
|
1451
1424
|
try {
|
|
@@ -1458,51 +1431,26 @@ var logger5 = chunkSMUUAKC3_js.createLogger("ConnectorClient"), ConnectorClient
|
|
|
1458
1431
|
this.config.debug && logger5.error("Connector initialization failed", { error: e });
|
|
1459
1432
|
}
|
|
1460
1433
|
}
|
|
1461
|
-
// ============================================================================
|
|
1462
|
-
// Public API - Delegates to collaborators
|
|
1463
|
-
// ============================================================================
|
|
1464
|
-
/**
|
|
1465
|
-
* Connect to a wallet by name
|
|
1466
|
-
*/
|
|
1467
1434
|
async select(walletName) {
|
|
1468
1435
|
let wallet = this.stateManager.getSnapshot().wallets.find((w) => w.wallet.name === walletName)?.wallet;
|
|
1469
1436
|
if (!wallet) throw new Error(`Wallet ${walletName} not found`);
|
|
1470
1437
|
await this.connectionManager.connect(wallet, walletName);
|
|
1471
1438
|
}
|
|
1472
|
-
/**
|
|
1473
|
-
* Disconnect from the current wallet
|
|
1474
|
-
*/
|
|
1475
1439
|
async disconnect() {
|
|
1476
1440
|
await this.connectionManager.disconnect();
|
|
1477
1441
|
}
|
|
1478
|
-
/**
|
|
1479
|
-
* Select a different account
|
|
1480
|
-
*/
|
|
1481
1442
|
async selectAccount(address) {
|
|
1482
1443
|
await this.connectionManager.selectAccount(address);
|
|
1483
1444
|
}
|
|
1484
|
-
/**
|
|
1485
|
-
* Set the active cluster (network)
|
|
1486
|
-
*/
|
|
1487
1445
|
async setCluster(clusterId) {
|
|
1488
1446
|
await this.clusterManager.setCluster(clusterId);
|
|
1489
1447
|
}
|
|
1490
|
-
/**
|
|
1491
|
-
* Get the currently active cluster
|
|
1492
|
-
*/
|
|
1493
1448
|
getCluster() {
|
|
1494
1449
|
return this.clusterManager.getCluster();
|
|
1495
1450
|
}
|
|
1496
|
-
/**
|
|
1497
|
-
* Get all available clusters
|
|
1498
|
-
*/
|
|
1499
1451
|
getClusters() {
|
|
1500
1452
|
return this.clusterManager.getClusters();
|
|
1501
1453
|
}
|
|
1502
|
-
/**
|
|
1503
|
-
* Get the RPC URL for the current cluster
|
|
1504
|
-
* @returns RPC URL or null if no cluster is selected
|
|
1505
|
-
*/
|
|
1506
1454
|
getRpcUrl() {
|
|
1507
1455
|
let cluster = this.clusterManager.getCluster();
|
|
1508
1456
|
if (!cluster) return null;
|
|
@@ -1512,36 +1460,12 @@ var logger5 = chunkSMUUAKC3_js.createLogger("ConnectorClient"), ConnectorClient
|
|
|
1512
1460
|
return this.config.debug && logger5.error("Failed to get RPC URL", { error }), null;
|
|
1513
1461
|
}
|
|
1514
1462
|
}
|
|
1515
|
-
/**
|
|
1516
|
-
* Subscribe to state changes
|
|
1517
|
-
*/
|
|
1518
1463
|
subscribe(listener) {
|
|
1519
1464
|
return this.stateManager.subscribe(listener);
|
|
1520
1465
|
}
|
|
1521
|
-
/**
|
|
1522
|
-
* Get current state snapshot
|
|
1523
|
-
*/
|
|
1524
1466
|
getSnapshot() {
|
|
1525
1467
|
return this.stateManager.getSnapshot();
|
|
1526
1468
|
}
|
|
1527
|
-
/**
|
|
1528
|
-
* Reset all storage to initial values
|
|
1529
|
-
* Useful for "logout", "forget this device", or clearing user data
|
|
1530
|
-
*
|
|
1531
|
-
* This will:
|
|
1532
|
-
* - Clear saved wallet name
|
|
1533
|
-
* - Clear saved account address
|
|
1534
|
-
* - Reset cluster to initial value (does not clear)
|
|
1535
|
-
*
|
|
1536
|
-
* Note: This does NOT disconnect the wallet. Call disconnect() separately if needed.
|
|
1537
|
-
*
|
|
1538
|
-
* @example
|
|
1539
|
-
* ```ts
|
|
1540
|
-
* // Complete logout flow
|
|
1541
|
-
* await client.disconnect();
|
|
1542
|
-
* client.resetStorage();
|
|
1543
|
-
* ```
|
|
1544
|
-
*/
|
|
1545
1469
|
resetStorage() {
|
|
1546
1470
|
this.config.debug && logger5.info("Resetting all storage to initial values");
|
|
1547
1471
|
let storageKeys = ["account", "wallet", "cluster"];
|
|
@@ -1559,66 +1483,34 @@ var logger5 = chunkSMUUAKC3_js.createLogger("ConnectorClient"), ConnectorClient
|
|
|
1559
1483
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1560
1484
|
});
|
|
1561
1485
|
}
|
|
1562
|
-
/**
|
|
1563
|
-
* Subscribe to connector events
|
|
1564
|
-
*/
|
|
1565
1486
|
on(listener) {
|
|
1566
1487
|
return this.eventEmitter.on(listener);
|
|
1567
1488
|
}
|
|
1568
|
-
/**
|
|
1569
|
-
* Remove a specific event listener
|
|
1570
|
-
*/
|
|
1571
1489
|
off(listener) {
|
|
1572
1490
|
this.eventEmitter.off(listener);
|
|
1573
1491
|
}
|
|
1574
|
-
/**
|
|
1575
|
-
* Remove all event listeners
|
|
1576
|
-
*/
|
|
1577
1492
|
offAll() {
|
|
1578
1493
|
this.eventEmitter.offAll();
|
|
1579
1494
|
}
|
|
1580
|
-
/**
|
|
1581
|
-
* Emit a connector event
|
|
1582
|
-
* Internal method used by transaction signer and other components
|
|
1583
|
-
* @internal
|
|
1584
|
-
*/
|
|
1585
1495
|
emitEvent(event) {
|
|
1586
1496
|
this.eventEmitter.emit(event);
|
|
1587
1497
|
}
|
|
1588
|
-
/**
|
|
1589
|
-
* Track a transaction for debugging and monitoring
|
|
1590
|
-
*/
|
|
1591
1498
|
trackTransaction(activity) {
|
|
1592
1499
|
this.transactionTracker.trackTransaction(activity);
|
|
1593
1500
|
}
|
|
1594
|
-
/**
|
|
1595
|
-
* Update transaction status
|
|
1596
|
-
*/
|
|
1597
1501
|
updateTransactionStatus(signature, status, error) {
|
|
1598
1502
|
this.transactionTracker.updateStatus(signature, status, error);
|
|
1599
1503
|
}
|
|
1600
|
-
/**
|
|
1601
|
-
* Clear transaction history
|
|
1602
|
-
*/
|
|
1603
1504
|
clearTransactionHistory() {
|
|
1604
1505
|
this.transactionTracker.clearHistory();
|
|
1605
1506
|
}
|
|
1606
|
-
/**
|
|
1607
|
-
* Get connector health and diagnostics
|
|
1608
|
-
*/
|
|
1609
1507
|
getHealth() {
|
|
1610
1508
|
return this.healthMonitor.getHealth();
|
|
1611
1509
|
}
|
|
1612
|
-
/**
|
|
1613
|
-
* Get performance and debug metrics
|
|
1614
|
-
*/
|
|
1615
1510
|
getDebugMetrics() {
|
|
1616
1511
|
this.stateManager.getSnapshot();
|
|
1617
1512
|
return this.debugMetrics.updateListenerCounts(this.eventEmitter.getListenerCount(), 0), this.debugMetrics.getMetrics();
|
|
1618
1513
|
}
|
|
1619
|
-
/**
|
|
1620
|
-
* Get debug state including transactions
|
|
1621
|
-
*/
|
|
1622
1514
|
getDebugState() {
|
|
1623
1515
|
return {
|
|
1624
1516
|
...this.getDebugMetrics(),
|
|
@@ -1626,15 +1518,9 @@ var logger5 = chunkSMUUAKC3_js.createLogger("ConnectorClient"), ConnectorClient
|
|
|
1626
1518
|
totalTransactions: this.transactionTracker.getTotalCount()
|
|
1627
1519
|
};
|
|
1628
1520
|
}
|
|
1629
|
-
/**
|
|
1630
|
-
* Reset debug metrics
|
|
1631
|
-
*/
|
|
1632
1521
|
resetDebugMetrics() {
|
|
1633
1522
|
this.debugMetrics.resetMetrics();
|
|
1634
1523
|
}
|
|
1635
|
-
/**
|
|
1636
|
-
* Cleanup resources
|
|
1637
|
-
*/
|
|
1638
1524
|
destroy() {
|
|
1639
1525
|
this.connectionManager.disconnect().catch(() => {
|
|
1640
1526
|
}), this.walletDetector.destroy(), this.eventEmitter.offAll(), this.stateManager.clear();
|
|
@@ -2555,6 +2441,8 @@ exports.formatSOL = formatSOL;
|
|
|
2555
2441
|
exports.formatTokenAmount = formatTokenAmount;
|
|
2556
2442
|
exports.getAddressUrl = getAddressUrl;
|
|
2557
2443
|
exports.getBlockUrl = getBlockUrl;
|
|
2444
|
+
exports.getChainIdForWalletStandard = getChainIdForWalletStandard;
|
|
2445
|
+
exports.getClusterChainId = getClusterChainId;
|
|
2558
2446
|
exports.getClusterExplorerUrl = getClusterExplorerUrl;
|
|
2559
2447
|
exports.getClusterName = getClusterName;
|
|
2560
2448
|
exports.getClusterRpcUrl = getClusterRpcUrl;
|
|
@@ -2590,5 +2478,5 @@ exports.toClusterId = toClusterId;
|
|
|
2590
2478
|
exports.toConnectorError = toConnectorError;
|
|
2591
2479
|
exports.truncate = truncate;
|
|
2592
2480
|
exports.withErrorBoundary = withErrorBoundary;
|
|
2593
|
-
//# sourceMappingURL=chunk-
|
|
2594
|
-
//# sourceMappingURL=chunk-
|
|
2481
|
+
//# sourceMappingURL=chunk-RIBOPAOD.js.map
|
|
2482
|
+
//# sourceMappingURL=chunk-RIBOPAOD.js.map
|