mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: expose additional eth functions on engine api (#13837)
This commit is contained in:
@ -221,10 +221,12 @@ pub trait EngineApi<Engine: EngineTypes> {
|
||||
|
||||
/// A subset of the ETH rpc interface: <https://ethereum.github.io/execution-apis/api-documentation/>
|
||||
///
|
||||
/// This also includes additional eth functions required by optimism.
|
||||
///
|
||||
/// Specifically for the engine auth server: <https://github.com/ethereum/execution-apis/blob/main/src/engine/common.md#underlying-protocol>
|
||||
#[cfg_attr(not(feature = "client"), rpc(server, namespace = "eth"))]
|
||||
#[cfg_attr(feature = "client", rpc(server, client, namespace = "eth"))]
|
||||
pub trait EngineEthApi<B: RpcObject> {
|
||||
pub trait EngineEthApi<B: RpcObject, R: RpcObject> {
|
||||
/// Returns an object with data about the sync status or false.
|
||||
#[method(name = "syncing")]
|
||||
fn syncing(&self) -> RpcResult<SyncStatus>;
|
||||
@ -259,10 +261,18 @@ pub trait EngineEthApi<B: RpcObject> {
|
||||
#[method(name = "getBlockByNumber")]
|
||||
async fn block_by_number(&self, number: BlockNumberOrTag, full: bool) -> RpcResult<Option<B>>;
|
||||
|
||||
/// Returns all transaction receipts for a given block.
|
||||
#[method(name = "getBlockReceipts")]
|
||||
async fn block_receipts(&self, block_id: BlockId) -> RpcResult<Option<Vec<R>>>;
|
||||
|
||||
/// Sends signed transaction, returning its hash.
|
||||
#[method(name = "sendRawTransaction")]
|
||||
async fn send_raw_transaction(&self, bytes: Bytes) -> RpcResult<B256>;
|
||||
|
||||
/// Returns the receipt of a transaction by transaction hash.
|
||||
#[method(name = "getTransactionReceipt")]
|
||||
async fn transaction_receipt(&self, hash: B256) -> RpcResult<Option<R>>;
|
||||
|
||||
/// Returns logs matching given filter object.
|
||||
#[method(name = "getLogs")]
|
||||
async fn logs(&self, filter: Filter) -> RpcResult<Vec<Log>>;
|
||||
|
||||
@ -34,7 +34,7 @@ impl<Eth, EthFilter> EngineEthApi<Eth, EthFilter> {
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl<Eth, EthFilter> EngineEthApiServer<RpcBlock<Eth::NetworkTypes>>
|
||||
impl<Eth, EthFilter> EngineEthApiServer<RpcBlock<Eth::NetworkTypes>, RpcReceipt<Eth::NetworkTypes>>
|
||||
for EngineEthApi<Eth, EthFilter>
|
||||
where
|
||||
Eth: EthApiServer<
|
||||
@ -103,11 +103,25 @@ where
|
||||
self.eth.block_by_number(number, full).instrument(engine_span!()).await
|
||||
}
|
||||
|
||||
async fn block_receipts(
|
||||
&self,
|
||||
block_id: BlockId,
|
||||
) -> Result<Option<Vec<RpcReceipt<Eth::NetworkTypes>>>> {
|
||||
self.eth.block_receipts(block_id).instrument(engine_span!()).await
|
||||
}
|
||||
|
||||
/// Handler for: `eth_sendRawTransaction`
|
||||
async fn send_raw_transaction(&self, bytes: Bytes) -> Result<B256> {
|
||||
self.eth.send_raw_transaction(bytes).instrument(engine_span!()).await
|
||||
}
|
||||
|
||||
async fn transaction_receipt(
|
||||
&self,
|
||||
hash: B256,
|
||||
) -> Result<Option<RpcReceipt<Eth::NetworkTypes>>> {
|
||||
self.eth.transaction_receipt(hash).instrument(engine_span!()).await
|
||||
}
|
||||
|
||||
/// Handler for `eth_getLogs`
|
||||
async fn logs(&self, filter: Filter) -> Result<Vec<Log>> {
|
||||
self.eth_filter.logs(filter).instrument(engine_span!()).await
|
||||
|
||||
Reference in New Issue
Block a user