feat(protocol): implement proper Display for fungible and non-fungible assets#2726
Closed
giwaov wants to merge 1 commit into0xMiden:nextfrom
Closed
feat(protocol): implement proper Display for fungible and non-fungible assets#2726giwaov wants to merge 1 commit into0xMiden:nextfrom
giwaov wants to merge 1 commit into0xMiden:nextfrom
Conversation
…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
Contributor
|
Thank you - but this issue is tackled best after we complete the asset refactoring. So, I'm closing this PR for now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the
Displayimplementations forFungibleAsset,NonFungibleAsset, andAssetthat previously delegated toDebugwith stable, user-readable representations.Rationale
The
Debugrepresentation 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] }Assetenum: delegates to the inner typeChanges
crates/miden-protocol/src/asset/fungible.rs:issuer(faucet ID in hex) andamountcrates/miden-protocol/src/asset/nonfungible.rs:issuer(faucet ID in hex) andvalue(word representation)crates/miden-protocol/src/asset/mod.rs:Displayimpl for theAssetenum, delegating to inner typeTest plan
cargo check -p miden-protocolpassescargo clippy -p miden-protocol -- -D warningspassesDisplayimpls ofAccountId(hex) andWordCloses #2526