feat(traverse): Add output-at helper method (#124)
This commit is contained in:
parent
40d58b816b
commit
82e5218de6
2 changed files with 16 additions and 1 deletions
|
|
@ -52,7 +52,7 @@ pub enum MultiEraBlock<'b> {
|
||||||
Byron(Box<Cow<'b, byron::MintedBlock<'b>>>),
|
Byron(Box<Cow<'b, byron::MintedBlock<'b>>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum MultiEraTx<'b> {
|
pub enum MultiEraTx<'b> {
|
||||||
AlonzoCompatible(Box<Cow<'b, alonzo::MintedTx<'b>>>, Era),
|
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> {
|
pub fn inputs(&self) -> Vec<MultiEraInput> {
|
||||||
match self {
|
match self {
|
||||||
MultiEraTx::AlonzoCompatible(x, _) => x
|
MultiEraTx::AlonzoCompatible(x, _) => x
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue