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
cdb7b6f954
commit
dd42b951a3
1 changed files with 11 additions and 1 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use pallas_primitives::{alonzo, byron};
|
use pallas_primitives::{alonzo::{self, Value}, byron};
|
||||||
|
|
||||||
use crate::MultiEraOutput;
|
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> {
|
pub fn as_alonzo(&self) -> Option<&alonzo::TransactionOutput> {
|
||||||
match self {
|
match self {
|
||||||
MultiEraOutput::Byron(_) => None,
|
MultiEraOutput::Byron(_) => None,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue