Skip to content

Commit

Permalink
Merge pull request #349 from multiversx/merge_rc_andromeda_into_feat_…
Browse files Browse the repository at this point in the history
…header_proof_2025.01.28

Merge rc andromeda into feat header proof 2025.01.28
  • Loading branch information
sstanculeanu authored Jan 28, 2025
2 parents 120b0b6 + 7dc847e commit 6481261
Show file tree
Hide file tree
Showing 15 changed files with 893 additions and 221 deletions.
1 change: 1 addition & 0 deletions data/api/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ type AccountQueryOptions struct {
type BlockQueryOptions struct {
WithTransactions bool
WithLogs bool
ForHyperblock bool
}
20 changes: 19 additions & 1 deletion data/esdt/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func IsValidPrefixedToken(token string) (string, bool) {
}

tokenRandSeq := tokenSplit[2]
if !(len(tokenRandSeq) >= esdtTickerNumRandChars) {
if !IsRandomSeqValid(tokenRandSeq) {
return "", false
}

Expand Down Expand Up @@ -83,3 +83,21 @@ func IsTickerValid(ticker string) bool {
func IsTokenTickerLenCorrect(tokenTickerLen int) bool {
return !(tokenTickerLen < minLengthForTickerName || tokenTickerLen > maxLengthForTickerName)
}

// IsRandomSeqValid checks if the token random sequence is valid
func IsRandomSeqValid(randomSeq string) bool {
if len(randomSeq) != esdtTickerNumRandChars {
return false
}

for _, ch := range randomSeq {
isSmallCharacter := ch >= 'a' && ch <= 'f'
isNumber := ch >= '0' && ch <= '9'
isReadable := isSmallCharacter || isNumber
if !isReadable {
return false
}
}

return true
}
10 changes: 5 additions & 5 deletions data/esdt/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ import (
)

func TestIsValidPrefixedToken(t *testing.T) {
prefix, valid := IsValidPrefixedToken("sov1-TKN-coffee")
prefix, valid := IsValidPrefixedToken("sov1-TKN-c0ffee")
require.True(t, valid)
require.Equal(t, "sov1", prefix)

prefix, valid = IsValidPrefixedToken("sOv1-TKN-coffee")
prefix, valid = IsValidPrefixedToken("sOv1-TKN-c0ffee")
require.False(t, valid)
require.Equal(t, "", prefix)

prefix, valid = IsValidPrefixedToken("sov1-TkN-coffee")
prefix, valid = IsValidPrefixedToken("sov1-TkN-c0ffee")
require.False(t, valid)
require.Equal(t, "", prefix)

prefix, valid = IsValidPrefixedToken("sov1-TKN-coffe")
prefix, valid = IsValidPrefixedToken("sov1-TKN-c0ffe")
require.False(t, valid)
require.Equal(t, "", prefix)

prefix, valid = IsValidPrefixedToken("sov1-TKN")
require.False(t, valid)
require.Equal(t, "", prefix)

prefix, valid = IsValidPrefixedToken("TKN-coffee")
prefix, valid = IsValidPrefixedToken("TKN-c0ffee")
require.False(t, valid)
require.Equal(t, "", prefix)
}
Expand Down
Loading

0 comments on commit 6481261

Please sign in to comment.