Skip to content

Commit

Permalink
chore: remove deprecated functions SortJSON and MustSortJSON (#19306)
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitrisJim authored Jan 31, 2024
1 parent c1a6c42 commit 27d99d1
Showing 1 changed file with 0 additions and 31 deletions.
31 changes: 0 additions & 31 deletions types/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package types

import (
"encoding/binary"
"encoding/json"
"fmt"
"time"

Expand All @@ -11,36 +10,6 @@ import (
"github.com/cosmos/cosmos-sdk/types/kv"
)

// SortedJSON takes any JSON and returns it sorted by keys. Also, all white-spaces
// are removed.
// This method can be used to canonicalize JSON to be returned by GetSignBytes,
// e.g. for the ledger integration.
// If the passed JSON isn't valid it will return an error.
// Deprecated: SortJSON was used for GetSignbytes, this is now automatic with amino signing
func SortJSON(toSortJSON []byte) ([]byte, error) {
var c interface{}
err := json.Unmarshal(toSortJSON, &c)
if err != nil {
return nil, err
}
js, err := json.Marshal(c)
if err != nil {
return nil, err
}
return js, nil
}

// MustSortJSON is like SortJSON but panic if an error occurs, e.g., if
// the passed JSON isn't valid.
// Deprecated: SortJSON was used for GetSignbytes, this is now automatic with amino signing
func MustSortJSON(toSortJSON []byte) []byte {
js, err := SortJSON(toSortJSON)
if err != nil {
panic(err)
}
return js
}

// Uint64ToBigEndian - marshals uint64 to a bigendian byte slice so it can be sorted
func Uint64ToBigEndian(i uint64) []byte {
b := make([]byte, 8)
Expand Down

0 comments on commit 27d99d1

Please sign in to comment.