Skip to content

Commit

Permalink
sdk/rust: add cosmos chain ids for ibc connections (#3727)
Browse files Browse the repository at this point in the history
  • Loading branch information
nik-suri authored Jan 31, 2024
1 parent 937af99 commit 4ffd961
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions sdk/rust/core/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ pub enum Chain {
Scroll,
Mantle,
Wormchain,
CosmosHub,
Evmos,
Kujira,
Neutron,
Celestia,
Stargaze,
Seda,
Sepolia,

// Allow arbitrary u16s to support future chains.
Expand Down Expand Up @@ -90,6 +97,13 @@ impl From<u16> for Chain {
34 => Chain::Scroll,
35 => Chain::Mantle,
3104 => Chain::Wormchain,
4000 => Chain::CosmosHub,
4001 => Chain::Evmos,
4002 => Chain::Kujira,
4003 => Chain::Neutron,
4004 => Chain::Celestia,
4005 => Chain::Stargaze,
4006 => Chain::Seda,
10002 => Chain::Sepolia,
c => Chain::Unknown(c),
}
Expand Down Expand Up @@ -134,6 +148,13 @@ impl From<Chain> for u16 {
Chain::Scroll => 34,
Chain::Mantle => 35,
Chain::Wormchain => 3104,
Chain::CosmosHub => 4000,
Chain::Evmos => 4001,
Chain::Kujira => 4002,
Chain::Neutron => 4003,
Chain::Celestia => 4004,
Chain::Stargaze => 4005,
Chain::Seda => 4006,
Chain::Sepolia => 10002,
Chain::Unknown(c) => c,
}
Expand Down Expand Up @@ -179,6 +200,13 @@ impl fmt::Display for Chain {
Self::Mantle => f.write_str("Mantle"),
Self::Sepolia => f.write_str("Sepolia"),
Self::Wormchain => f.write_str("Wormchain"),
Self::CosmosHub => f.write_str("CosmosHub"),
Self::Evmos => f.write_str("Evmos"),
Self::Kujira => f.write_str("Kujira"),
Self::Neutron => f.write_str("Neutron"),
Self::Celestia => f.write_str("Celestia"),
Self::Stargaze => f.write_str("Stargaze"),
Self::Seda => f.write_str("Seda"),
Self::Unknown(v) => write!(f, "Unknown({v})"),
}
}
Expand Down Expand Up @@ -229,6 +257,13 @@ impl FromStr for Chain {
"Mantle" | "mantle" | "MANTLE" => Ok(Chain::Mantle),
"Sepolia" | "sepolia" | "SEPOLIA" => Ok(Chain::Sepolia),
"Wormchain" | "wormchain" | "WORMCHAIN" => Ok(Chain::Wormchain),
"CosmosHub" | "cosmoshub" | "COSMOSHUB" => Ok(Chain::CosmosHub),
"Evmos" | "evmos" | "EVMOS" => Ok(Chain::Evmos),
"Kujira" | "kujira" | "KUJIRA" => Ok(Chain::Kujira),
"Neutron" | "neutron" | "NEUTRON" => Ok(Chain::Neutron),
"Celestia" | "celestia" | "CELESTIA" => Ok(Chain::Celestia),
"Stargaze" | "stargaze" | "STARGAZE" => Ok(Chain::Stargaze),
"Seda" | "seda" | "SEDA" => Ok(Chain::Seda),
_ => {
let mut parts = s.split(&['(', ')']);
let _ = parts
Expand Down

0 comments on commit 4ffd961

Please sign in to comment.