@@ -96,6 +96,13 @@ pub enum Eip7702SendError {
9696 inner_error : Option < EngineError > ,
9797 } ,
9898
99+ #[ error( "Failed to fetch nonce: {message}" ) ]
100+ #[ serde( rename_all = "camelCase" ) ]
101+ NonceFetchError {
102+ message : String ,
103+ inner_error : Option < EngineError > ,
104+ } ,
105+
99106 #[ error( "Failed to call bundler: {message}" ) ]
100107 BundlerCallError { message : String } ,
101108
@@ -264,7 +271,13 @@ where
264271
265272 // 5. Sign authorization if needed
266273 let authorization = if !is_minimal_account {
267- let nonce = job_data. nonce . unwrap_or_default ( ) ;
274+ let nonce = get_eoa_nonce ( & chain, job_data. eoa_address )
275+ . await
276+ . map_err ( |e| Eip7702SendError :: NonceFetchError {
277+ message : format ! ( "Failed to fetch nonce: {e}" ) ,
278+ inner_error : Some ( e) ,
279+ } )
280+ . map_err_fail ( ) ?;
268281
269282 let auth = self
270283 . eoa_signer
@@ -511,3 +524,18 @@ async fn check_is_7702_minimal_account(
511524
512525 Ok ( is_delegated)
513526}
527+
528+ async fn get_eoa_nonce ( chain : & impl Chain , eoa_address : Address ) -> Result < u64 , EngineError > {
529+ chain
530+ . provider ( )
531+ . get_transaction_count ( eoa_address)
532+ . await
533+ . map_err ( |e| EngineError :: RpcError {
534+ chain_id : chain. chain_id ( ) ,
535+ rpc_url : chain. rpc_url ( ) . to_string ( ) ,
536+ message : format ! ( "Failed to get nonce for address {}: {}" , eoa_address, e) ,
537+ kind : RpcErrorKind :: InternalError {
538+ message : e. to_string ( ) ,
539+ } ,
540+ } )
541+ }
0 commit comments