2022-11-22 12:12:55 +00:00
|
|
|
package beacon_api
|
|
|
|
|
|
|
|
import (
|
2022-12-06 12:27:26 +00:00
|
|
|
"fmt"
|
|
|
|
neturl "net/url"
|
2022-11-22 12:12:55 +00:00
|
|
|
"regexp"
|
2022-12-12 10:39:51 +00:00
|
|
|
"strconv"
|
|
|
|
|
|
|
|
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
2022-11-22 12:12:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func validRoot(root string) bool {
|
|
|
|
matchesRegex, err := regexp.MatchString("^0x[a-fA-F0-9]{64}$", root)
|
|
|
|
if err != nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return matchesRegex
|
|
|
|
}
|
2022-12-06 12:27:26 +00:00
|
|
|
|
2022-12-12 10:39:51 +00:00
|
|
|
func uint64ToString[T uint64 | types.Slot | types.ValidatorIndex | types.CommitteeIndex | types.Epoch](val T) string {
|
|
|
|
return strconv.FormatUint(uint64(val), 10)
|
|
|
|
}
|
|
|
|
|
2022-12-06 12:27:26 +00:00
|
|
|
func buildURL(path string, queryParams ...neturl.Values) string {
|
|
|
|
if len(queryParams) == 0 {
|
|
|
|
return path
|
|
|
|
}
|
|
|
|
|
|
|
|
return fmt.Sprintf("%s?%s", path, queryParams[0].Encode())
|
|
|
|
}
|