feat(traverse): Add ada amount method on output (#135)
Co-authored-by: Mateusz Czeladka <mateusz.szczap[at]gmail.com>
This commit is contained in:
parent
19844889e6
commit
879d70285b
1 changed files with 11 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue