Skip to content

Commit ed8f549

Browse files
committed
wip smart account signatures
1 parent ab83a22 commit ed8f549

File tree

14 files changed

+1069
-6
lines changed

14 files changed

+1069
-6
lines changed

aa-core/src/account_factory/chained.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ sol! {
1818
#[sol(rpc)]
1919
contract AccountFactoryContract {
2020
function getAddress(address _adminSigner, bytes _data) view returns (address);
21+
function accountImplementation() external view returns (address);
2122
}
2223
}
2324

@@ -42,4 +43,17 @@ impl<C: Chain> AccountFactory for ChainedAccountFactory<'_, C> {
4243

4344
Ok(predicted_address)
4445
}
46+
47+
async fn implementation_address(&self) -> Result<Address, EngineError> {
48+
let account_factory_contract =
49+
AccountFactoryContract::new(self.factory_address, self.chain.provider().clone());
50+
51+
let predicted_address = account_factory_contract
52+
.accountImplementation()
53+
.call()
54+
.await
55+
.map_err(|e| e.to_engine_error(self.chain.chain_id(), Some(self.factory_address)))?;
56+
57+
Ok(predicted_address)
58+
}
4559
}

aa-core/src/account_factory/default.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ impl AccountFactory for DefaultAccountFactory {
6666
let address = SyncAccountFactory::predict_address_sync(self, signer, salt_data);
6767
std::future::ready(Ok(address))
6868
}
69+
70+
fn implementation_address(&self) -> impl Future<Output = Result<Address, EngineError>> {
71+
// Use the sync implementation but return as a ready future
72+
std::future::ready(Ok(self.implementation_address))
73+
}
6974
}
7075

7176
#[cfg(test)]

aa-core/src/account_factory/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ pub trait AccountFactory {
4242
}
4343
.abi_encode()
4444
}
45+
46+
fn implementation_address(&self) -> impl Future<Output = Result<Address, EngineError>> + Send;
4547
}
4648

4749
/// A factory that can use either implementation based on the provided addresses
@@ -69,6 +71,13 @@ impl<'a, C: Chain> AccountFactory for SmartAccountFactory<'a, C> {
6971
Self::Chained(factory) => factory.predict_address(signer, salt_data).await,
7072
}
7173
}
74+
75+
async fn implementation_address(&self) -> Result<Address, EngineError> {
76+
match self {
77+
Self::Default(factory) => factory.implementation_address().await,
78+
Self::Chained(factory) => factory.implementation_address().await,
79+
}
80+
}
7281
}
7382

7483
/// Get the appropriate account factory based on the factory address

aa-core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
pub mod account_factory;
2+
pub mod signer;
23
pub mod smart_account;
34
pub mod userop;

0 commit comments

Comments
 (0)