Skip to content

Commit

Permalink
chore: more impl
Browse files Browse the repository at this point in the history
  • Loading branch information
chris13524 committed Dec 19, 2024
1 parent 7fe2d9a commit 4089a61
Show file tree
Hide file tree
Showing 10 changed files with 293 additions and 110 deletions.
2 changes: 1 addition & 1 deletion crates/kotlin-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl ChainAbstractionClient {

pub async fn erc20_token_balance(
&self,
chain_id: String,
chain_id: &str,
token: FFIAddress,
owner: FFIAddress,
) -> Result<FFIU256, FFIError> {
Expand Down
3 changes: 3 additions & 0 deletions crates/yttrium/src/bundler/models/user_operation_receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use {
};

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
#[serde(rename_all = "camelCase")]
pub struct TransactionReceipt {
pub transaction_hash: TxHash,
Expand All @@ -25,6 +26,7 @@ pub struct TransactionReceipt {

// TODO replace with alloy's UserOperationReceipt
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
#[serde(rename_all = "camelCase")]
pub struct UserOperationReceipt {
pub user_op_hash: B256,
Expand All @@ -41,6 +43,7 @@ pub struct UserOperationReceipt {
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
#[serde(rename_all = "camelCase")]
pub struct TransactionLog {
pub address: Address,
Expand Down
12 changes: 5 additions & 7 deletions crates/yttrium/src/chain_abstraction/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use {
chain_abstraction::{
error::UiFieldsError, l1_data_fee::get_l1_data_fee, ui_fields,
},
config::Config,
erc20::ERC20,
provider_pool::ProviderPool,
},
Expand All @@ -49,7 +50,7 @@ pub struct Client {

impl Client {
pub fn new(project_id: ProjectId) -> Self {
Self { provider_pool: ProviderPool::new(project_id) }
Self { provider_pool: ProviderPool::new(project_id, Config::local()) }
}

pub async fn prepare(
Expand Down Expand Up @@ -155,7 +156,7 @@ impl Client {
|chain_id| async move {
let estimate = self
.provider_pool
.get_provider(chain_id.clone())
.get_provider(chain_id)
.await
.estimate_eip1559_fees(None)
.await
Expand Down Expand Up @@ -186,10 +187,7 @@ impl Client {
)
.with_max_fee_per_gas(100000)
.with_max_priority_fee_per_gas(1),
providers
.provider_pool
.get_provider(txn.chain_id.clone())
.await,
providers.provider_pool.get_provider(&txn.chain_id).await,
)
.await)
}
Expand Down Expand Up @@ -392,7 +390,7 @@ impl Client {

pub async fn erc20_token_balance(
&self,
chain_id: String,
chain_id: &str,
token: Address,
owner: Address,
) -> Result<U256, alloy::contract::Error> {
Expand Down
27 changes: 4 additions & 23 deletions crates/yttrium/src/examples/eip7702_smart_sessions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ use {
smart_accounts::{
nonce::get_nonce_with_key,
safe::{
get_call_data, Owners, SAFE_4337_MODULE_ADDRESS,
SAFE_ERC_7579_LAUNCHPAD_ADDRESS, SAFE_L2_SINGLETON_1_4_1,
get_call_data, AddSafe7579Contract, Owners, SetupContract,
SAFE_4337_MODULE_ADDRESS, SAFE_ERC_7579_LAUNCHPAD_ADDRESS,
SAFE_L2_SINGLETON_1_4_1,
},
},
test_helpers::anvil_faucet,
Expand All @@ -41,7 +42,6 @@ use {
},
rpc::types::Authorization,
signers::{local::LocalSigner, SignerSync},
sol,
sol_types::SolCall,
},
alloy_provider::{Provider, ProviderBuilder, ReqwestProvider},
Expand Down Expand Up @@ -99,25 +99,6 @@ async fn test() {
let sig = account.sign_hash_sync(&auth_7702.signature_hash()).unwrap();
let auth = auth_7702.into_signed(sig);

sol! {
#[allow(clippy::too_many_arguments)]
#[sol(rpc)]
contract SetupContract {
function setup(address[] calldata _owners,uint256 _threshold,address to,bytes calldata data,address fallbackHandler,address paymentToken,uint256 payment, address paymentReceiver) external;
}

#[allow(clippy::too_many_arguments)]
#[sol(rpc)]
contract AddSafe7579Contract {
struct ModuleInit {
address module;
bytes initData;
}

function addSafe7579(address safe7579, ModuleInit[] calldata validators, ModuleInit[] calldata executors, ModuleInit[] calldata fallbacks, ModuleInit[] calldata hooks, address[] calldata attesters, uint8 threshold) external;
}
};

let faucet = anvil_faucet(rpc_url).await;
let wallet = EthereumWallet::new(faucet);
let wallet_provider = ProviderBuilder::new()
Expand Down Expand Up @@ -148,7 +129,7 @@ async fn test() {
RHINESTONE_ATTESTER_ADDRESS,
MOCK_ATTESTER_ADDRESS,
],
threshold: owners.threshold,
threshold: 1,
}
.abi_encode()
.into(),
Expand Down
1 change: 1 addition & 0 deletions crates/yttrium/src/execution/send/safe_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ pub async fn send_transactions(
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
pub struct PreparedSendTransaction {
pub safe_op: SafeOp,
pub domain: Eip712Domain,
Expand Down
Loading

0 comments on commit 4089a61

Please sign in to comment.