Skip to content

Commit

Permalink
✨ Add default Rpc for localnet
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielePicco committed Oct 22, 2023
1 parent 56399a1 commit 753c5e6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Solana.Unity.Programs/SysVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static class SysVars
/// <summary>
/// The public key of the Recent Slot Hashes System Variable.
/// </summary>
public static readonly PublicKet RecentSlotHashesKey = new("SysvarS1otHashes111111111111111111111111111");
public static readonly PublicKey RecentSlotHashesKey = new("SysvarS1otHashes111111111111111111111111111");

/// <summary>
/// The public key of the Rent System Variable.
Expand Down
10 changes: 10 additions & 0 deletions src/Solana.Unity.Rpc/ClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ namespace Solana.Unity.Rpc
/// </summary>
public static class ClientFactory
{
/// <summary>
/// The local net cluster.
/// </summary>
private const string RpcLocalNet = "http://127.0.0.1:8899";
/// <summary>
/// The dev net cluster.
/// </summary>
Expand All @@ -24,6 +28,10 @@ public static class ClientFactory
/// </summary>
private const string RpcMainNet = "https://api.mainnet-beta.solana.com";

/// <summary>
/// The localnet net cluster.
/// </summary>
private const string StreamingRpcLocalNet = "ws://127.0.0.1:8900";

/// <summary>
/// The dev net cluster.
Expand Down Expand Up @@ -91,6 +99,7 @@ public static IRpcClient GetClient(Cluster cluster, object logger = null,
{
Cluster.DevNet => RpcDevNet,
Cluster.TestNet => RpcTestNet,
Cluster.LocalNet => RpcLocalNet,
_ => RpcMainNet,
};

Expand Down Expand Up @@ -147,6 +156,7 @@ public static IStreamingRpcClient GetStreamingClient(
{
Cluster.DevNet => StreamingRpcDevNet,
Cluster.TestNet => StreamingRpcTestNet,
Cluster.LocalNet => StreamingRpcLocalNet,
_ => StreamingRpcMainNet,
};
return GetStreamingClient(url, logger);
Expand Down
7 changes: 6 additions & 1 deletion src/Solana.Unity.Rpc/Cluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public enum Cluster
/// <remarks>
/// Tokens that are issued on Mainnet Beta are real SOL.
/// </remarks>
MainNet
MainNet,

/// <summary>
/// A local cluster for development and testing.
/// </summary>
LocalNet
}
}

0 comments on commit 753c5e6

Please sign in to comment.