Skip to content

Commit 394da33

Browse files
authored
Merge pull request oasisprotocol#2371 from oasisprotocol/ZigaMr/feat/rofl-client-rs
feat(rofl-client/rs): add Rust ROFL client
2 parents b89a8af + 0da5cd9 commit 394da33

File tree

8 files changed

+558
-1
lines changed

8 files changed

+558
-1
lines changed

Cargo.lock

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ members = [
2323
"rofl-containers",
2424
"rofl-scheduler",
2525
"rofl-proxy",
26+
"rofl-client/rs",
2627

2728
# Test runtimes.
2829
"tests/runtimes/benchmarking",

rofl-client/rs/CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog], and this project adheres to [Semantic Versioning].
6+
7+
## [Unreleased]
8+
9+
### Added
10+
-
11+
12+
### Changed
13+
-
14+
15+
### Fixed
16+
-
17+
18+
## 0.1.0 - 2025-10-21
19+
20+
### Added
21+
- Initial public release of the Rust ROFL client (`oasis-rofl-client`).
22+
- Core API:
23+
- `RoflClient::get_app_id`
24+
- `RoflClient::generate_key` with `KeyKind` (`raw-256`, `raw-384`, `ed25519`, `secp256k1`)
25+
- `RoflClient::sign_submit` (supports `eth` and `std` tx kinds)
26+
- `RoflClient::sign_submit_eth` convenience helper
27+
- `RoflClient::get_metadata` getter for Metadata entries
28+
- `RoflClient::set_metadata` setter for Metadata entries
29+
- `RoflClient::query` on-chain data queries
30+
- HTTP-over-UDS transport targeting `/run/rofl-appd.sock` with async methods offloading blocking I/O.
31+
- Example: `examples/basic.rs`.
32+
- README with quickstart.
33+
34+
[Keep a Changelog]: https://keepachangelog.com/en/1.0.0/
35+
[Semantic Versioning]: https://semver.org/spec/v2.0.0.html

rofl-client/rs/Cargo.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
name = "oasis-rofl-client"
3+
version = "0.1.0"
4+
edition = "2021"
5+
license = "Apache-2.0"
6+
description = "Rust client for ROFL appd (Unix domain socket HTTP)."
7+
8+
[dependencies]
9+
serde = { version = "1", features = ["derive"] }
10+
serde_json = "1"
11+
tokio = { version = "1", features = ["full", "test-util"] }
12+
hex = "0.4.3"
13+
thiserror = "1.0"
14+
anyhow = "1.0"
15+
16+
[dev-dependencies]
17+
tempfile = "3.8"

rofl-client/rs/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# rofl-client/rs/README.md
2+
Rust client for the ROFL appd over a Unix domain socket.
3+
4+
- Default socket: `/run/rofl-appd.sock`
5+
- Endpoints used:
6+
- `GET /rofl/v1/app/id`
7+
- `POST /rofl/v1/keys/generate`
8+
- `POST /rofl/v1/tx/sign-submit`
9+
10+
Quickstart:
11+
12+
```rust
13+
use oasis_rofl_client::{KeyKind, RoflClient};
14+
15+
#[tokio::main]
16+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
17+
let client = RoflClient::new()?;
18+
println!("app id: {}", client.get_app_id().await?);
19+
println!(
20+
"key: {}",
21+
client.generate_key("example", KeyKind::Ed25519).await?
22+
);
23+
Ok(())
24+
}
25+
```
26+
27+
Notes:
28+
- Requires Unix socks. Windows is not supported unless using WSL.
29+
- Methods are `async` and internally offload blocking UDS I/O via `tokio::task::spawn_blocking`.

rofl-client/rs/examples/basic.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// rofl-client/rs/examples/basic.rs
2+
use oasis_rofl_client::{KeyKind, RoflClient};
3+
4+
#[tokio::main]
5+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
6+
let client = RoflClient::new()?;
7+
println!("app id: {}", client.get_app_id().await?);
8+
println!(
9+
"key: {}",
10+
client.generate_key("example", KeyKind::Ed25519).await?
11+
);
12+
Ok(())
13+
}

0 commit comments

Comments
 (0)