Skip to content

Commit

Permalink
better debugging for accountid32 in debug build (paritytech#2990)
Browse files Browse the repository at this point in the history
  • Loading branch information
pgherveou authored Jan 19, 2024
1 parent 7bd0949 commit 672b0e6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions substrate/primitives/core/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,14 +593,16 @@ impl std::fmt::Display for AccountId32 {
}

impl sp_std::fmt::Debug for AccountId32 {
#[cfg(feature = "std")]
fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
let s = self.to_ss58check();
write!(f, "{} ({}...)", crate::hexdisplay::HexDisplay::from(&self.0), &s[0..8])
}
#[cfg(feature = "serde")]
{
let s = self.to_ss58check();
write!(f, "{} ({}...)", crate::hexdisplay::HexDisplay::from(&self.0), &s[0..8])?;
}

#[cfg(not(feature = "serde"))]
write!(f, "{}", crate::hexdisplay::HexDisplay::from(&self.0))?;

#[cfg(not(feature = "std"))]
fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
Ok(())
}
}
Expand Down

0 comments on commit 672b0e6

Please sign in to comment.