Skip to content

Commit

Permalink
add blocks and example
Browse files Browse the repository at this point in the history
  • Loading branch information
mycognosist committed Feb 12, 2024
1 parent 6edf08c commit 28cd2f8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
21 changes: 21 additions & 0 deletions solar_client/examples/blocks.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use anyhow::Result;
use solar_client::{Client, SolarClient};

const SERVER_ADDR: &str = "http://127.0.0.1:3030";
const PUB_KEY: &str = "@HEqy940T6uB+T+d9Jaa58aNfRzLx9eRWqkZljBmnkmk=.ed25519";

#[tokio::main]
async fn main() -> Result<()> {
let client = Client::new(SERVER_ADDR.to_owned())?;

let blocks = client.blocks(PUB_KEY).await?;
println!("{:#?}", blocks);
// [
// "@dW5ch5miTnxLJDVDtB4ZCvrVxh+S8kGCQIBbd5paLhw=.ed25519",
// "@QIlKZ8DMw9XpjpRZ96RBLpfkLnOUZSqamC6WMddGh3I=.ed25519",
// ...
// "@+rMXLy1md42gvbBq+6l6rp95/drh6QyACO1ZZMMnWI0=.ed25519",
// ]

Ok(())
}
2 changes: 2 additions & 0 deletions solar_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use anyhow::Result;

#[jsonrpc_client::api]
pub trait SolarClient {
async fn blocks(&self, pub_key: &str) -> Vec<String>;

async fn ping(&self) -> String;

async fn whoami(&self) -> String;
Expand Down

0 comments on commit 28cd2f8

Please sign in to comment.