package types
import (
"github.com/cosmos/cosmos-sdk/codec"
)
// module codec
var ModuleCdc = codec.New()
// RegisterCodec registers all the necessary types and interfaces for
// governance.
func RegisterCodec(cdc *codec.Codec) {
cdc.RegisterInterface((*Content)(nil), nil)
cdc.RegisterConcrete(MsgSubmitProposal{}, "cosmos-sdk/MsgSubmitProposal", nil)
cdc.RegisterConcrete(MsgDeposit{}, "cosmos-sdk/MsgDeposit", nil)
cdc.RegisterConcrete(MsgVote{}, "cosmos-sdk/MsgVote", nil)
cdc.RegisterConcrete(TextProposal{}, "cosmos-sdk/TextProposal", nil)
}
// RegisterProposalTypeCodec registers an external proposal content type defined
// in another module for the internal ModuleCdc. This allows the MsgSubmitProposal
// to be correctly Amino encoded and decoded.
func RegisterProposalTypeCodec(o interface{}, name string) {
ModuleCdc.RegisterConcrete(o, name, nil)
// TODO determine a good place to seal this codec
func init() {
RegisterCodec(ModuleCdc)
type GovCodec interface {
codec.Marshaler
MarshalProposal(p Proposal) ([]byte, error)
UnmarshalProposal(bz []byte, ptr *Proposal) error
type AminoGovCodec struct {
amino *codec.Codec
func NewAminoGovCodec(amino *codec.Codec) AminoGovCodec {
return AminoGovCodec{Marshaler: codec.NewHybridCodec(amino), amino: amino}
func (a AminoGovCodec) MarshalProposal(p Proposal) ([]byte, error) {
return a.amino.MarshalBinaryBare(p)
func (a AminoGovCodec) UnmarshalProposal(bz []byte, ptr *Proposal) error {
return a.amino.UnmarshalBinaryBare(bz, ptr)
var _ GovCodec = AminoGovCodec{}