feat(traverse): Add missing getters for witness fields (#160)
This commit is contained in:
parent
a4873c404e
commit
74d5731118
1 changed files with 56 additions and 1 deletions
|
|
@ -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(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue