types: remove unused CanonicalSignBytes (#6912)

Removes all vestiges of CanonicalSignBytes, which is unused
and untested.

Fixes #6679
This commit is contained in:
Emmanuel T Odeke 2020-08-02 08:13:41 -07:00 committed by GitHub
parent b3bbca343f
commit c7c66f8b36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 26 deletions

View File

@ -338,8 +338,6 @@ type TxBuilder interface {
SetFee(sdk.Fee)
GetMemo() string
SetMemo(string)
CanonicalSignBytes(cid string, num, seq uint64) ([]byte, error)
}
```

View File

@ -1,8 +1,6 @@
package types
import (
jsonc "github.com/gibson042/canonicaljson-go"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/codec"
@ -18,25 +16,3 @@ func RegisterCodec(cdc *codec.Codec) {
func RegisterInterfaces(registry types.InterfaceRegistry) {
registry.RegisterInterface("cosmos_sdk.v1.Msg", (*Msg)(nil))
}
// CanonicalSignBytes returns a canonical JSON encoding of a Proto message that
// can be signed over. The JSON encoding ensures all field names adhere to their
// Proto definition, default values are omitted, and follows the JSON Canonical
// Form.
func CanonicalSignBytes(msg codec.ProtoMarshaler) ([]byte, error) {
// first, encode via canonical Proto3 JSON
bz, err := codec.ProtoMarshalJSON(msg)
if err != nil {
return nil, err
}
genericJSON := make(map[string]interface{})
// decode canonical proto encoding into a generic map
if err := jsonc.Unmarshal(bz, &genericJSON); err != nil {
return nil, err
}
// finally, return the canonical JSON encoding via JSON Canonical Form
return jsonc.Marshal(genericJSON)
}