sdk/rust: add cosmos chain ids for ibc connections (#3727)

This commit is contained in:
Nikhil Suri 2024-01-31 10:34:49 -05:00 committed by GitHub
parent 937af99b94
commit 4ffd961be2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 35 additions and 0 deletions

View File

@ -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.
@ -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),
}
@ -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,
}
@ -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})"),
}
}
@ -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