-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Populate src Directory and Initial Client / Config Code
- Loading branch information
Showing
9 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use crate::config::Config; | ||
use crate::error::Result; | ||
use crate::types::Cluster; | ||
|
||
use reqwest::Client; | ||
|
||
pub struct Helius { | ||
config: Config, | ||
client: Client, | ||
} | ||
|
||
impl Helius { | ||
pub fn new(api_key: &str, cluster: Cluster) -> Result<Self> { | ||
let config: Config = Config::new(api_key, cluster)?; | ||
let client: Client = Client::new(); | ||
|
||
Ok(Helius {config, client}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use crate::error::{ HeliusError, Result }; | ||
use crate::types::{ Cluster, HeliusEndpoints }; | ||
|
||
pub struct Config { | ||
pub api_key: String, | ||
pub cluster: Cluster, | ||
pub endpoints: HeliusEndpoints, | ||
} | ||
|
||
impl Config { | ||
pub fn new(api_key: &str, cluster: Cluster) -> Result<Self> { | ||
if api_key.is_empty() { | ||
return Err(HeliusError::InvalidInput("API key must not be empty".to_string())); | ||
} | ||
|
||
|
||
let endpoints: HeliusEndpoints = match cluster { | ||
Cluster::Devnet => HeliusEndpoints { | ||
api: "https://api-devnet.helius-rpc.com".to_string(), | ||
rpc: "https://devnet.helius-rpc.com".to_string(), | ||
}, | ||
Cluster::MainnetBeta => HeliusEndpoints { | ||
api: "https://api-mainnet.helius-rpc.com".to_string(), | ||
rpc: "https://mainnet.helius-rpc.com".to_string(), | ||
}, | ||
}; | ||
|
||
Ok(Config { | ||
api_key: api_key.to_string(), | ||
cluster, | ||
endpoints, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
mod client; | ||
mod config; | ||
mod das_api; | ||
mod error; | ||
mod mint_api; | ||
mod webhook; | ||
mod rpc; | ||
mod types; | ||
mod utils; | ||
mod webhook; | ||
|
||
pub use client::Helius; | ||
pub use client::Helius; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|