Skip to content

Commit

Permalink
feat(NamedChain): is_arbitrum (#103)
Browse files Browse the repository at this point in the history
Adds helper method to check if `NamedChain` belongs to the Arbitrum
configuration
  • Loading branch information
yash-atreya authored Oct 25, 2024
1 parent 5fd24e7 commit e55020e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,12 @@ impl Chain {
matches!(self.named(), Some(named) if named.is_optimism())
}

/// Returns true if the chain contains Arbitrum configuration.
#[inline]
pub const fn is_arbitrum(self) -> bool {
matches!(self.named(), Some(named) if named.is_arbitrum())
}

/// Attempts to convert the chain into a named chain.
#[inline]
pub const fn named(self) -> Option<NamedChain> {
Expand Down
7 changes: 7 additions & 0 deletions src/named.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,13 @@ impl NamedChain {
)
}

/// Returns true if the chain contains Arbitrum configuration.
pub const fn is_arbitrum(self) -> bool {
use NamedChain::*;

matches!(self, Arbitrum | ArbitrumTestnet | ArbitrumGoerli | ArbitrumSepolia | ArbitrumNova)
}

/// Returns the chain's average blocktime, if applicable.
///
/// It can be beneficial to know the average blocktime to adjust the polling of an HTTP provider
Expand Down

0 comments on commit e55020e

Please sign in to comment.