diff --git a/pallas-traverse/src/witnesses.rs b/pallas-traverse/src/witnesses.rs index dbc0da79..6c8e1ea1 100644 --- a/pallas-traverse/src/witnesses.rs +++ b/pallas-traverse/src/witnesses.rs @@ -1,4 +1,4 @@ -use pallas_primitives::{alonzo, babbage}; +use pallas_primitives::{alonzo::{self, VKeyWitness, Redeemer, PlutusData, BootstrapWitness, NativeScript}, babbage::{self, PlutusV2Script}}; use crate::MultiEraWitnesses; @@ -17,6 +17,61 @@ impl<'b> MultiEraWitnesses<'b> { } } + pub fn vkeywitness(&self) -> Option<&[VKeyWitness]> { + match self { + Self::AlonzoCompatible(x) => x.vkeywitness.as_ref().map(|x| x.as_ref()), + Self::Babbage(x) => x.vkeywitness.as_ref().map(|x| x.as_ref()), + _ => None, + } + } + + pub fn native_script(&self) -> Option<&[NativeScript]> { + match self { + Self::AlonzoCompatible(x) => x.native_script.as_ref().map(|x| x.as_ref()), + Self::Babbage(x) => x.native_script.as_ref().map(|x| x.as_ref()), + _ => None, + } + } + + pub fn bootstrap_witness(&self) -> Option<&[BootstrapWitness]> { + match self { + Self::AlonzoCompatible(x) => x.bootstrap_witness.as_ref().map(|x| x.as_ref()), + Self::Babbage(x) => x.bootstrap_witness.as_ref().map(|x| x.as_ref()), + _ => None, + } + } + + pub fn plutus_v1_script(&self) -> Option<&[alonzo::PlutusScript]> { + match self { + Self::AlonzoCompatible(x) => x.plutus_script.as_ref().map(|x| x.as_ref()), + Self::Babbage(x) => x.plutus_v1_script.as_ref().map(|x| x.as_ref()), + _ => None, + } + } + + pub fn plutus_data(&self) -> Option<&[PlutusData]> { + match self { + Self::AlonzoCompatible(x) => x.plutus_data.as_ref().map(|x| x.as_ref()), + Self::Babbage(x) => x.plutus_data.as_ref().map(|x| x.as_ref()), + _ => None, + } + } + + pub fn redeemer(&self) -> Option<&[Redeemer]> { + match self { + Self::AlonzoCompatible(x) => x.redeemer.as_ref().map(|x| x.as_ref()), + Self::Babbage(x) => x.redeemer.as_ref().map(|x| x.as_ref()), + _ => None, + } + } + + pub fn plutus_v2_script(&self) -> Option<&[PlutusV2Script]> { + match self { + Self::Babbage(x) => x.plutus_v2_script.as_ref().map(|x| x.as_ref()), + _ => None, + } + } + pub fn cbor(&self) -> &[u8] { match self { MultiEraWitnesses::AlonzoCompatible(x) => x.raw_cbor(),