Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/HEAD'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/named.rs
  • Loading branch information
vacekj committed Jan 8, 2024
2 parents b79d667 + d0d8224 commit 9696336
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 50 deletions.
12 changes: 12 additions & 0 deletions assets/chains.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 13 additions & 50 deletions src/named.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ pub enum NamedChain {
#[cfg_attr(feature = "serde", serde(alias = "mantle_testnet"))]
MantleTestnet = 5001,

Viction = 88,

Zora = 7777777,
ZoraGoerli = 999,
ZoraSepolia = 999999999,
Expand Down Expand Up @@ -284,23 +286,6 @@ impl NamedChain {
}

/// 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
/// for example.
///
/// **Note:** this is not an accurate average, but is rather a sensible default derived from
/// blocktime charts such as [Etherscan's](https://etherscan.com/chart/blocktime)
/// or [Polygonscan's](https://polygonscan.com/chart/blocktime).
///
/// # Examples
///
/// ```
/// use alloy_chains::NamedChain;
/// use std::time::Duration;
///
/// assert_eq!(NamedChain::Mainnet.average_blocktime_hint(), Some(Duration::from_millis(12_000)),);
/// assert_eq!(NamedChain::Optimism.average_blocktime_hint(), Some(Duration::from_millis(2_000)),);
/// ```
pub const fn average_blocktime_hint(self) -> Option<Duration> {
use NamedChain as C;

Expand All @@ -325,6 +310,8 @@ impl NamedChain {
| C::Pgn
| C::PgnSepolia => 2_000,

C::Viction => 2_000,

C::Polygon | C::PolygonMumbai => 2_100,

C::Moonbeam | C::Moonriver => 12_500,
Expand Down Expand Up @@ -419,7 +406,8 @@ impl NamedChain {
| C::PolygonZkEvmTestnet
| C::Scroll
| C::ScrollSepolia
| C::Metis => true,
| C::Metis
| C::Viction => true,

// Known EIP-1559 chains.
C::Mainnet
Expand Down Expand Up @@ -589,7 +577,8 @@ impl NamedChain {
| C::ZkSync
| C::Mantle
| C::Zora
| C::Pgn => false,
| C::Pgn
| C::Viction => false,
}
}

Expand All @@ -614,26 +603,6 @@ impl NamedChain {
}

/// Returns the chain's blockchain explorer and its API (Etherscan and Etherscan-like) URLs.
///
/// Returns `(API_URL, BASE_URL)`.
///
/// All URLs have no trailing `/`
///
/// # Examples
///
/// ```
/// use alloy_chains::NamedChain;
///
/// assert_eq!(
/// NamedChain::Mainnet.etherscan_urls(),
/// Some(("https://api.etherscan.io/api", "https://etherscan.io"))
/// );
/// assert_eq!(
/// NamedChain::Avalanche.etherscan_urls(),
/// Some(("https://api.snowtrace.io/api", "https://snowtrace.io"))
/// );
/// assert_eq!(NamedChain::AnvilHardhat.etherscan_urls(), None);
/// ```
pub const fn etherscan_urls(self) -> Option<(&'static str, &'static str)> {
use NamedChain as C;

Expand Down Expand Up @@ -805,6 +774,8 @@ impl NamedChain {
("https://explorer.testnet.mantle.xyz/api", "https://explorer.testnet.mantle.xyz")
}

C::Viction => ("https://www.vicscan.xyz/api", "https://www.vicscan.xyz"),

C::Zora => ("https://explorer.zora.energy/api", "https://explorer.zora.energy"),
C::ZoraGoerli => {
("https://testnet.explorer.zora.energy/api", "https://testnet.explorer.zora.energy")
Expand All @@ -829,16 +800,7 @@ impl NamedChain {
}

/// Returns the chain's blockchain explorer's API key environment variable's default name.
///
/// # Examples
///
/// ```
/// use alloy_chains::NamedChain;
///
/// assert_eq!(NamedChain::Mainnet.etherscan_api_key_name(), Some("ETHERSCAN_API_KEY"));
/// assert_eq!(NamedChain::AnvilHardhat.etherscan_api_key_name(), None);
/// ```
/// pub const fn etherscan_api_key_name(self) -> Option<&'static str> {
pub const fn etherscan_api_key_name(self) -> Option<&'static str> {
use NamedChain as C;

let api_key_name = match self {
Expand Down Expand Up @@ -916,7 +878,8 @@ impl NamedChain {
| C::ZkSyncTestnet
| C::FilecoinMainnet
| C::LineaTestnet
| C::FilecoinCalibrationTestnet => return None,
| C::FilecoinCalibrationTestnet
| C::Viction => return None,
};

Some(api_key_name)
Expand Down

0 comments on commit 9696336

Please sign in to comment.