Skip to content

Commit 99a25ae

Browse files
committed
fix clippy
1 parent 12ed42a commit 99a25ae

File tree

6 files changed

+17
-24
lines changed

6 files changed

+17
-24
lines changed

src/models/results/account_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl<'a> TryFrom<XRPLResult<'a>> for AccountInfoVersionMap<'a> {
126126

127127
fn try_from(result: XRPLResult<'a>) -> XRPLModelResult<Self> {
128128
match result {
129-
XRPLResult::AccountInfo(account_info) => Ok(account_info),
129+
XRPLResult::AccountInfo(account_info) => Ok(*account_info),
130130
res => Err(XRPLResultException::UnexpectedResultType(
131131
"AccountInfo".to_string(),
132132
res.get_name(),

src/models/results/mod.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl XRPLOtherResult {
8686
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
8787
#[serde(untagged)]
8888
pub enum XRPLResult<'a> {
89-
AccountInfo(account_info::AccountInfoVersionMap<'a>),
89+
AccountInfo(Box<account_info::AccountInfoVersionMap<'a>>), // Boxed because AccountInfo is large
9090
AccountTx(account_tx::AccountTxVersionMap<'a>),
9191
Fee(fee::Fee<'a>),
9292
Ledger(ledger::Ledger<'a>),
@@ -104,19 +104,23 @@ pub enum XRPLResult<'a> {
104104

105105
impl<'a> From<account_info::AccountInfo<'a>> for XRPLResult<'a> {
106106
fn from(account_info: account_info::AccountInfo<'a>) -> Self {
107-
XRPLResult::AccountInfo(account_info::AccountInfoVersionMap::Default(account_info))
107+
XRPLResult::AccountInfo(Box::new(account_info::AccountInfoVersionMap::Default(
108+
account_info,
109+
)))
108110
}
109111
}
110112

111113
impl<'a> From<account_info::AccountInfoV1<'a>> for XRPLResult<'a> {
112114
fn from(account_info: account_info::AccountInfoV1<'a>) -> Self {
113-
XRPLResult::AccountInfo(account_info::AccountInfoVersionMap::V1(account_info))
115+
XRPLResult::AccountInfo(Box::new(account_info::AccountInfoVersionMap::V1(
116+
account_info,
117+
)))
114118
}
115119
}
116120

117121
impl<'a> From<account_info::AccountInfoVersionMap<'a>> for XRPLResult<'a> {
118122
fn from(account_info: account_info::AccountInfoVersionMap<'a>) -> Self {
119-
XRPLResult::AccountInfo(account_info)
123+
XRPLResult::AccountInfo(Box::new(account_info))
120124
}
121125
}
122126

src/utils/str_conversion.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
use alloc::{borrow::Cow, format, string::String};
1+
use alloc::{borrow::Cow, string::String};
22

33
use super::exceptions::XRPLUtilsResult;
44

55
/// Convert a UTF-8-encoded string into hexadecimal encoding.
66
/// XRPL uses hex strings as inputs in fields like `domain`
77
/// in the `AccountSet` transaction.
88
pub fn str_to_hex<'a: 'b, 'b>(value: Cow<'a, str>) -> XRPLUtilsResult<Cow<'b, str>> {
9-
let hex_string = value
10-
.as_bytes()
11-
.iter()
12-
.map(|b| format!("{:02x}", b))
13-
.collect::<String>();
9+
let hex_string = hex::encode(value.as_bytes());
10+
1411
Ok(Cow::Owned(hex_string))
1512
}
1613

src/utils/txn_parser/get_balance_changes.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ use bigdecimal::BigDecimal;
33

44
use crate::{
55
models::transactions::metadata::TransactionMetadata,
6-
utils::{
7-
exceptions::XRPLUtilsResult,
8-
txn_parser::utils::parser::get_value,
9-
},
6+
utils::{exceptions::XRPLUtilsResult, txn_parser::utils::parser::get_value},
107
};
118

129
use super::utils::{
@@ -16,7 +13,7 @@ use super::utils::{
1613
pub fn get_balance_changes<'a: 'b, 'b>(
1714
meta: &'a TransactionMetadata<'a>,
1815
) -> XRPLUtilsResult<Vec<AccountBalances<'b>>> {
19-
Ok(derive_account_balances(meta, compute_balance_change)?)
16+
derive_account_balances(meta, compute_balance_change)
2017
}
2118

2219
/// Get the balance change from a node.
@@ -56,7 +53,6 @@ mod test {
5653

5754
use super::*;
5855
use crate::models::transactions::metadata::TransactionMetadata;
59-
6056

6157
#[test]
6258
fn test_parse_balance_changes() {

src/utils/txn_parser/utils/balance_parser.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +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-
let negated_xrp_value = negate(&dec);
42-
43-
negated_xrp_value
41+
negate(&dec)
4442
};
4543
if let Some(final_fields) = node.final_fields {
4644
if let Some(account) = final_fields.account {
@@ -76,9 +74,7 @@ fn get_xrp_quantity(
7674
}
7775
}
7876

79-
fn flip_trustline_perspective<'a>(
80-
account_balance: AccountBalance<'a>,
81-
) -> XRPLUtilsResult<AccountBalance<'a>> {
77+
fn flip_trustline_perspective(account_balance: AccountBalance) -> XRPLUtilsResult<AccountBalance> {
8278
let balance = account_balance.balance.clone();
8379
let negated_value = negate(&BigDecimal::from_str(balance.value.as_ref())?);
8480
let issuer = balance.issuer.clone();

src/utils/txn_parser/utils/order_book_parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fn get_offer_status(node: &NormalizedNode<'_>) -> OfferStatus {
99
NodeType::CreatedNode => OfferStatus::Created,
1010
NodeType::ModifiedNode => OfferStatus::PartiallyFilled,
1111
NodeType::DeletedNode => {
12-
if let Some(_) = node.previous_fields {
12+
if node.previous_fields.is_some() {
1313
// a filled offer has previous fields
1414
OfferStatus::Filled
1515
} else {

0 commit comments

Comments
 (0)