2021-12-08 06:21:04 -08:00
|
|
|
//! Exposes an API implementation depending on which feature flags have been toggled for the
|
|
|
|
//! library. Check submodules for chain runtime specific documentation.
|
|
|
|
use std::convert::TryFrom; // Remove in 2021
|
|
|
|
|
|
|
|
/// Chain contains a mapping of Wormhole supported chains to their u16 representation. These are
|
|
|
|
/// universally defined among all Wormhole contracts.
|
|
|
|
#[repr(u16)]
|
2022-09-30 00:53:04 -07:00
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
2021-12-08 06:21:04 -08:00
|
|
|
pub enum Chain {
|
2022-09-30 00:28:48 -07:00
|
|
|
All = 0,
|
|
|
|
Solana = 1,
|
2021-12-08 06:21:04 -08:00
|
|
|
Ethereum = 2,
|
2022-09-30 00:28:48 -07:00
|
|
|
Terra = 3,
|
|
|
|
Binance = 4,
|
|
|
|
Polygon = 5,
|
|
|
|
AVAX = 6,
|
|
|
|
Oasis = 7,
|
2021-12-08 06:21:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
impl TryFrom<u16> for Chain {
|
|
|
|
type Error = ();
|
|
|
|
fn try_from(other: u16) -> Result<Chain, Self::Error> {
|
|
|
|
match other {
|
|
|
|
0 => Ok(Chain::All),
|
|
|
|
1 => Ok(Chain::Solana),
|
|
|
|
2 => Ok(Chain::Ethereum),
|
|
|
|
3 => Ok(Chain::Terra),
|
|
|
|
4 => Ok(Chain::Binance),
|
|
|
|
5 => Ok(Chain::Polygon),
|
|
|
|
6 => Ok(Chain::AVAX),
|
|
|
|
7 => Ok(Chain::Oasis),
|
|
|
|
_ => Err(()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for Chain {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self::All
|
|
|
|
}
|
|
|
|
}
|