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.
Summary
QueryAllBalancesRequest.ResolveDenomresolves a stored base denom to themetadata display denom, but it keeps the original base-unit amount.
For metadata like:
an account balance of
100000000uatomcan be returned as100000000atominstead of100atom.Expected Behavior
When the display denom is present in
denom_units,AllBalancesshould usethat 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 queryshould keep the base denom and base amount.
Actual Behavior
AllBalancescurrently returns:This changes only the denom and leaves the base-unit amount unchanged.
Notes
Metadata validation already requires
displayto be a valid denom and toappear in
denom_units, so the display unit exponent is available for validmetadata.