cosmos-sdk/x/staking/types/codec.go

41 lines
1.2 KiB
Go

package types
import (
"github.com/cosmos/cosmos-sdk/codec"
)
type Codec struct {
codec.Marshaler
// Keep reference to the amino codec to allow backwards compatibility along
// with type, and interface registration.
amino *codec.Codec
}
func NewCodec(amino *codec.Codec) *Codec {
return &Codec{Marshaler: codec.NewHybridCodec(amino), amino: amino}
}
// ----------------------------------------------------------------------------
// RegisterCodec registers all the necessary staking module concrete types and
// interfaces with the provided codec reference.
func RegisterCodec(cdc *codec.Codec) {
cdc.RegisterConcrete(MsgCreateValidator{}, "cosmos-sdk/MsgCreateValidator", nil)
cdc.RegisterConcrete(MsgEditValidator{}, "cosmos-sdk/MsgEditValidator", nil)
cdc.RegisterConcrete(MsgDelegate{}, "cosmos-sdk/MsgDelegate", nil)
cdc.RegisterConcrete(MsgUndelegate{}, "cosmos-sdk/MsgUndelegate", nil)
cdc.RegisterConcrete(MsgBeginRedelegate{}, "cosmos-sdk/MsgBeginRedelegate", nil)
}
// ModuleCdc defines a staking module global Amino codec.
var ModuleCdc *Codec
func init() {
ModuleCdc = NewCodec(codec.New())
RegisterCodec(ModuleCdc.amino)
codec.RegisterCrypto(ModuleCdc.amino)
ModuleCdc.amino.Seal()
}