Skip to content

Commit

Permalink
feat: add darwinia crab koi (#77)
Browse files Browse the repository at this point in the history
- **Add darwinia crab koi network**

---------

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
  • Loading branch information
hujw77 and mattsse authored Aug 9, 2024
1 parent 03246db commit 832fa62
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 6 deletions.
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.

19 changes: 19 additions & 0 deletions src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,25 @@ impl Chain {
pub const fn flare_coston2() -> Self {
Self::from_named(NamedChain::FlareCoston2)
}

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

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

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

/// Returns the kind of this chain.
#[inline]
pub const fn kind(&self) -> &ChainKind {
Expand Down
50 changes: 44 additions & 6 deletions src/named.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ pub enum NamedChain {

Rsk = 30,

#[strum(to_string = "crab")]
#[cfg_attr(feature = "serde", serde(alias = "crab"))]
Crab = 44,
#[strum(to_string = "darwinia")]
#[cfg_attr(feature = "serde", serde(alias = "darwinia"))]
Darwinia = 46,
#[strum(to_string = "koi")]
#[cfg_attr(feature = "serde", serde(alias = "koi"))]
Koi = 701,

#[strum(to_string = "bsc", serialize = "binance-smart-chain")]
#[cfg_attr(feature = "serde", serde(alias = "bsc", alias = "binance-smart-chain"))]
BinanceSmartChain = 56,
Expand Down Expand Up @@ -477,7 +487,7 @@ impl NamedChain {

C::Oasis => 5_500,

C::Emerald => 6_000,
C::Emerald | C::Darwinia | C::Crab | C::Koi => 6_000,

C::Dev | C::AnvilHardhat => 200,

Expand Down Expand Up @@ -629,7 +639,10 @@ impl NamedChain {
| C::Flare
| C::FlareCoston2
| C::Scroll
| C::ScrollSepolia => false,
| C::ScrollSepolia
| C::Darwinia
| C::Crab
| C::Koi => false,

// Unknown / not applicable, default to false for backwards compatibility.
C::Dev
Expand Down Expand Up @@ -706,7 +719,10 @@ impl NamedChain {
| C::AcalaMandalaTestnet
| C::AcalaTestnet
| C::Karura
| C::KaruraTestnet => true,
| C::KaruraTestnet
| C::Darwinia
| C::Crab
| C::Koi => true,
_ => false,
}
}
Expand Down Expand Up @@ -776,7 +792,8 @@ impl NamedChain {
| C::FlareCoston2
| C::AcalaMandalaTestnet
| C::AcalaTestnet
| C::KaruraTestnet => true,
| C::KaruraTestnet
| C::Koi => true,

// Dev chains.
C::Dev | C::AnvilHardhat => true,
Expand Down Expand Up @@ -828,7 +845,9 @@ impl NamedChain {
| C::Taiko
| C::Flare
| C::Acala
| C::Karura => false,
| C::Karura
| C::Darwinia
| C::Crab => false,
}
}

Expand Down Expand Up @@ -869,6 +888,12 @@ impl NamedChain {

C::FlareCoston2 => "C2FLR",

C::Darwinia => "RING",

C::Crab => "CRAB",

C::Koi => "KRING",

_ => return None,
})
}
Expand Down Expand Up @@ -1161,6 +1186,16 @@ impl NamedChain {
"https://blockscout.karura-testnet.aca-staging.network/api",
"https://blockscout.karura-testnet.aca-staging.network",
),

C::Darwinia => {
("https://explorer.darwinia.network/api", "https://explorer.darwinia.network")
}
C::Crab => {
("https://crab-scan.darwinia.network/api", "https://crab-scan.darwinia.network")
}
C::Koi => {
("https://koi-scan.darwinia.network/api", "https://koi-scan.darwinia.network")
}
})
}

Expand Down Expand Up @@ -1254,7 +1289,10 @@ impl NamedChain {
| C::Shimmer
| C::Zora
| C::ZoraGoerli
| C::ZoraSepolia => "BLOCKSCOUT_API_KEY",
| C::ZoraSepolia
| C::Darwinia
| C::Crab
| C::Koi => "BLOCKSCOUT_API_KEY",

C::Boba => "BOBASCAN_API_KEY",

Expand Down

0 comments on commit 832fa62

Please sign in to comment.