Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shimmer + Flare support #71

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions assets/chains.json

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

17 changes: 17 additions & 0 deletions src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,23 @@ impl Chain {
Self::from_named(NamedChain::TaikoHekla)
}

/// Returns the shimmer testnet chain.
#[inline]
pub const fn shimmer() -> Self {
Self::from_named(NamedChain::Shimmer)
}

/// Returns the flare mainnet chain.
#[inline]
pub const fn flare() -> Self {
Self::from_named(NamedChain::Flare)
}

/// Returns the flare testnet chain.
#[inline]
pub const fn flare_coston2() -> Self {
Self::from_named(NamedChain::FlareCoston2)
}
/// Returns the kind of this chain.
#[inline]
pub const fn kind(&self) -> &ChainKind {
Expand Down
47 changes: 43 additions & 4 deletions src/named.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ pub enum NamedChain {
#[cfg_attr(feature = "serde", serde(alias = "syndr-sepolia"))]
SyndrSepolia = 444444,

Shimmer = 148,

#[strum(to_string = "fraxtal")]
#[cfg_attr(feature = "serde", serde(alias = "fraxtal"))]
Fraxtal = 252,
Expand Down Expand Up @@ -261,6 +263,10 @@ pub enum NamedChain {
serde(rename = "autonomys_nova_testnet", alias = "autonomys-nova-testnet")
)]
AutonomysNovaTestnet = 490000,

Flare = 14,
#[cfg_attr(feature = "serde", serde(alias = "flare-coston2"))]
FlareCoston2 = 114,
}

// This must be implemented manually so we avoid a conflict with `TryFromPrimitive` where it treats
Expand Down Expand Up @@ -453,6 +459,8 @@ impl NamedChain {

C::Scroll | C::ScrollSepolia => 3_000,

C::Shimmer => 5_000,

C::Gnosis | C::Chiado => 5_000,

C::Elastos => 5_000,
Expand Down Expand Up @@ -490,6 +498,10 @@ impl NamedChain {
C::OpBNBMainnet | C::OpBNBTestnet | C::AutonomysNovaTestnet => 1_000,

C::Ronin => 3_000,

C::Flare => 1_800,

C::FlareCoston2 => 2_500,
}))
}

Expand Down Expand Up @@ -530,6 +542,7 @@ impl NamedChain {
| C::PolygonZkEvmTestnet
| C::Scroll
| C::ScrollSepolia
| C::Shimmer
| C::Metis
| C::Viction
| C::Elastos
Expand Down Expand Up @@ -581,7 +594,9 @@ impl NamedChain {
| C::OpBNBTestnet
| C::Taiko
| C::TaikoHekla
| C::AutonomysNovaTestnet => false,
| C::AutonomysNovaTestnet
| C::Flare
| C::FlareCoston2 => false,

// Unknown / not applicable, default to false for backwards compatibility.
C::Dev
Expand Down Expand Up @@ -643,6 +658,7 @@ impl NamedChain {
| C::EtherlinkTestnet
| C::Scroll
| C::ScrollSepolia
| C::Shimmer
| C::OpBNBMainnet
| C::OpBNBTestnet
| C::KakarotSepolia
Expand Down Expand Up @@ -703,6 +719,7 @@ impl NamedChain {
| C::PolygonAmoy
| C::PolygonZkEvmTestnet
| C::ScrollSepolia
| C::Shimmer
| C::ZkSyncTestnet
| C::ZoraGoerli
| C::ZoraSepolia
Expand All @@ -712,7 +729,8 @@ impl NamedChain {
| C::EtherlinkTestnet
| C::OpBNBTestnet
| C::TaikoHekla
| C::AutonomysNovaTestnet => true,
| C::AutonomysNovaTestnet
| C::FlareCoston2 => true,

// Dev chains.
C::Dev | C::AnvilHardhat => true,
Expand Down Expand Up @@ -761,7 +779,8 @@ impl NamedChain {
| C::Degen
| C::OpBNBMainnet
| C::Ronin
| C::Taiko => false,
| C::Taiko
| C::Flare => false,
}
}

Expand Down Expand Up @@ -794,6 +813,12 @@ impl NamedChain {

C::Ronin => "RON",

C::Shimmer => "SMR",

C::Flare => "FLR",

C::FlareCoston2 => "C2FLR",

_ => return None,
})
}
Expand Down Expand Up @@ -918,6 +943,10 @@ impl NamedChain {
("https://api-sepolia.scrollscan.com/api", "https://sepolia.scrollscan.com")
}

C::Shimmer => {
("https://explorer.evm.shimmer.network/api", "https://explorer.evm.shimmer.network")
}

C::Metis => {
("https://andromeda-explorer.metis.io/api", "https://andromeda-explorer.metis.io")
}
Expand Down Expand Up @@ -1056,6 +1085,13 @@ impl NamedChain {
C::Ronin => ("https://skynet-api.roninchain.com/ronin", "https://app.roninchain.com"),
C::Taiko => ("https://api.taikoscan.io/api", "https://taikoscan.io"),
C::TaikoHekla => ("https://api-testnet.taikoscan.io/api", "https://hekla.taikoscan.io"),
C::Flare => {
("https://flare-explorer.flare.network/api", "https://flare-explorer.flare.network")
}
C::FlareCoston2 => (
"https://coston2-explorer.flare.network/api",
"https://coston2-explorer.flare.network",
),
})
}

Expand Down Expand Up @@ -1140,7 +1176,10 @@ impl NamedChain {
| C::Pgn
| C::PgnSepolia
| C::KakarotSepolia
| C::EtherlinkTestnet => "BLOCKSCOUT_API_KEY",
| C::EtherlinkTestnet
| C::Shimmer
| C::Flare
| C::FlareCoston2 => "BLOCKSCOUT_API_KEY",

C::Boba => "BOBASCAN_API_KEY",

Expand Down