@solana/client 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.
@@ -246,11 +246,6 @@ function createActions({ connectors, logger: inputLogger, runtime, store }) {
246
246
  },
247
247
  lastUpdatedAt: now()
248
248
  }));
249
- logger({
250
- data: { endpoint, latencyMs, websocketEndpoint },
251
- level: "info",
252
- message: "cluster ready"
253
- });
254
249
  } catch (error) {
255
250
  store.setState((state) => ({
256
251
  ...state,
@@ -536,24 +531,30 @@ function createActions({ connectors, logger: inputLogger, runtime, store }) {
536
531
  }
537
532
  __name(sendTransaction, "sendTransaction");
538
533
  async function requestAirdrop(address4, lamports2) {
539
- if (!("requestAirdrop" in runtime.rpc)) {
540
- throw new Error("The current RPC endpoint does not support airdrops.");
534
+ try {
535
+ const factory = airdropFactory({
536
+ rpc: runtime.rpc,
537
+ rpcSubscriptions: runtime.rpcSubscriptions
538
+ });
539
+ const signature4 = await factory({
540
+ commitment: getCommitment("confirmed"),
541
+ lamports: lamports2,
542
+ recipientAddress: address4
543
+ });
544
+ logger({
545
+ data: { address: address4.toString(), lamports: lamports2.toString(), signature: signature4 },
546
+ level: "info",
547
+ message: "airdrop requested"
548
+ });
549
+ return signature4;
550
+ } catch (error) {
551
+ logger({
552
+ data: { address: address4.toString(), lamports: lamports2.toString(), ...formatError(error) },
553
+ level: "error",
554
+ message: "airdrop request failed"
555
+ });
556
+ throw error;
541
557
  }
542
- const factory = airdropFactory({
543
- rpc: runtime.rpc,
544
- rpcSubscriptions: runtime.rpcSubscriptions
545
- });
546
- const signature4 = await factory({
547
- commitment: getCommitment("confirmed"),
548
- lamports: lamports2,
549
- recipientAddress: address4
550
- });
551
- logger({
552
- data: { address: address4.toString(), lamports: lamports2.toString(), signature: signature4 },
553
- level: "info",
554
- message: "airdrop requested"
555
- });
556
- return signature4;
557
558
  }
558
559
  __name(requestAirdrop, "requestAirdrop");
559
560
  return {
@@ -2243,6 +2244,33 @@ function lamportsFromJson(value) {
2243
2244
  return lamports(value, "lamports");
2244
2245
  }
2245
2246
  __name(lamportsFromJson, "lamportsFromJson");
2247
+
2248
+ // src/serialization/state.ts
2249
+ var SERIALIZABLE_STATE_VERSION = 1;
2250
+ function getInitialSerializableState(config) {
2251
+ return {
2252
+ autoconnect: false,
2253
+ commitment: config.commitment,
2254
+ endpoint: config.endpoint,
2255
+ lastConnectorId: null,
2256
+ lastPublicKey: null,
2257
+ version: SERIALIZABLE_STATE_VERSION,
2258
+ websocketEndpoint: config.websocketEndpoint
2259
+ };
2260
+ }
2261
+ __name(getInitialSerializableState, "getInitialSerializableState");
2262
+ function applySerializableState(config, state) {
2263
+ if (!state) {
2264
+ return config;
2265
+ }
2266
+ return {
2267
+ ...config,
2268
+ commitment: state.commitment ?? config.commitment,
2269
+ endpoint: state.endpoint ?? config.endpoint,
2270
+ websocketEndpoint: state.websocketEndpoint ?? config.websocketEndpoint
2271
+ };
2272
+ }
2273
+ __name(applySerializableState, "applySerializableState");
2246
2274
  var COMMITMENT_PRIORITY = {
2247
2275
  processed: 0,
2248
2276
  confirmed: 1,
@@ -2555,6 +2583,56 @@ function toAddressString(addressLike) {
2555
2583
  }
2556
2584
  __name(toAddressString, "toAddressString");
2557
2585
 
2586
+ // src/utils/cluster.ts
2587
+ var MONIKER_ENDPOINTS = {
2588
+ devnet: {
2589
+ endpoint: "https://api.devnet.solana.com",
2590
+ websocketEndpoint: "wss://api.devnet.solana.com"
2591
+ },
2592
+ localhost: {
2593
+ endpoint: "http://127.0.0.1:8899",
2594
+ websocketEndpoint: "ws://127.0.0.1:8900"
2595
+ },
2596
+ localnet: {
2597
+ endpoint: "http://127.0.0.1:8899",
2598
+ websocketEndpoint: "ws://127.0.0.1:8900"
2599
+ },
2600
+ "mainnet-beta": {
2601
+ endpoint: "https://api.mainnet-beta.solana.com",
2602
+ websocketEndpoint: "wss://api.mainnet-beta.solana.com"
2603
+ },
2604
+ mainnet: {
2605
+ endpoint: "https://api.mainnet-beta.solana.com",
2606
+ websocketEndpoint: "wss://api.mainnet-beta.solana.com"
2607
+ },
2608
+ testnet: {
2609
+ endpoint: "https://api.testnet.solana.com",
2610
+ websocketEndpoint: "wss://api.testnet.solana.com"
2611
+ }
2612
+ };
2613
+ function inferWebsocketEndpoint(endpoint) {
2614
+ if (endpoint.startsWith("https://")) {
2615
+ return endpoint.replace("https://", "wss://");
2616
+ }
2617
+ if (endpoint.startsWith("http://")) {
2618
+ return endpoint.replace("http://", "ws://");
2619
+ }
2620
+ return endpoint;
2621
+ }
2622
+ __name(inferWebsocketEndpoint, "inferWebsocketEndpoint");
2623
+ function resolveCluster(config) {
2624
+ const moniker = config.moniker ?? (config.endpoint ? "custom" : "devnet");
2625
+ const mapped = moniker === "custom" ? void 0 : MONIKER_ENDPOINTS[moniker];
2626
+ const endpoint = config.endpoint ?? mapped?.endpoint;
2627
+ const websocketEndpoint = config.websocketEndpoint ?? mapped?.websocketEndpoint ?? inferWebsocketEndpoint(endpoint);
2628
+ return {
2629
+ endpoint,
2630
+ moniker,
2631
+ websocketEndpoint
2632
+ };
2633
+ }
2634
+ __name(resolveCluster, "resolveCluster");
2635
+
2558
2636
  // src/utils/stableStringify.ts
2559
2637
  function stableStringify(value) {
2560
2638
  const result = JSON.stringify(value, (_key, candidate) => {
@@ -2616,7 +2694,8 @@ function createWalletStandardConnector(wallet, options = {}) {
2616
2694
  canAutoConnect: options.canAutoConnect ?? Boolean(wallet.features[StandardConnect]),
2617
2695
  icon: options.icon ?? wallet.icon,
2618
2696
  id: options.id ?? deriveConnectorId(wallet),
2619
- name: options.name ?? wallet.name
2697
+ name: options.name ?? wallet.name,
2698
+ ready: typeof window !== "undefined"
2620
2699
  };
2621
2700
  async function connect(connectionOptions = {}) {
2622
2701
  const connectFeature = wallet.features[StandardConnect];
@@ -2740,6 +2819,6 @@ function watchWalletStandardConnectors(onChange, options = {}) {
2740
2819
  }
2741
2820
  __name(watchWalletStandardConnectors, "watchWalletStandardConnectors");
2742
2821
 
2743
- export { LAMPORTS_PER_SOL, SIGNATURE_STATUS_TIMEOUT_MS, applyRatio, assertDecimals, assertNonNegative, bigintFromJson, bigintToJson, checkedAdd, checkedDivide, checkedMultiply, checkedSubtract, confirmationMeetsCommitment, createAsyncState, createClient, createClientStore, createDefaultClientStore, createInitialAsyncState, createInitialClientState, createRatio, createSolTransferController, createSolTransferHelper, createSolanaRpcClient, createSplTokenHelper, createSplTransferController, createTokenAmount, createTransactionHelper, createTransactionPoolController, createTransactionRecipe, createWalletRegistry, createWalletStandardConnector, deriveConfirmationStatus, getWalletStandardConnectors, insertReferenceKey, insertReferenceKeys, lamports, lamportsFromJson, lamportsFromSol, lamportsMath, lamportsToJson, lamportsToSolString, normalizeSignature, pow10, prepareTransaction, stableStringify, toAddress2 as toAddress, toAddressString, toBigint2 as toBigint, transactionToBase64, transactionToBase64WithSigners, watchWalletStandardConnectors };
2822
+ export { LAMPORTS_PER_SOL, SIGNATURE_STATUS_TIMEOUT_MS, applyRatio, applySerializableState, assertDecimals, assertNonNegative, bigintFromJson, bigintToJson, checkedAdd, checkedDivide, checkedMultiply, checkedSubtract, confirmationMeetsCommitment, createAsyncState, createClient, createClientStore, createDefaultClientStore, createInitialAsyncState, createInitialClientState, createRatio, createSolTransferController, createSolTransferHelper, createSolanaRpcClient, createSplTokenHelper, createSplTransferController, createTokenAmount, createTransactionHelper, createTransactionPoolController, createTransactionRecipe, createWalletRegistry, createWalletStandardConnector, deriveConfirmationStatus, getInitialSerializableState, getWalletStandardConnectors, insertReferenceKey, insertReferenceKeys, lamports, lamportsFromJson, lamportsFromSol, lamportsMath, lamportsToJson, lamportsToSolString, normalizeSignature, pow10, prepareTransaction, resolveCluster, stableStringify, toAddress2 as toAddress, toAddressString, toBigint2 as toBigint, transactionToBase64, transactionToBase64WithSigners, watchWalletStandardConnectors };
2744
2823
  //# sourceMappingURL=index.node.mjs.map
2745
2824
  //# sourceMappingURL=index.node.mjs.map