diff --git a/pallas-traverse/src/lib.rs b/pallas-traverse/src/lib.rs index 2c707d1..a87bb14 100644 --- a/pallas-traverse/src/lib.rs +++ b/pallas-traverse/src/lib.rs @@ -52,7 +52,7 @@ pub enum MultiEraBlock<'b> { Byron(Box>>), } -#[derive(Debug)] +#[derive(Debug, Clone)] #[non_exhaustive] pub enum MultiEraTx<'b> { AlonzoCompatible(Box>>, Era), diff --git a/pallas-traverse/src/tx.rs b/pallas-traverse/src/tx.rs index 9774bdb..abae439 100644 --- a/pallas-traverse/src/tx.rs +++ b/pallas-traverse/src/tx.rs @@ -67,6 +67,21 @@ impl<'b> MultiEraTx<'b> { } } + pub fn output_at(&self, index: usize) -> Option { + 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 { match self { MultiEraTx::AlonzoCompatible(x, _) => x