Skip to content

x/bank ResolveDenom returns display denom with base amount #26484

@chalabi2

Description

@chalabi2

Summary

QueryAllBalancesRequest.ResolveDenom resolves a stored base denom to the
metadata display denom, but it keeps the original base-unit amount.

For metadata like:

base: uatom
display: atom
denom_units:
  - denom: uatom
    exponent: 0
  - denom: atom
    exponent: 6

an account balance of 100000000uatom can be returned as
100000000atom instead of 100atom.

Expected Behavior

When the display denom is present in denom_units, AllBalances should use
that unit's exponent to scale the amount if the result can be represented as
an integer sdk.Coin.

If the scaled display amount would require a fractional sdk.Coin, the query
should keep the base denom and base amount.

Actual Behavior

AllBalances currently returns:

sdk.NewCoin(metadata.Display, value)

This changes only the denom and leaves the base-unit amount unchanged.

Notes

Metadata validation already requires display to be a valid denom and to
appear in denom_units, so the display unit exponent is available for valid
metadata.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions