From 75b7f3965db2b74614ab742834c2fbbee7c7305b Mon Sep 17 00:00:00 2001 From: quasisamurai Date: Wed, 28 Feb 2024 11:02:38 -0300 Subject: [PATCH] convertation using try into --- .../neutron-sdk/src/interchain_queries/v045/types.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/neutron-sdk/src/interchain_queries/v045/types.rs b/packages/neutron-sdk/src/interchain_queries/v045/types.rs index da6ba1c9..4a0f6ea4 100644 --- a/packages/neutron-sdk/src/interchain_queries/v045/types.rs +++ b/packages/neutron-sdk/src/interchain_queries/v045/types.rs @@ -476,14 +476,10 @@ impl KVReconstruct for Delegations { } fn uint256_to_u128(value: Uint256) -> Result { - // Convert Uint256 to string - let value_str = value.to_string(); - - // Attempt to parse the string as u128 - match value_str.parse::() { - Ok(parsed_value) => Ok(parsed_value), - Err(_) => Err(StdError::generic_err("Uint256 value exceeds u128 limits")), - } + let converted: Uint128 = value + .try_into() + .map_err(|_| StdError::generic_err("Uint256 value exceeds u128 limits"))?; + Ok(converted.u128()) } /// Represents a single unbonding delegation from some validator to some delegator on remote chain