Skip to content

Commit 26d8ab7

Browse files
committed
fix: get merkle proof by uuid query
1 parent 8c78c41 commit 26d8ab7

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

aggregation_mode/batcher/src/db.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use sqlx::{postgres::PgPoolOptions, Pool, Postgres};
1+
use sqlx::{postgres::PgPoolOptions, types::Uuid, Pool, Postgres};
22

33
#[derive(Clone, Debug)]
44
pub struct Db {
@@ -33,7 +33,7 @@ impl Db {
3333

3434
pub async fn get_merkle_path_by_proof_id(
3535
&self,
36-
proof_id: &str,
36+
proof_id: Uuid,
3737
) -> Result<Option<Vec<u8>>, sqlx::Error> {
3838
sqlx::query_scalar::<_, Option<Vec<u8>>>(
3939
"SELECT merkle_path FROM proofs WHERE proof_id = $1",

aggregation_mode/batcher/src/server/http.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,12 @@ impl BatcherServer {
9797
));
9898
}
9999

100-
let db_result = state.db.get_merkle_path_by_proof_id(&id).await;
100+
let Ok(proof_id) = sqlx::types::Uuid::parse_str(&id) else {
101+
return HttpResponse::BadRequest()
102+
.json(AppResponse::new_unsucessfull("Proof id invalid uuid", 400));
103+
};
104+
105+
let db_result = state.db.get_merkle_path_by_proof_id(proof_id).await;
101106
let merkle_path = match db_result {
102107
Ok(Some(merkle_path)) => merkle_path,
103108
Ok(None) => {
@@ -106,9 +111,9 @@ impl BatcherServer {
106111
404,
107112
))
108113
}
109-
Err(_) => {
114+
Err(s) => {
110115
return HttpResponse::InternalServerError()
111-
.json(AppResponse::new_unsucessfull("Internal server error", 500))
116+
.json(AppResponse::new_unsucessfull("Internal server error", 500));
112117
}
113118
};
114119

0 commit comments

Comments
 (0)