diff --git a/Cargo.toml b/Cargo.toml index cd856a7..50d0f6f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,11 +11,7 @@ repository = "https://github.com/init4tech/zenith" license = "AGPL-3.0" [dependencies] -alloy = { version = "=0.7.3", features = ["full", "json-rpc", "signer-aws", "rpc-types-mev"] } -alloy-primitives = { version = "0.8.11", features = ["serde", "tiny-keccak"] } -alloy-sol-types = { version = "0.8.11", features = ["json"] } -alloy-rlp = { version = "0.3.4" } -alloy-contract = { version = "=0.7.3", features = ["pubsub"] } +alloy = { version = "=0.7.3", features = ["full", "json-rpc", "signer-aws", "rpc-types-mev", "rlp"] } serde = { version = "1.0.197", features = ["derive"] } diff --git a/src/bindings.rs b/src/bindings.rs index f2f87d8..fa35cd3 100644 --- a/src/bindings.rs +++ b/src/bindings.rs @@ -1,9 +1,8 @@ #![allow(clippy::too_many_arguments)] #![allow(missing_docs)] -use alloy_primitives::{Address, Bytes, FixedBytes, U256}; - +use alloy::primitives::{Address, Bytes, FixedBytes, U256}; mod mint { - alloy::sol_types::sol!( + alloy::sol!( #[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)] function mint(address to, uint256 amount); ); @@ -13,7 +12,7 @@ pub use mint::mintCall; mod zenith { use super::*; - alloy::sol_types::sol!( + alloy::sol!( #[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[sol(rpc)] Zenith, @@ -107,7 +106,7 @@ mod zenith { mod passage { use super::*; - alloy::sol_types::sol!( + alloy::sol!( #[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[sol(rpc)] Passage, @@ -207,7 +206,7 @@ mod passage { mod orders { use super::*; - alloy::sol_types::sol!( + alloy::sol!( #[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[sol(rpc)] Orders, @@ -303,7 +302,7 @@ mod orders { mod transactor { use super::*; - alloy::sol_types::sol!( + alloy::sol!( #[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[sol(rpc)] Transactor, @@ -358,7 +357,7 @@ mod transactor { mod rollup_passage { - alloy_sol_types::sol!( + alloy::sol!( #[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[sol(rpc)] RollupPassage, @@ -381,7 +380,7 @@ mod rollup_passage { } mod bundle_helper { - alloy_sol_types::sol!( + alloy::sol!( #[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[sol(rpc)] BundleHelper, diff --git a/src/block.rs b/src/block.rs index 11af25b..4fa7de3 100644 --- a/src/block.rs +++ b/src/block.rs @@ -3,8 +3,8 @@ use std::{marker::PhantomData, sync::OnceLock}; use crate::Zenith::BlockHeader as ZenithHeader; use alloy::consensus::TxEnvelope; use alloy::eips::eip2718::{Decodable2718, Encodable2718}; -use alloy_primitives::{keccak256, Address, B256}; -use alloy_rlp::Decodable; +use alloy::primitives::{keccak256, Address, B256}; +use alloy::rlp::Decodable; /// Zenith processes normal Ethereum txns. pub type ZenithTransaction = TxEnvelope; @@ -216,15 +216,14 @@ where let encoded_txns = transactions.into_iter().map(|tx| C::encode(tx)).collect::>>(); let mut buf = Vec::new(); - alloy_rlp::Encodable::encode(&encoded_txns, &mut buf); + alloy::rlp::Encodable::encode(&encoded_txns, &mut buf); buf } #[cfg(test)] mod test { use alloy::consensus::{Signed, TxEip1559}; - use alloy_primitives::PrimitiveSignature; - use alloy_primitives::{b256, bytes, Address, U256}; + use alloy::primitives::{b256, bytes, Address, PrimitiveSignature, U256}; use super::*; diff --git a/src/bundle.rs b/src/bundle.rs index 4ee9800..9aa5754 100644 --- a/src/bundle.rs +++ b/src/bundle.rs @@ -1,8 +1,8 @@ +use alloy::primitives::{keccak256, Address, Bytes, B256, U256}; use alloy::{ eips::{eip2718::Encodable2718, BlockNumberOrTag}, rpc::types::mev::{EthCallBundle, EthCallBundleResponse, EthSendBundle}, }; -use alloy_primitives::{keccak256, Address, Bytes, B256, U256}; use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; @@ -222,7 +222,7 @@ impl ZenithCallBundle { /// `keccak(NUM_OF_ASSETS_LE + asset1 + NUM_OF_FILLS_LE + asset1_user1 + user1_amount2 + ... + asset1_usern + asset1_amountn + ...)`. /// For the number of users/fills and amounts in the host_preimage, the amounts are serialized as little-endian U256 slice. pub fn bundle_hash(&self) -> B256 { - let mut hasher = alloy_primitives::Keccak256::new(); + let mut hasher = alloy::primitives::Keccak256::new(); // Concatenate the transaction hashes, to then hash them. This is the tx_preimage. for tx in self.bundle.txs.iter() { @@ -237,7 +237,7 @@ impl ZenithCallBundle { // 3. Concatenate the asset address. // 4. Prefix the number of fills. // 5. For each fill, concatenate the user and amount, the latter encoded as a little-endian U256 slice. - let mut hasher = alloy_primitives::Keccak256::new(); + let mut hasher = alloy::primitives::Keccak256::new(); // Prefix the list of users with the number of assets. hasher.update(U256::from(self.host_fills.len()).as_le_slice()); @@ -259,7 +259,7 @@ impl ZenithCallBundle { // Hash the host pre-image. let host_preimage = hasher.finalize(); - let mut pre_image = alloy_primitives::Keccak256::new(); + let mut pre_image = alloy::primitives::Keccak256::new(); pre_image.update(tx_preimage.as_slice()); pre_image.update(host_preimage.as_slice()); diff --git a/src/lib.rs b/src/lib.rs index bfb1cc6..c803054 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,7 +33,7 @@ pub use req::SignRequest; mod resp; pub use resp::SignResponse; -use alloy_primitives::{address, Address}; +use alloy::primitives::{address, Address}; /// System address with permission to mint tokens on pre-deploys. pub const MINTER_ADDRESS: Address = address!("00000000000000000000746f6b656e61646d696e"); @@ -41,12 +41,12 @@ pub const MINTER_ADDRESS: Address = address!("00000000000000000000746f6b656e6164 /// A [`RequestSigner`] signs [`SignRequest`]s by delegating to an /// [`alloy::signers::Signer`]. pub trait RequestSigner { - /// Signs a [`SignRequest`] and returns the [`alloy_primitives::Signature`]. + /// Signs a [`SignRequest`] and returns the [`alloy::primitives::Signature`]. fn sign_request( &self, request: &SignRequest, ) -> impl std::future::Future< - Output = Result, + Output = Result, > + Send; } @@ -57,7 +57,7 @@ where async fn sign_request( &self, request: &SignRequest, - ) -> Result { + ) -> Result { let hash = request.signing_hash(); self.sign_hash(&hash).await } diff --git a/src/orders/agg.rs b/src/orders/agg.rs index 5d18916..487ff92 100644 --- a/src/orders/agg.rs +++ b/src/orders/agg.rs @@ -1,5 +1,5 @@ use crate::RollupOrders; -use alloy_primitives::{Address, U256}; +use alloy::primitives::{Address, U256}; use std::collections::HashMap; /// Aggregated orders for a transaction or set of transactions. @@ -67,7 +67,7 @@ impl<'a> FromIterator<&'a RollupOrders::Order> for AggregateOrders { #[cfg(test)] mod test { use super::*; - use alloy_primitives::{Address, U256}; + use alloy::primitives::{Address, U256}; const ASSET_A: Address = Address::repeat_byte(1); const ASSET_B: Address = Address::repeat_byte(2); diff --git a/src/req.rs b/src/req.rs index 5b6af86..0a1f57a 100644 --- a/src/req.rs +++ b/src/req.rs @@ -1,4 +1,4 @@ -use alloy_primitives::{Address, Keccak256, B256, U256}; +use alloy::primitives::{Address, Keccak256, B256, U256}; use serde::{Deserialize, Serialize}; /// The domain binding for the signing service. @@ -55,7 +55,7 @@ impl core::fmt::Display for SignRequest { #[cfg(test)] mod test { use super::*; - use alloy_primitives::b256; + use alloy::primitives::b256; #[test] fn roundtrip() { diff --git a/src/resp.rs b/src/resp.rs index a3cff07..cd5698c 100644 --- a/src/resp.rs +++ b/src/resp.rs @@ -1,5 +1,5 @@ use crate::SignRequest; -use alloy_primitives::{Address, PrimitiveSignature, SignatureError}; +use alloy::primitives::{Address, PrimitiveSignature, SignatureError}; use serde::{Deserialize, Serialize}; /// A signature response from a [`RequestSigner`]. @@ -29,7 +29,7 @@ impl SignResponse { mod test { use super::*; use crate::{RequestSigner, SignRequest}; - use alloy_primitives::U256; + use alloy::primitives::U256; #[tokio::test] async fn test_sign_response() {