diff --git a/core/codec/codec.go b/core/codec/codec.go new file mode 100644 index 000000000000..cc8fbf5959eb --- /dev/null +++ b/core/codec/codec.go @@ -0,0 +1,22 @@ +package codec + +import "cosmossdk.io/core/transaction" + +// Codec defines a Binary Codec and JSON Codec for modules to encode and decode data +type Codec interface { + BinaryCodec + JSONCodec +} + +// BinaryCodec defines a binary encoding and decoding interface for modules to encode and decode data +// The Binary Codec uses protobuf +type BinaryCodec interface { + Marshal(transaction.Msg) ([]byte, error) + Unmarshal([]byte, transaction.Msg) error +} + +// JSONCodec defines a JSON encoding and decoding interface for modules to encode and decode data +type JSONCodec interface { + MarshalJSON(transaction.Msg) ([]byte, error) + UnmarshalJSON([]byte, transaction.Msg) error +}