diff --git a/bolt-sidecar/src/api/commitments/handlers.rs b/bolt-sidecar/src/api/commitments/handlers.rs index d9cbd541b..db8a5a73f 100644 --- a/bolt-sidecar/src/api/commitments/handlers.rs +++ b/bolt-sidecar/src/api/commitments/handlers.rs @@ -65,9 +65,9 @@ pub async fn rpc_entrypoint( }; // Parse the inclusion request from the parameters - let mut inclusion_request: InclusionRequest = serde_json::from_value(request_json) - .map_err(|e| RejectionError::ValidationFailed(e.to_string())) - .inspect_err(|e| error!("Failed to parse inclusion request: {:?}", e))?; + let mut inclusion_request = serde_json::from_value::(request_json) + .map_err(RejectionError::Json) + .inspect_err(|err| error!(?err, "Failed to parse inclusion request"))?; debug!(?inclusion_request, "New inclusion request"); diff --git a/bolt-sidecar/src/api/commitments/spec.rs b/bolt-sidecar/src/api/commitments/spec.rs index 31478abdd..b996837a9 100644 --- a/bolt-sidecar/src/api/commitments/spec.rs +++ b/bolt-sidecar/src/api/commitments/spec.rs @@ -1,5 +1,11 @@ use alloy::primitives::SignatureError; -use axum::{extract::rejection::JsonRejection, http::StatusCode, response::IntoResponse, Json}; +use axum::{ + body::Body, + extract::rejection::JsonRejection, + http::{Response, StatusCode}, + response::IntoResponse, + Json, +}; use thiserror::Error; use crate::{ @@ -58,7 +64,7 @@ pub enum CommitmentError { } impl IntoResponse for CommitmentError { - fn into_response(self) -> axum::http::Response { + fn into_response(self) -> Response { match self { Self::Rejected(err) => { (StatusCode::BAD_REQUEST, Json(JsonResponse::from_error(-32000, err.to_string()))) @@ -117,6 +123,9 @@ pub enum RejectionError { /// State validation failed for this request. #[error("Validation failed: {0}")] ValidationFailed(String), + /// JSON parsing error. + #[error("JSON parsing error: {0}")] + Json(#[from] serde_json::Error), } /// Implements the commitments-API: