From 6a944a53cf6ac4ad6ea122059e9cee0b508e37af Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Mon, 16 Jun 2025 17:05:40 +0530 Subject: [PATCH 1/2] Allow $Z denom --- client/v2/internal/coins/format.go | 1 + types/coin.go | 8 ++++---- types/dec_coin.go | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/client/v2/internal/coins/format.go b/client/v2/internal/coins/format.go index b3ca0866a8..1525602f11 100644 --- a/client/v2/internal/coins/format.go +++ b/client/v2/internal/coins/format.go @@ -11,6 +11,7 @@ import ( // Amount can be a whole number or a decimal number. Denominations can be 3 ~ 128 // characters long and support letters, followed by either a letter, a number or // a separator ('/', ':', '.', '_' or '-'). +// TODO: Update? var coinRegex = regexp.MustCompile(`^(\d+(\.\d+)?)([a-zA-Z][a-zA-Z0-9\/\:\._\-]{2,127})$`) // ParseCoin parses a coin from a string. The string must be in the format diff --git a/types/coin.go b/types/coin.go index 8c66866900..9d628b2d7c 100644 --- a/types/coin.go +++ b/types/coin.go @@ -877,20 +877,20 @@ func ValidateDenom(denom string) error { // isValidRune checks if a given rune is a valid character for a rune. // It returns true if the rune is a letter, digit, '/', ':', '.', '_', or '-'. func isValidRune(r rune) bool { - return unicode.IsLetter(r) || unicode.IsDigit(r) || r == '/' || r == ':' || r == '.' || r == '_' || r == '-' + return unicode.IsLetter(r) || unicode.IsDigit(r) || r == '/' || r == ':' || r == '.' || r == '_' || r == '-' || r == '$' } // MatchDenom checks if the given string is a valid denomination. -// A valid denomination must have a length between 3 and 128 characters, +// A valid denomination must have a length between 2 and 128 characters, // start with a letter, and only contain valid runes. func MatchDenom(s string) bool { length := len(s) - if length < 3 || length > 128 { + if length < 2 || length > 128 { return false } firstRune := rune(s[0]) - if !unicode.IsLetter(firstRune) { + if !unicode.IsLetter(firstRune) && firstRune != '$' { return false } diff --git a/types/dec_coin.go b/types/dec_coin.go index 9a2a499424..82f317ed0b 100644 --- a/types/dec_coin.go +++ b/types/dec_coin.go @@ -676,7 +676,7 @@ func ParseDecAmount(coinStr string) (string, string, error) { amountRune = append(amountRune, r) } else if unicode.IsSpace(r) { // if space is seen, indicates that we have finished parsing amount parsingAmount = false - } else if unicode.IsLetter(r) { // if letter is seen, indicates that it is the start of denom + } else if unicode.IsLetter(r) || r == '$' { // if letter is seen, indicates that it is the start of denom parsingAmount = false seenLetter = true denomRune = append(denomRune, r) @@ -693,7 +693,7 @@ func ParseDecAmount(coinStr string) (string, string, error) { } } else { // Parsing the denomination - if unicode.IsLetter(r) || unicode.IsDigit(r) || r == '/' || r == ':' || r == '.' || r == '_' || r == '-' { + if unicode.IsLetter(r) || unicode.IsDigit(r) || r == '/' || r == ':' || r == '.' || r == '_' || r == '-' || r == '$' { denomRune = append(denomRune, r) } else { // Invalid character encountered in denomination part -- 2.45.2 From 2b7e027dc7313ea1769ccf23b3d5d63904d94a69 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Mon, 23 Jun 2025 11:24:33 +0530 Subject: [PATCH 2/2] Remove unnecessary todo --- client/v2/internal/coins/format.go | 1 - types/coin.go | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/client/v2/internal/coins/format.go b/client/v2/internal/coins/format.go index 1525602f11..b3ca0866a8 100644 --- a/client/v2/internal/coins/format.go +++ b/client/v2/internal/coins/format.go @@ -11,7 +11,6 @@ import ( // Amount can be a whole number or a decimal number. Denominations can be 3 ~ 128 // characters long and support letters, followed by either a letter, a number or // a separator ('/', ':', '.', '_' or '-'). -// TODO: Update? var coinRegex = regexp.MustCompile(`^(\d+(\.\d+)?)([a-zA-Z][a-zA-Z0-9\/\:\._\-]{2,127})$`) // ParseCoin parses a coin from a string. The string must be in the format diff --git a/types/coin.go b/types/coin.go index 9d628b2d7c..93d42b4bb0 100644 --- a/types/coin.go +++ b/types/coin.go @@ -875,7 +875,7 @@ func ValidateDenom(denom string) error { } // isValidRune checks if a given rune is a valid character for a rune. -// It returns true if the rune is a letter, digit, '/', ':', '.', '_', or '-'. +// It returns true if the rune is a letter, digit, '/', ':', '.', '_', '-', or '$'. func isValidRune(r rune) bool { return unicode.IsLetter(r) || unicode.IsDigit(r) || r == '/' || r == ':' || r == '.' || r == '_' || r == '-' || r == '$' } -- 2.45.2