reintroduce old MsgSubmitProposal type

This commit is contained in:
Aleksandr Bezobchuk 2020-03-02 16:29:10 -05:00
parent fe7b02231e
commit 833368cc74
No known key found for this signature in database
GPG Key ID: 7DAC30FBD99879B0
6 changed files with 131 additions and 35 deletions

View File

@ -83,6 +83,7 @@ var (
SplitKeyDeposit = types.SplitKeyDeposit
SplitKeyVote = types.SplitKeyVote
NewMsgSubmitProposalBase = types.NewMsgSubmitProposalBase
NewMsgSubmitProposal = types.NewMsgSubmitProposal
NewMsgDeposit = types.NewMsgDeposit
NewMsgVote = types.NewMsgVote
ParamKeyTable = types.ParamKeyTable
@ -131,6 +132,7 @@ type (
Deposit = types.Deposit
Deposits = types.Deposits
GenesisState = types.GenesisState
MsgSubmitProposalI = types.MsgSubmitProposalI
MsgSubmitProposal = types.MsgSubmitProposal
MsgSubmitProposalBase = types.MsgSubmitProposalBase
MsgDeposit = types.MsgDeposit

View File

@ -17,7 +17,7 @@ func NewHandler(keeper Keeper) sdk.Handler {
case MsgDeposit:
return handleMsgDeposit(ctx, keeper, msg)
case MsgSubmitProposal:
case MsgSubmitProposalI:
return handleMsgSubmitProposal(ctx, keeper, msg)
case MsgVote:
@ -29,7 +29,7 @@ func NewHandler(keeper Keeper) sdk.Handler {
}
}
func handleMsgSubmitProposal(ctx sdk.Context, keeper Keeper, msg MsgSubmitProposal) (*sdk.Result, error) {
func handleMsgSubmitProposal(ctx sdk.Context, keeper Keeper, msg MsgSubmitProposalI) (*sdk.Result, error) {
proposal, err := keeper.SubmitProposal(ctx, msg.GetContent())
if err != nil {
return nil, err

View File

@ -19,7 +19,7 @@ import (
const custom = "custom"
func getQueriedParams(t *testing.T, ctx sdk.Context, cdc codec.Marshaler, querier sdk.Querier) (types.DepositParams, types.VotingParams, types.TallyParams) {
func getQueriedParams(t *testing.T, ctx sdk.Context, cdc codec.JSONMarshaler, querier sdk.Querier) (types.DepositParams, types.VotingParams, types.TallyParams) {
query := abci.RequestQuery{
Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryParams, types.ParamDeposit}, "/"),
Data: []byte{},
@ -60,7 +60,7 @@ func getQueriedParams(t *testing.T, ctx sdk.Context, cdc codec.Marshaler, querie
}
func getQueriedProposals(
t *testing.T, ctx sdk.Context, cdc codec.Marshaler, querier sdk.Querier,
t *testing.T, ctx sdk.Context, cdc codec.JSONMarshaler, querier sdk.Querier,
depositor, voter sdk.AccAddress, status types.ProposalStatus, page, limit int,
) []types.Proposal {
@ -79,7 +79,7 @@ func getQueriedProposals(
return proposals
}
func getQueriedDeposit(t *testing.T, ctx sdk.Context, cdc codec.Marshaler, querier sdk.Querier, proposalID uint64, depositor sdk.AccAddress) types.Deposit {
func getQueriedDeposit(t *testing.T, ctx sdk.Context, cdc codec.JSONMarshaler, querier sdk.Querier, proposalID uint64, depositor sdk.AccAddress) types.Deposit {
query := abci.RequestQuery{
Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryDeposit}, "/"),
Data: cdc.MustMarshalJSON(types.NewQueryDepositParams(proposalID, depositor)),
@ -95,7 +95,7 @@ func getQueriedDeposit(t *testing.T, ctx sdk.Context, cdc codec.Marshaler, queri
return deposit
}
func getQueriedDeposits(t *testing.T, ctx sdk.Context, cdc codec.Marshaler, querier sdk.Querier, proposalID uint64) []types.Deposit {
func getQueriedDeposits(t *testing.T, ctx sdk.Context, cdc codec.JSONMarshaler, querier sdk.Querier, proposalID uint64) []types.Deposit {
query := abci.RequestQuery{
Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryDeposits}, "/"),
Data: cdc.MustMarshalJSON(types.NewQueryProposalParams(proposalID)),
@ -111,7 +111,7 @@ func getQueriedDeposits(t *testing.T, ctx sdk.Context, cdc codec.Marshaler, quer
return deposits
}
func getQueriedVote(t *testing.T, ctx sdk.Context, cdc codec.Marshaler, querier sdk.Querier, proposalID uint64, voter sdk.AccAddress) types.Vote {
func getQueriedVote(t *testing.T, ctx sdk.Context, cdc codec.JSONMarshaler, querier sdk.Querier, proposalID uint64, voter sdk.AccAddress) types.Vote {
query := abci.RequestQuery{
Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryVote}, "/"),
Data: cdc.MustMarshalJSON(types.NewQueryVoteParams(proposalID, voter)),
@ -127,7 +127,7 @@ func getQueriedVote(t *testing.T, ctx sdk.Context, cdc codec.Marshaler, querier
return vote
}
func getQueriedVotes(t *testing.T, ctx sdk.Context, cdc codec.Marshaler, querier sdk.Querier,
func getQueriedVotes(t *testing.T, ctx sdk.Context, cdc codec.JSONMarshaler, querier sdk.Querier,
proposalID uint64, page, limit int) []types.Vote {
query := abci.RequestQuery{
Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryVote}, "/"),

View File

@ -16,10 +16,10 @@ const (
var _, _, _ sdk.Msg = MsgSubmitProposalBase{}, MsgDeposit{}, MsgVote{}
// MsgSubmitProposal defines the specific interface a concrete message must
// MsgSubmitProposalI defines the specific interface a concrete message must
// implement in order to process governance proposals. The concrete MsgSubmitProposal
// must be defined at the application-level.
type MsgSubmitProposal interface {
type MsgSubmitProposalI interface {
sdk.Msg
GetContent() Content
@ -155,3 +155,62 @@ func (msg MsgVote) GetSignBytes() []byte {
func (msg MsgVote) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{msg.Voter}
}
// ---------------------------------------------------------------------------
// Deprecated
//
// TODO: Remove once client-side Protobuf migration has been completed.
// ---------------------------------------------------------------------------
// MsgSubmitProposal defines a (deprecated) message to create/submit a governance
// proposal.
//
// TODO: Remove once client-side Protobuf migration has been completed.
type MsgSubmitProposal struct {
Content Content `json:"content" yaml:"content"`
InitialDeposit sdk.Coins `json:"initial_deposit" yaml:"initial_deposit"` // Initial deposit paid by sender. Must be strictly positive
Proposer sdk.AccAddress `json:"proposer" yaml:"proposer"` // Address of the proposer
}
// NewMsgSubmitProposal returns a (deprecated) MsgSubmitProposal message.
//
// TODO: Remove once client-side Protobuf migration has been completed.
func NewMsgSubmitProposal(content Content, initialDeposit sdk.Coins, proposer sdk.AccAddress) MsgSubmitProposal {
return MsgSubmitProposal{content, initialDeposit, proposer}
}
// ValidateBasic implements Msg
func (msg MsgSubmitProposal) ValidateBasic() error {
if msg.Content == nil {
return sdkerrors.Wrap(ErrInvalidProposalContent, "missing content")
}
if msg.Proposer.Empty() {
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.Proposer.String())
}
if !msg.InitialDeposit.IsValid() {
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, msg.InitialDeposit.String())
}
if msg.InitialDeposit.IsAnyNegative() {
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, msg.InitialDeposit.String())
}
if !IsValidProposalType(msg.Content.ProposalType()) {
return sdkerrors.Wrap(ErrInvalidProposalType, msg.Content.ProposalType())
}
return msg.Content.ValidateBasic()
}
// GetSignBytes implements Msg
func (msg MsgSubmitProposal) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(msg)
return sdk.MustSortJSON(bz)
}
// GetSigners implements Msg
func (msg MsgSubmitProposal) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{msg.Proposer}
}
// nolint
func (msg MsgSubmitProposal) Route() string { return RouterKey }
func (msg MsgSubmitProposal) Type() string { return TypeMsgSubmitProposal }

View File

@ -164,33 +164,66 @@ func init() {
func init() { proto.RegisterFile("x/upgrade/types/types.proto", fileDescriptor_2a308fd9dd71aff8) }
var fileDescriptor_2a308fd9dd71aff8 = []byte{
// 376 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x52, 0x31, 0x6f, 0xe2, 0x30,
0x18, 0x8d, 0x8f, 0x1c, 0x3a, 0xcc, 0x66, 0x9d, 0x8e, 0x88, 0x13, 0x4e, 0xc4, 0x70, 0x62, 0xb8,
0x73, 0x74, 0xdc, 0x70, 0xa7, 0x1b, 0xe9, 0x5e, 0xa1, 0xb4, 0x5d, 0x2a, 0x55, 0xc8, 0x24, 0x26,
0xb1, 0x48, 0x62, 0x2b, 0x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xc1, 0x2e, 0xcc, 0x88,
0xc3, 0x42, 0x48, 0xa1, 0x68, 0x8a, 0xbe, 0xc2, 0xcf, 0x9a, 0xeb, 0xf4, 0x18, 0xcb, 0x14, 0xc8,
0x83, 0xcd, 0x88, 0xa9, 0xb0, 0xe0, 0x52, 0x73, 0x91, 0x57, 0xf1, 0x1a, 0xc1, 0xeb, 0x23, 0xf4,
0x17, 0xda, 0x32, 0xa5, 0x79, 0xe5, 0xde, 0xec, 0x77, 0xc8, 0x3b, 0xf7, 0x48, 0xca, 0xd1, 0x07,
0x76, 0x19, 0x3e, 0xa8, 0x1a, 0xfe, 0xdb, 0x4f, 0x77, 0x2e, 0xe8, 0x5e, 0xc1, 0xce, 0x09, 0xcd,
0x43, 0x96, 0x7e, 0x70, 0x2e, 0x23, 0x3f, 0x38, 0x5d, 0x6d, 0xb1, 0xb5, 0xd9, 0x62, 0x6b, 0xb5,
0xc3, 0x60, 0xbd, 0xc3, 0xe0, 0x71, 0x87, 0xc1, 0x72, 0x8f, 0xad, 0xf5, 0x1e, 0x5b, 0x9b, 0x3d,
0xb6, 0x2e, 0x7f, 0xc6, 0x5c, 0x27, 0xb3, 0x31, 0x09, 0x45, 0xe6, 0x9b, 0xec, 0x87, 0xed, 0x97,
0x8a, 0xa6, 0xfe, 0x9b, 0x2f, 0x33, 0xae, 0x57, 0x2f, 0xf2, 0xe7, 0x39, 0x00, 0x00, 0xff, 0xff,
0x4f, 0x2c, 0xc2, 0xac, 0x4c, 0x02, 0x00, 0x00,
// 379 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0x41, 0x6f, 0xda, 0x30,
0x14, 0xc7, 0xe3, 0x91, 0xa1, 0x61, 0x6e, 0xd6, 0x34, 0x22, 0x26, 0x9c, 0x88, 0xc3, 0xc4, 0x61,
0x73, 0x34, 0x76, 0xd8, 0xb4, 0x23, 0xbb, 0x4f, 0x28, 0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d8, 0xa6, 0x4b, 0x19, 0xff, 0xb6, 0x1f, 0x6e, 0x5c, 0xd0, 0x5f, 0x03, 0xd8, 0xf9, 0x27,
0x66, 0xfa, 0x8a, 0x16, 0xec, 0xcc, 0x0c, 0x3a, 0x2e, 0x84, 0x14, 0x8a, 0xa6, 0xe8, 0x23, 0x7c,
0xaf, 0xb9, 0x4e, 0x4f, 0x70, 0x26, 0x41, 0x1e, 0x6c, 0x47, 0x4c, 0x85, 0x05, 0x97, 0x9a, 0x8b,
0xbc, 0x82, 0x6c, 0x05, 0xcf, 0x8f, 0xd0, 0x4f, 0x68, 0xcb, 0x94, 0xe6, 0x15, 0x43, 0x7b, 0xd8,
0x23, 0xaf, 0x6c, 0x93, 0x94, 0x0b, 0x18, 0xd9, 0xe5, 0x08, 0x41, 0x55, 0x50, 0x23, 0x5d, 0xc0,
0xde, 0x1f, 0x9a, 0x87, 0x2c, 0x7d, 0x63, 0x2e, 0x63, 0x3f, 0xfa, 0xbb, 0xd9, 0x63, 0x6b, 0xb7,
0xc7, 0xd6, 0xe6, 0x80, 0xc1, 0xf6, 0x80, 0xc1, 0xfd, 0x01, 0x83, 0xf5, 0x11, 0x5b, 0xdb, 0x23,
0xb6, 0x76, 0x47, 0x6c, 0x9d, 0x7f, 0x8d, 0xb9, 0x4e, 0x16, 0x53, 0x12, 0x8a, 0xcc, 0x37, 0xec,
0xf5, 0xef, 0x9b, 0x8a, 0xe6, 0xfe, 0x8b, 0x87, 0x33, 0x6d, 0x56, 0xf7, 0xf2, 0xe3, 0x31, 0x00,
0x00, 0xff, 0xff, 0x45, 0x05, 0x01, 0x90, 0x52, 0x02, 0x00, 0x00,
}
func (this *Plan) Equal(that interface{}) bool {
if that == nil {
return this == nil
}
that1, ok := that.(*Plan)
if !ok {
that2, ok := that.(Plan)
if ok {
that1 = &that2
} else {
return false
}
}
if that1 == nil {
return this == nil
} else if this == nil {
return false
}
if this.Name != that1.Name {
return false
}
if !this.Time.Equal(that1.Time) {
return false
}
if this.Height != that1.Height {
return false
}
if this.Info != that1.Info {
return false
}
return true
}
func (this *SoftwareUpgradeProposal) Equal(that interface{}) bool {
if that == nil {
return this == nil

View File

@ -10,6 +10,8 @@ option (gogoproto.goproto_getters_all) = false;
// Plan specifies information about a planned upgrade and when it should occur
message Plan {
option (gogoproto.equal) = true;
// Sets the name for the upgrade. This name will be used by the upgraded version of the software to apply any
// special "on-upgrade" commands during the first BeginBlock method after the upgrade is applied. It is also used
// to detect whether a software version can handle a given upgrade. If no upgrade handler with this name has been