Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support for Staked RPC Endpoint #63

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ semver = "1.0.23"
serde = "1.0.198"
serde-enum-str = "0.4.0"
serde_json = "1.0.116"
solana-account-decoder = "=1.18.12"
solana-client = "=1.18.12"
solana-program = "=1.18.12"
solana-rpc-client-api = "=1.18.12"
solana-sdk = "=1.18.12"
solana-transaction-status = "=1.18.12"
solana-account-decoder = "=2.0.7"
solana-client = "=2.0.7"
solana-program = "=2.0.7"
solana-rpc-client-api = "=2.0.7"
solana-sdk = "=2.0.7"
solana-transaction-status = "=2.0.7"
thiserror = "1.0.58"
tokio = { version = "1.37.0", features = ["macros", "rt-multi-thread", "net"] }
tokio-stream = "0.1.15"
Expand Down
3 changes: 3 additions & 0 deletions src/types/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ impl MintApiAuthority {
Cluster::MainnetBeta => Ok(MintApiAuthority::Mainnet(
"HnT5KVAywGgQDhmh6Usk4bxRg4RwKxCK4jmECyaDth5R",
)),
Cluster::StakedMainnetBeta => Ok(MintApiAuthority::Mainnet(
"HnT5KVAywGgQDhmh6Usk4bxRg4RwKxCK4jmECyaDth5R",
)),
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/types/types.rs
0xIchigo marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use solana_sdk::{address_lookup_table::AddressLookupTableAccount, instruction::I
pub enum Cluster {
Devnet,
MainnetBeta,
StakedMainnetBeta,
}

/// Stores the API and RPC endpoint URLs for a specific Helius cluster
Expand All @@ -36,6 +37,10 @@ impl HeliusEndpoints {
api: "https://api-mainnet.helius-rpc.com/".to_string(),
rpc: "https://mainnet.helius-rpc.com/".to_string(),
},
Cluster::StakedMainnetBeta => HeliusEndpoints {
api: "https://api-mainnet.helius-rpc.com/".to_string(),
rpc: "https://staked.helius-rpc.com/".to_string(),
},
}
}
}
Expand Down
28 changes: 28 additions & 0 deletions tests/test_client_staked.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use helius::client::Helius;
use helius::error::Result;
use helius::types::Cluster;

#[test]
fn test_creating_new_client_staked_success() {
let api_key: &str = "valid-api-key";
let cluster: Cluster = Cluster::StakedMainnetBeta;

let result: Result<Helius> = Helius::new(api_key, cluster);
assert!(result.is_ok());

let helius: Helius = result.unwrap();
assert_eq!(helius.config.api_key, api_key);
}

#[test]
fn test_creating_new_async_client_staked_success() {
let api_key: &str = "valid-api-key";
let cluster: Cluster = Cluster::StakedMainnetBeta;

let result: Result<Helius> = Helius::new_with_async_solana(api_key, cluster);
assert!(result.is_ok());

let helius: Helius = result.unwrap();
assert_eq!(helius.config.api_key, api_key);
assert!(helius.async_rpc_client.is_some());
}
10 changes: 10 additions & 0 deletions tests/test_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ fn test_factory_create_mainnet_instance() {
assert_eq!(helius.config.endpoints.rpc, "https://mainnet.helius-rpc.com/");
}

#[test]
fn test_factory_create_staked_mainnet_instance() {
let factory: HeliusFactory = HeliusFactory::new("valid_api_key");
let helius: Helius = factory.create(Cluster::StakedMainnetBeta).unwrap();

assert_eq!(helius.config.api_key, "valid_api_key");
assert_eq!(helius.config.endpoints.api, "https://api-mainnet.helius-rpc.com/");
assert_eq!(helius.config.endpoints.rpc, "https://staked.helius-rpc.com/");
}

#[test]
fn test_factory_create_with_reqwest() {
let mut factory = HeliusFactory::new("valid_api_key");
Expand Down
Loading