diff --git a/packages/std/src/coin.rs b/packages/std/src/coin.rs index b88a6da3ee..3744e8ed1e 100644 --- a/packages/std/src/coin.rs +++ b/packages/std/src/coin.rs @@ -4,7 +4,7 @@ use std::{fmt, str::FromStr}; use crate::{errors::CoinFromStrError, math::Uint128}; -#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, JsonSchema)] +#[derive(Serialize, Deserialize, Clone, Default, PartialEq, Eq, JsonSchema)] pub struct Coin { pub denom: String, pub amount: Uint128, @@ -19,6 +19,12 @@ impl Coin { } } +impl fmt::Debug for Coin { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}{}", self.amount, self.denom) + } +} + impl FromStr for Coin { type Err = CoinFromStrError; @@ -235,4 +241,10 @@ mod tests { "Invalid amount: number too large to fit in target type" ); } + + #[test] + fn debug_coin() { + let coin = Coin::new(123, "ucosm"); + assert_eq!(format!("{:?}", coin), "123ucosm"); + } }