Skip to content

Commit

Permalink
feat: bump alloy (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris13524 authored Nov 12, 2024
1 parent 86348f5 commit 04554d3
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 54 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ serde_json = "1.0"
oslog = "0.2.0"
log = "0.4.20"

alloy = "0.6.1"
alloy-provider = "0.6.1"
erc6492 = { git = "https://github.com/reown-com/erc6492.git", branch = "main" }

[profile.release]
opt-level = 'z'
lto = true
Expand Down
4 changes: 2 additions & 2 deletions crates/ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ swift-bridge = { git = "https://github.com/wooden-worm/swift-bridge.git", branch
"async",
] }
yttrium = { path = "../yttrium" }
erc6492 = { git = "https://github.com/reown-com/erc6492.git", branch = "main" }
alloy = { version = "0.3.6" }
erc6492.workspace = true
alloy.workspace = true

# Errors
eyre.workspace = true
Expand Down
8 changes: 4 additions & 4 deletions crates/ffi/src/account_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use alloy::sol_types::SolStruct;
use std::str::FromStr;
use yttrium::smart_accounts::safe::SignOutputEnum;
use yttrium::transaction::send::safe_test::{
Address, OwnerSignature, Signature,
Address, OwnerSignature, PrimitiveSignature,
};
use yttrium::{
account_client::{AccountClient, SignerType},
Expand Down Expand Up @@ -161,7 +161,7 @@ impl FFIAccountClient {
.map_err(|e| FFIError::Unknown(e.to_string()))?,
signature: signature
.signature
.parse::<Signature>()
.parse::<PrimitiveSignature>()
.map_err(|e| FFIError::Unknown(e.to_string()))?,
});
}
Expand Down Expand Up @@ -224,7 +224,7 @@ impl FFIAccountClient {
.map_err(|e| FFIError::Unknown(e.to_string()))?,
signature: signature
.signature
.parse::<Signature>()
.parse::<PrimitiveSignature>()
.map_err(|e| FFIError::Unknown(e.to_string()))?,
});
}
Expand Down Expand Up @@ -335,7 +335,7 @@ impl FFIAccountClient {
.map_err(|e| FFIError::Unknown(e.to_string()))?,
signature: signature
.signature
.parse::<Signature>()
.parse::<PrimitiveSignature>()
.map_err(|e| FFIError::Unknown(e.to_string()))?,
});
}
Expand Down
4 changes: 2 additions & 2 deletions crates/kotlin-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ uniffi::setup_scaffolding!();

