feat: add is_ethereum trait fn (#12197)

This commit is contained in:
Matthias Seitz
2024-10-30 16:39:12 +01:00
committed by GitHub
parent ff9a42ae8f
commit bb8da983b0
2 changed files with 7 additions and 3 deletions

View File

@ -57,6 +57,11 @@ pub trait EthChainSpec: Send + Sync + Unpin + Debug {
fn is_optimism(&self) -> bool {
self.chain().is_optimism()
}
/// Returns `true` if this chain contains Ethereum configuration.
fn is_ethereum(&self) -> bool {
self.chain().is_ethereum()
}
}
impl EthChainSpec for ChainSpec {

View File

@ -20,12 +20,11 @@ impl NetworkStackId {
/// ENR fork ID kv-pair key, for an Optimism CL node.
pub const OPSTACK: &'static [u8] = b"opstack";
#[allow(clippy::missing_const_for_fn)]
/// Returns the [`NetworkStackId`] that matches the given chain spec.
pub fn id(chain: impl EthChainSpec) -> Option<&'static [u8]> {
if chain.chain().is_optimism() {
if chain.is_optimism() {
return Some(Self::OPEL)
} else if chain.chain().is_ethereum() {
} else if chain.is_ethereum() {
return Some(Self::ETH)
}