Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added ada amount method on output #135

Merged
merged 1 commit into from
Jun 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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