Skip to content

Commit 4373cfd

Browse files
committed
fix gh workflow
1 parent eb24b2f commit 4373cfd

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/utils/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
pub mod exceptions;
44
#[cfg(feature = "models")]
55
pub mod get_nftoken_id;
6+
#[cfg(feature = "models")]
67
pub mod get_xchain_claim_id;
78
#[cfg(feature = "models")]
89
pub mod parse_nftoken_id;
910
pub mod str_conversion;
1011
pub mod time_conversion;
1112
#[cfg(feature = "models")]
1213
pub(crate) mod transactions;
14+
#[cfg(feature = "models")]
1315
pub mod txn_parser;
1416
pub mod xrpl_conversion;
1517

src/utils/txn_parser/utils/balance_parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn get_xrp_quantity(
3838
} else {
3939
let xrp_value = drops_to_xrp(absulte_value.to_string().as_str())?;
4040
let dec = BigDecimal::from_str(&xrp_value)?;
41-
negate(&dec)
41+
negate(&dec)?
4242
};
4343
if let Some(final_fields) = node.final_fields {
4444
if let Some(account) = final_fields.account {
@@ -76,7 +76,7 @@ fn get_xrp_quantity(
7676

7777
fn flip_trustline_perspective(account_balance: AccountBalance) -> XRPLUtilsResult<AccountBalance> {
7878
let balance = account_balance.balance.clone();
79-
let negated_value = negate(&BigDecimal::from_str(balance.value.as_ref())?);
79+
let negated_value = negate(&BigDecimal::from_str(balance.value.as_ref())?)?;
8080
let issuer = balance.issuer.clone();
8181

8282
Ok(AccountBalance {
@@ -122,7 +122,7 @@ fn get_trustline_quantity<'a>(
122122
balance: Balance {
123123
currency: balance_currency.to_string().into(),
124124
issuer: Some(high_limit_issuer.to_string().into()),
125-
value: format!("{}", value.unwrap().normalized()).into(),
125+
value: format!("{}", value.unwrap().normalized()).into(), // safe to unwrap because we checked for None above
126126
},
127127
};
128128
return Ok([result.clone(), flip_trustline_perspective(result)?].into());

src/utils/txn_parser/utils/mod.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ use core::str::FromStr;
33
use alloc::{borrow::Cow, string::ToString, vec::Vec};
44
use bigdecimal::BigDecimal;
55

6-
use crate::models::{transactions::offer_create::OfferCreateFlag, Amount, FlagCollection};
6+
use crate::{
7+
models::{transactions::offer_create::OfferCreateFlag, Amount, FlagCollection},
8+
utils::exceptions::XRPLUtilsResult,
9+
};
710

811
pub mod balance_parser;
912
pub mod nodes;
@@ -84,9 +87,9 @@ pub struct AccountObjectGroup<'a> {
8487
pub account_offer_changes: Vec<AccountOfferChange<'a>>,
8588
}
8689

87-
pub fn negate(value: &BigDecimal) -> BigDecimal {
88-
let zero = BigDecimal::from_str("0").unwrap();
90+
pub fn negate(value: &BigDecimal) -> XRPLUtilsResult<BigDecimal> {
91+
let zero = BigDecimal::from_str("0")?;
8992
let working_value = zero - value;
9093

91-
BigDecimal::from_str(&working_value.to_string()).unwrap()
94+
Ok(BigDecimal::from_str(&working_value.to_string())?)
9295
}

0 commit comments

Comments
 (0)