Skip to content

Commit

Permalink
fix gh workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
LimpidCrypto committed Jan 4, 2025
1 parent eb24b2f commit 4373cfd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
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;
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;

Expand Down
6 changes: 3 additions & 3 deletions src/utils/txn_parser/utils/balance_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -76,7 +76,7 @@ fn get_xrp_quantity(

fn flip_trustline_perspective(account_balance: AccountBalance) -> XRPLUtilsResult<AccountBalance> {
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 {
Expand Down Expand Up @@ -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());
Expand Down
11 changes: 7 additions & 4 deletions src/utils/txn_parser/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -84,9 +87,9 @@ pub struct AccountObjectGroup<'a> {
pub account_offer_changes: Vec<AccountOfferChange<'a>>,
}

pub fn negate(value: &BigDecimal) -> BigDecimal {
let zero = BigDecimal::from_str("0").unwrap();
pub fn negate(value: &BigDecimal) -> XRPLUtilsResult<BigDecimal> {
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())?)
}

0 comments on commit 4373cfd

Please sign in to comment.