Skip to content

Commit 6d0db54

Browse files
committed
various fixes + clippy fix
1 parent d09e375 commit 6d0db54

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+514
-599
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.gitignore
2+
README.md
3+
.github/
4+
scripts/
5+
target/

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aa-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
edition = "2024"
55

66
[dependencies]
7-
alloy = { version = "1.0.8" }
7+
alloy = { version = "1.0.8", features = ["serde"] }
88
tokio = "1.44.2"
99
engine-core = { path = "../core" }
1010
vault-types = { version = "0.1.0", git = "ssh://git@github.com/thirdweb-dev/vault.git", branch = "main" }

aa-core/src/account_factory/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub enum SmartAccountFactory<'a, C: Chain> {
5353
}
5454

5555
// Implement the AccountFactory trait for our enum
56-
impl<'a, C: Chain> AccountFactory for SmartAccountFactory<'a, C> {
56+
impl<C: Chain> AccountFactory for SmartAccountFactory<'_, C> {
5757
fn factory_address(&self) -> &Address {
5858
match self {
5959
Self::Default(factory) => &factory.factory_address,
@@ -81,11 +81,11 @@ impl<'a, C: Chain> AccountFactory for SmartAccountFactory<'a, C> {
8181
}
8282

8383
/// Get the appropriate account factory based on the factory address
84-
pub fn get_account_factory<'a, C: Chain>(
85-
chain: &'a C,
84+
pub fn get_account_factory<C: Chain>(
85+
chain: &C,
8686
factory_address: Address,
8787
implementation_address: Option<Address>,
88-
) -> SmartAccountFactory<'a, C> {
88+
) -> SmartAccountFactory<'_, C> {
8989
// Check if the factory address matches default v0.6
9090
if factory_address == DEFAULT_FACTORY_ADDRESS_V0_6 {
9191
SmartAccountFactory::Default(DefaultAccountFactory::v0_6())

aa-core/src/account_factory/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub fn predict_deterministic_address(
3434
init_code.extend_from_slice(&code_prefix);
3535

3636
// Add the implementation address
37-
init_code.extend_from_slice(&implementation.as_slice());
37+
init_code.extend_from_slice(implementation.as_slice());
3838

3939
// Add the suffix, but without the final 'ff' byte
4040
// The suffix in your constant is 16 bytes, but OpenZeppelin uses 15 bytes

aa-core/src/signer.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ use alloy::{
55
hex::FromHex,
66
primitives::{Address, B256, Bytes, hex, keccak256},
77
sol,
8-
sol_types::{SolCall, SolStruct, SolValue, eip712_domain},
8+
sol_types::{SolCall, SolValue, decode_revert_reason, eip712_domain},
99
};
1010
use engine_core::{
1111
chain::Chain,
1212
credentials::SigningCredential,
1313
error::EngineError,
14-
signer::{AccountSigner, EoaSigner, EoaSigningOptions, SmartAccountSigningOptions},
14+
signer::{AccountSigner, EoaSigner, EoaSigningOptions, Erc4337SigningOptions},
1515
};
16+
use serde::Serialize;
1617
use vault_types::enclave::encrypted::eoa::MessageFormat;
1718

1819
use crate::{
@@ -35,6 +36,7 @@ sol! {
3536
}
3637

3738
sol! {
39+
#[derive(Serialize)]
3840
struct AccountMessage {
3941
bytes message;
4042
}
@@ -48,15 +50,15 @@ const ERC6492_MAGIC_SUFFIX: [u8; 32] =
4850
pub struct SmartAccountSignerBuilder<C: Chain> {
4951
eoa_signer: Arc<EoaSigner>,
5052
credentials: SigningCredential,
51-
options: SmartAccountSigningOptions,
53+
options: Erc4337SigningOptions,
5254
chain: C,
5355
}
5456

5557
impl<C: Chain + Clone> SmartAccountSignerBuilder<C> {
5658
pub fn new(
5759
eoa_signer: Arc<EoaSigner>,
5860
credentials: SigningCredential,
59-
options: SmartAccountSigningOptions,
61+
options: Erc4337SigningOptions,
6062
chain: C,
6163
) -> Self {
6264
Self {
@@ -141,7 +143,7 @@ impl<C: Chain + Clone> SmartAccountSignerBuilder<C> {
141143
/// Smart Account signer with pre-computed address and factory pattern support
142144
#[derive(Clone)]
143145
pub struct SmartAccountSigner<C: Chain> {
144-
options: SmartAccountSigningOptions,
146+
options: Erc4337SigningOptions,
145147
credentials: SigningCredential,
146148
chain: C,
147149
eoa_signer: Arc<EoaSigner>,
@@ -242,17 +244,16 @@ impl<C: Chain + Clone> SmartAccountSigner<C> {
242244
};
243245

244246
// Get the EIP712 signing hash using alloy's native functionality
245-
let signing_hash = account_message.eip712_signing_hash(&domain);
247+
let typed_data = TypedData::from_struct(&account_message, Some(domain));
246248

247249
// Sign the hash directly with EOA
248250
self.eoa_signer
249-
.sign_message(
251+
.sign_typed_data(
250252
EoaSigningOptions {
251253
chain_id: Some(self.chain.chain_id()),
252254
from: self.options.signer_address,
253255
},
254-
&format!("0x{}", hex::encode(signing_hash)),
255-
MessageFormat::Hex,
256+
&typed_data,
256257
self.credentials.clone(),
257258
)
258259
.await
@@ -268,16 +269,25 @@ impl<C: Chain + Clone> SmartAccountSigner<C> {
268269
let contract =
269270
ERC1271Contract::new(self.smart_account.address, self.chain.provider().clone());
270271

272+
dbg!(self.options.signer_address);
273+
dbg!(hash);
274+
dbg!(signature);
275+
271276
match contract
272277
.isValidSignature(hash, signature_bytes.into())
273278
.call()
274279
.await
275280
{
276281
Ok(response) => {
282+
dbg!(response);
277283
let expected_magic = ERC1271Contract::isValidSignatureCall::SELECTOR;
278284
Ok(response.as_slice() == expected_magic)
279285
}
280-
Err(_) => Ok(false),
286+
Err(e) => {
287+
let data = e.as_revert_data().unwrap();
288+
dbg!(decode_revert_reason(data.as_ref()));
289+
Ok(false)
290+
}
281291
}
282292
}
283293

aa-core/src/smart_account/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ pub trait SmartAccount {
2828
async fn is_deployed(&self, chain: &impl Chain) -> Result<bool, EngineError> {
2929
let code = chain
3030
.provider()
31-
.get_code_at(self.address().clone())
31+
.get_code_at(self.address().to_owned())
3232
.await
3333
.map_err(|t| t.to_engine_error(chain))?;
3434

35-
Ok(code.len() > 0)
35+
Ok(!code.is_empty())
3636
}
3737

3838
/// Encode a transaction call to the account
@@ -74,7 +74,7 @@ impl<C: Chain> SmartAccountFromSalt<'_, C> {
7474
pub async fn to_determined_smart_account(self) -> Result<DeterminedSmartAccount, EngineError> {
7575
let factory = get_account_factory(self.chain, self.factory_address, None);
7676
let address = factory
77-
.predict_address(&self.admin_address, &self.salt_data)
77+
.predict_address(&self.admin_address, self.salt_data)
7878
.await?;
7979

8080
Ok(DeterminedSmartAccount { address })

aa-core/src/userop/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl<'a, C: Chain> UserOpBuilderV0_6<'a, C> {
130130
let pm_response = self
131131
.chain
132132
.paymaster_client()
133-
.get_user_op_paymaster_and_data_v0_6(&self.userop, self.entrypoint.clone())
133+
.get_user_op_paymaster_and_data_v0_6(&self.userop, self.entrypoint)
134134
.await
135135
.map_err(|err| err.to_engine_paymaster_error(self.chain))?;
136136

core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ async-nats = "0.40.0"
1717
twmq = { version = "0.1.0", path = "../twmq" }
1818
thirdweb-core = { version = "0.1.0", path = "../thirdweb-core" }
1919
uuid = { version = "1.17.0", features = ["v4"] }
20-
utoipa = "5.4.0"
20+
utoipa = { version = "5.4.0", features = ["preserve_order"] }
2121
serde_with = "3.13.0"

core/src/chain.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl Chain for ThirdwebChain {
124124
}
125125
}
126126

127-
impl<'a> ThirdwebChainConfig<'a> {
127+
impl ThirdwebChainConfig<'_> {
128128
pub fn to_chain(&self) -> Result<ThirdwebChain, EngineError> {
129129
let rpc_url = Url::parse(&format!(
130130
"https://{chain_id}.{base_url}/{client_id}",
@@ -133,7 +133,7 @@ impl<'a> ThirdwebChainConfig<'a> {
133133
client_id = self.client_id,
134134
))
135135
.map_err(|e| EngineError::RpcConfigError {
136-
message: format!("Failed to parse RPC URL: {}", e.to_string()),
136+
message: format!("Failed to parse RPC URL: {}", e),
137137
})?;
138138

139139
let bundler_url = Url::parse(&format!(
@@ -142,7 +142,7 @@ impl<'a> ThirdwebChainConfig<'a> {
142142
base_url = self.bundler_base_url,
143143
))
144144
.map_err(|e| EngineError::RpcConfigError {
145-
message: format!("Failed to parse Bundler URL: {}", e.to_string()),
145+
message: format!("Failed to parse Bundler URL: {}", e),
146146
})?;
147147

148148
let paymaster_url = Url::parse(&format!(
@@ -151,20 +151,20 @@ impl<'a> ThirdwebChainConfig<'a> {
151151
base_url = self.paymaster_base_url,
152152
))
153153
.map_err(|e| EngineError::RpcConfigError {
154-
message: format!("Failed to parse Paymaster URL: {}", e.to_string()),
154+
message: format!("Failed to parse Paymaster URL: {}", e),
155155
})?;
156156

157157
let mut sensitive_headers = HeaderMap::new();
158158
sensitive_headers.insert(
159159
"x-client-id",
160-
HeaderValue::from_str(&self.client_id).map_err(|e| EngineError::RpcConfigError {
160+
HeaderValue::from_str(self.client_id).map_err(|e| EngineError::RpcConfigError {
161161
message: format!("Unserialisable client-id used: {e}"),
162162
})?,
163163
);
164164

165165
sensitive_headers.insert(
166166
"x-secret-key",
167-
HeaderValue::from_str(&self.secret_key).map_err(|e| EngineError::RpcConfigError {
167+
HeaderValue::from_str(self.secret_key).map_err(|e| EngineError::RpcConfigError {
168168
message: format!("Unserialisable secret-key used: {e}"),
169169
})?,
170170
);
@@ -217,8 +217,7 @@ impl<'a> ThirdwebChainConfig<'a> {
217217

218218
provider: ProviderBuilder::new()
219219
.disable_recommended_fillers()
220-
.connect_http(rpc_url)
221-
.into(),
220+
.connect_http(rpc_url),
222221

223222
bundler_url,
224223
paymaster_url,

0 commit comments

Comments
 (0)