Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
members = [
"anchor",
"anchor/client",
"anchor/common/api_types",
"anchor/common/bls_lagrange",
"anchor/common/qbft",
"anchor/common/ssv_network_config",
Expand Down Expand Up @@ -31,6 +32,7 @@ edition = "2021"
# This table has three subsections: first the internal dependencies, then the lighthouse dependencies, then all other.
[workspace.dependencies]
anchor_validator_store = { path = "anchor/validator_store" }
api_types = { path = "anchor/common/api_types" }
bls_lagrange = { path = "anchor/common/bls_lagrange" }
client = { path = "anchor/client" }
database = { path = "anchor/database" }
Expand Down Expand Up @@ -111,7 +113,7 @@ rand = "0.8.5"
reqwest = "0.12.12"
rusqlite = "0.28.0"
serde = { version = "1.0.208", features = ["derive"] }
serde_json = "1.0.138"
serde_json = "1.0.140"
serde_yaml = "0.9"
sha2 = "0.10.8"
strum = { version = "0.26.3", features = ["derive"] }
Expand Down
7 changes: 7 additions & 0 deletions anchor/common/api_types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "api_types"
version = "0.1.0"
edition = { workspace = true }

[dependencies]
serde = { workspace = true }
16 changes: 16 additions & 0 deletions anchor/common/api_types/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use serde::Serialize;

#[derive(Serialize)]
pub struct VersionData {
pub version: String,
}
#[derive(Serialize)]
pub struct GenericResponse<T> {
pub data: T,
}

impl<T> From<T> for GenericResponse<T> {
fn from(data: T) -> Self {
Self { data }
}
}
1 change: 0 additions & 1 deletion anchor/common/version/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ pub const COMMIT_PREFIX: &str = git_version!(
/// ## Example
///
/// `Anchor/v0.1.0-67da032+/x86_64-linux`
#[allow(dead_code)]
pub fn version_with_platform() -> String {
format!("{}/{}-{}", VERSION, Target::arch(), Target::os())
}
Expand Down
3 changes: 3 additions & 0 deletions anchor/http_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ name = "http_api"
path = "src/lib.rs"

[dependencies]
api_types = { workspace = true }
axum = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
slot_clock = { workspace = true }
task_executor = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
version = { workspace = true }
15 changes: 12 additions & 3 deletions anchor/http_api/src/router.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
//! The routes for the HTTP API

use axum::{routing::get, Router};

use api_types::{GenericResponse, VersionData};
use axum::{routing::get, Json, Router};
use version::version_with_platform;
/// Creates all the routes for HTTP API
pub fn new() -> Router {
// Default route
Router::new().route("/", get(root))
Router::new()
.route("/", get(root))
.route("/anchor/version", get(get_version))
}

// Temporary return value.
async fn root() -> &'static str {
"Anchor client"
}

async fn get_version() -> Json<GenericResponse<VersionData>> {
Json(GenericResponse::from(VersionData {
version: version_with_platform(),
}))
}