@solana/connector 0.1.3 → 0.1.5
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/LICENSE +21 -0
- package/README.md +685 -1071
- package/dist/chunk-3STZXVXD.mjs +2185 -0
- package/dist/chunk-3STZXVXD.mjs.map +1 -0
- package/dist/chunk-I64FD2EH.js +312 -0
- package/dist/chunk-I64FD2EH.js.map +1 -0
- package/dist/{chunk-TIW3EQPC.js → chunk-JUZVCBAI.js} +127 -104
- package/dist/chunk-JUZVCBAI.js.map +1 -0
- package/dist/{chunk-7CKCRY25.js → chunk-NQXK7PGX.js} +75 -79
- package/dist/chunk-NQXK7PGX.js.map +1 -0
- package/dist/{chunk-HPENTIPE.mjs → chunk-QKVL45F6.mjs} +57 -57
- package/dist/chunk-QKVL45F6.mjs.map +1 -0
- package/dist/chunk-QL3IT3TS.mjs +299 -0
- package/dist/chunk-QL3IT3TS.mjs.map +1 -0
- package/dist/chunk-ULUYX23Q.js +2213 -0
- package/dist/chunk-ULUYX23Q.js.map +1 -0
- package/dist/{chunk-TKJSKXSA.mjs → chunk-VMSZJPR5.mjs} +42 -20
- package/dist/chunk-VMSZJPR5.mjs.map +1 -0
- package/dist/compat.d.mts +4 -2
- package/dist/compat.d.ts +4 -2
- package/dist/compat.js +3 -3
- package/dist/compat.mjs +1 -1
- package/dist/headless.d.mts +146 -18
- package/dist/headless.d.ts +146 -18
- package/dist/headless.js +144 -111
- package/dist/headless.mjs +3 -2
- package/dist/index.d.mts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +207 -126
- package/dist/index.mjs +4 -3
- package/dist/react.d.mts +707 -67
- package/dist/react.d.ts +707 -67
- package/dist/react.js +64 -16
- package/dist/react.mjs +2 -2
- package/dist/{transaction-signer-D3csM_Mf.d.mts → transaction-signer-D9d8nxwb.d.mts} +3 -1
- package/dist/{transaction-signer-D3csM_Mf.d.ts → transaction-signer-D9d8nxwb.d.ts} +3 -1
- package/dist/{wallet-standard-shim-Cg0GVGwu.d.mts → wallet-standard-shim--YcrQNRt.d.ts} +216 -6
- package/dist/{wallet-standard-shim-C1tisl9S.d.ts → wallet-standard-shim-Dx7H8Ctf.d.mts} +216 -6
- package/package.json +16 -12
- package/dist/chunk-5ZUVZZWU.mjs +0 -180
- package/dist/chunk-5ZUVZZWU.mjs.map +0 -1
- package/dist/chunk-7CKCRY25.js.map +0 -1
- package/dist/chunk-FTD7F7CS.js +0 -314
- package/dist/chunk-FTD7F7CS.js.map +0 -1
- package/dist/chunk-HPENTIPE.mjs.map +0 -1
- package/dist/chunk-MPZFJEJK.mjs +0 -298
- package/dist/chunk-MPZFJEJK.mjs.map +0 -1
- package/dist/chunk-SMUUAKC3.js +0 -186
- package/dist/chunk-SMUUAKC3.js.map +0 -1
- package/dist/chunk-TIW3EQPC.js.map +0 -1
- package/dist/chunk-TKJSKXSA.mjs.map +0 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { createLogger, __publicField, isWeb3jsTransaction, prepareTransactionForWallet, convertSignedTransaction } from './chunk-
|
|
2
|
-
import { getPublicSolanaRpcUrl, getExplorerLink, LAMPORTS_PER_SOL, address, getTransactionDecoder, getSignatureFromBytes, isAddress } from 'gill';
|
|
1
|
+
import { createLogger, __publicField, getPublicSolanaRpcUrl, getExplorerLink, isWeb3jsTransaction, prepareTransactionForWallet, convertSignedTransaction } from './chunk-QL3IT3TS.mjs';
|
|
3
2
|
import { Component, useTransition, useState, useCallback, useMemo } from 'react';
|
|
4
3
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
5
4
|
import { install } from '@solana/webcrypto-ed25519-polyfill';
|
|
5
|
+
import { address, isAddress } from '@solana/addresses';
|
|
6
|
+
import { getTransactionDecoder, assertIsTransactionWithinSizeLimit } from '@solana/transactions';
|
|
7
|
+
import { getBase58Decoder } from '@solana/codecs';
|
|
6
8
|
|
|
7
9
|
// src/lib/adapters/wallet-standard-shim.ts
|
|
8
10
|
var registry = null;
|
|
@@ -123,11 +125,16 @@ function isTransactionError(error) {
|
|
|
123
125
|
}
|
|
124
126
|
var Errors = {
|
|
125
127
|
walletNotConnected: (context) => new ConnectionError("WALLET_NOT_CONNECTED", "No wallet connected", context),
|
|
126
|
-
walletNotFound: (walletName) => new ConnectionError("WALLET_NOT_FOUND", `Wallet not found${walletName ? `: ${walletName}` : ""}`, {
|
|
128
|
+
walletNotFound: (walletName) => new ConnectionError("WALLET_NOT_FOUND", `Wallet not found${walletName ? `: ${walletName}` : ""}`, {
|
|
129
|
+
walletName
|
|
130
|
+
}),
|
|
127
131
|
connectionFailed: (originalError) => new ConnectionError("CONNECTION_FAILED", "Failed to connect to wallet", void 0, originalError),
|
|
128
132
|
accountNotAvailable: (address) => new ConnectionError("ACCOUNT_NOT_AVAILABLE", "Requested account not available", { address }),
|
|
129
133
|
invalidTransaction: (reason, context) => new ValidationError("INVALID_TRANSACTION", `Invalid transaction: ${reason}`, context),
|
|
130
|
-
invalidFormat: (expectedFormat, actualFormat) => new ValidationError("INVALID_FORMAT", `Invalid format: expected ${expectedFormat}`, {
|
|
134
|
+
invalidFormat: (expectedFormat, actualFormat) => new ValidationError("INVALID_FORMAT", `Invalid format: expected ${expectedFormat}`, {
|
|
135
|
+
expectedFormat,
|
|
136
|
+
actualFormat
|
|
137
|
+
}),
|
|
131
138
|
unsupportedFormat: (format) => new ValidationError("UNSUPPORTED_FORMAT", `Unsupported format: ${format}`, { format }),
|
|
132
139
|
missingProvider: (hookName) => new ConfigurationError(
|
|
133
140
|
"MISSING_PROVIDER",
|
|
@@ -170,6 +177,8 @@ function getUserFriendlyMessage(error) {
|
|
|
170
177
|
NETWORK_TIMEOUT: "Request timed out. Please try again."
|
|
171
178
|
}[error.code] || error.message || "An error occurred." : "An unexpected error occurred. Please try again.";
|
|
172
179
|
}
|
|
180
|
+
|
|
181
|
+
// src/utils/network.ts
|
|
173
182
|
var PUBLIC_RPC_ENDPOINTS = {
|
|
174
183
|
mainnet: "https://api.mainnet-beta.solana.com",
|
|
175
184
|
devnet: "https://api.devnet.solana.com",
|
|
@@ -217,6 +226,8 @@ function getNetworkDisplayName(network) {
|
|
|
217
226
|
let normalized = normalizeNetwork(network);
|
|
218
227
|
return normalized.charAt(0).toUpperCase() + normalized.slice(1);
|
|
219
228
|
}
|
|
229
|
+
|
|
230
|
+
// src/utils/cluster.ts
|
|
220
231
|
function getClusterRpcUrl(cluster) {
|
|
221
232
|
if (typeof cluster == "string") {
|
|
222
233
|
let presets2 = {
|
|
@@ -334,7 +345,7 @@ var StateManager = class {
|
|
|
334
345
|
* Fast array equality check for wallet/account arrays
|
|
335
346
|
*/
|
|
336
347
|
arraysEqual(a, b) {
|
|
337
|
-
return a.length !== b.length ? false : a[0] && typeof a[0] == "object" && "name" in a[0] && b[0] && typeof b[0] == "object" && "name" in b[0] ? a.every((item, i) => {
|
|
348
|
+
return a.length !== b.length ? false : a.length === 0 ? true : a[0] && typeof a[0] == "object" && "name" in a[0] && b[0] && typeof b[0] == "object" && "name" in b[0] ? a.every((item, i) => {
|
|
338
349
|
let aItem = item, bItem = b[i];
|
|
339
350
|
if (!bItem || typeof bItem != "object") return false;
|
|
340
351
|
let keysA = Object.keys(aItem), keysB = Object.keys(bItem);
|
|
@@ -1527,6 +1538,12 @@ var logger5 = createLogger("ConnectorClient"), ConnectorClient = class {
|
|
|
1527
1538
|
totalTransactions: this.transactionTracker.getTotalCount()
|
|
1528
1539
|
};
|
|
1529
1540
|
}
|
|
1541
|
+
/**
|
|
1542
|
+
* Get the current connector configuration
|
|
1543
|
+
*/
|
|
1544
|
+
getConfig() {
|
|
1545
|
+
return this.config;
|
|
1546
|
+
}
|
|
1530
1547
|
resetDebugMetrics() {
|
|
1531
1548
|
this.debugMetrics.resetMetrics();
|
|
1532
1549
|
}
|
|
@@ -1810,7 +1827,7 @@ var logger7 = createLogger("Polyfills"), installed = false;
|
|
|
1810
1827
|
function installPolyfills() {
|
|
1811
1828
|
if (!(installed || typeof window > "u"))
|
|
1812
1829
|
try {
|
|
1813
|
-
install(), installed = true,
|
|
1830
|
+
install(), installed = true, logger7.info("Browser compatibility polyfills installed");
|
|
1814
1831
|
} catch (error) {
|
|
1815
1832
|
logger7 && logger7.warn("Failed to install polyfills", { error }), installed = true;
|
|
1816
1833
|
}
|
|
@@ -1833,6 +1850,8 @@ function getPolyfillStatus() {
|
|
|
1833
1850
|
environment: typeof window < "u" ? "browser" : "server"
|
|
1834
1851
|
};
|
|
1835
1852
|
}
|
|
1853
|
+
|
|
1854
|
+
// src/utils/formatting.ts
|
|
1836
1855
|
function formatAddress(address, options = {}) {
|
|
1837
1856
|
let { length = 4, separator = "..." } = options;
|
|
1838
1857
|
return !address || address.length <= length * 2 + separator.length ? address : `${address.slice(0, length)}${separator}${address.slice(-length)}`;
|
|
@@ -1840,10 +1859,10 @@ function formatAddress(address, options = {}) {
|
|
|
1840
1859
|
function formatSOL(lamports, options = {}) {
|
|
1841
1860
|
let { decimals = 4, suffix = true, fast = false } = options;
|
|
1842
1861
|
if (fast && typeof lamports == "number") {
|
|
1843
|
-
let formatted2 = (lamports /
|
|
1862
|
+
let formatted2 = (lamports / 1e9).toFixed(decimals);
|
|
1844
1863
|
return suffix ? `${formatted2} SOL` : formatted2;
|
|
1845
1864
|
}
|
|
1846
|
-
let lamportsBigInt = typeof lamports == "bigint" ? lamports : BigInt(lamports), formatted = (Number(lamportsBigInt) /
|
|
1865
|
+
let lamportsBigInt = typeof lamports == "bigint" ? lamports : BigInt(lamports), formatted = (Number(lamportsBigInt) / 1e9).toFixed(decimals);
|
|
1847
1866
|
return suffix ? `${formatted} SOL` : formatted;
|
|
1848
1867
|
}
|
|
1849
1868
|
function formatNumber(value, options = {}) {
|
|
@@ -2300,7 +2319,7 @@ var TransactionSignerError = class extends TransactionError {
|
|
|
2300
2319
|
function isTransactionSignerError(error) {
|
|
2301
2320
|
return error instanceof TransactionSignerError || error instanceof TransactionError;
|
|
2302
2321
|
}
|
|
2303
|
-
var logger10 = createLogger("
|
|
2322
|
+
var logger10 = createLogger("KitTransactionSigner");
|
|
2304
2323
|
function encodeShortVecLength(value) {
|
|
2305
2324
|
let bytes = [], remaining = value;
|
|
2306
2325
|
for (; remaining >= 128; )
|
|
@@ -2345,7 +2364,7 @@ function extractSignature(signedTx) {
|
|
|
2345
2364
|
}
|
|
2346
2365
|
throw new Error("Cannot extract signature from transaction format");
|
|
2347
2366
|
}
|
|
2348
|
-
function
|
|
2367
|
+
function createKitTransactionSigner(connectorSigner) {
|
|
2349
2368
|
let signerAddress = address(connectorSigner.address);
|
|
2350
2369
|
return {
|
|
2351
2370
|
address: signerAddress,
|
|
@@ -2402,29 +2421,32 @@ function createGillTransactionSigner(connectorSigner) {
|
|
|
2402
2421
|
return logger10.debug("Using modified transaction from wallet", {
|
|
2403
2422
|
modifiedMessageBytesLength: walletTransaction.messageBytes.length,
|
|
2404
2423
|
signatures: Object.keys(walletTransaction.signatures)
|
|
2405
|
-
}), result;
|
|
2424
|
+
}), assertIsTransactionWithinSizeLimit(result), result;
|
|
2406
2425
|
}
|
|
2407
|
-
let
|
|
2408
|
-
|
|
2426
|
+
let extractedSignatureBytes = extractSignature(signedTxBytes), signatureBase58 = getBase58Decoder().decode(extractedSignatureBytes);
|
|
2427
|
+
logger10.debug("Extracted signature from wallet (unmodified)", {
|
|
2409
2428
|
signerAddress,
|
|
2410
|
-
signatureLength:
|
|
2429
|
+
signatureLength: extractedSignatureBytes.length,
|
|
2411
2430
|
signatureBase58
|
|
2412
2431
|
// Human-readable signature for debugging/logging
|
|
2413
|
-
})
|
|
2432
|
+
});
|
|
2433
|
+
let typedSignatureBytes = extractedSignatureBytes, signedTransaction = {
|
|
2414
2434
|
...originalTransaction,
|
|
2415
2435
|
signatures: Object.freeze({
|
|
2416
2436
|
...originalTransaction.signatures,
|
|
2417
|
-
[signerAddress]:
|
|
2437
|
+
[signerAddress]: typedSignatureBytes
|
|
2418
2438
|
})
|
|
2419
2439
|
};
|
|
2440
|
+
return assertIsTransactionWithinSizeLimit(signedTransaction), signedTransaction;
|
|
2420
2441
|
} catch (error) {
|
|
2421
|
-
return logger10.error("Failed to decode signed transaction", { error }), originalTransaction;
|
|
2442
|
+
return logger10.error("Failed to decode signed transaction", { error }), assertIsTransactionWithinSizeLimit(originalTransaction), originalTransaction;
|
|
2422
2443
|
}
|
|
2423
2444
|
});
|
|
2424
2445
|
}
|
|
2425
2446
|
};
|
|
2426
2447
|
}
|
|
2448
|
+
var createGillTransactionSigner = createKitTransactionSigner;
|
|
2427
2449
|
|
|
2428
|
-
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 };
|
|
2429
|
-
//# sourceMappingURL=chunk-
|
|
2430
|
-
//# sourceMappingURL=chunk-
|
|
2450
|
+
export { ClipboardErrorType, ConfigurationError, ConnectionError, ConnectorClient, ConnectorError, ConnectorErrorBoundary, DEFAULT_MAX_RETRIES, Errors, NetworkError, PUBLIC_RPC_ENDPOINTS, TransactionError, TransactionSignerError, ValidationError, WalletErrorType, copyAddressToClipboard, copySignatureToClipboard, copyToClipboard, createGillTransactionSigner, createKitTransactionSigner, 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 };
|
|
2451
|
+
//# sourceMappingURL=chunk-VMSZJPR5.mjs.map
|
|
2452
|
+
//# sourceMappingURL=chunk-VMSZJPR5.mjs.map
|