Skip to content

Commit

Permalink
feat: add missing eth_ types (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Aug 7, 2023
1 parent cf21128 commit 9b770ea
Show file tree
Hide file tree
Showing 2 changed files with 282 additions and 30 deletions.
32 changes: 27 additions & 5 deletions crates/mev-share-rpc-api/src/eth.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
use crate::{
CancelBundleRequest, CancelPrivateTransactionRequest, EthBundleHash, EthCallBundleResponse,
EthCallBundleTransactionResult, EthSendBundle, PrivateTransactionRequest,
};
use ethers_core::types::{Bytes, H256};
use jsonrpsee::proc_macros::rpc;

/// Eth bundle rpc interface.
Expand All @@ -10,26 +15,43 @@ use jsonrpsee::proc_macros::rpc;
pub trait EthBundleApi {
/// `eth_sendBundle` can be used to send your bundles to the builder.
#[method(name = "sendBundle")]
async fn send_bundle(&self, request: ()) -> jsonrpsee::core::RpcResult<()>;
async fn send_bundle(&self, bundle: EthSendBundle)
-> jsonrpsee::core::RpcResult<EthBundleHash>;

/// `eth_callBundle` can be used to simulate a bundle against a specific block number, including
/// simulating a bundle at the top of the next block.
#[method(name = "callBundle")]
async fn call_bundle(&self, request: ()) -> jsonrpsee::core::RpcResult<()>;
async fn call_bundle(
&self,
request: EthCallBundleResponse,
) -> jsonrpsee::core::RpcResult<EthCallBundleTransactionResult>;

/// `eth_cancelBundle` is used to prevent a submitted bundle from being included on-chain. See [bundle cancellations](https://docs.flashbots.net/flashbots-auction/searchers/advanced/bundle-cancellations) for more information.
#[method(name = "cancelBundle")]
async fn cancel_bundle(&self, request: ()) -> jsonrpsee::core::RpcResult<()>;
async fn cancel_bundle(&self, request: CancelBundleRequest) -> jsonrpsee::core::RpcResult<()>;

/// `eth_sendPrivateTransaction` is used to send a single transaction to Flashbots. Flashbots will attempt to build a block including the transaction for the next 25 blocks. See [Private Transactions](https://docs.flashbots.net/flashbots-auction/searchers/advanced/private-transaction) for more info.
#[method(name = "sendPrivateTransaction")]
async fn send_private_transaction(&self, request: ()) -> jsonrpsee::core::RpcResult<()>;
async fn send_private_transaction(
&self,
request: PrivateTransactionRequest,
) -> jsonrpsee::core::RpcResult<bool>;

/// 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
/// included in a block. A request to this endpoint needs to follow the standard
/// eth_sendRawTransactio
#[method(name = "sendPrivateRawTransaction")]
async fn send_private_raw_transaction(&self, bytes: Bytes) -> jsonrpsee::core::RpcResult<H256>;

/// The `eth_cancelPrivateTransaction` method stops private transactions from being submitted
/// for future blocks.
///
/// A transaction can only be cancelled if the request is signed by the same key as the
/// eth_sendPrivateTransaction call submitting the transaction in first place.
#[method(name = "cancelPrivateTransaction")]
async fn cancel_private_transaction(&self, request: ()) -> jsonrpsee::core::RpcResult<()>;
async fn cancel_private_transaction(
&self,
request: CancelPrivateTransactionRequest,
) -> jsonrpsee::core::RpcResult<bool>;
}
Loading

0 comments on commit 9b770ea

Please sign in to comment.