feat(traverse): Add ada amount method on output (#135)

Co-authored-by: Mateusz Czeladka <mateusz.szczap[at]gmail.com>
This commit is contained in:
matiwinnetou 2022-06-21 00:04:53 +02:00 committed by GitHub
parent 19844889e6
commit 879d70285b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,