Skip to content

Commit 0657763

Browse files
authored
Merge pull request #1 from thirdweb-dev/pb/utoipa
clean and merge local changes
2 parents 59191b2 + db2d5d8 commit 0657763

Some content is hidden

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

52 files changed

+2707
-1114
lines changed

Cargo.lock

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

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)