Skip to content

Commit

Permalink
Update utils/keccak.go
Browse files Browse the repository at this point in the history
Co-authored-by: Rian Hughes <ryanhughes4500@hotmail.com>
  • Loading branch information
thiagodeev and rianhughes authored Dec 4, 2024
1 parent 36554fb commit 905ea9c
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions utils/keccak.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,16 @@ func StrToBig(str string) *big.Int {
// - str: The string to convert to a hexadecimal
// Returns:
// - hex: a string representing the converted value
func StrToHex(str string) (hex string) {
func StrToHex(str string) string {
if strings.HasPrefix(str, "0x") {
return str
}
bigNum, ok := new(big.Int).SetString(str, 0)
if ok {
hex = bigNum.Text(16)
hex = "0x" + hex
} else {
hex = fmt.Sprintf("0x%x", str)

if bigNum, ok := new(big.Int).SetString(str, 0); ok {
return "0x" + bigNum.Text(16)
}

return hex
return "0x" + fmt.Sprintf("%x", str)
}

// HexToShortStr converts a hexadecimal string to a short string (Starknet) representation.
Expand Down

0 comments on commit 905ea9c

Please sign in to comment.