@solana/client 0.1.1 → 0.1.3

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.
@@ -533,24 +533,30 @@ function createActions({ connectors, logger: inputLogger, runtime, store }) {
533
533
  }
534
534
  __name(sendTransaction, "sendTransaction");
535
535
  async function requestAirdrop(address4, lamports2) {
536
- if (!("requestAirdrop" in runtime.rpc)) {
537
- throw new Error("The current RPC endpoint does not support airdrops.");
536
+ try {
537
+ const factory = kit.airdropFactory({
538
+ rpc: runtime.rpc,
539
+ rpcSubscriptions: runtime.rpcSubscriptions
540
+ });
541
+ const signature4 = await factory({
542
+ commitment: getCommitment("confirmed"),
543
+ lamports: lamports2,
544
+ recipientAddress: address4
545
+ });
546
+ logger({
547
+ data: { address: address4.toString(), lamports: lamports2.toString(), signature: signature4 },
548
+ level: "info",
549
+ message: "airdrop requested"
550
+ });
551
+ return signature4;
552
+ } catch (error) {
553
+ logger({
554
+ data: { address: address4.toString(), lamports: lamports2.toString(), ...formatError(error) },
555
+ level: "error",
556
+ message: "airdrop request failed"
557
+ });
558
+ throw error;
538
559
  }
539
- const factory = kit.airdropFactory({
540
- rpc: runtime.rpc,
541
- rpcSubscriptions: runtime.rpcSubscriptions
542
- });
543
- const signature4 = await factory({
544
- commitment: getCommitment("confirmed"),
545
- lamports: lamports2,
546
- recipientAddress: address4
547
- });
548
- logger({
549
- data: { address: address4.toString(), lamports: lamports2.toString(), signature: signature4 },
550
- level: "info",
551
- message: "airdrop requested"
552
- });
553
- return signature4;
554
560
  }
555
561
  __name(requestAirdrop, "requestAirdrop");
556
562
  return {
@@ -2240,6 +2246,33 @@ function lamportsFromJson(value) {
2240
2246
  return lamports(value, "lamports");
2241
2247
  }
2242
2248
  __name(lamportsFromJson, "lamportsFromJson");
2249
+
2250
+ // src/serialization/state.ts
2251
+ var SERIALIZABLE_STATE_VERSION = 1;
2252
+ function getInitialSerializableState(config) {
2253
+ return {
2254
+ autoconnect: false,
2255
+ commitment: config.commitment,
2256
+ endpoint: config.endpoint,
2257
+ lastConnectorId: null,
2258
+ lastPublicKey: null,
2259
+ version: SERIALIZABLE_STATE_VERSION,
2260
+ websocketEndpoint: config.websocketEndpoint
2261
+ };
2262
+ }
2263
+ __name(getInitialSerializableState, "getInitialSerializableState");
2264
+ function applySerializableState(config, state) {
2265
+ if (!state) {
2266
+ return config;
2267
+ }
2268
+ return {
2269
+ ...config,
2270
+ commitment: state.commitment ?? config.commitment,
2271
+ endpoint: state.endpoint ?? config.endpoint,
2272
+ websocketEndpoint: state.websocketEndpoint ?? config.websocketEndpoint
2273
+ };
2274
+ }
2275
+ __name(applySerializableState, "applySerializableState");
2243
2276
  var COMMITMENT_PRIORITY = {
2244
2277
  processed: 0,
2245
2278
  confirmed: 1,
@@ -2552,6 +2585,56 @@ function toAddressString(addressLike) {
2552
2585
  }
2553
2586
  __name(toAddressString, "toAddressString");
2554
2587
 
2588
+ // src/utils/cluster.ts
2589
+ var MONIKER_ENDPOINTS = {
2590
+ devnet: {
2591
+ endpoint: "https://api.devnet.solana.com",
2592
+ websocketEndpoint: "wss://api.devnet.solana.com"
2593
+ },
2594
+ localhost: {
2595
+ endpoint: "http://127.0.0.1:8899",
2596
+ websocketEndpoint: "ws://127.0.0.1:8900"
2597
+ },
2598
+ localnet: {
2599
+ endpoint: "http://127.0.0.1:8899",
2600
+ websocketEndpoint: "ws://127.0.0.1:8900"
2601
+ },
2602
+ "mainnet-beta": {
2603
+ endpoint: "https://api.mainnet-beta.solana.com",
2604
+ websocketEndpoint: "wss://api.mainnet-beta.solana.com"
2605
+ },
2606
+ mainnet: {
2607
+ endpoint: "https://api.mainnet-beta.solana.com",
2608
+ websocketEndpoint: "wss://api.mainnet-beta.solana.com"
2609
+ },
2610
+ testnet: {
2611
+ endpoint: "https://api.testnet.solana.com",
2612
+ websocketEndpoint: "wss://api.testnet.solana.com"
2613
+ }
2614
+ };
2615
+ function inferWebsocketEndpoint(endpoint) {
2616
+ if (endpoint.startsWith("https://")) {
2617
+ return endpoint.replace("https://", "wss://");
2618
+ }
2619
+ if (endpoint.startsWith("http://")) {
2620
+ return endpoint.replace("http://", "ws://");
2621
+ }
2622
+ return endpoint;
2623
+ }
2624
+ __name(inferWebsocketEndpoint, "inferWebsocketEndpoint");
2625
+ function resolveCluster(config) {
2626
+ const moniker = config.moniker ?? (config.endpoint ? "custom" : "devnet");
2627
+ const mapped = moniker === "custom" ? void 0 : MONIKER_ENDPOINTS[moniker];
2628
+ const endpoint = config.endpoint ?? mapped?.endpoint;
2629
+ const websocketEndpoint = config.websocketEndpoint ?? mapped?.websocketEndpoint ?? inferWebsocketEndpoint(endpoint);
2630
+ return {
2631
+ endpoint,
2632
+ moniker,
2633
+ websocketEndpoint
2634
+ };
2635
+ }
2636
+ __name(resolveCluster, "resolveCluster");
2637
+
2555
2638
  // src/utils/stableStringify.ts
2556
2639
  function stableStringify(value) {
2557
2640
  const result = JSON.stringify(value, (_key, candidate) => {
@@ -2570,7 +2653,8 @@ var base58Decoder = codecsStrings.getBase58Decoder();
2570
2653
  var transactionDecoder = transactions.getTransactionDecoder();
2571
2654
  var transactionEncoder = transactions.getTransactionEncoder();
2572
2655
  function deriveConnectorId(wallet) {
2573
- return wallet.name.toLowerCase().replace(/[^a-z0-9]+/g, "-");
2656
+ const kebab = wallet.name.toLowerCase().replace(/[^a-z0-9]+/g, "-");
2657
+ return `wallet-standard:${kebab}`;
2574
2658
  }
2575
2659
  __name(deriveConnectorId, "deriveConnectorId");
2576
2660
  function getPrimaryAccount(accounts) {
@@ -2613,7 +2697,9 @@ function createWalletStandardConnector(wallet, options = {}) {
2613
2697
  canAutoConnect: options.canAutoConnect ?? Boolean(wallet.features[features.StandardConnect]),
2614
2698
  icon: options.icon ?? wallet.icon,
2615
2699
  id: options.id ?? deriveConnectorId(wallet),
2616
- name: options.name ?? wallet.name
2700
+ kind: options.kind ?? "wallet-standard",
2701
+ name: options.name ?? wallet.name,
2702
+ ready: typeof window !== "undefined"
2617
2703
  };
2618
2704
  async function connect(connectionOptions = {}) {
2619
2705
  const connectFeature = wallet.features[features.StandardConnect];
@@ -2740,6 +2826,7 @@ __name(watchWalletStandardConnectors, "watchWalletStandardConnectors");
2740
2826
  exports.LAMPORTS_PER_SOL = LAMPORTS_PER_SOL;
2741
2827
  exports.SIGNATURE_STATUS_TIMEOUT_MS = SIGNATURE_STATUS_TIMEOUT_MS;
2742
2828
  exports.applyRatio = applyRatio;
2829
+ exports.applySerializableState = applySerializableState;
2743
2830
  exports.assertDecimals = assertDecimals;
2744
2831
  exports.assertNonNegative = assertNonNegative;
2745
2832
  exports.bigintFromJson = bigintFromJson;
@@ -2768,6 +2855,7 @@ exports.createTransactionRecipe = createTransactionRecipe;
2768
2855
  exports.createWalletRegistry = createWalletRegistry;
2769
2856
  exports.createWalletStandardConnector = createWalletStandardConnector;
2770
2857
  exports.deriveConfirmationStatus = deriveConfirmationStatus;
2858
+ exports.getInitialSerializableState = getInitialSerializableState;
2771
2859
  exports.getWalletStandardConnectors = getWalletStandardConnectors;
2772
2860
  exports.insertReferenceKey = insertReferenceKey;
2773
2861
  exports.insertReferenceKeys = insertReferenceKeys;
@@ -2780,6 +2868,7 @@ exports.lamportsToSolString = lamportsToSolString;
2780
2868
  exports.normalizeSignature = normalizeSignature;
2781
2869
  exports.pow10 = pow10;
2782
2870
  exports.prepareTransaction = prepareTransaction;
2871
+ exports.resolveCluster = resolveCluster;
2783
2872
  exports.stableStringify = stableStringify;
2784
2873
  exports.toAddress = toAddress2;
2785
2874
  exports.toAddressString = toAddressString;