Skip to content

Commit

Permalink
Merge pull request #251 from binance-chain/symbol_length
Browse files Browse the repository at this point in the history
change minimum length to 2
  • Loading branch information
fletcher142 authored Jan 11, 2021
2 parents 32ba1b5 + 0fbea09 commit 27d3e31
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions types/coin.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,11 @@ func (coins Coins) Sort() Coins {
// Parsing

var (
// Denominations can be 3 ~ 10 characters long (8 + .B suffix).
// Denominations can be 2 ~ 10 characters long (8 + .B suffix).
// Extra token symbol tx hash suffix can be 2 ~ 6 characters long.
reAmt = `[[:digit:]]+`
reSpc = `\:`
reDnm = `[[:alnum:]]{3,8}(\.[[:alpha:]])?(-[0-9A-Z]{2,6})?`
reDnm = `[[:alnum:]]{2,8}(\.[[:alpha:]])?(-[0-9A-Z]{2,6})?`
reCoin = regexp.MustCompile(fmt.Sprintf(`^(%s)%s(%s)$`, reAmt, reSpc, reDnm))
)

Expand Down
1 change: 1 addition & 0 deletions types/coin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ func TestParse(t *testing.T) {
{"98:bar , 1:foo ", true, Coins{{"bar", 98}, {"foo", one}}},
{" 55:bling\n", true, Coins{{"bling", 55}}},
{"2:foo, 97:bar", true, Coins{{"bar", 97}, {"foo", 2}}},
{"10:ba-1BC", true, Coins{{"ba-1BC", 10}}},
{"5:mycoin,", false, nil}, // no empty coins in a list
{"2:3foo, 97:bar", true, Coins{{"3foo", 2}, {"bar", 97}}}, // 3foo is invalid coin name
{"11me:coin, 12you:coin", false, nil}, // no spaces in coin names
Expand Down

0 comments on commit 27d3e31

Please sign in to comment.