feat(traverse): expose tx update field (#313)
This commit is contained in:
parent
e94fa32f6c
commit
eace470b4f
3 changed files with 55 additions and 1 deletions
|
|
@ -26,6 +26,7 @@ pub mod signers;
|
||||||
pub mod size;
|
pub mod size;
|
||||||
pub mod time;
|
pub mod time;
|
||||||
pub mod tx;
|
pub mod tx;
|
||||||
|
pub mod update;
|
||||||
pub mod withdrawals;
|
pub mod withdrawals;
|
||||||
pub mod witnesses;
|
pub mod witnesses;
|
||||||
|
|
||||||
|
|
@ -139,6 +140,14 @@ pub enum MultiEraWithdrawals<'b> {
|
||||||
AlonzoCompatible(&'b alonzo::Withdrawals),
|
AlonzoCompatible(&'b alonzo::Withdrawals),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
#[non_exhaustive]
|
||||||
|
pub enum MultiEraUpdate<'b> {
|
||||||
|
NotApplicable,
|
||||||
|
AlonzoCompatible(Box<Cow<'b, alonzo::Update>>),
|
||||||
|
Babbage(Box<Cow<'b, babbage::Update>>),
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum MultiEraSigners<'b> {
|
pub enum MultiEraSigners<'b> {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use pallas_primitives::{
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Era, MultiEraCert, MultiEraInput, MultiEraMeta, MultiEraOutput, MultiEraPolicyAssets,
|
Era, MultiEraCert, MultiEraInput, MultiEraMeta, MultiEraOutput, MultiEraPolicyAssets,
|
||||||
MultiEraSigners, MultiEraTx, MultiEraWithdrawals, OriginalHash,
|
MultiEraSigners, MultiEraTx, MultiEraUpdate, MultiEraWithdrawals, OriginalHash,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl<'b> MultiEraTx<'b> {
|
impl<'b> MultiEraTx<'b> {
|
||||||
|
|
@ -182,6 +182,22 @@ impl<'b> MultiEraTx<'b> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn update(&self) -> Option<MultiEraUpdate> {
|
||||||
|
match self {
|
||||||
|
MultiEraTx::AlonzoCompatible(x, _) => x
|
||||||
|
.transaction_body
|
||||||
|
.update
|
||||||
|
.as_ref()
|
||||||
|
.map(MultiEraUpdate::from_alonzo_compatible),
|
||||||
|
MultiEraTx::Babbage(x) => x
|
||||||
|
.transaction_body
|
||||||
|
.update
|
||||||
|
.as_ref()
|
||||||
|
.map(MultiEraUpdate::from_babbage),
|
||||||
|
MultiEraTx::Byron(_) => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn mints(&self) -> Vec<MultiEraPolicyAssets> {
|
pub fn mints(&self) -> Vec<MultiEraPolicyAssets> {
|
||||||
match self {
|
match self {
|
||||||
MultiEraTx::AlonzoCompatible(x, _) => x
|
MultiEraTx::AlonzoCompatible(x, _) => x
|
||||||
|
|
|
||||||
29
pallas-traverse/src/update.rs
Normal file
29
pallas-traverse/src/update.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
use pallas_primitives::{alonzo, babbage};
|
||||||
|
|
||||||
|
use crate::MultiEraUpdate;
|
||||||
|
|
||||||
|
impl<'b> MultiEraUpdate<'b> {
|
||||||
|
pub fn from_alonzo_compatible(update: &'b alonzo::Update) -> Self {
|
||||||
|
Self::AlonzoCompatible(Box::new(Cow::Borrowed(update)))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn from_babbage(update: &'b babbage::Update) -> Self {
|
||||||
|
Self::Babbage(Box::new(Cow::Borrowed(update)))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn as_alonzo(&self) -> Option<&alonzo::Update> {
|
||||||
|
match self {
|
||||||
|
Self::AlonzoCompatible(x) => Some(x),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn as_babbage(&self) -> Option<&babbage::Update> {
|
||||||
|
match self {
|
||||||
|
Self::Babbage(x) => Some(x),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue