Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(deps): Alloy primitives migration #41

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 113 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ ethers-core = { version = "2.0", default-features = false }
ethers-signers = "2.0"
ethers-providers = "2.0"

alloy-primitives = { version = "0.4", default-features = false}

## net
http = "0.2.9"
tower = "0.4"
Expand Down
6 changes: 3 additions & 3 deletions crates/mev-share-backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,17 @@ impl SimulatedBundle {

/// Returns the profit of the simulation.
pub fn profit(&self) -> u64 {
self.response.profit.as_u64()
self.response.profit.to::<u64>()
}

/// Returns the gas used by the simulation.
pub fn gas_used(&self) -> u64 {
self.response.gas_used.as_u64()
self.response.gas_used.to::<u64>()
}

/// Returns the mev gas price of the simulation.
pub fn mev_gas_price(&self) -> u64 {
self.response.mev_gas_price.as_u64()
self.response.mev_gas_price.to::<u64>()
}

///
Expand Down
2 changes: 2 additions & 0 deletions crates/mev-share-rpc-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ MEV-share RPC API trait definitions
ethers-core.workspace = true
ethers-signers.workspace = true

alloy-primitives = {workspace = true, features = ["serde"] }

## misc
jsonrpsee = { workspace = true, features = ["server", "macros"] }
serde.workspace = true
Expand Down
6 changes: 3 additions & 3 deletions crates/mev-share-rpc-api/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{
task::{Context, Poll},
};

use ethers_core::{types::H256, utils::keccak256};
use alloy_primitives::{keccak256, B256};
use ethers_signers::Signer;
use futures_util::future::BoxFuture;

Expand Down Expand Up @@ -98,7 +98,7 @@ where

// sign request body and insert header
let signature = signer
.sign_message(format!("0x{:x}", H256::from(keccak256(body_bytes.as_ref()))))
.sign_message(format!("0x{:x}", B256::from(keccak256(body_bytes.as_ref()))))
.await?;

let header_val =
Expand Down Expand Up @@ -159,7 +159,7 @@ mod tests {

let signer_address = format!("{:?}", fb_signer.address());
let expected_signature = fb_signer
.sign_message(format!("0x{:x}", H256::from(keccak256(bytes.clone()))))
.sign_message(format!("0x{:x}", B256::from(keccak256(bytes.clone()))))
.await
.unwrap()
.to_string();
Expand Down
16 changes: 8 additions & 8 deletions crates/mev-share-rpc-api/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
CancelBundleRequest, CancelPrivateTransactionRequest, EthBundleHash, EthCallBundleResponse,
EthCallBundleTransactionResult, EthSendBundle, PrivateTransactionRequest,
};
use ethers_core::types::{Bytes, H256};
use alloy_primitives::{Bytes, B256};

// re-export the rpc server trait
#[cfg(feature = "server")]
Expand All @@ -16,7 +16,7 @@ mod rpc {
CancelBundleRequest, CancelPrivateTransactionRequest, EthBundleHash, EthCallBundleResponse,
EthCallBundleTransactionResult, EthSendBundle, PrivateTransactionRequest,
};
use ethers_core::types::{Bytes, H256};
use alloy_primitives::{Bytes, B256};
use jsonrpsee::proc_macros::rpc;

/// Eth bundle rpc interface.
Expand Down Expand Up @@ -54,7 +54,7 @@ mod rpc {
async fn send_private_transaction(
&self,
request: PrivateTransactionRequest,
) -> jsonrpsee::core::RpcResult<H256>;
) -> jsonrpsee::core::RpcResult<B256>;

/// The `eth_sendPrivateRawTransaction` method can be used to send private transactions to
/// the RPC endpoint. Private transactions are protected from frontrunning and kept
Expand All @@ -64,7 +64,7 @@ mod rpc {
async fn send_private_raw_transaction(
&self,
bytes: Bytes,
) -> jsonrpsee::core::RpcResult<H256>;
) -> jsonrpsee::core::RpcResult<B256>;

/// The `eth_cancelPrivateTransaction` method stops private transactions from being
/// submitted for future blocks.
Expand Down Expand Up @@ -106,7 +106,7 @@ pub trait EthBundleApiClient {
async fn send_private_transaction(
&self,
request: PrivateTransactionRequest,
) -> Result<H256, jsonrpsee::core::Error>;
) -> Result<B256, jsonrpsee::core::Error>;

/// The `eth_sendPrivateRawTransaction` method can be used to send private transactions to the
/// RPC endpoint. Private transactions are protected from frontrunning and kept private until
Expand All @@ -115,7 +115,7 @@ pub trait EthBundleApiClient {
async fn send_private_raw_transaction(
&self,
bytes: Bytes,
) -> Result<H256, jsonrpsee::core::Error>;
) -> Result<B256, jsonrpsee::core::Error>;

/// The `eth_cancelPrivateTransaction` method stops private transactions from being submitted
/// for future blocks.
Expand Down Expand Up @@ -158,14 +158,14 @@ where
async fn send_private_transaction(
&self,
request: PrivateTransactionRequest,
) -> Result<H256, jsonrpsee::core::Error> {
) -> Result<B256, jsonrpsee::core::Error> {
rpc::EthBundleApiClient::send_private_transaction(self, request).await
}

async fn send_private_raw_transaction(
&self,
bytes: Bytes,
) -> Result<H256, jsonrpsee::core::Error> {
) -> Result<B256, jsonrpsee::core::Error> {
rpc::EthBundleApiClient::send_private_raw_transaction(self, bytes).await
}

Expand Down
Loading