2019-04-30 09:31:38 -07:00
|
|
|
package types
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
2020-05-05 07:28:20 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/codec/types"
|
2020-06-04 03:38:24 -07:00
|
|
|
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
|
2020-05-19 13:17:29 -07:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2019-04-30 09:31:38 -07:00
|
|
|
)
|
|
|
|
|
2020-09-07 07:47:12 -07:00
|
|
|
// RegisterLegacyAminoCodec registers all the necessary types and interfaces for the
|
2020-03-02 08:54:43 -08:00
|
|
|
// governance module.
|
2020-09-07 07:47:12 -07:00
|
|
|
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
|
2019-04-30 09:31:38 -07:00
|
|
|
cdc.RegisterInterface((*Content)(nil), nil)
|
2020-04-14 12:05:14 -07:00
|
|
|
cdc.RegisterConcrete(&MsgSubmitProposal{}, "cosmos-sdk/MsgSubmitProposal", nil)
|
2020-06-03 12:52:05 -07:00
|
|
|
cdc.RegisterConcrete(&MsgDeposit{}, "cosmos-sdk/MsgDeposit", nil)
|
|
|
|
cdc.RegisterConcrete(&MsgVote{}, "cosmos-sdk/MsgVote", nil)
|
2020-04-14 12:05:14 -07:00
|
|
|
cdc.RegisterConcrete(&TextProposal{}, "cosmos-sdk/TextProposal", nil)
|
2019-04-30 09:31:38 -07:00
|
|
|
}
|
|
|
|
|
2020-05-19 13:17:29 -07:00
|
|
|
func RegisterInterfaces(registry types.InterfaceRegistry) {
|
|
|
|
registry.RegisterImplementations((*sdk.Msg)(nil),
|
|
|
|
&MsgSubmitProposal{},
|
|
|
|
&MsgVote{},
|
|
|
|
&MsgDeposit{},
|
|
|
|
)
|
|
|
|
registry.RegisterInterface(
|
2020-08-11 04:49:45 -07:00
|
|
|
"cosmos.gov.v1beta1.Content",
|
2020-05-19 13:17:29 -07:00
|
|
|
(*Content)(nil),
|
|
|
|
&TextProposal{},
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2019-04-30 09:31:38 -07:00
|
|
|
// RegisterProposalTypeCodec registers an external proposal content type defined
|
2019-05-16 08:25:32 -07:00
|
|
|
// in another module for the internal ModuleCdc. This allows the MsgSubmitProposal
|
2019-04-30 09:31:38 -07:00
|
|
|
// to be correctly Amino encoded and decoded.
|
2020-03-02 08:54:43 -08:00
|
|
|
//
|
|
|
|
// NOTE: This should only be used for applications that are still using a concrete
|
|
|
|
// Amino codec for serialization.
|
2019-04-30 09:31:38 -07:00
|
|
|
func RegisterProposalTypeCodec(o interface{}, name string) {
|
2020-03-02 08:54:43 -08:00
|
|
|
amino.RegisterConcrete(o, name, nil)
|
2020-01-28 13:30:28 -08:00
|
|
|
}
|
|
|
|
|
2020-03-02 08:54:43 -08:00
|
|
|
var (
|
2020-09-07 07:47:12 -07:00
|
|
|
amino = codec.NewLegacyAmino()
|
2020-01-28 13:30:28 -08:00
|
|
|
|
2020-03-02 08:54:43 -08:00
|
|
|
// ModuleCdc references the global x/gov module codec. Note, the codec should
|
|
|
|
// ONLY be used in certain instances of tests and for JSON encoding as Amino is
|
|
|
|
// still used for that purpose.
|
|
|
|
//
|
|
|
|
// The actual codec used for serialization should be provided to x/gov and
|
|
|
|
// defined at the application level.
|
2020-08-13 06:20:02 -07:00
|
|
|
ModuleCdc = codec.NewAminoCodec(amino)
|
2020-03-02 08:54:43 -08:00
|
|
|
)
|
2020-01-28 13:30:28 -08:00
|
|
|
|
2020-03-02 08:54:43 -08:00
|
|
|
func init() {
|
2020-09-07 07:47:12 -07:00
|
|
|
RegisterLegacyAminoCodec(amino)
|
2020-06-04 03:38:24 -07:00
|
|
|
cryptocodec.RegisterCrypto(amino)
|
2020-01-28 13:30:28 -08:00
|
|
|
}
|