feat(traverse): Expose aux data scripts (#232)
This commit is contained in:
parent
4a7afe94f0
commit
8fa662b4de
3 changed files with 46 additions and 2 deletions
42
pallas-traverse/src/aux.rs
Normal file
42
pallas-traverse/src/aux.rs
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
use std::ops::Deref;
|
||||||
|
|
||||||
|
use pallas_primitives::alonzo;
|
||||||
|
|
||||||
|
use crate::MultiEraTx;
|
||||||
|
|
||||||
|
impl<'b> MultiEraTx<'b> {
|
||||||
|
pub fn aux_plutus_v1_scripts(&self) -> &[alonzo::PlutusScript] {
|
||||||
|
if let Some(aux_data) = self.aux_data() {
|
||||||
|
match aux_data.deref() {
|
||||||
|
alonzo::AuxiliaryData::PostAlonzo(x) => {
|
||||||
|
if let Some(plutus) = &x.plutus_scripts {
|
||||||
|
return plutus.as_ref();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&[]
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn aux_native_scripts(&self) -> &[alonzo::NativeScript] {
|
||||||
|
if let Some(aux_data) = self.aux_data() {
|
||||||
|
match aux_data.deref() {
|
||||||
|
alonzo::AuxiliaryData::PostAlonzo(x) => {
|
||||||
|
if let Some(scripts) = &x.native_scripts {
|
||||||
|
return scripts.as_ref();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
alonzo::AuxiliaryData::ShelleyMa(x) => {
|
||||||
|
if let Some(scripts) = &x.auxiliary_scripts {
|
||||||
|
return scripts.as_ref();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&[]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,7 +9,10 @@ use pallas_codec::utils::KeepRaw;
|
||||||
use pallas_crypto::hash::Hash;
|
use pallas_crypto::hash::Hash;
|
||||||
use pallas_primitives::{alonzo, babbage, byron};
|
use pallas_primitives::{alonzo, babbage, byron};
|
||||||
|
|
||||||
|
mod support;
|
||||||
|
|
||||||
pub mod assets;
|
pub mod assets;
|
||||||
|
pub mod aux;
|
||||||
pub mod block;
|
pub mod block;
|
||||||
pub mod cert;
|
pub mod cert;
|
||||||
pub mod era;
|
pub mod era;
|
||||||
|
|
@ -21,7 +24,6 @@ pub mod meta;
|
||||||
pub mod output;
|
pub mod output;
|
||||||
pub mod probe;
|
pub mod probe;
|
||||||
pub mod signers;
|
pub mod signers;
|
||||||
mod support;
|
|
||||||
pub mod time;
|
pub mod time;
|
||||||
pub mod tx;
|
pub mod tx;
|
||||||
pub mod withdrawals;
|
pub mod withdrawals;
|
||||||
|
|
|
||||||
|
|
@ -319,7 +319,7 @@ impl<'b> MultiEraTx<'b> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn aux_data(&self) -> Option<&KeepRaw<'_, alonzo::AuxiliaryData>> {
|
pub(crate) fn aux_data(&self) -> Option<&KeepRaw<'_, alonzo::AuxiliaryData>> {
|
||||||
match self {
|
match self {
|
||||||
MultiEraTx::AlonzoCompatible(x, _) => match &x.auxiliary_data {
|
MultiEraTx::AlonzoCompatible(x, _) => match &x.auxiliary_data {
|
||||||
pallas_codec::utils::Nullable::Some(x) => Some(x),
|
pallas_codec::utils::Nullable::Some(x) => Some(x),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue