Skip to content

Commit

Permalink
add a new codec to avoid sdk imports in modules
Browse files Browse the repository at this point in the history
  • Loading branch information
tac0turtle committed Oct 21, 2024
1 parent 6e59ad0 commit beec467
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions core/codec/codec.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit beec467

Please sign in to comment.