2023-07-28 08:27:48 -07:00
|
|
|
package utils
|
2023-04-25 10:48:26 -07:00
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2023-07-28 08:27:48 -07:00
|
|
|
func StartsWith0x(input string) bool {
|
|
|
|
return strings.HasPrefix(input, "0x") || strings.HasPrefix(input, "0X")
|
|
|
|
}
|
|
|
|
|
2023-04-25 10:48:26 -07:00
|
|
|
func Remove0x(input string) string {
|
|
|
|
return strings.Replace(input, "0x", "", -1)
|
|
|
|
}
|
|
|
|
|
|
|
|
func DecodeUint64(input string) (uint64, error) {
|
|
|
|
input = Remove0x(input)
|
|
|
|
return strconv.ParseUint(input, 16, 64)
|
|
|
|
}
|
|
|
|
|
|
|
|
func EncodeHex(v uint64) string {
|
|
|
|
return "0x" + strconv.FormatUint(v, 16)
|
|
|
|
}
|