From 6b1cb8db022f32abbf2eae46ac30bc9021f7c7b0 Mon Sep 17 00:00:00 2001 From: Max Kalashnikoff Date: Wed, 11 Dec 2024 12:08:31 +0100 Subject: [PATCH] feat: adding to_amount implementation --- crates/yttrium/src/chain_abstraction/api/route.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/yttrium/src/chain_abstraction/api/route.rs b/crates/yttrium/src/chain_abstraction/api/route.rs index 39e3ac68..de5b0e70 100644 --- a/crates/yttrium/src/chain_abstraction/api/route.rs +++ b/crates/yttrium/src/chain_abstraction/api/route.rs @@ -39,6 +39,16 @@ pub struct InitialTransactionMetadata { pub decimals: u8, } +impl InitialTransactionMetadata { + pub fn to_amount(&self) -> Amount { + Amount::new( + self.symbol.clone(), + self.amount, + Unit::new(self.decimals).unwrap(), + ) + } +} + #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[cfg_attr(feature = "uniffi", derive(uniffi_macros::Record))] #[serde(rename_all = "camelCase")]