@solana/connector 0.1.3 → 0.1.4

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.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +460 -1082
  3. package/dist/{chunk-TIW3EQPC.js → chunk-CLXM6UEE.js} +120 -103
  4. package/dist/chunk-CLXM6UEE.js.map +1 -0
  5. package/dist/{chunk-7CKCRY25.js → chunk-D6PZY5G6.js} +69 -77
  6. package/dist/chunk-D6PZY5G6.js.map +1 -0
  7. package/dist/chunk-LUZWUZ5N.js +2012 -0
  8. package/dist/chunk-LUZWUZ5N.js.map +1 -0
  9. package/dist/{chunk-HPENTIPE.mjs → chunk-N3Q2J2FG.mjs} +51 -55
  10. package/dist/chunk-N3Q2J2FG.mjs.map +1 -0
  11. package/dist/chunk-P5MWBDFG.mjs +298 -0
  12. package/dist/chunk-P5MWBDFG.mjs.map +1 -0
  13. package/dist/chunk-RIQH5W7D.js +311 -0
  14. package/dist/chunk-RIQH5W7D.js.map +1 -0
  15. package/dist/chunk-U64YZRJL.mjs +1984 -0
  16. package/dist/chunk-U64YZRJL.mjs.map +1 -0
  17. package/dist/{chunk-TKJSKXSA.mjs → chunk-YTCSTE3Q.mjs} +35 -19
  18. package/dist/chunk-YTCSTE3Q.mjs.map +1 -0
  19. package/dist/compat.d.mts +4 -2
  20. package/dist/compat.d.ts +4 -2
  21. package/dist/compat.js +3 -3
  22. package/dist/compat.mjs +1 -1
  23. package/dist/headless.d.mts +146 -18
  24. package/dist/headless.d.ts +146 -18
  25. package/dist/headless.js +144 -111
  26. package/dist/headless.mjs +3 -2
  27. package/dist/index.d.mts +6 -5
  28. package/dist/index.d.ts +6 -5
  29. package/dist/index.js +207 -126
  30. package/dist/index.mjs +4 -3
  31. package/dist/react.d.mts +707 -67
  32. package/dist/react.d.ts +707 -67
  33. package/dist/react.js +64 -16
  34. package/dist/react.mjs +2 -2
  35. package/dist/{transaction-signer-D3csM_Mf.d.mts → transaction-signer-D9d8nxwb.d.mts} +3 -1
  36. package/dist/{transaction-signer-D3csM_Mf.d.ts → transaction-signer-D9d8nxwb.d.ts} +3 -1
  37. package/dist/{wallet-standard-shim-C1tisl9S.d.ts → wallet-standard-shim-Cp4vF4oo.d.mts} +133 -6
  38. package/dist/{wallet-standard-shim-Cg0GVGwu.d.mts → wallet-standard-shim-DC_Z7DS-.d.ts} +133 -6
  39. package/package.json +16 -12
  40. package/dist/chunk-5ZUVZZWU.mjs +0 -180
  41. package/dist/chunk-5ZUVZZWU.mjs.map +0 -1
  42. package/dist/chunk-7CKCRY25.js.map +0 -1
  43. package/dist/chunk-FTD7F7CS.js +0 -314
  44. package/dist/chunk-FTD7F7CS.js.map +0 -1
  45. package/dist/chunk-HPENTIPE.mjs.map +0 -1
  46. package/dist/chunk-MPZFJEJK.mjs +0 -298
  47. package/dist/chunk-MPZFJEJK.mjs.map +0 -1
  48. package/dist/chunk-SMUUAKC3.js +0 -186
  49. package/dist/chunk-SMUUAKC3.js.map +0 -1
  50. package/dist/chunk-TIW3EQPC.js.map +0 -1
  51. package/dist/chunk-TKJSKXSA.mjs.map +0 -1
@@ -1,8 +1,10 @@
1
- import { createLogger, __publicField, isWeb3jsTransaction, prepareTransactionForWallet, convertSignedTransaction } from './chunk-5ZUVZZWU.mjs';
2
- import { getPublicSolanaRpcUrl, getExplorerLink, LAMPORTS_PER_SOL, address, getTransactionDecoder, getSignatureFromBytes, isAddress } from 'gill';
1
+ import { createLogger, __publicField, getPublicSolanaRpcUrl, getExplorerLink, isWeb3jsTransaction, prepareTransactionForWallet, convertSignedTransaction } from './chunk-P5MWBDFG.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}` : ""}`, { 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}`, { expectedFormat, actualFormat }),
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);
@@ -1833,6 +1844,8 @@ function getPolyfillStatus() {
1833
1844
  environment: typeof window < "u" ? "browser" : "server"
1834
1845
  };
1835
1846
  }
