fix(textual): error if a formatted coin contains a comma (#19265)
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
This commit is contained in:
parent
bb239a4571
commit
7d66bb3a50
@ -31,6 +31,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* [#19265](https://github.com/cosmos/cosmos-sdk/pull/19265) Reject denoms that contain a comma.
|
||||
|
||||
### Improvements
|
||||
|
||||
* [#18857](https://github.com/cosmos/cosmos-sdk/pull/18857) Moved `FormatCoins` from `core/coins` to this package under `signing/textual`.
|
||||
|
||||
@ -284,6 +284,12 @@ func FormatCoins(coins []*basev1beta1.Coin, metadata []*bankv1beta1.Metadata) (s
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// If a coin contains a comma, return an error given that the output
|
||||
// could be misinterpreted by the user as 2 different coins.
|
||||
if strings.Contains(formatted[i], ",") {
|
||||
return "", fmt.Errorf("coin %s contains a comma", formatted[i])
|
||||
}
|
||||
}
|
||||
|
||||
if len(coins) == 0 {
|
||||
|
||||
@ -327,5 +327,10 @@
|
||||
{"text":"", "error": true},
|
||||
{"text":"1COSM", "error": true},
|
||||
{"text":"1 COSM", "error": true},
|
||||
{"text":" 1 COSM", "error": true}
|
||||
{"text":" 1 COSM", "error": true},
|
||||
{
|
||||
"proto": {"amount": "10000000", "denom": "point, 222222 point"},
|
||||
"metadata": {"display": "POINT", "base": "point", "denom_units": [{"denom": "point", "exponent": 0}, {"denom": "POINT", "exponent": 0}]},
|
||||
"error": true
|
||||
}
|
||||
]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user