Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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
2 changes: 1 addition & 1 deletion aa-core/src/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl<C: Chain + Clone> SmartAccountSignerBuilder<C> {
.to_determined_smart_account()
.await
.map_err(|e| EngineError::ValidationError {
message: format!("Failed to determine smart account: {}", e),
message: format!("Failed to determine smart account: {e}"),
})?,
};

Expand Down
8 changes: 4 additions & 4 deletions core/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl ThirdwebChainConfig<'_> {
// For local anvil, use localhost URLs
let local_rpc_url = "http://127.0.0.1:8545";
let rpc_url = Url::parse(local_rpc_url).map_err(|e| EngineError::RpcConfigError {
message: format!("Failed to parse local anvil RPC URL: {}", e),
message: format!("Failed to parse local anvil RPC URL: {e}"),
})?;

// For bundler and paymaster, use the same local RPC URL
Expand All @@ -149,7 +149,7 @@ impl ThirdwebChainConfig<'_> {
client_id = self.client_id,
))
.map_err(|e| EngineError::RpcConfigError {
message: format!("Failed to parse RPC URL: {}", e),
message: format!("Failed to parse RPC URL: {e}"),
})?;

let bundler_url = Url::parse(&format!(
Expand All @@ -158,7 +158,7 @@ impl ThirdwebChainConfig<'_> {
base_url = self.bundler_base_url,
))
.map_err(|e| EngineError::RpcConfigError {
message: format!("Failed to parse Bundler URL: {}", e),
message: format!("Failed to parse Bundler URL: {e}"),
})?;

let paymaster_url = Url::parse(&format!(
Expand All @@ -167,7 +167,7 @@ impl ThirdwebChainConfig<'_> {
base_url = self.paymaster_base_url,
))
.map_err(|e| EngineError::RpcConfigError {
message: format!("Failed to parse Paymaster URL: {}", e),
message: format!("Failed to parse Paymaster URL: {e}"),
})?;