use yttrium::config::Config;
use yttrium::transaction::send::safe_test::{
Address, OwnerSignature as YOwnerSignature, Signature,
Address, OwnerSignature as YOwnerSignature, PrimitiveSignature,
};
use yttrium::{
account_client::{AccountClient as YAccountClient, SignerType},
Expand Down Expand Up @@ -148,7 +148,7 @@ impl AccountClient {
.map_err(|e| Error::Unknown(e.to_string()))?,
signature: signature
.signature
.parse::<Signature>()
.parse::<PrimitiveSignature>()
.map_err(|e| Error::Unknown(e.to_string()))?,
});
}
Expand Down
10 changes: 4 additions & 6 deletions crates/yttrium/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test_pimlico_api = []
uniffi = { version = "0.28.1", optional = true }
uniffi_macros = { version = "0.28.1", optional = true }
# Ethereum
alloy = { version = "0.3.6", features = [
alloy = { workspace = true, features = [
"contract",
"network",
"providers",
Expand All @@ -23,8 +23,9 @@ alloy = { version = "0.3.6", features = [
"signer-mnemonic",
"eip712",
] }
alloy-provider = { version = "0.3.6", features = ["erc4337-api"] }
erc6492 = { git = "https://github.com/reown-com/erc6492.git", branch = "main" }
alloy-provider = { workspace = true, features = ["erc4337-api"] }
erc6492.workspace = true

# foundry-block-explorers = "0.2.3"
getrandom = { version = "0.2", features = ["js"] }

Expand Down Expand Up @@ -58,6 +59,3 @@ wiremock = "0.6.0"

# Networking
reqwest.workspace = true

[build-dependencies]
serde_json = "1"
4 changes: 2 additions & 2 deletions crates/yttrium/src/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ impl Signer {

impl<S> From<S> for Signer
where
S: alloy::signers::SignerSync<alloy::signers::Signature>
S: alloy::signers::SignerSync<alloy::primitives::PrimitiveSignature>
+ Send
+ Sync
+ 'static,
S: alloy::signers::Signer<alloy::signers::Signature>
S: alloy::signers::Signer<alloy::primitives::PrimitiveSignature>
+ Send
+ Sync
+ 'static,
Expand Down
74 changes: 38 additions & 36 deletions crates/yttrium/src/transaction/send/safe_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,10 @@ where
}

pub use alloy::primitives::Address;
pub use alloy::primitives::Signature;
pub use alloy::primitives::PrimitiveSignature;
pub struct OwnerSignature {
pub owner: Address,
pub signature: Signature,
pub signature: PrimitiveSignature,
}

pub async fn encode_send_transactions(
Expand Down Expand Up @@ -518,9 +518,9 @@ mod tests {
test_helpers::{self, use_faucet},
transaction::Transaction,
};
use alloy::network::{TransactionBuilder, TransactionBuilder7702};
use alloy::rpc::types::TransactionRequest;
use alloy::{
consensus::{SignableTransaction, TxEip7702},
network::TxSignerSync,
primitives::{eip191_hash_message, fixed_bytes, U160, U64},
providers::{ext::AnvilApi, PendingTransactionConfig},
sol,
Expand Down Expand Up @@ -1260,7 +1260,7 @@ mod tests {

let chain_id = ChainId::ETHEREUM_SEPOLIA.eip155_chain_id();
let auth_7702 = alloy::rpc::types::Authorization {
chain_id: U256::from(chain_id),
chain_id,
address: contract_address.into(),
nonce: provider.get_transaction_count(authority.address()).await?,
};
Expand All @@ -1275,15 +1275,9 @@ mod tests {
U64::from(auth.chain_id).to_be_bytes(),
),
nonce: auth.nonce,
y_parity: auth.signature().v().y_parity_byte(),
r: format!(
"0x{}",
hex::encode(auth.signature().r().to_be_bytes_vec())
),
s: format!(
"0x{}",
hex::encode(auth.signature().s().to_be_bytes_vec())
),
y_parity: auth.y_parity(),
r: auth.r(),
s: auth.s(),
}];

let transaction = vec![];
Expand Down Expand Up @@ -1392,7 +1386,7 @@ mod tests {

let chain_id = ChainId::ETHEREUM_SEPOLIA.eip155_chain_id();
let auth_7702 = alloy::rpc::types::Authorization {
chain_id: U256::from(chain_id),
chain_id,
address: contract_address.into(),
nonce: provider.get_transaction_count(authority.address()).await?,
};
Expand All @@ -1402,35 +1396,43 @@ mod tests {
let auth = auth_7702.into_signed(sig);

// Estimate the EIP1559 fees
let eip1559_est = provider.estimate_eip1559_fees(None).await?;
// let eip1559_est = provider.estimate_eip1559_fees(None).await?;

// Build the transaction
// let sender = authority.clone(); // The one sending the txn can be
// different form the EOA being delgated
let sender = LocalSigner::random();
provider.anvil_set_balance(sender.address(), U256::MAX).await?;
let mut tx = TxEip7702 {
to: dummy_contract_address,
authorization_list: vec![auth],
input: dummy_contract_calldata,
nonce: provider.get_transaction_count(sender.address()).await?,
chain_id,
gas_limit: 1000000,
max_fee_per_gas: eip1559_est.max_fee_per_gas,
max_priority_fee_per_gas: eip1559_est.max_priority_fee_per_gas,
..Default::default()
};

let tx = TransactionRequest::default()
.with_to(dummy_contract_address)
.with_authorization_list(vec![auth])
.with_input(dummy_contract_calldata);
// let mut tx = TxEip7702 {
// to: dummy_contract_address,
// authorization_list: vec![auth],
// input: dummy_contract_calldata,
// nonce: provider.get_transaction_count(sender.address()).await?,
// chain_id,
// gas_limit: 1000000,
// max_fee_per_gas: eip1559_est.max_fee_per_gas,
// max_priority_fee_per_gas: eip1559_est.max_priority_fee_per_gas,
// ..Default::default()
// };

// Sign and Encode the transaction
let sig = sender.sign_transaction_sync(&mut tx)?;
let tx = tx.into_signed(sig);
let mut encoded = Vec::new();
tx.tx().encode_with_signature(tx.signature(), &mut encoded, false);
let receipt = provider
.send_raw_transaction(&encoded)
.await?
.get_receipt()
.await?;
// let sig = sender.sign_transaction_sync(&mut tx)?;
// let tx = tx.into_signed(sig);
// let mut encoded = Vec::new();
// tx.tx().encode_with_signature(tx.signature(), &mut encoded, false);
// let receipt = provider
// .send_raw_transaction(&encoded)
// .await?
// .get_receipt()
// .await?;

let receipt =
provider.send_transaction(tx).await?.get_receipt().await?;

assert!(receipt.status());
assert_eq!(receipt.inner.logs().len(), 1);
Expand Down
4 changes: 2 additions & 2 deletions crates/yttrium/src/user_operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ pub struct Authorization {
pub chain_id: u64,
pub nonce: u64,
pub y_parity: u8,
pub r: String,
pub s: String,
pub r: U256,
pub s: U256,
}

#[derive(
Expand Down

0 comments on commit 04554d3

Please sign in to comment.