Skip to content

Commit

Permalink
fix: using evmos validation for rollappID (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsitrin authored Jul 10, 2023
1 parent a6eca00 commit 97502af
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
27 changes: 27 additions & 0 deletions config/chainid.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package config

import (
"fmt"
"regexp"
)

var (
regexChainID = `[a-z]{1,}`
regexEIP155Separator = `_{1}`
regexEIP155 = `[1-9][0-9]*`
regexEpochSeparator = `-{1}`
regexEpoch = `[1-9][0-9]*`
rollappID = regexp.MustCompile(fmt.Sprintf(`^(%s)%s(%s)%s(%s)$`,
regexChainID,
regexEIP155Separator,
regexEIP155,
regexEpochSeparator,
regexEpoch))
)

func ValidateRollAppID(id string) error {
if !rollappID.MatchString(id) {
return fmt.Errorf("invalid RollApp ID '%s'", id)
}
return nil
}
10 changes: 0 additions & 10 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package config
import (
"fmt"
"math/big"
"regexp"
"strings"
"unicode"
)
Expand Down Expand Up @@ -71,15 +70,6 @@ func IsValidDAType(t string) bool {
return false
}

func ValidateRollAppID(id string) error {
pattern := `^[a-z]+_[0-9]{1,5}-[0-9]{1,5}$`
r := regexp.MustCompile(pattern)
if !r.MatchString(id) {
return fmt.Errorf("invalid RollApp ID '%s'", id)
}
return nil
}

func VerifyHubID(data HubData) error {
if data.RPC_URL == "" {
return fmt.Errorf("invalid hub ID: %s. RPC URL cannot be empty", data.ID)
Expand Down

0 comments on commit 97502af

Please sign in to comment.