Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions core/src/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ pub trait AccountSigner {
options: Self::SigningOptions,
chain_id: u64,
address: Address,
nonce: alloy::primitives::U256,
nonce: u64,
credentials: &SigningCredential,
) -> impl std::future::Future<Output = Result<SignedAuthorization, EngineError>> + Send;
}
Expand Down Expand Up @@ -355,14 +355,14 @@ impl AccountSigner for EoaSigner {
options: EoaSigningOptions,
chain_id: u64,
address: Address,
nonce: U256,
nonce: u64,
credentials: &SigningCredential,
) -> Result<SignedAuthorization, EngineError> {
// Create the Authorization struct that both clients expect
let authorization = Authorization {
chain_id: U256::from(chain_id),
address,
nonce: nonce.to::<u64>(),
nonce,
};
match credentials {
SigningCredential::Vault(auth_method) => {
Expand Down
30 changes: 29 additions & 1 deletion executors/src/eip7702_executor/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ pub enum Eip7702SendError {
inner_error: Option<EngineError>,
},

#[error("Failed to fetch nonce: {message}")]
#[serde(rename_all = "camelCase")]
NonceFetchError {
message: String,
inner_error: Option<EngineError>,
},

#[error("Failed to call bundler: {message}")]
BundlerCallError { message: String },

Expand Down Expand Up @@ -264,7 +271,13 @@ where

// 5. Sign authorization if needed
let authorization = if !is_minimal_account {
let nonce = job_data.nonce.unwrap_or_default();
let nonce = get_eoa_nonce(&chain, job_data.eoa_address)
.await
.map_err(|e| Eip7702SendError::NonceFetchError {
message: format!("Failed to fetch nonce: {e}"),
inner_error: Some(e),
})
.map_err_fail()?;

let auth = self
.eoa_signer
Expand Down Expand Up @@ -511,3 +524,18 @@ async fn check_is_7702_minimal_account(

Ok(is_delegated)
}

async fn get_eoa_nonce(chain: &impl Chain, eoa_address: Address) -> Result<u64, EngineError> {
chain
.provider()
.get_transaction_count(eoa_address)
.await
.map_err(|e| EngineError::RpcError {
chain_id: chain.chain_id(),
rpc_url: chain.rpc_url().to_string(),
message: format!("Failed to get nonce for address {}: {}", eoa_address, e),
kind: RpcErrorKind::InternalError {
message: e.to_string(),
},
})
}