File tree Expand file tree Collapse file tree 3 files changed +12
-7
lines changed
Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change 33pub mod exceptions;
44#[ cfg( feature = "models" ) ]
55pub mod get_nftoken_id;
6+ #[ cfg( feature = "models" ) ]
67pub mod get_xchain_claim_id;
78#[ cfg( feature = "models" ) ]
89pub mod parse_nftoken_id;
910pub mod str_conversion;
1011pub mod time_conversion;
1112#[ cfg( feature = "models" ) ]
1213pub ( crate ) mod transactions;
14+ #[ cfg( feature = "models" ) ]
1315pub mod txn_parser;
1416pub mod xrpl_conversion;
1517
Original file line number Diff line number Diff 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
7777fn 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 ( ) ) ;
Original file line number Diff line number Diff line change @@ -3,7 +3,10 @@ use core::str::FromStr;
33use alloc:: { borrow:: Cow , string:: ToString , vec:: Vec } ;
44use 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
811pub mod balance_parser;
912pub 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}
You can’t perform that action at this time.
0 commit comments