diff --git a/Cargo.lock b/Cargo.lock index e3887b3e..11cf84cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2945,8 +2945,8 @@ dependencies = [ "serde_json", "sha2 0.10.8", "slog", - "strum", - "strum_macros", + "strum 0.26.3", + "strum_macros 0.26.4", "thiserror 2.0.12", "tokio", "tracing", @@ -4065,6 +4065,7 @@ dependencies = [ "ic-cdk", "regex", "serde", + "strum 0.27.1", "thiserror 2.0.12", "url", ] @@ -5540,7 +5541,16 @@ version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" dependencies = [ - "strum_macros", + "strum_macros 0.26.4", +] + +[[package]] +name = "strum" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f64def088c51c9510a8579e3c5d67c65349dcf755e5479ad3d010aa6454e2c32" +dependencies = [ + "strum_macros 0.27.1", ] [[package]] @@ -5556,6 +5566,19 @@ dependencies = [ "syn 2.0.100", ] +[[package]] +name = "strum_macros" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c77a8c5abcaf0f9ce05d62342b7d298c346515365c36b673df4ebe3ced01fde8" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.100", +] + [[package]] name = "subtle" version = "2.6.1" diff --git a/canister/src/providers/mod.rs b/canister/src/providers/mod.rs index 68ca0065..2043bd3d 100644 --- a/canister/src/providers/mod.rs +++ b/canister/src/providers/mod.rs @@ -55,7 +55,7 @@ thread_local! { }, }, SupportedRpcProviderId::DrpcDevnet => SupportedRpcProvider { - cluster: SolanaCluster::Mainnet, + cluster: SolanaCluster::Devnet, access: RpcAccess::Unauthenticated { public_url: "https://solana-devnet.drpc.org".to_string(), }, @@ -70,7 +70,7 @@ thread_local! { }, }, SupportedRpcProviderId::HeliusDevnet => SupportedRpcProvider { - cluster: SolanaCluster::Mainnet, + cluster: SolanaCluster::Devnet, access: RpcAccess::Authenticated { auth: RpcAuth::UrlParameter { url_pattern: "https://mainnet.helius-rpc.com/?api-key={API_KEY}".to_string(), diff --git a/canister/src/providers/tests.rs b/canister/src/providers/tests.rs index 4fa8ff7f..1984dd47 100644 --- a/canister/src/providers/tests.rs +++ b/canister/src/providers/tests.rs @@ -39,3 +39,14 @@ fn test_rpc_provider_url_patterns() { } }) } + +#[test] +fn should_have_consistent_name_for_cluster() { + PROVIDERS.with(|providers| { + for (provider_id, provider) in providers { + assert!(provider_id + .to_string() + .ends_with(&provider.cluster.to_string())); + } + }) +} diff --git a/libs/types/Cargo.toml b/libs/types/Cargo.toml index 1ba6bcad..72412e4a 100644 --- a/libs/types/Cargo.toml +++ b/libs/types/Cargo.toml @@ -13,9 +13,10 @@ include = ["src", "Cargo.toml", "CHANGELOG.md", "LICENSE", "README.md"] [dependencies] candid = { workspace = true } canlog = { path = "../../canlog" } +derive_more = { workspace = true } ic-cdk = { workspace = true } regex = { workspace = true } serde = { workspace = true } +strum = { workspace = true } thiserror = { workspace = true } url = { workspace = true } -derive_more = { workspace = true } diff --git a/libs/types/src/rpc_client/mod.rs b/libs/types/src/rpc_client/mod.rs index a43af238..2dfdc061 100644 --- a/libs/types/src/rpc_client/mod.rs +++ b/libs/types/src/rpc_client/mod.rs @@ -8,6 +8,7 @@ pub use ic_cdk::api::management_canister::http_request::HttpHeader; use regex::Regex; use serde::{Deserialize, Serialize}; use std::fmt::Debug; +use strum::Display; use thiserror::Error; /// An RPC result type. @@ -146,7 +147,18 @@ impl Debug for RpcEndpoint { /// [Solana clusters](https://solana.com/docs/references/clusters). #[derive( - Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, CandidType, Deserialize, Serialize, + Copy, + Clone, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + CandidType, + Deserialize, + Serialize, + Display, )] pub enum SolanaCluster { /// Mainnet: live production environment for deployed applications. @@ -159,7 +171,18 @@ pub enum SolanaCluster { /// Uniquely identifies a supported RPC provider for a particular Solana cluster. #[derive( - Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, CandidType, Deserialize, Serialize, + Copy, + Clone, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + CandidType, + Deserialize, + Serialize, + Display, )] pub enum SupportedRpcProviderId { /// [Alchemy](https://www.alchemy.com/) provider for [Solana Mainnet](https://solana.com/docs/references/clusters)