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