Skip to content

Commit

Permalink
added ada amount method on output
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Czeladka committed Jun 20, 2022
1 parent 1984488 commit fba54db
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pallas-traverse/src/output.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::borrow::Cow;

use pallas_primitives::{alonzo, byron};
use pallas_primitives::{alonzo::{self, Value}, byron};

use crate::MultiEraOutput;

Expand All @@ -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,
Expand Down

0 comments on commit fba54db

Please sign in to comment.