Skip to content

Commit

Permalink
bump
Browse files Browse the repository at this point in the history
  • Loading branch information
codchen committed Apr 25, 2023
1 parent 8b29f3e commit d066ae8
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions x/wasm/types/bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ func (bz *HexBytes) Unmarshal(data []byte) error {

// MarshalText encodes a HexBytes value as hexadecimal digits.
// This method is used by json.Marshal.
func (bz HexBytes) MarshalText() ([]byte, error) {
func (bz HexBytes) MarshalJSON() ([]byte, error) {
enc := hex.EncodeToString([]byte(bz))
return []byte(strings.ToUpper(enc)), nil
}

// UnmarshalText handles decoding of HexBytes from JSON strings.
// This method is used by json.Unmarshal.
// It allows decoding of both hex and base64-encoded byte arrays.
func (bz *HexBytes) UnmarshalText(data []byte) error {
func (bz *HexBytes) UnmarshalJSON(data []byte) error {
input := string(data)
if input == "" || input == "null" {
return nil
Expand Down Expand Up @@ -67,11 +67,3 @@ func (bz HexBytes) Format(s fmt.State, verb rune) {
s.Write([]byte(fmt.Sprintf("%X", []byte(bz))))
}
}

func (bz HexBytes) MarshalJSON() ([]byte, error) {
return bz.MarshalText()
}

func (bz *HexBytes) UnmarshalJSON(data []byte) error {
return bz.UnmarshalText(data)
}

0 comments on commit d066ae8

Please sign in to comment.