feat(traverse): Add output-at helper method (#124)
This commit is contained in:
parent
f708c9c687
commit
0ada7cb4c7
2 changed files with 16 additions and 1 deletions
|
|
@ -52,7 +52,7 @@ pub enum MultiEraBlock<'b> {
|
|||
Byron(Box<Cow<'b, byron::MintedBlock<'b>>>),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
#[non_exhaustive]
|
||||
pub enum MultiEraTx<'b> {
|
||||
AlonzoCompatible(Box<Cow<'b, alonzo::MintedTx<'b>>>, Era),
|
||||
|
|
|
|||
|
|
@ -67,6 +67,21 @@ impl<'b> MultiEraTx<'b> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn output_at(&self, index: usize) -> Option<MultiEraOutput> {
|
||||
match self {
|
||||
MultiEraTx::AlonzoCompatible(x, _) => x
|
||||
.transaction_body
|
||||
.outputs
|
||||
.get(index)
|
||||
.map(MultiEraOutput::from_alonzo_compatible),
|
||||
MultiEraTx::Byron(x) => x
|
||||
.transaction
|
||||
.outputs
|
||||
.get(index)
|
||||
.map(MultiEraOutput::from_byron),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn inputs(&self) -> Vec<MultiEraInput> {
|
||||
match self {
|
||||
MultiEraTx::AlonzoCompatible(x, _) => x
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue