Skip to content

Commit

Permalink
Update Examples
Browse files Browse the repository at this point in the history
  • Loading branch information
0xIchigo committed May 7, 2024
1 parent ff8136b commit 6c74de7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,15 @@ async fn main() -> Result<(), HeliusError> {
let api_key: &str = "YOUR_API_KEY";
let cluster: Cluster = Cluster::MainnetBeta;

let config: Config = Config::new(api_key, cluster)?;
let config: Arc<Config> = Arc::new(Config::new(api_key, cluster)?);
let client: Client = Client::new();
let rpc_client: RpcClient = RpcClient::new(Arc::new(client), Arc::new(config))?;
let rpc_client: Arc<RpcClient> = Arc::new(RpcClient::new(Arc::new(client.clone()), Arc::clone(&config)).unwrap());

let helius: Helius = Helius {
config,
client,
rpc_client,
};

let request: GetAssetRequest = GetAssetRequest {
id: "F9Lw3ki3hJ7PF9HQXsBzoY8GyE6sPoEZZdXJBsTTD2rk".to_string(),
Expand All @@ -46,7 +52,7 @@ async fn main() -> Result<(), HeliusError> {
}),
};

let response: Result<Option<GetAssetResponseForAsset>, HeliusError> = rpc_client.get_asset(request).await;
let response: Result<Option<GetAssetResponseForAsset>, HeliusError> = helius.rpc().get_asset(request).await;

match response {
Ok(Some(asset)) => {
Expand Down
17 changes: 13 additions & 4 deletions examples/get_asset_batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,25 @@ use helius_sdk::config::Config;
use helius_sdk::error::HeliusError;
use helius_sdk::rpc_client::RpcClient;
use helius_sdk::types::{Asset, Cluster, GetAssetBatch, GetAssetOptions};
use helius_sdk::Helius;

use reqwest::Client;
use std::sync::Arc;

#[tokio::main]
async fn main() -> Result<(), HeliusError> {
let api_key: &str = "your_api_key";
let cluster: Cluster = Cluster::MainnetBeta;

let config: Config = Config::new(api_key, cluster)?;
let client: reqwest::Client = reqwest::Client::new();
let rpc_client: RpcClient = RpcClient::new(Arc::new(client), Arc::new(config))?;
let config: Arc<Config> = Arc::new(Config::new(api_key, cluster)?);
let client: Client = Client::new();
let rpc_client: Arc<RpcClient> = Arc::new(RpcClient::new(Arc::new(client.clone()), Arc::clone(&config)).unwrap());

let helius: Helius = Helius {
config,
client,
rpc_client,
};

let request: GetAssetBatch = GetAssetBatch {
ids: vec![
Expand All @@ -24,7 +33,7 @@ async fn main() -> Result<(), HeliusError> {
}),
};

let response: Result<Vec<Option<Asset>>, HeliusError> = rpc_client.get_asset_batch(request).await;
let response: Result<Vec<Option<Asset>>, HeliusError> = helius.rpc().get_asset_batch(request).await;
println!("Assets: {:?}", response);

Ok(())
Expand Down

0 comments on commit 6c74de7

Please sign in to comment.