Skip to content

feat(protocol): implement proper Display for fungible and non-fungible assets#2726

Closed
giwaov wants to merge 1 commit into0xMiden:nextfrom
giwaov:feat/asset-display
Closed

feat(protocol): implement proper Display for fungible and non-fungible assets#2726
giwaov wants to merge 1 commit into0xMiden:nextfrom
giwaov:feat/asset-display

Conversation

@giwaov
Copy link
Copy Markdown
Contributor

@giwaov giwaov commented Apr 4, 2026

Summary

Replace the Display implementations for FungibleAsset, NonFungibleAsset, and Asset that previously delegated to Debug with stable, user-readable representations.

Rationale

The Debug representation is not stable across versions and should not be used for user-facing output (error messages, logs, etc.). The TODO comments in both files noted this needed fixing.

As suggested by @bobbinth in the original discussion, the Display output now shows the issuer (faucet ID) and amount/value in a readable format:

  • FungibleAsset: FungibleAsset { issuer: 0x..., amount: 1000 }
  • NonFungibleAsset: NonFungibleAsset { issuer: 0x..., value: [f0, f1, f2, f3] }
  • Asset enum: delegates to the inner type

Changes

crates/miden-protocol/src/asset/fungible.rs:

  • Display shows issuer (faucet ID in hex) and amount

crates/miden-protocol/src/asset/nonfungible.rs:

  • Display shows issuer (faucet ID in hex) and value (word representation)

crates/miden-protocol/src/asset/mod.rs:

  • Added Display impl for the Asset enum, delegating to inner type

Test plan

  • cargo check -p miden-protocol passes
  • cargo clippy -p miden-protocol -- -D warnings passes
  • The output format uses the existing Display impls of AccountId (hex) and Word

Closes #2526

…e assets

Replace the Display implementations that delegated to Debug with
user-readable representations showing issuer and amount/value:

- FungibleAsset: shows faucet ID (hex) and amount
- NonFungibleAsset: shows faucet ID (hex) and value word
- Asset enum: delegates to the inner type's Display

Debug should not be used for user-facing output as it is not a stable
representation and could change with non-breaking changes.

Closes 0xMiden#2526
@bobbinth
Copy link
Copy Markdown
Contributor

bobbinth commented Apr 5, 2026

Thank you - but this issue is tackled best after we complete the asset refactoring. So, I'm closing this PR for now.

@bobbinth bobbinth closed this Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement proper Display for fungible and non-fungible assets

2 participants