- for binary encoding we almost always want protobuf
- for json we almost always want amino for querier backwards compatibility (protobuf json will happen elsewhere)
- in some cases we want to allow amino as a fallback for interfaces
type Marshaler interface {
// proto used for binary
MarshalBinaryBare(o ProtoMarshaler) ([]byte, error)
UnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler{}) error
...
// amino json
MarshalJSON(o interface{}) ([]byte, error) // nolint: stdmethods
MustMarshalJSON(o interface{}) []byte
UnmarshalJSON(bz []byte, ptr interface{}) error // nolint: stdmethods
MustUnmarshalJSON(bz []byte, ptr interface{})
}
// ProtoMarshaler defines an interface a type must implement as protocol buffer
// defined message.
type ProtoMarshaler interface {
proto.Message // for JSON serialization
Marshal() ([]byte, error)
MarshalTo(data []byte) (n int, err error)
MarshalToSizedBuffer(dAtA []byte) (int, error)
Size() int
Unmarshal(data []byte) error
}
What was there before to allow amino or pb for Account
type AuthCodec interface {
codec.Marshaler
MarshalAccount(acc exported.AccountI) ([]byte, error)
UnmarshalAccount(bz []byte) (exported.AccountI, error)
MarshalAccountJSON(acc exported.AccountI) ([]byte, error)
UnmarshalAccountJSON(bz []byte) (exported.AccountI, error)
}