From 4373cfda5e2e307d0c51e5be3e5b2b7e63bbabf9 Mon Sep 17 00:00:00 2001 From: LimpidCrypto Date: Sat, 4 Jan 2025 23:56:32 +0000 Subject: [PATCH] fix gh workflow --- src/utils/mod.rs | 2 ++ src/utils/txn_parser/utils/balance_parser.rs | 6 +++--- src/utils/txn_parser/utils/mod.rs | 11 +++++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/utils/mod.rs b/src/utils/mod.rs index ea7ee37..403c486 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -3,6 +3,7 @@ pub mod exceptions; #[cfg(feature = "models")] pub mod get_nftoken_id; +#[cfg(feature = "models")] pub mod get_xchain_claim_id; #[cfg(feature = "models")] pub mod parse_nftoken_id; @@ -10,6 +11,7 @@ pub mod str_conversion; pub mod time_conversion; #[cfg(feature = "models")] pub(crate) mod transactions; +#[cfg(feature = "models")] pub mod txn_parser; pub mod xrpl_conversion; diff --git a/src/utils/txn_parser/utils/balance_parser.rs b/src/utils/txn_parser/utils/balance_parser.rs index 92776cb..89ae94c 100644 --- a/src/utils/txn_parser/utils/balance_parser.rs +++ b/src/utils/txn_parser/utils/balance_parser.rs @@ -38,7 +38,7 @@ fn get_xrp_quantity( } else { let xrp_value = drops_to_xrp(absulte_value.to_string().as_str())?; let dec = BigDecimal::from_str(&xrp_value)?; - negate(&dec) + negate(&dec)? }; if let Some(final_fields) = node.final_fields { if let Some(account) = final_fields.account { @@ -76,7 +76,7 @@ fn get_xrp_quantity( fn flip_trustline_perspective(account_balance: AccountBalance) -> XRPLUtilsResult { let balance = account_balance.balance.clone(); - let negated_value = negate(&BigDecimal::from_str(balance.value.as_ref())?); + let negated_value = negate(&BigDecimal::from_str(balance.value.as_ref())?)?; let issuer = balance.issuer.clone(); Ok(AccountBalance { @@ -122,7 +122,7 @@ fn get_trustline_quantity<'a>( balance: Balance { currency: balance_currency.to_string().into(), issuer: Some(high_limit_issuer.to_string().into()), - value: format!("{}", value.unwrap().normalized()).into(), + value: format!("{}", value.unwrap().normalized()).into(), // safe to unwrap because we checked for None above }, }; return Ok([result.clone(), flip_trustline_perspective(result)?].into()); diff --git a/src/utils/txn_parser/utils/mod.rs b/src/utils/txn_parser/utils/mod.rs index ccb5b6d..7d446ca 100644 --- a/src/utils/txn_parser/utils/mod.rs +++ b/src/utils/txn_parser/utils/mod.rs @@ -3,7 +3,10 @@ use core::str::FromStr; use alloc::{borrow::Cow, string::ToString, vec::Vec}; use bigdecimal::BigDecimal; -use crate::models::{transactions::offer_create::OfferCreateFlag, Amount, FlagCollection}; +use crate::{ + models::{transactions::offer_create::OfferCreateFlag, Amount, FlagCollection}, + utils::exceptions::XRPLUtilsResult, +}; pub mod balance_parser; pub mod nodes; @@ -84,9 +87,9 @@ pub struct AccountObjectGroup<'a> { pub account_offer_changes: Vec>, } -pub fn negate(value: &BigDecimal) -> BigDecimal { - let zero = BigDecimal::from_str("0").unwrap(); +pub fn negate(value: &BigDecimal) -> XRPLUtilsResult { + let zero = BigDecimal::from_str("0")?; let working_value = zero - value; - BigDecimal::from_str(&working_value.to_string()).unwrap() + Ok(BigDecimal::from_str(&working_value.to_string())?) }