11use alloy:: primitives:: { Address , TxHash } ;
22use alloy:: providers:: Provider ;
3+ use engine_core:: error:: { AlloyRpcErrorToEngineError , EngineError } ;
34use engine_core:: {
45 chain:: { Chain , ChainService , RpcCredentials } ,
56 execution_options:: WebhookOptions ,
@@ -62,13 +63,25 @@ pub struct Eip7702ConfirmationResult {
6263#[ serde( rename_all = "SCREAMING_SNAKE_CASE" , tag = "errorCode" ) ]
6364pub enum Eip7702ConfirmationError {
6465 #[ error( "Chain service error for chainId {chain_id}: {message}" ) ]
66+ #[ serde( rename_all = "camelCase" ) ]
6567 ChainServiceError { chain_id : u64 , message : String } ,
6668
6769 #[ error( "Failed to get transaction hash from bundler: {message}" ) ]
6870 TransactionHashError { message : String } ,
6971
7072 #[ error( "Failed to confirm transaction: {message}" ) ]
71- ConfirmationError { message : String } ,
73+ #[ serde( rename_all = "camelCase" ) ]
74+ ConfirmationError {
75+ message : String ,
76+ inner_error : Option < EngineError > ,
77+ } ,
78+
79+ #[ error( "Receipt not yet available for transaction: {message}" ) ]
80+ #[ serde( rename_all = "camelCase" ) ]
81+ ReceiptNotAvailable {
82+ message : String ,
83+ transaction_hash : TxHash ,
84+ } ,
7285
7386 #[ error( "Transaction failed: {message}" ) ]
7487 TransactionFailed { message : String } ,
@@ -169,26 +182,25 @@ where
169182 . bundler_client ( )
170183 . tw_get_transaction_hash ( & job_data. bundler_transaction_id )
171184 . await
172- . map_err ( |e| {
173- // Check if it's a "not found" or "pending" error
174- let error_msg = e. to_string ( ) ;
175- if error_msg. contains ( "not found" ) || error_msg. contains ( "pending" ) {
176- // Transaction not ready yet, nack and retry
177- Eip7702ConfirmationError :: TransactionHashError {
178- message : format ! ( "Transaction not ready: {}" , error_msg) ,
179- }
180- . nack ( Some ( Duration :: from_secs ( 5 ) ) , RequeuePosition :: Last )
181- } else {
182- Eip7702ConfirmationError :: TransactionHashError { message : error_msg } . fail ( )
183- }
184- } ) ?;
185+ . map_err ( |e| Eip7702ConfirmationError :: TransactionHashError {
186+ message : e. to_string ( ) ,
187+ } )
188+ . map_err_fail ( ) ?;
185189
186- let transaction_hash = transaction_hash_str. parse :: < TxHash > ( ) . map_err ( |e| {
187- Eip7702ConfirmationError :: TransactionHashError {
188- message : format ! ( "Invalid transaction hash format: {}" , e) ,
190+ let transaction_hash = match transaction_hash_str {
191+ Some ( hash) => hash. parse :: < TxHash > ( ) . map_err ( |e| {
192+ Eip7702ConfirmationError :: TransactionHashError {
193+ message : format ! ( "Invalid transaction hash format: {}" , e) ,
194+ }
195+ . fail ( )
196+ } ) ?,
197+ None => {
198+ return Err ( Eip7702ConfirmationError :: TransactionHashError {
199+ message : "Transaction not found" . to_string ( ) ,
200+ } )
201+ . map_err_nack ( Some ( Duration :: from_secs ( 2 ) ) , RequeuePosition :: Last ) ;
189202 }
190- . fail ( )
191- } ) ?;
203+ } ;
192204
193205 tracing:: debug!(
194206 transaction_hash = ?transaction_hash,
@@ -205,18 +217,20 @@ where
205217 // If transaction not found, nack and retry
206218 Eip7702ConfirmationError :: ConfirmationError {
207219 message : format ! ( "Failed to get transaction receipt: {}" , e) ,
220+ inner_error : Some ( e. to_engine_error ( & chain) ) ,
208221 }
209- . nack ( Some ( Duration :: from_secs ( 10 ) ) , RequeuePosition :: Last )
222+ . nack ( Some ( Duration :: from_secs ( 5 ) ) , RequeuePosition :: Last )
210223 } ) ?;
211224
212225 let receipt = match receipt {
213226 Some ( receipt) => receipt,
214227 None => {
215228 // Transaction not mined yet, nack and retry
216- return Err ( Eip7702ConfirmationError :: ConfirmationError {
229+ return Err ( Eip7702ConfirmationError :: ReceiptNotAvailable {
217230 message : "Transaction not mined yet" . to_string ( ) ,
231+ transaction_hash,
218232 } )
219- . map_err_nack ( Some ( Duration :: from_secs ( 10 ) ) , RequeuePosition :: Last ) ;
233+ . map_err_nack ( Some ( Duration :: from_secs ( 2 ) ) , RequeuePosition :: Last ) ;
220234 }
221235 } ;
222236
0 commit comments