diff --git a/solar_client/examples/blocks.rs b/solar_client/examples/blocks.rs new file mode 100644 index 0000000..c645b1e --- /dev/null +++ b/solar_client/examples/blocks.rs @@ -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(()) +} diff --git a/solar_client/src/lib.rs b/solar_client/src/lib.rs index 880c630..d4227a5 100644 --- a/solar_client/src/lib.rs +++ b/solar_client/src/lib.rs @@ -2,6 +2,8 @@ use anyhow::Result; #[jsonrpc_client::api] pub trait SolarClient { + async fn blocks(&self, pub_key: &str) -> Vec; + async fn ping(&self) -> String; async fn whoami(&self) -> String;