(rpc_url, bundler_url, paymaster_url)
Expand Down
33 changes: 15 additions & 18 deletions core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,22 +331,22 @@ impl<T: Debug> From<SdkError<T>> for SerialisableAwsSdkError {
fn from(err: SdkError<T>) -> Self {
match err {
SdkError::ConstructionFailure(err) => SerialisableAwsSdkError::ConstructionFailure {
message: format!("{:?}", err),
message: format!("{err:?}"),
},
SdkError::TimeoutError(err) => SerialisableAwsSdkError::TimeoutError {
message: format!("{:?}", err),
message: format!("{err:?}"),
},
SdkError::DispatchFailure(err) => SerialisableAwsSdkError::DispatchFailure {
message: format!("{:?}", err),
message: format!("{err:?}"),
},
SdkError::ResponseError(err) => SerialisableAwsSdkError::ResponseError {
message: format!("{:?}", err),
message: format!("{err:?}"),
},
SdkError::ServiceError(err) => SerialisableAwsSdkError::ServiceError {
message: format!("{:?}", err),
message: format!("{err:?}"),
},
_ => SerialisableAwsSdkError::Other {
message: format!("{:?}", err),
message: format!("{err:?}"),
},
}
}
Expand Down Expand Up @@ -398,11 +398,8 @@ impl From<vault_sdk::error::VaultError> for EngineError {
message,
details,
} => match details {
Some(details) => format!(
"Enclave error: {} - {} - details: {}",
code, message, details
),
None => format!("Enclave error: {} - {}", code, message),
Some(details) => format!("Enclave error: {code} - {message} - details: {details}"),
None => format!("Enclave error: {code} - {message}"),
},
_ => err.to_string(),
};
Expand Down Expand Up @@ -536,15 +533,15 @@ impl ContractErrorToEngineError for alloy::contract::Error {
fn to_engine_error(self, chain_id: u64, contract_address: Option<Address>) -> EngineError {
let (message, kind) = match self {
alloy::contract::Error::UnknownFunction(name) => (
format!("Unknown function: {}", name),
format!("Unknown function: {name}"),
ContractInteractionErrorKind::UnknownFunction {
function_name: name,
},
),
alloy::contract::Error::UnknownSelector(selector) => (
format!("Unknown selector: {:?}", selector),
format!("Unknown selector: {selector:?}"),
ContractInteractionErrorKind::UnknownSelector {
function_selector: format!("{:?}", selector),
function_selector: format!("{selector:?}"),
},
),
alloy::contract::Error::NotADeploymentTransaction => (
Expand All @@ -556,26 +553,26 @@ impl ContractErrorToEngineError for alloy::contract::Error {
ContractInteractionErrorKind::ContractNotDeployed,
),
alloy::contract::Error::ZeroData(function, err) => (
format!("Zero data returned from contract call to {}", function),
format!("Zero data returned from contract call to {function}"),
ContractInteractionErrorKind::ZeroData {
function,
message: err.to_string(),
},
),
alloy::contract::Error::AbiError(err) => (
format!("ABI error: {}", err),
format!("ABI error: {err}"),
ContractInteractionErrorKind::AbiError {
message: err.to_string(),
},
),
alloy::contract::Error::TransportError(err) => (
format!("Transport error: {}", err),
format!("Transport error: {err}"),
ContractInteractionErrorKind::TransportError {
message: err.to_string(),
},
),
alloy::contract::Error::PendingTransactionError(err) => (
format!("Pending transaction error: {}", err),
format!("Pending transaction error: {err}"),
ContractInteractionErrorKind::PendingTransactionError {
message: err.to_string(),
},
Expand Down
4 changes: 2 additions & 2 deletions core/src/execution_options/aa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ impl Erc4337ExecutionOptions {
pub fn get_salt_data(&self) -> Result<Bytes, EngineError> {
if self.account_salt.starts_with("0x") {
Bytes::from_hex(&self.account_salt).map_err(|e| EngineError::ValidationError {
message: format!("Failed to parse hex salt: {}", e),
message: format!("Failed to parse hex salt: {e}"),
})
} else {
let hex_string = alloy::hex::encode(&self.account_salt);
Bytes::from_hex(hex_string).map_err(|e| EngineError::ValidationError {
message: format!("Failed to encode salt as hex: {}", e),
message: format!("Failed to encode salt as hex: {e}"),
})
}
}
Expand Down
5 changes: 2 additions & 3 deletions core/src/execution_options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,8 @@ mod tests {
r#"{{
"url": "https://example.com/webhook",
"secret": "test_secret",
"userMetadata": "{}"
}}"#,
large_metadata
"userMetadata": "{large_metadata}"
}}"#
);

let webhook_options: Result<WebhookOptions, _> = serde_json::from_str(&invalid_json);
Expand Down
12 changes: 6 additions & 6 deletions core/src/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ impl Erc4337SigningOptions {
pub fn get_salt_data(&self) -> Result<Bytes, EngineError> {
if self.account_salt.starts_with("0x") {
Bytes::from_hex(&self.account_salt).map_err(|e| EngineError::ValidationError {
message: format!("Failed to parse hex salt: {}", e),
message: format!("Failed to parse hex salt: {e}"),
})
} else {
let hex_string = alloy::hex::encode(&self.account_salt);
Bytes::from_hex(hex_string).map_err(|e| EngineError::ValidationError {
message: format!("Failed to encode salt as hex: {}", e),
message: format!("Failed to encode salt as hex: {e}"),
})
}
}
Expand Down Expand Up @@ -308,7 +308,7 @@ impl AccountSigner for EoaSigner {
let signature = signer.sign_message(&message_bytes).await.map_err(|e| {
tracing::error!("Error signing message with EOA (PrivateKey): {:?}", e);
EngineError::ValidationError {
message: format!("Failed to sign message: {}", e),
message: format!("Failed to sign message: {e}"),
}
})?;
Ok(signature.to_string())
Expand Down Expand Up @@ -377,7 +377,7 @@ impl AccountSigner for EoaSigner {
.map_err(|e| {
tracing::error!("Error signing typed data with EOA (PrivateKey): {:?}", e);
EngineError::ValidationError {
message: format!("Failed to sign typed data: {}", e),
message: format!("Failed to sign typed data: {e}"),
}
})?;
Ok(signature.to_string())
Expand Down Expand Up @@ -447,7 +447,7 @@ impl AccountSigner for EoaSigner {
.map_err(|e| {
tracing::error!("Error signing transaction with EOA (PrivateKey): {:?}", e);
EngineError::ValidationError {
message: format!("Failed to sign transaction: {}", e),
message: format!("Failed to sign transaction: {e}"),
}
})?;
Ok(signature.to_string())
Expand Down Expand Up @@ -521,7 +521,7 @@ impl AccountSigner for EoaSigner {
let signature = signer.sign_hash_sync(&authorization_hash).map_err(|e| {
tracing::error!("Error signing authorization with EOA (PrivateKey): {:?}", e);
EngineError::ValidationError {
message: format!("Failed to sign authorization: {}", e),
message: format!("Failed to sign authorization: {e}"),
}
})?;

Expand Down
8 changes: 4 additions & 4 deletions core/src/userop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl UserOpSigner {
)
.await
.map_err(|e| EngineError::ValidationError {
message: format!("Failed to sign userop: {}", e),
message: format!("Failed to sign userop: {e}"),
})?;

Ok(Bytes::from_hex(&result.signature).map_err(|_| {
Expand All @@ -128,7 +128,7 @@ impl UserOpSigner {
let signer = creds.get_signer(Some(params.chain_id)).await?;
let userophash = params.userop.hash(params.chain_id).map_err(|e| {
EngineError::ValidationError {
message: format!("Failed to hash userop: {}", e),
message: format!("Failed to hash userop: {e}"),
}
})?;

Expand All @@ -147,13 +147,13 @@ impl UserOpSigner {
SigningCredential::PrivateKey(signer) => {
let userophash = params.userop.hash(params.chain_id).map_err(|e| {
EngineError::ValidationError {
message: format!("Failed to hash userop: {}", e),
message: format!("Failed to hash userop: {e}"),
}
})?;

let signature = signer.sign_hash(&userophash).await.map_err(|e| {
EngineError::ValidationError {
message: format!("Failed to sign userop: {}", e),
message: format!("Failed to sign userop: {e}"),
}
})?;

Expand Down
2 changes: 1 addition & 1 deletion eip7702-core/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl<C: Chain> MinimalAccountTransaction<C> {
// Serialize wrapped calls to JSON
let wrapped_calls_json = serde_json::to_value(&self.wrapped_calls).map_err(|e| {
EngineError::ValidationError {
message: format!("Failed to serialize wrapped calls: {}", e),
message: format!("Failed to serialize wrapped calls: {e}"),
}
})?;

Expand Down
23 changes: 9 additions & 14 deletions eip7702-core/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ use std::time::Duration;

use alloy::{
consensus::{SignableTransaction, TypedTransaction},
eips::{BlockNumberOrTag, eip7702::SignedAuthorization},
hex,
eips::eip7702::SignedAuthorization,
network::{EthereumWallet, TransactionBuilder, TransactionBuilder7702, TxSigner},
node_bindings::{Anvil, AnvilInstance},
primitives::{Address, BlockNumber, Bytes, TxHash, U256},
primitives::{Address, Bytes, U256},
providers::{
DynProvider, Identity, Provider, ProviderBuilder, RootProvider,
ext::AnvilApi,
Expand All @@ -25,7 +23,7 @@ use engine_core::{
chain::Chain,
credentials::SigningCredential,
error::EngineError,
signer::{AccountSigner, EoaSigner, EoaSigningOptions},
signer::{AccountSigner, EoaSigningOptions},
transaction::InnerTransaction,
};
use engine_eip7702_core::{
Expand All @@ -36,8 +34,6 @@ use engine_eip7702_core::{
use serde_json::Value;
use tokio::time::sleep;

use crate::MockERC20::{MockERC20Calls, MockERC20Instance};

// Mock ERC20 contract
sol! {
#[allow(missing_docs)]
Expand Down Expand Up @@ -185,7 +181,7 @@ impl AccountSigner for MockEoaSigner {
let message_bytes = _message.as_bytes();
let signature = signer.sign_message(message_bytes).await.map_err(|e| {
EngineError::ValidationError {
message: format!("Failed to sign message: {}", e),
message: format!("Failed to sign message: {e}"),
}
})?;
Ok(signature.to_string())
Expand All @@ -208,7 +204,7 @@ impl AccountSigner for MockEoaSigner {
.sign_dynamic_typed_data(typed_data)
.await
.map_err(|e| EngineError::ValidationError {
message: format!("Failed to sign typed data: {}", e),
message: format!("Failed to sign typed data: {e}"),
})?;
Ok(signature.to_string())
}
Expand All @@ -229,7 +225,7 @@ impl AccountSigner for MockEoaSigner {
let mut tx = transaction.clone();
let signature = signer.sign_transaction(&mut tx).await.map_err(|e| {
EngineError::ValidationError {
message: format!("Failed to sign transaction: {}", e),
message: format!("Failed to sign transaction: {e}"),
}
})?;
Ok(signature.to_string())
Expand Down Expand Up @@ -258,7 +254,7 @@ impl AccountSigner for MockEoaSigner {
let authorization_hash = authorization.signature_hash();
let signature = signer.sign_hash(&authorization_hash).await.map_err(|e| {
EngineError::ValidationError {
message: format!("Failed to sign authorization: {}", e),
message: format!("Failed to sign authorization: {e}"),
}
})?;
Ok(authorization.into_signed(signature))
Expand Down Expand Up @@ -374,7 +370,7 @@ impl TestSetup {
let _: () = chain
.provider()
.client()
.request("anvil_setBalance", (address, format!("0x{:x}", balance)))
.request("anvil_setBalance", (address, format!("0x{balance:x}")))
.await?;

Ok(())
Expand All @@ -395,8 +391,7 @@ impl TestSetup {
.await?;

println!(
"Set bytecode for minimal account implementation at {}",
MINIMAL_ACCOUNT_IMPLEMENTATION_ADDRESS
"Set bytecode for minimal account implementation at {MINIMAL_ACCOUNT_IMPLEMENTATION_ADDRESS}"
);

Ok(())
Expand Down
10 changes: 5 additions & 5 deletions executors/src/eip7702_executor/confirm.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use alloy::primitives::{Address, TxHash};
use alloy::primitives::TxHash;
use alloy::providers::Provider;
use alloy::rpc::types::TransactionReceipt;
use engine_core::error::{AlloyRpcErrorToEngineError, EngineError};
Expand Down Expand Up @@ -107,7 +107,7 @@ pub enum Eip7702ConfirmationError {
impl From<TwmqError> for Eip7702ConfirmationError {
fn from(error: TwmqError) -> Self {
Eip7702ConfirmationError::InternalError {
message: format!("Deserialization error for job data: {}", error),
message: format!("Deserialization error for job data: {error}"),
}
}
}
Expand Down Expand Up @@ -171,7 +171,7 @@ where
.get_chain(job_data.chain_id)
.map_err(|e| Eip7702ConfirmationError::ChainServiceError {
chain_id: job_data.chain_id,
message: format!("Failed to get chain instance: {}", e),
message: format!("Failed to get chain instance: {e}"),
})
.map_err_fail()?;

Expand Down Expand Up @@ -199,7 +199,7 @@ where
TwGetTransactionHashResponse::Success { transaction_hash } => {
transaction_hash.parse::<TxHash>().map_err(|e| {
Eip7702ConfirmationError::TransactionHashError {
message: format!("Invalid transaction hash format: {}", e),
message: format!("Invalid transaction hash format: {e}"),
}
.fail()
})?
Expand Down Expand Up @@ -227,7 +227,7 @@ where
.map_err(|e| {
// If transaction not found, nack and retry
Eip7702ConfirmationError::ConfirmationError {
message: format!("Failed to get transaction receipt: {}", e),
message: format!("Failed to get transaction receipt: {e}"),
inner_error: Some(e.to_engine_error(&chain)),
}
.nack(Some(Duration::from_secs(5)), RequeuePosition::Last)
Expand Down
Loading
Loading