solana: mainnet is actually mainnet-beta, make mainnet an alias for mainnet-beta

This commit is contained in:
Ryan Heywood 2024-12-17 14:24:04 -05:00
parent 00d7f18eb3
commit cf71b48492
Signed by: ryan
GPG Key ID: 8E401478A3FBEF72
1 changed files with 7 additions and 5 deletions

View File

@ -77,7 +77,8 @@ pub enum Error {}
pub enum Cluster { pub enum Cluster {
Devnet, Devnet,
Testnet, Testnet,
Mainnet, #[serde(alias = "mainnet")]
MainnetBeta,
} }
impl std::str::FromStr for Cluster { impl std::str::FromStr for Cluster {
@ -87,7 +88,8 @@ impl std::str::FromStr for Cluster {
match s { match s {
"devnet" => Ok(Self::Devnet), "devnet" => Ok(Self::Devnet),
"testnet" => Ok(Self::Testnet), "testnet" => Ok(Self::Testnet),
"mainnet" => Ok(Self::Mainnet), "mainnet" => Ok(Self::MainnetBeta),
"mainnet-beta" => Ok(Self::MainnetBeta),
_ => Err("Invalid value"), _ => Err("Invalid value"),
} }
} }
@ -98,7 +100,7 @@ impl std::fmt::Display for Cluster {
match self { match self {
Cluster::Devnet => f.write_str("devnet"), Cluster::Devnet => f.write_str("devnet"),
Cluster::Testnet => f.write_str("testnet"), Cluster::Testnet => f.write_str("testnet"),
Cluster::Mainnet => f.write_str("mainnet"), Cluster::MainnetBeta => f.write_str("mainnet-beta"),
} }
} }
} }
@ -393,7 +395,7 @@ impl Module for Solana {
fn handle_request(request: Self::Request) -> Result<serde_json::Value, Self::Error> { fn handle_request(request: Self::Request) -> Result<serde_json::Value, Self::Error> {
match request.operation { match request.operation {
Operation::GetBlockhash(GetBlockhash { cluster }) => { Operation::GetBlockhash(GetBlockhash { cluster }) => {
let cluster = cluster.unwrap_or(Cluster::Mainnet); let cluster = cluster.unwrap_or(Cluster::MainnetBeta);
let cluster_url = format!("https://api.{cluster}.solana.com"); let cluster_url = format!("https://api.{cluster}.solana.com");
let client = solana_rpc_client::rpc_client::RpcClient::new(cluster_url); let client = solana_rpc_client::rpc_client::RpcClient::new(cluster_url);
let response = client.get_latest_blockhash().unwrap(); let response = client.get_latest_blockhash().unwrap();
@ -631,7 +633,7 @@ impl Module for Solana {
})) }))
} }
Operation::Broadcast(Broadcast { cluster }) => { Operation::Broadcast(Broadcast { cluster }) => {
let cluster = cluster.unwrap_or(Cluster::Mainnet); let cluster = cluster.unwrap_or(Cluster::MainnetBeta);
let cluster_url = format!("https://api.{cluster}.solana.com"); let cluster_url = format!("https://api.{cluster}.solana.com");
let blob = request.blob.expect("passed in instruction blob"); let blob = request.blob.expect("passed in instruction blob");