forked from Kuska-ssb/solar
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from mycognosist/jsonrpc_client
Add a JSON-RPC client library
- Loading branch information
Showing
29 changed files
with
827 additions
and
129 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -2,4 +2,6 @@ | |
members = [ | ||
"solar", | ||
"solar_cli", | ||
"solar_client", | ||
] | ||
resolver = "2" |
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
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
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "solar_client" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
anyhow = "1.0.79" | ||
jsonrpc_client = { version = "0.7.1", features = ["macros", "reqwest"] } | ||
reqwest = { version = "0.11", default-features = false, features = [ "json" ] } | ||
serde_json = { version = "1", features = ["preserve_order", "arbitrary_precision"] } | ||
|
||
[dev-dependencies] | ||
tokio = { version = "1.36.0", features = [ "macros", "rt-multi-thread" ] } |
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,9 @@ | ||
# 🌞 Solar JSON-RPC Client | ||
|
||
An HTTP JSON-RPC client for the Solar node. | ||
|
||
See `src/lib.rs` and `examples/` for API details and usage examples. | ||
|
||
## License | ||
|
||
AGPL-3.0 |
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,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(()) | ||
} |
Oops, something went wrong.