1847
+
1848
+ // src/utils/formatting.ts
1836
1849
  function formatAddress(address, options = {}) {
1837
1850
  let { length = 4, separator = "..." } = options;
1838
1851
  return !address || address.length <= length * 2 + separator.length ? address : `${address.slice(0, length)}${separator}${address.slice(-length)}`;
@@ -1840,10 +1853,10 @@ function formatAddress(address, options = {}) {
1840
1853
  function formatSOL(lamports, options = {}) {
1841
1854
  let { decimals = 4, suffix = true, fast = false } = options;
1842
1855
  if (fast && typeof lamports == "number") {
1843
- let formatted2 = (lamports / LAMPORTS_PER_SOL).toFixed(decimals);
1856
+ let formatted2 = (lamports / 1e9).toFixed(decimals);
1844
1857
  return suffix ? `${formatted2} SOL` : formatted2;
1845
1858
  }
1846
- let lamportsBigInt = typeof lamports == "bigint" ? lamports : BigInt(lamports), formatted = (Number(lamportsBigInt) / LAMPORTS_PER_SOL).toFixed(decimals);
1859
+ let lamportsBigInt = typeof lamports == "bigint" ? lamports : BigInt(lamports), formatted = (Number(lamportsBigInt) / 1e9).toFixed(decimals);
1847
1860
  return suffix ? `${formatted} SOL` : formatted;
1848
1861
  }
1849
1862
  function formatNumber(value, options = {}) {
@@ -2300,7 +2313,7 @@ var TransactionSignerError = class extends TransactionError {
2300
2313
  function isTransactionSignerError(error) {
2301
2314
  return error instanceof TransactionSignerError || error instanceof TransactionError;
2302
2315
  }
2303
- var logger10 = createLogger("GillTransactionSigner");
2316
+ var logger10 = createLogger("KitTransactionSigner");
2304
2317
  function encodeShortVecLength(value) {
2305
2318
  let bytes = [], remaining = value;
2306
2319
  for (; remaining >= 128; )
@@ -2345,7 +2358,7 @@ function extractSignature(signedTx) {
2345
2358
  }
2346
2359
  throw new Error("Cannot extract signature from transaction format");
2347
2360
  }
2348
- function createGillTransactionSigner(connectorSigner) {
2361
+ function createKitTransactionSigner(connectorSigner) {
2349
2362
  let signerAddress = address(connectorSigner.address);
2350
2363
  return {
2351
2364
  address: signerAddress,
@@ -2402,29 +2415,32 @@ function createGillTransactionSigner(connectorSigner) {
2402
2415
  return logger10.debug("Using modified transaction from wallet", {
2403
2416
  modifiedMessageBytesLength: walletTransaction.messageBytes.length,
2404
2417
  signatures: Object.keys(walletTransaction.signatures)
2405
- }), result;
2418
+ }), assertIsTransactionWithinSizeLimit(result), result;
2406
2419
  }
2407
- let signatureBytes = extractSignature(signedTxBytes), signatureBase58 = getSignatureFromBytes(signatureBytes);
2408
- return logger10.debug("Extracted signature from wallet (unmodified)", {
2420
+ let extractedSignatureBytes = extractSignature(signedTxBytes), signatureBase58 = getBase58Decoder().decode(extractedSignatureBytes);
2421
+ logger10.debug("Extracted signature from wallet (unmodified)", {
2409
2422
  signerAddress,
2410
- signatureLength: signatureBytes.length,
2423
+ signatureLength: extractedSignatureBytes.length,
2411
2424
  signatureBase58
2412
2425
  // Human-readable signature for debugging/logging
2413
- }), {
2426
+ });
2427
+ let typedSignatureBytes = extractedSignatureBytes, signedTransaction = {
2414
2428
  ...originalTransaction,
2415
2429
  signatures: Object.freeze({
2416
2430
  ...originalTransaction.signatures,
2417
- [signerAddress]: signatureBytes
2431
+ [signerAddress]: typedSignatureBytes
2418
2432
  })
2419
2433
  };
2434
+ return assertIsTransactionWithinSizeLimit(signedTransaction), signedTransaction;
2420
2435
  } catch (error) {
2421
- return logger10.error("Failed to decode signed transaction", { error }), originalTransaction;
2436
+ return logger10.error("Failed to decode signed transaction", { error }), assertIsTransactionWithinSizeLimit(originalTransaction), originalTransaction;
2422
2437
  }
2423
2438
  });
2424
2439
  }
2425
2440
  };
2426
2441
  }
2442
+ var createGillTransactionSigner = createKitTransactionSigner;
2427
2443
 
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-TKJSKXSA.mjs.map
2430
- //# sourceMappingURL=chunk-TKJSKXSA.mjs.map
2444
+ 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 };
2445
+ //# sourceMappingURL=chunk-YTCSTE3Q.mjs.map
2446
+ //# sourceMappingURL=chunk-YTCSTE3Q.mjs.map