@@ -7,6 +7,7 @@ use jsonrpsee::{
77use reth_network_api:: FullNetwork ;
88use reth_scroll_node:: ScrollNetworkPrimitives ;
99use rollup_node_chain_orchestrator:: { ChainOrchestratorHandle , ChainOrchestratorStatus } ;
10+ use rollup_node_primitives:: L1MessageEnvelope ;
1011use tokio:: sync:: { oneshot, Mutex , OnceCell } ;
1112
1213/// RPC extension for rollup node management operations.
@@ -79,6 +80,10 @@ pub trait RollupNodeExtApi {
7980 /// Returns the current status of the rollup node.
8081 #[ method( name = "status" ) ]
8182 async fn status ( & self ) -> RpcResult < ChainOrchestratorStatus > ;
83+
84+ /// Returns the L1 message by index.
85+ #[ method( name = "getL1MessageByIndex" ) ]
86+ async fn get_l1_message_by_index ( & self , index : u64 ) -> RpcResult < Option < L1MessageEnvelope > > ;
8287}
8388
8489#[ async_trait]
@@ -139,4 +144,22 @@ where
139144 )
140145 } )
141146 }
147+
148+ async fn get_l1_message_by_index ( & self , index : u64 ) -> RpcResult < Option < L1MessageEnvelope > > {
149+ let handle = self . rollup_manager_handle ( ) . await . map_err ( |e| {
150+ ErrorObjectOwned :: owned (
151+ error:: INTERNAL_ERROR_CODE ,
152+ format ! ( "Failed to get rollup manager handle: {}" , e) ,
153+ None :: < ( ) > ,
154+ )
155+ } ) ?;
156+
157+ handle. get_l1_message_by_index ( index) . await . map_err ( |e| {
158+ ErrorObjectOwned :: owned (
159+ error:: INTERNAL_ERROR_CODE ,
160+ format ! ( "Failed to get L1 message by index: {}" , e) ,
161+ None :: < ( ) > ,
162+ )
163+ } )
164+ }
142165}
0 commit comments