Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

Commit 79cd57e

Browse files
authored
chore(deps): use alloy for everything (#73)
* chore(deps): use alloy for everything removes alloy primitives. Closes ENG-732 * chore: also remove sol-types and contract
1 parent 56a324b commit 79cd57e

File tree

8 files changed

+27
-33
lines changed

8 files changed

+27
-33
lines changed

Cargo.toml

+1-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ repository = "https://github.com/init4tech/zenith"
1111
license = "AGPL-3.0"
1212

1313
[dependencies]
14-
alloy = { version = "=0.7.3", features = ["full", "json-rpc", "signer-aws", "rpc-types-mev"] }
15-
alloy-primitives = { version = "0.8.11", features = ["serde", "tiny-keccak"] }
16-
alloy-sol-types = { version = "0.8.11", features = ["json"] }
17-
alloy-rlp = { version = "0.3.4" }
18-
alloy-contract = { version = "=0.7.3", features = ["pubsub"] }
14+
alloy = { version = "=0.7.3", features = ["full", "json-rpc", "signer-aws", "rpc-types-mev", "rlp"] }
1915

2016
serde = { version = "1.0.197", features = ["derive"] }
2117

src/bindings.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#![allow(clippy::too_many_arguments)]
22
#![allow(missing_docs)]
3-
use alloy_primitives::{Address, Bytes, FixedBytes, U256};
4-
3+
use alloy::primitives::{Address, Bytes, FixedBytes, U256};
54
mod mint {
6-
alloy::sol_types::sol!(
5+
alloy::sol!(
76
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
87
function mint(address to, uint256 amount);
98
);
@@ -13,7 +12,7 @@ pub use mint::mintCall;
1312
mod zenith {
1413
use super::*;
1514

16-
alloy::sol_types::sol!(
15+
alloy::sol!(
1716
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
1817
#[sol(rpc)]
1918
Zenith,
@@ -107,7 +106,7 @@ mod zenith {
107106
mod passage {
108107
use super::*;
109108

110-
alloy::sol_types::sol!(
109+
alloy::sol!(
111110
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
112111
#[sol(rpc)]
113112
Passage,
@@ -207,7 +206,7 @@ mod passage {
207206
mod orders {
208207
use super::*;
209208

210-
alloy::sol_types::sol!(
209+
alloy::sol!(
211210
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
212211
#[sol(rpc)]
213212
Orders,
@@ -303,7 +302,7 @@ mod orders {
303302
mod transactor {
304303
use super::*;
305304

306-
alloy::sol_types::sol!(
305+
alloy::sol!(
307306
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
308307
#[sol(rpc)]
309308
Transactor,
@@ -358,7 +357,7 @@ mod transactor {
358357

359358
mod rollup_passage {
360359

361-
alloy_sol_types::sol!(
360+
alloy::sol!(
362361
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
363362
#[sol(rpc)]
364363
RollupPassage,
@@ -381,7 +380,7 @@ mod rollup_passage {
381380
}
382381

383382
mod bundle_helper {
384-
alloy_sol_types::sol!(
383+
alloy::sol!(
385384
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
386385
#[sol(rpc)]
387386
BundleHelper,

src/block.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use std::{marker::PhantomData, sync::OnceLock};
33
use crate::Zenith::BlockHeader as ZenithHeader;
44
use alloy::consensus::TxEnvelope;
55
use alloy::eips::eip2718::{Decodable2718, Encodable2718};
6-
use alloy_primitives::{keccak256, Address, B256};
7-
use alloy_rlp::Decodable;
6+
use alloy::primitives::{keccak256, Address, B256};
7+
use alloy::rlp::Decodable;
88

99
/// Zenith processes normal Ethereum txns.
1010
pub type ZenithTransaction = TxEnvelope;
@@ -216,15 +216,14 @@ where
216216
let encoded_txns = transactions.into_iter().map(|tx| C::encode(tx)).collect::<Vec<Vec<u8>>>();
217217

218218
let mut buf = Vec::new();
219-
alloy_rlp::Encodable::encode(&encoded_txns, &mut buf);
219+
alloy::rlp::Encodable::encode(&encoded_txns, &mut buf);
220220
buf
221221
}
222222

223223
#[cfg(test)]
224224
mod test {
225225
use alloy::consensus::{Signed, TxEip1559};
226-
use alloy_primitives::PrimitiveSignature;
227-
use alloy_primitives::{b256, bytes, Address, U256};
226+
use alloy::primitives::{b256, bytes, Address, PrimitiveSignature, U256};
228227

229228
use super::*;
230229

src/bundle.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
use alloy::primitives::{keccak256, Address, Bytes, B256, U256};
12
use alloy::{
23
eips::{eip2718::Encodable2718, BlockNumberOrTag},
34
rpc::types::mev::{EthCallBundle, EthCallBundleResponse, EthSendBundle},
45
};
5-
use alloy_primitives::{keccak256, Address, Bytes, B256, U256};
66
use serde::{Deserialize, Serialize};
77
use std::collections::BTreeMap;
88

@@ -222,7 +222,7 @@ impl ZenithCallBundle {
222222
/// `keccak(NUM_OF_ASSETS_LE + asset1 + NUM_OF_FILLS_LE + asset1_user1 + user1_amount2 + ... + asset1_usern + asset1_amountn + ...)`.
223223
/// For the number of users/fills and amounts in the host_preimage, the amounts are serialized as little-endian U256 slice.
224224
pub fn bundle_hash(&self) -> B256 {
225-
let mut hasher = alloy_primitives::Keccak256::new();
225+
let mut hasher = alloy::primitives::Keccak256::new();
226226

227227
// Concatenate the transaction hashes, to then hash them. This is the tx_preimage.
228228
for tx in self.bundle.txs.iter() {
@@ -237,7 +237,7 @@ impl ZenithCallBundle {
237237
// 3. Concatenate the asset address.
238238
// 4. Prefix the number of fills.
239239
// 5. For each fill, concatenate the user and amount, the latter encoded as a little-endian U256 slice.
240-
let mut hasher = alloy_primitives::Keccak256::new();
240+
let mut hasher = alloy::primitives::Keccak256::new();
241241

242242
// Prefix the list of users with the number of assets.
243243
hasher.update(U256::from(self.host_fills.len()).as_le_slice());
@@ -259,7 +259,7 @@ impl ZenithCallBundle {
259259
// Hash the host pre-image.
260260
let host_preimage = hasher.finalize();
261261

262-
let mut pre_image = alloy_primitives::Keccak256::new();
262+
let mut pre_image = alloy::primitives::Keccak256::new();
263263
pre_image.update(tx_preimage.as_slice());
264264
pre_image.update(host_preimage.as_slice());
265265

src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,20 @@ pub use req::SignRequest;
3333
mod resp;
3434
pub use resp::SignResponse;
3535

36-
use alloy_primitives::{address, Address};
36+
use alloy::primitives::{address, Address};
3737

3838
/// System address with permission to mint tokens on pre-deploys.
3939
pub const MINTER_ADDRESS: Address = address!("00000000000000000000746f6b656e61646d696e");
4040

4141
/// A [`RequestSigner`] signs [`SignRequest`]s by delegating to an
4242
/// [`alloy::signers::Signer`].
4343
pub trait RequestSigner {
44-
/// Signs a [`SignRequest`] and returns the [`alloy_primitives::Signature`].
44+
/// Signs a [`SignRequest`] and returns the [`alloy::primitives::Signature`].
4545
fn sign_request(
4646
&self,
4747
request: &SignRequest,
4848
) -> impl std::future::Future<
49-
Output = Result<alloy_primitives::PrimitiveSignature, alloy::signers::Error>,
49+
Output = Result<alloy::primitives::PrimitiveSignature, alloy::signers::Error>,
5050
> + Send;
5151
}
5252

@@ -57,7 +57,7 @@ where
5757
async fn sign_request(
5858
&self,
5959
request: &SignRequest,
60-
) -> Result<alloy_primitives::PrimitiveSignature, alloy::signers::Error> {
60+
) -> Result<alloy::primitives::PrimitiveSignature, alloy::signers::Error> {
6161
let hash = request.signing_hash();
6262
self.sign_hash(&hash).await
6363
}

src/orders/agg.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::RollupOrders;
2-
use alloy_primitives::{Address, U256};
2+
use alloy::primitives::{Address, U256};
33
use std::collections::HashMap;
44

55
/// Aggregated orders for a transaction or set of transactions.
@@ -67,7 +67,7 @@ impl<'a> FromIterator<&'a RollupOrders::Order> for AggregateOrders {
6767
#[cfg(test)]
6868
mod test {
6969
use super::*;
70-
use alloy_primitives::{Address, U256};
70+
use alloy::primitives::{Address, U256};
7171

7272
const ASSET_A: Address = Address::repeat_byte(1);
7373
const ASSET_B: Address = Address::repeat_byte(2);

src/req.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use alloy_primitives::{Address, Keccak256, B256, U256};
1+
use alloy::primitives::{Address, Keccak256, B256, U256};
22
use serde::{Deserialize, Serialize};
33

44
/// The domain binding for the signing service.
@@ -55,7 +55,7 @@ impl core::fmt::Display for SignRequest {
5555
#[cfg(test)]
5656
mod test {
5757
use super::*;
58-
use alloy_primitives::b256;
58+
use alloy::primitives::b256;
5959

6060
#[test]
6161
fn roundtrip() {

src/resp.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::SignRequest;
2-
use alloy_primitives::{Address, PrimitiveSignature, SignatureError};
2+
use alloy::primitives::{Address, PrimitiveSignature, SignatureError};
33
use serde::{Deserialize, Serialize};
44

55
/// A signature response from a [`RequestSigner`].
@@ -29,7 +29,7 @@ impl SignResponse {
2929
mod test {
3030
use super::*;
3131
use crate::{RequestSigner, SignRequest};
32-
use alloy_primitives::U256;
32+
use alloy::primitives::U256;
3333

3434
#[tokio::test]
3535
async fn test_sign_response() {

0 commit comments

Comments
 (0)