From fba54db8b106dea9961e798fd1f67c15984f2cfe Mon Sep 17 00:00:00 2001 From: Mateusz Czeladka Date: Mon, 20 Jun 2022 23:15:45 +0200 Subject: [PATCH] added ada amount method on output --- pallas-traverse/src/output.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pallas-traverse/src/output.rs b/pallas-traverse/src/output.rs index 66be8879..30307754 100644 --- a/pallas-traverse/src/output.rs +++ b/pallas-traverse/src/output.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; -use pallas_primitives::{alonzo, byron}; +use pallas_primitives::{alonzo::{self, Value}, byron}; use crate::MultiEraOutput; @@ -22,6 +22,16 @@ impl<'b> MultiEraOutput<'b> { } } + pub fn ada_amount(&self) -> u64 { + match self { + MultiEraOutput::Byron(x) => x.amount, + MultiEraOutput::AlonzoCompatible(x) => match x.amount { + Value::Coin(c) => u64::from(c), + Value::Multiasset(c, _) => u64::from(c) + } + } + } + pub fn as_alonzo(&self) -> Option<&alonzo::TransactionOutput> { match self { MultiEraOutput::Byron(_) => None,