diff --git a/pallas-traverse/src/era.rs b/pallas-traverse/src/era.rs new file mode 100644 index 0000000..aa5595b --- /dev/null +++ b/pallas-traverse/src/era.rs @@ -0,0 +1,17 @@ +use crate::{Era, Feature}; + +impl Era { + #[allow(clippy::match_like_matches_macro)] + pub fn has_feature(&self, feature: Feature) -> bool { + match (self, feature) { + (Era::Byron, _) => false, + (Era::Shelley, Feature::SmartContracts) => false, + (Era::Shelley, Feature::TimeLocks) => false, + (Era::Shelley, Feature::MultiAssets) => false, + (Era::Allegra, Feature::MultiAssets) => false, + (Era::Allegra, Feature::SmartContracts) => false, + (Era::Mary, Feature::SmartContracts) => false, + _ => true, + } + } +} diff --git a/pallas-traverse/src/lib.rs b/pallas-traverse/src/lib.rs index 5257ffd..22e4466 100644 --- a/pallas-traverse/src/lib.rs +++ b/pallas-traverse/src/lib.rs @@ -8,6 +8,7 @@ use thiserror::Error; pub mod block; pub mod cert; +pub mod era; pub mod output; pub mod probe; mod support; @@ -23,6 +24,15 @@ pub enum Era { Alonzo, // smart-contracts } +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] +#[non_exhaustive] +pub enum Feature { + TimeLocks, + MultiAssets, + Staking, + SmartContracts, +} + #[derive(Debug, Clone)] #[non_exhaustive] pub enum MultiEraBlock<'b> {