Skip to content

Commit

Permalink
fix(asset): 🔊 Metadata: Debug includes all fields (#4207)
Browse files Browse the repository at this point in the history
fixes #4190.

> The `Debug` impl for `asset::Metadata` throws away all data except for
the base denom. This is extremely inconvenient for debugging.

this commit updates `Metadata`'s impl of `std::fmt::Debug` so that it
includes all of the fields in the `Inner` structure.

**note for review:** #4190 didn't explicitly mention which fields to
include, so i have included all of them as a starting point. if we
should find a middle ground, i am open and interested in hearing about
that!

#### issue ticket number and link

#4190

#### checklist before requesting a review

- [x] If this code contains consensus-breaking changes, I have added the
"consensus-breaking" label. Otherwise, I declare my belief that there
are not consensus-breaking changes, for the following reason:

  > debug representations should not affect consensus.
  • Loading branch information
cratelyn authored Apr 15, 2024
1 parent 60ecaf1 commit 2d9c784
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion crates/core/asset/src/asset/denom_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,28 @@ impl Ord for Metadata {

impl Debug for Metadata {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.inner.base_denom.as_str())
let Self { inner } = self;
let Inner {
id,
base_denom,
description,
images,
units,
display_index,
name,
symbol,
} = inner.as_ref();

f.debug_struct("Metadata")
.field("id", id)
.field("base_denom", base_denom)
.field("description", description)
.field("images", images)
.field("units", units)
.field("display_index", display_index)
.field("name", name)
.field("symbol", symbol)
.finish()
}
}

Expand Down

0 comments on commit 2d9c784

Please sign in to comment.