Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(server): cleanup all rust warnings #396

Merged
merged 1 commit into from
Jun 20, 2024
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
4 changes: 2 additions & 2 deletions crates/server/src/admin/handlers/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ pub struct GetContextUsersResponse {
}

pub async fn get_context_users_handler(
Path(context_id): Path<String>,
Extension(state): Extension<Arc<AdminState>>,
Path(_context_id): Path<String>,
Extension(_state): Extension<Arc<AdminState>>,
) -> impl IntoResponse {
ApiResponse {
payload: GetContextUsersResponse {
Expand Down
3 changes: 1 addition & 2 deletions crates/server/src/admin/handlers/root_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ use serde::Serialize;
use tracing::info;

use super::add_client_key::transform_request;
use crate::admin::handlers::add_client_key::store_client_key;
use crate::admin::service::{parse_api_error, AdminState, ApiError, ApiResponse};
use crate::admin::storage::root_key::{add_root_key, get_root_keys};
use crate::admin::storage::root_key::add_root_key;
use crate::admin::utils::auth::validate_challenge;

#[derive(Debug, Serialize)]
Expand Down
57 changes: 36 additions & 21 deletions crates/server/src/admin/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,10 @@ use calimero_store::Store;
use libp2p::identity::Keypair;
use serde::{Deserialize, Serialize};
use serde_json::json;
use tower_http::services::{ServeDir, ServeFile};
use tower_http::set_status::SetStatus;
use tower_sessions::{MemoryStore, SessionManagerLayer};
use tracing::info;

use super::handlers::add_client_key::add_client_key_handler;
use super::handlers::challenge::request_challenge_handler;
use super::handlers::context::{
create_context_handler, delete_context_handler, get_context_handler, get_contexts_handler,
get_context_storage_handler, get_context_client_keys_handler, get_context_users_handler
};
use super::handlers::fetch_did::fetch_did_handler;
use super::handlers::root_keys::create_root_key_handler;
use super::handlers;

#[derive(Debug, Serialize, Deserialize)]
pub struct AdminConfig {
Expand Down Expand Up @@ -63,19 +54,43 @@ pub(crate) fn setup(

let admin_router = Router::new()
.route("/health", get(health_check_handler))
.route("/root-key", post(create_root_key_handler))
.route("/request-challenge", post(request_challenge_handler))
.route(
"/root-key",
post(handlers::root_keys::create_root_key_handler),
)
.route(
"/request-challenge",
post(handlers::challenge::request_challenge_handler),
)
.route("/install-application", post(install_application_handler))
.route("/applications", get(list_applications_handler))
.route("/add-client-key", post(add_client_key_handler))
.route("/did", get(fetch_did_handler))
.route("/contexts", post(create_context_handler))
.route("/contexts/:context_id", delete(delete_context_handler))
.route("/contexts/:context_id", get(get_context_handler))
.route("/contexts/:context_id/users", get(get_context_users_handler))
.route("/contexts/:context_id/client-keys", get(get_context_client_keys_handler))
.route("/contexts/:context_id/storage", get(get_context_storage_handler))
.route("/contexts", get(get_contexts_handler))
.route(
"/add-client-key",
post(handlers::add_client_key::add_client_key_handler),
)
.route("/did", get(handlers::fetch_did::fetch_did_handler))
.route("/contexts", post(handlers::context::create_context_handler))
.route(
"/contexts/:context_id",
delete(handlers::context::delete_context_handler),
)
.route(
"/contexts/:context_id",
get(handlers::context::get_context_handler),
)
.route(
"/contexts/:context_id/users",
get(handlers::context::get_context_users_handler),
)
.route(
"/contexts/:context_id/client-keys",
get(handlers::context::get_context_client_keys_handler),
)
.route(
"/contexts/:context_id/storage",
get(handlers::context::get_context_storage_handler),
)
.route("/contexts", get(handlers::context::get_contexts_handler))
.layer(Extension(shared_state))
.layer(session_layer);

Expand Down
8 changes: 0 additions & 8 deletions crates/server/src/admin/storage/root_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ use super::did::{get_or_create_did, update_did};
pub fn add_root_key(store: &Store, root_key: RootKey) -> eyre::Result<bool> {
let mut did_document = get_or_create_did(store)?;

let serialized_root_key = match serde_json::to_string(&root_key) {
fbozic marked this conversation as resolved.
Show resolved Hide resolved
Ok(json) => json,
Err(err) => {
eprintln!("Serialization error: {}", err);
return Err(eyre::eyre!("Serialization error: {}", err));
}
};

if !did_document
.root_keys
.iter()
Expand Down