-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: op eth api scaffolding (#9324)
- Loading branch information
Showing
5 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
//! OP-Reth `eth_` endpoint implementation. | ||
use alloy_primitives::{Address, U64}; | ||
use reth_chainspec::ChainInfo; | ||
use reth_errors::RethResult; | ||
use reth_rpc_eth_api::helpers::EthApiSpec; | ||
use reth_rpc_types::SyncStatus; | ||
use std::future::Future; | ||
|
||
/// OP-Reth `Eth` API implementation. | ||
/// | ||
/// This type provides the functionality for handling `eth_` related requests. | ||
/// | ||
/// This wraps a default `Eth` implementation, and provides additional functionality where the | ||
/// optimism spec deviates from the default (ethereum) spec, e.g. transaction forwarding to the | ||
/// sequencer, receipts, additional RPC fields for transaction receipts. | ||
/// | ||
/// This type implements the [`FullEthApi`](reth_rpc_eth_api::helpers::FullEthApi) by implemented | ||
/// all the `Eth` helper traits and prerequisite traits. | ||
#[derive(Debug, Clone)] | ||
pub struct OpEthApi<Eth> { | ||
inner: Eth, | ||
} | ||
|
||
impl<Eth> OpEthApi<Eth> { | ||
/// Creates a new `OpEthApi` from the provided `Eth` implementation. | ||
pub const fn new(inner: Eth) -> Self { | ||
Self { inner } | ||
} | ||
} | ||
|
||
impl<Eth: EthApiSpec> EthApiSpec for OpEthApi<Eth> { | ||
fn protocol_version(&self) -> impl Future<Output = RethResult<U64>> + Send { | ||
self.inner.protocol_version() | ||
} | ||
|
||
fn chain_id(&self) -> U64 { | ||
self.inner.chain_id() | ||
} | ||
|
||
fn chain_info(&self) -> RethResult<ChainInfo> { | ||
self.inner.chain_info() | ||
} | ||
|
||
fn accounts(&self) -> Vec<Address> { | ||
self.inner.accounts() | ||
} | ||
|
||
fn is_syncing(&self) -> bool { | ||
self.inner.is_syncing() | ||
} | ||
|
||
fn sync_status(&self) -> RethResult<SyncStatus> { | ||
self.inner.sync_status() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters