@@ -11,15 +11,16 @@ use aligned_sdk::aggregation_layer::AggregationModeProvingSystem;
1111use sqlx:: types:: BigDecimal ;
1212
1313use super :: {
14- helpers:: format_merkle_paths ,
14+ helpers:: format_merkle_path ,
1515 types:: { AppResponse , GetReceiptsQueryParams } ,
1616} ;
1717
1818use crate :: {
1919 config:: Config ,
2020 db:: Db ,
2121 server:: types:: {
22- SubmitProofRequest , SubmitProofRequestMessageRisc0 , SubmitProofRequestMessageSP1 ,
22+ GetReceiptsResponse , SubmitProofRequest , SubmitProofRequestMessageRisc0 ,
23+ SubmitProofRequestMessageSP1 ,
2324 } ,
2425} ;
2526
@@ -232,14 +233,34 @@ impl BatcherServer {
232233 ) ) ;
233234 } ;
234235
235- match format_merkle_paths ( receipts) {
236- Ok ( receipts) => {
237- HttpResponse :: Ok ( ) . json ( AppResponse :: new_sucessfull ( serde_json:: json!( {
238- "receipts" : receipts
239- } ) ) )
240- }
241- Err ( _) => HttpResponse :: InternalServerError ( )
242- . json ( AppResponse :: new_unsucessfull ( "Internal server error" , 500 ) ) ,
236+ let mut responses: Vec < GetReceiptsResponse > = Vec :: new ( ) ;
237+ for receipt in receipts {
238+ let Some ( merkle_path) = receipt. merkle_path else {
239+ responses. push ( GetReceiptsResponse {
240+ status : receipt. status ,
241+ merkle_path : Vec :: new ( ) ,
242+ nonce : receipt. nonce ,
243+ address : receipt. address ,
244+ } ) ;
245+
246+ continue ;
247+ } ;
248+
249+ let Ok ( formatted_merkle_path) = format_merkle_path ( & merkle_path) else {
250+ return HttpResponse :: InternalServerError ( )
251+ . json ( AppResponse :: new_unsucessfull ( "Internal server error" , 500 ) ) ;
252+ } ;
253+
254+ responses. push ( GetReceiptsResponse {
255+ status : receipt. status ,
256+ merkle_path : formatted_merkle_path,
257+ nonce : receipt. nonce ,
258+ address : receipt. address ,
259+ } ) ;
243260 }
261+
262+ HttpResponse :: Ok ( ) . json ( AppResponse :: new_sucessfull ( serde_json:: json!( {
263+ "receipts" : responses
264+ } ) ) )
244265 }
245266}
0 commit comments