From 029dc713e9f8923bc849ed69101a5f6a26661e46 Mon Sep 17 00:00:00 2001 From: LimpidCrypto Date: Sat, 12 Oct 2024 14:54:27 +0000 Subject: [PATCH] normalize IssuedCurrency before serializing --- src/_serde/mod.rs | 7 ------- src/core/types/amount.rs | 8 +++++++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/_serde/mod.rs b/src/_serde/mod.rs index 34e6f8d..9556367 100644 --- a/src/_serde/mod.rs +++ b/src/_serde/mod.rs @@ -290,10 +290,3 @@ macro_rules! serde_with_tag { } }; } - -/// Normally when using bigdecimal "serde_json" feature a `1` will be serialized as `1.000000000000000`. -/// This function serializes a `BigDecimal` to a string without the trailing zeros. -pub fn serialize_bigdecimal(value: &BigDecimal, s: S) -> Result { - let trimmed_str = value.normalized().to_string(); - s.serialize_str(&trimmed_str) -} diff --git a/src/core/types/amount.rs b/src/core/types/amount.rs index 96b1df6..8aced60 100644 --- a/src/core/types/amount.rs +++ b/src/core/types/amount.rs @@ -3,7 +3,6 @@ //! See Amount Fields: //! `` -use crate::_serde::serialize_bigdecimal; use crate::core::binarycodec::exceptions::XRPLBinaryCodecException; use crate::core::types::exceptions::XRPLTypeException; use crate::core::types::*; @@ -35,6 +34,13 @@ const _ZERO_CURRENCY_AMOUNT_HEX: u64 = 0x8000000000000000; const _NATIVE_AMOUNT_BYTE_LENGTH: u8 = 8; const _CURRENCY_AMOUNT_BYTE_LENGTH: u8 = 48; +/// Normally when using bigdecimal "serde_json" feature a `1` will be serialized as `1.000000000000000`. +/// This function normalizes a `BigDecimal` before serializing to a string. +pub fn serialize_bigdecimal(value: &BigDecimal, s: S) -> Result { + let trimmed_str = value.normalized().to_string(); + s.serialize_str(&trimmed_str) +} + /// An Issued Currency object. #[derive(Debug, Serialize, Deserialize, Clone)] pub(crate) struct IssuedCurrency {