Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
pkieltyka committed Dec 19, 2024
1 parent 6f770f5 commit 805b45d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ethcoder/typed_data_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,16 @@ func (t *TypedData) jsonEncodeMessageValues(typeName string, message map[string]

func (t *TypedData) jsonEncodeValue(fieldType string, value interface{}) (interface{}, error) {
// Handle bytes/bytes32
if fieldType == "bytes" || fieldType == "bytes32" {
if strings.HasPrefix(fieldType, "bytes") {
switch v := value.(type) {
case []byte:
return "0x" + common.Bytes2Hex(v), nil
case [8]byte:
return "0x" + common.Bytes2Hex(v[:]), nil
case [16]byte:
return "0x" + common.Bytes2Hex(v[:]), nil
case [24]byte:
return "0x" + common.Bytes2Hex(v[:]), nil
case [32]byte:
return "0x" + common.Bytes2Hex(v[:]), nil
}
Expand Down

0 comments on commit 805b45d

Please sign in to comment.