Merge PR #5737: x/gov - Proto Migration
This commit is contained in:
commit
b9ab834732
|
@ -136,6 +136,13 @@ serialization instead of Amino.
|
|||
Buffers for state serialization instead of Amino.
|
||||
* The `internal` sub-package has been removed in order to expose the types proto file.
|
||||
* The `x/upgrade` module now accepts a `codec.Marshaler` interface.
|
||||
* (x/gov) [\#5737](https://github.com/cosmos/cosmos-sdk/pull/5737) Migrate the `x/gov` module to use Protocol
|
||||
Buffers for state serialization instead of Amino.
|
||||
* `MsgSubmitProposal` will be removed in favor of the application-level proto-defined `MsgSubmitProposal` which
|
||||
implements the `MsgSubmitProposalI` interface. Applications should extend the `NewMsgSubmitProposalBase` type
|
||||
to define their own concrete `MsgSubmitProposal` types.
|
||||
* The module now accepts a `Codec` interface which extends the `codec.Marshaler` interface by
|
||||
requiring a concrete codec to know how to serialize `Proposal` types.
|
||||
|
||||
### Improvements
|
||||
|
||||
|
|
|
@ -207,7 +207,7 @@ func NewSimApp(
|
|||
AddRoute(distr.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
|
||||
AddRoute(upgrade.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper))
|
||||
app.GovKeeper = gov.NewKeeper(
|
||||
app.cdc, keys[gov.StoreKey], app.subspaces[gov.ModuleName], app.SupplyKeeper,
|
||||
appCodec, keys[gov.StoreKey], app.subspaces[gov.ModuleName], app.SupplyKeeper,
|
||||
&stakingKeeper, govRouter,
|
||||
)
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence"
|
||||
eviexported "github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||
"github.com/cosmos/cosmos-sdk/x/supply"
|
||||
supplyexported "github.com/cosmos/cosmos-sdk/x/supply/exported"
|
||||
)
|
||||
|
@ -17,6 +18,7 @@ var (
|
|||
_ auth.Codec = (*Codec)(nil)
|
||||
_ supply.Codec = (*Codec)(nil)
|
||||
_ evidence.Codec = (*Codec)(nil)
|
||||
_ gov.Codec = (*Codec)(nil)
|
||||
)
|
||||
|
||||
// Codec defines the application-level codec. This codec contains all the
|
||||
|
@ -151,6 +153,33 @@ func (c *Codec) UnmarshalEvidenceJSON(bz []byte) (eviexported.Evidence, error) {
|
|||
return evidence.GetEvidence(), nil
|
||||
}
|
||||
|
||||
// MarshalProposal marshals a Proposal. It accepts a Proposal defined by the x/gov
|
||||
// module and uses the application-level Proposal type which has the concrete
|
||||
// Content implementation to serialize.
|
||||
func (c *Codec) MarshalProposal(p gov.Proposal) ([]byte, error) {
|
||||
proposal := &Proposal{ProposalBase: p.ProposalBase}
|
||||
if err := proposal.Content.SetContent(p.Content); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return c.Marshaler.MarshalBinaryLengthPrefixed(proposal)
|
||||
}
|
||||
|
||||
// UnmarshalProposal decodes a Proposal defined by the x/gov module and uses the
|
||||
// application-level Proposal type which has the concrete Content implementation
|
||||
// to deserialize.
|
||||
func (c *Codec) UnmarshalProposal(bz []byte) (gov.Proposal, error) {
|
||||
proposal := &Proposal{}
|
||||
if err := c.Marshaler.UnmarshalBinaryLengthPrefixed(bz, proposal); err != nil {
|
||||
return gov.Proposal{}, err
|
||||
}
|
||||
|
||||
return gov.Proposal{
|
||||
Content: proposal.Content.GetContent(),
|
||||
ProposalBase: proposal.ProposalBase,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// necessary types and interfaces registered. This codec is provided to all the
|
||||
// modules the application depends on.
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -7,6 +7,10 @@ import "x/auth/types/types.proto";
|
|||
import "x/auth/vesting/types/types.proto";
|
||||
import "x/supply/types/types.proto";
|
||||
import "x/evidence/types/types.proto";
|
||||
import "x/gov/types/types.proto";
|
||||
import "x/params/types/proposal/types.proto";
|
||||
import "x/upgrade/types/types.proto";
|
||||
import "x/distribution/types/types.proto";
|
||||
|
||||
option go_package = "github.com/cosmos/cosmos-sdk/simapp/codec";
|
||||
|
||||
|
@ -56,3 +60,38 @@ message MsgSubmitEvidence {
|
|||
Evidence evidence = 1;
|
||||
cosmos_sdk.x.evidence.v1.MsgSubmitEvidenceBase base = 2 [(gogoproto.nullable) = false, (gogoproto.embed) = true];
|
||||
}
|
||||
|
||||
// MsgSubmitProposal defines the application-level message type for handling
|
||||
// governance proposals.
|
||||
message MsgSubmitProposal {
|
||||
option (gogoproto.equal) = true;
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
cosmos_sdk.x.gov.v1.MsgSubmitProposalBase base = 1 [(gogoproto.nullable) = false, (gogoproto.embed) = true];
|
||||
Content content = 2;
|
||||
}
|
||||
|
||||
// Proposal defines the application-level concrete proposal type used in governance
|
||||
// proposals.
|
||||
message Proposal {
|
||||
option (gogoproto.equal) = true;
|
||||
|
||||
cosmos_sdk.x.gov.v1.ProposalBase base = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false];
|
||||
Content content = 2 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
// Content defines the application-level allowed Content to be included in a
|
||||
// governance proposal.
|
||||
message Content {
|
||||
option (gogoproto.equal) = true;
|
||||
option (cosmos_proto.interface_type) = "github.com/cosmos/cosmos-sdk/x/gov/types.Content";
|
||||
|
||||
// sum defines a set of all acceptable concrete governance proposal Content types.
|
||||
oneof sum {
|
||||
cosmos_sdk.x.gov.v1.TextProposal text = 1;
|
||||
cosmos_sdk.x.params.v1.ParameterChangeProposal parameter_change = 2;
|
||||
cosmos_sdk.x.upgrade.v1.SoftwareUpgradeProposal software_upgrade = 3;
|
||||
cosmos_sdk.x.upgrade.v1.CancelSoftwareUpgradeProposal cancel_software_upgrade = 4;
|
||||
cosmos_sdk.x.distribution.v1.CommunityPoolSpendProposal community_pool_spend = 5;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,13 @@ import (
|
|||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence"
|
||||
eviexported "github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||
)
|
||||
|
||||
var _ eviexported.MsgSubmitEvidence = MsgSubmitEvidence{}
|
||||
var (
|
||||
_ eviexported.MsgSubmitEvidence = MsgSubmitEvidence{}
|
||||
_ gov.MsgSubmitProposalI = MsgSubmitProposal{}
|
||||
)
|
||||
|
||||
// NewMsgSubmitEvidence returns a new MsgSubmitEvidence.
|
||||
func NewMsgSubmitEvidence(evidenceI eviexported.Evidence, s sdk.AccAddress) (MsgSubmitEvidence, error) {
|
||||
|
@ -16,7 +20,10 @@ func NewMsgSubmitEvidence(evidenceI eviexported.Evidence, s sdk.AccAddress) (Msg
|
|||
return MsgSubmitEvidence{}, err
|
||||
}
|
||||
|
||||
return MsgSubmitEvidence{Evidence: e, MsgSubmitEvidenceBase: evidence.NewMsgSubmitEvidenceBase(s)}, nil
|
||||
return MsgSubmitEvidence{
|
||||
Evidence: e,
|
||||
MsgSubmitEvidenceBase: evidence.NewMsgSubmitEvidenceBase(s),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ValidateBasic performs basic (non-state-dependant) validation on a
|
||||
|
@ -38,3 +45,40 @@ func (msg MsgSubmitEvidence) ValidateBasic() error {
|
|||
// nolint
|
||||
func (msg MsgSubmitEvidence) GetEvidence() eviexported.Evidence { return msg.Evidence.GetEvidence() }
|
||||
func (msg MsgSubmitEvidence) GetSubmitter() sdk.AccAddress { return msg.Submitter }
|
||||
|
||||
// NewMsgSubmitProposal returns a new MsgSubmitProposal.
|
||||
func NewMsgSubmitProposal(c gov.Content, d sdk.Coins, p sdk.AccAddress) (MsgSubmitProposal, error) {
|
||||
content := &Content{}
|
||||
if err := content.SetContent(c); err != nil {
|
||||
return MsgSubmitProposal{}, err
|
||||
}
|
||||
|
||||
return MsgSubmitProposal{
|
||||
Content: content,
|
||||
MsgSubmitProposalBase: gov.NewMsgSubmitProposalBase(d, p),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ValidateBasic performs basic (non-state-dependant) validation on a
|
||||
// MsgSubmitProposal.
|
||||
func (msg MsgSubmitProposal) ValidateBasic() error {
|
||||
if err := msg.MsgSubmitProposalBase.ValidateBasic(); err != nil {
|
||||
return nil
|
||||
}
|
||||
if msg.Content == nil {
|
||||
return sdkerrors.Wrap(gov.ErrInvalidProposalContent, "missing content")
|
||||
}
|
||||
if !gov.IsValidProposalType(msg.Content.GetContent().ProposalType()) {
|
||||
return sdkerrors.Wrap(gov.ErrInvalidProposalType, msg.Content.GetContent().ProposalType())
|
||||
}
|
||||
if err := msg.Content.GetContent().ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// nolint
|
||||
func (msg MsgSubmitProposal) GetContent() gov.Content { return msg.Content.GetContent() }
|
||||
func (msg MsgSubmitProposal) GetInitialDeposit() sdk.Coins { return msg.InitialDeposit }
|
||||
func (msg MsgSubmitProposal) GetProposer() sdk.AccAddress { return msg.Proposer }
|
||||
|
|
|
@ -747,77 +747,77 @@ func init() {
|
|||
func init() { proto.RegisterFile("x/distribution/types/types.proto", fileDescriptor_9fddf2a8e4a90b09) }
|
||||
|
||||
var fileDescriptor_9fddf2a8e4a90b09 = []byte{
|
||||
// 1113 bytes of a gzipped FileDescriptorProto
|
||||
// 1116 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x57, 0xcf, 0x6f, 0x1b, 0x45,
|
||||
0x14, 0xf6, 0x38, 0x4e, 0x9a, 0x4c, 0xd3, 0xa4, 0xd9, 0xd8, 0x49, 0xe4, 0x14, 0xaf, 0x35, 0x88,
|
||||
0x2a, 0x12, 0x8a, 0x43, 0xe8, 0x2d, 0x07, 0xa4, 0x38, 0x3f, 0x04, 0xa8, 0xa1, 0xd1, 0x26, 0x14,
|
||||
0x09, 0x09, 0xad, 0xc6, 0xbb, 0x13, 0x7b, 0x94, 0xf5, 0xce, 0x6a, 0x66, 0x6c, 0x27, 0xbd, 0x20,
|
||||
0x71, 0x02, 0x01, 0x15, 0x07, 0x04, 0x3d, 0x70, 0xe8, 0x05, 0x09, 0x2a, 0xf1, 0x6f, 0xa0, 0x1e,
|
||||
0x7b, 0x03, 0x71, 0x70, 0x51, 0x72, 0xe3, 0x98, 0x1b, 0x9c, 0xd0, 0xee, 0x8c, 0x77, 0x37, 0x8e,
|
||||
0x45, 0xe3, 0x48, 0xa5, 0x97, 0x24, 0xf3, 0x66, 0xe6, 0xfb, 0xbe, 0xf9, 0x66, 0xde, 0x7b, 0x1b,
|
||||
0x58, 0x3e, 0x5a, 0x71, 0xa9, 0x90, 0x9c, 0xd6, 0x5a, 0x92, 0x32, 0x7f, 0x45, 0x1e, 0x07, 0x44,
|
||||
0xa8, 0x9f, 0x95, 0x80, 0x33, 0xc9, 0x8c, 0x5b, 0x0e, 0x13, 0x4d, 0x26, 0x6c, 0xe1, 0x1e, 0x56,
|
||||
0x8e, 0x2a, 0xe9, 0xc5, 0x95, 0xf6, 0x6a, 0xf1, 0xb6, 0x6c, 0x50, 0xee, 0xda, 0x01, 0xe6, 0xf2,
|
||||
0x78, 0x25, 0xda, 0xb0, 0x52, 0x67, 0x75, 0x96, 0xfc, 0xa5, 0x50, 0x8a, 0x33, 0x17, 0x80, 0xd1,
|
||||
0x57, 0x59, 0x58, 0xd8, 0x11, 0xf5, 0x3d, 0x22, 0x3f, 0xa2, 0xb2, 0xe1, 0x72, 0xdc, 0x59, 0x77,
|
||||
0x5d, 0x4e, 0x84, 0x30, 0x1e, 0xc0, 0x19, 0x97, 0x78, 0xa4, 0x8e, 0x25, 0xe3, 0x36, 0x56, 0xc1,
|
||||
0x05, 0x50, 0x06, 0x4b, 0x93, 0xd5, 0x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2, 0xc1, 0xa8, 0x5f, 0x7d, 0xeb, 0x69, 0xd7, 0xcc, 0x3c, 0x79, 0x6e, 0x2e, 0x5d,
|
||||
0x42, 0x46, 0xb8, 0x41, 0x58, 0x1a, 0xd4, 0xb8, 0x07, 0x27, 0x5c, 0x12, 0x30, 0x41, 0x25, 0xe3,
|
||||
0xfa, 0x2a, 0x56, 0x87, 0xbf, 0xea, 0x04, 0x03, 0xfd, 0x36, 0x02, 0xc7, 0x76, 0x31, 0xc7, 0x4d,
|
||||
0x61, 0x1c, 0xc2, 0x1b, 0x4e, 0xef, 0x2c, 0xb6, 0xc4, 0x47, 0x91, 0x97, 0x13, 0xd5, 0xed, 0x50,
|
||||
0xec, 0x1f, 0x5d, 0xf3, 0xf6, 0x25, 0x38, 0x36, 0x89, 0x73, 0xd6, 0x35, 0xf3, 0xca, 0xf9, 0x73,
|
||||
0x60, 0xc8, 0x9a, 0x8c, 0xc7, 0xfb, 0xf8, 0xc8, 0xf8, 0x14, 0xe6, 0x6b, 0x58, 0x10, 0x3b, 0xe0,
|
||||
0x2c, 0x60, 0x82, 0x70, 0x9b, 0x47, 0xef, 0x3d, 0x3a, 0xd3, 0x44, 0x75, 0x67, 0x68, 0xce, 0x45,
|
||||
0xc5, 0x39, 0x08, 0x13, 0x59, 0x46, 0x18, 0xde, 0xd5, 0x51, 0x9d, 0x58, 0x9f, 0x01, 0x58, 0xa8,
|
||||
0x31, 0xbf, 0x25, 0x2e, 0x48, 0x18, 0x89, 0x24, 0x7c, 0x30, 0xb4, 0x84, 0x5b, 0x5a, 0xc2, 0x20,
|
||||
0x50, 0x64, 0xcd, 0x46, 0xf1, 0x3e, 0x11, 0xfb, 0xb0, 0x70, 0xae, 0xa6, 0xd8, 0xc4, 0xc7, 0x35,
|
||||
0x8f, 0xb8, 0x0b, 0xb9, 0x32, 0x58, 0x1a, 0xaf, 0x96, 0x13, 0xd4, 0x81, 0xcb, 0x90, 0x35, 0x9b,
|
||||
0x2e, 0x27, 0x5b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 0xbd,
|
||||
0x80, 0xf8, 0xae, 0x2a, 0xa3, 0xd8, 0x33, 0xf2, 0x70, 0x54, 0x52, 0xe9, 0x11, 0xd5, 0xab, 0x2c,
|
||||
0x35, 0x30, 0xca, 0xf0, 0xba, 0x4b, 0x84, 0xc3, 0x69, 0x90, 0xdc, 0xa6, 0x95, 0x0e, 0x85, 0x7d,
|
||||
0x94, 0x13, 0x87, 0x06, 0x94, 0xf8, 0x32, 0x2a, 0xf8, 0x57, 0xeb, 0xa3, 0x31, 0x46, 0xaa, 0xef,
|
||||
0xe7, 0x5e, 0x42, 0xdf, 0x5f, 0x1b, 0xff, 0xfc, 0xb1, 0x99, 0x89, 0xae, 0xea, 0x6f, 0x00, 0x0b,
|
||||
0xf1, 0x47, 0xe2, 0x9e, 0xc4, 0x5c, 0x52, 0xbf, 0xfe, 0x9e, 0x7f, 0x10, 0x55, 0xca, 0x80, 0x93,
|
||||
0x36, 0x65, 0x61, 0xfb, 0x49, 0xe7, 0x41, 0xaa, 0x52, 0xf6, 0x2d, 0x40, 0xd6, 0x54, 0x2f, 0xa2,
|
||||
0xb3, 0x60, 0x1f, 0x8e, 0x0a, 0x89, 0x0f, 0x89, 0x4e, 0x81, 0x77, 0x86, 0xee, 0x82, 0x93, 0x8a,
|
||||
0x28, 0x02, 0x41, 0x96, 0x02, 0x33, 0xb6, 0xe0, 0x58, 0x83, 0xd0, 0x7a, 0x43, 0x79, 0x9d, 0xab,
|
||||
0x2e, 0xff, 0xd5, 0x35, 0xa7, 0x1d, 0x4e, 0xc2, 0x0a, 0xef, 0xdb, 0x6a, 0x2a, 0x11, 0xd9, 0x37,
|
||||
0x81, 0x2c, 0xbd, 0xb9, 0xfa, 0xfa, 0x4f, 0x27, 0x25, 0xf0, 0xf4, 0xa4, 0x04, 0x9e, 0x9d, 0x94,
|
||||
0xc0, 0x9f, 0x27, 0x25, 0xf0, 0xcd, 0x69, 0x29, 0xf3, 0xec, 0xb4, 0x94, 0xf9, 0xfd, 0xb4, 0x94,
|
||||
0xf9, 0x78, 0x34, 0x92, 0x51, 0x1b, 0x8b, 0xfe, 0xcd, 0xb8, 0xf3, 0x6f, 0x00, 0x00, 0x00, 0xff,
|
||||
0xff, 0x9c, 0x88, 0x6a, 0xf1, 0xe3, 0x0c, 0x00, 0x00,
|
||||
0x14, 0xf6, 0x38, 0x6e, 0x9a, 0x4c, 0xd3, 0xa4, 0xd9, 0xd8, 0x49, 0xe4, 0x14, 0xaf, 0x35, 0x12,
|
||||
0x55, 0x24, 0x14, 0x87, 0xd0, 0x5b, 0x0e, 0x48, 0x71, 0x7e, 0x08, 0x50, 0x43, 0xa2, 0x4d, 0x28,
|
||||
0x12, 0x12, 0x5a, 0x8d, 0x77, 0x27, 0xf6, 0x28, 0xeb, 0x9d, 0xd5, 0xcc, 0xd8, 0x4e, 0x7a, 0x41,
|
||||
0xe2, 0x04, 0x02, 0x2a, 0x0e, 0x08, 0x7a, 0xe0, 0xd0, 0x0b, 0x12, 0x54, 0xe2, 0xdf, 0x40, 0x3d,
|
||||
0xf6, 0x06, 0xe2, 0xe0, 0xa2, 0xe4, 0xc6, 0x31, 0x37, 0x38, 0xa1, 0xdd, 0x19, 0xef, 0x6e, 0x1c,
|
||||
0xab, 0x8d, 0x23, 0x95, 0x5e, 0x12, 0xef, 0x9b, 0x99, 0xef, 0xfb, 0xe6, 0x9b, 0x79, 0xef, 0xed,
|
||||
0xc2, 0xf2, 0xd1, 0xb2, 0x4b, 0x85, 0xe4, 0xb4, 0xd6, 0x92, 0x94, 0xf9, 0xcb, 0xf2, 0x38, 0x20,
|
||||
0x42, 0xfd, 0xad, 0x04, 0x9c, 0x49, 0x66, 0xdc, 0x76, 0x98, 0x68, 0x32, 0x61, 0x0b, 0xf7, 0xb0,
|
||||
0x72, 0x54, 0x49, 0x4f, 0xae, 0xb4, 0x57, 0x8a, 0x77, 0x64, 0x83, 0x72, 0xd7, 0x0e, 0x30, 0x97,
|
||||
0xc7, 0xcb, 0xd1, 0x82, 0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c, 0x52, 0x21, 0x28, 0xf3, 0x07, 0xcb, 0x03, 0xff, 0x8f, 0xbc, 0xdf, 0x00, 0xcc, 0x6f, 0x8b,
|
||||
0xfa, 0x56, 0xcb, 0x77, 0x43, 0x45, 0x2d, 0x9f, 0xca, 0xe3, 0x5d, 0xc6, 0x3c, 0xe3, 0x53, 0x38,
|
||||
0x8a, 0x9b, 0xac, 0xe5, 0xcb, 0x79, 0x50, 0x1e, 0x59, 0xbc, 0xf1, 0xce, 0x4c, 0x25, 0x95, 0x47,
|
||||
0xed, 0x95, 0xca, 0x3a, 0xa3, 0x7e, 0xf5, 0xed, 0xa7, 0x5d, 0x33, 0xf3, 0xe4, 0xb9, 0xb9, 0x78,
|
||||
0x09, 0x19, 0xe1, 0x02, 0x61, 0x69, 0x50, 0x63, 0x07, 0x8e, 0xbb, 0x24, 0x60, 0x82, 0x4a, 0xc6,
|
||||
0xf5, 0x51, 0xac, 0x0c, 0x7f, 0xd4, 0x09, 0x06, 0xfa, 0x7d, 0x04, 0x8e, 0xee, 0x62, 0x8e, 0x9b,
|
||||
0xc2, 0x38, 0x84, 0x37, 0x9d, 0xde, 0x5e, 0x6c, 0x89, 0x8f, 0x22, 0x2f, 0xc7, 0xab, 0x5b, 0xa1,
|
||||
0xd8, 0x3f, 0xbb, 0xe6, 0x9d, 0x4b, 0x70, 0x6c, 0x10, 0xe7, 0xac, 0x6b, 0xe6, 0x95, 0xf3, 0xe7,
|
||||
0xc0, 0x90, 0x35, 0x11, 0x3f, 0xef, 0xe3, 0x23, 0xe3, 0x33, 0x98, 0xaf, 0x61, 0x41, 0xec, 0x80,
|
||||
0xb3, 0x80, 0x09, 0xc2, 0x6d, 0x1e, 0xdd, 0xf7, 0x68, 0x4f, 0xe3, 0xd5, 0xed, 0xa1, 0x39, 0x17,
|
||||
0x14, 0xe7, 0x20, 0x4c, 0x64, 0x19, 0x61, 0x78, 0x57, 0x47, 0x75, 0x62, 0x7d, 0x0e, 0x60, 0xa1,
|
||||
0xc6, 0xfc, 0x96, 0xb8, 0x20, 0x61, 0x24, 0x92, 0xf0, 0xe1, 0xd0, 0x12, 0x6e, 0x6b, 0x09, 0x83,
|
||||
0x40, 0x91, 0x35, 0x13, 0xc5, 0xfb, 0x44, 0xec, 0xc3, 0xc2, 0xb9, 0x9a, 0x62, 0x13, 0x1f, 0xd7,
|
||||
0x3c, 0xe2, 0xce, 0xe7, 0xca, 0x60, 0x71, 0xac, 0x5a, 0x4e, 0x50, 0x07, 0x4e, 0x43, 0xd6, 0x4c,
|
||||
0xba, 0x9c, 0x6c, 0xaa, 0xe8, 0x6a, 0xee, 0xd1, 0x63, 0x33, 0x83, 0xbe, 0xcc, 0xc2, 0x62, 0x9c,
|
||||
0x36, 0xef, 0x51, 0x21, 0x19, 0xa7, 0x0e, 0xf6, 0x14, 0xb3, 0x30, 0x7e, 0x02, 0x70, 0xce, 0x69,
|
||||
0x35, 0x5b, 0x1e, 0x96, 0xb4, 0x4d, 0xb4, 0x4c, 0x9b, 0x63, 0x49, 0x99, 0xbe, 0xba, 0xb3, 0x7d,
|
||||
0x57, 0x77, 0x83, 0x38, 0xd1, 0xed, 0xfd, 0x28, 0x74, 0xe6, 0xac, 0x6b, 0x96, 0xf4, 0x31, 0x0f,
|
||||
0x06, 0x41, 0x4f, 0x9e, 0x9b, 0x6f, 0x5d, 0xce, 0x3b, 0x75, 0xc5, 0x0b, 0x09, 0x90, 0xd2, 0x68,
|
||||
0x85, 0x30, 0xc6, 0x3a, 0x9c, 0xe2, 0xe4, 0x80, 0x70, 0xe2, 0x3b, 0xc4, 0x76, 0xa2, 0xcc, 0x0a,
|
||||
0xef, 0xc8, 0xcd, 0x6a, 0xf1, 0xac, 0x6b, 0xce, 0x2a, 0x09, 0x7d, 0x13, 0x90, 0x35, 0x19, 0x47,
|
||||
0xd6, 0xa3, 0xc0, 0x23, 0x00, 0xe7, 0x92, 0x12, 0xd2, 0xe2, 0x9c, 0xf8, 0xb2, 0x67, 0x04, 0x81,
|
||||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28, 0xaf, 0x73,
|
||||
0xd5, 0xa5, 0xbf, 0xbb, 0xe6, 0x94, 0xc3, 0x49, 0x58, 0xe1, 0x7d, 0x5b, 0x0d, 0x25, 0x22, 0xfb,
|
||||
0x06, 0x90, 0xa5, 0x17, 0x57, 0x77, 0x7e, 0x3e, 0x29, 0x81, 0xa7, 0x27, 0x25, 0xf0, 0xec, 0xa4,
|
||||
0x04, 0xfe, 0x3a, 0x29, 0x81, 0x6f, 0x4f, 0x4b, 0x99, 0x67, 0xa7, 0xa5, 0xcc, 0x1f, 0xa7, 0xa5,
|
||||
0xcc, 0x27, 0x2b, 0x2f, 0xd4, 0x38, 0xe8, 0x83, 0xa7, 0x36, 0x1a, 0x7d, 0x92, 0xdc, 0xfd, 0x2f,
|
||||
0x00, 0x00, 0xff, 0xff, 0x34, 0x5a, 0x18, 0x60, 0x0f, 0x0d, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (this *MsgSetWithdrawAddress) Equal(that interface{}) bool {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
syntax = "proto3";
|
||||
package cosmos_sdk.x.distribution.v1;
|
||||
|
||||
option go_package = "types";
|
||||
option go_package = "github.com/cosmos/cosmos-sdk/x/distribution/types";
|
||||
option (gogoproto.equal_all) = true;
|
||||
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||
)
|
||||
|
||||
// EvidenceCodec defines the interface required to serialize evidence
|
||||
// Codec defines the interface required to serialize evidence
|
||||
type Codec interface {
|
||||
codec.Marshaler
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
simappcodec "github.com/cosmos/cosmos-sdk/simapp/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
|
@ -27,11 +28,12 @@ func TestTickExpiredDepositPeriod(t *testing.T) {
|
|||
require.False(t, inactiveQueue.Valid())
|
||||
inactiveQueue.Close()
|
||||
|
||||
newProposalMsg := gov.NewMsgSubmitProposal(
|
||||
newProposalMsg, err := simappcodec.NewMsgSubmitProposal(
|
||||
gov.ContentFromProposalType("test", "test", gov.ProposalTypeText),
|
||||
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)},
|
||||
addrs[0],
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
res, err := govHandler(ctx, newProposalMsg)
|
||||
require.NoError(t, err)
|
||||
|
@ -78,11 +80,12 @@ func TestTickMultipleExpiredDepositPeriod(t *testing.T) {
|
|||
require.False(t, inactiveQueue.Valid())
|
||||
inactiveQueue.Close()
|
||||
|
||||
newProposalMsg := gov.NewMsgSubmitProposal(
|
||||
newProposalMsg, err := simappcodec.NewMsgSubmitProposal(
|
||||
gov.ContentFromProposalType("test", "test", gov.ProposalTypeText),
|
||||
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)},
|
||||
addrs[0],
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
res, err := govHandler(ctx, newProposalMsg)
|
||||
require.NoError(t, err)
|
||||
|
@ -100,11 +103,12 @@ func TestTickMultipleExpiredDepositPeriod(t *testing.T) {
|
|||
require.False(t, inactiveQueue.Valid())
|
||||
inactiveQueue.Close()
|
||||
|
||||
newProposalMsg2 := gov.NewMsgSubmitProposal(
|
||||
newProposalMsg2, err := simappcodec.NewMsgSubmitProposal(
|
||||
gov.ContentFromProposalType("test2", "test2", gov.ProposalTypeText),
|
||||
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)},
|
||||
addrs[0],
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
res, err = govHandler(ctx, newProposalMsg2)
|
||||
require.NoError(t, err)
|
||||
|
@ -156,11 +160,12 @@ func TestTickPassedDepositPeriod(t *testing.T) {
|
|||
require.False(t, activeQueue.Valid())
|
||||
activeQueue.Close()
|
||||
|
||||
newProposalMsg := gov.NewMsgSubmitProposal(
|
||||
newProposalMsg, err := simappcodec.NewMsgSubmitProposal(
|
||||
gov.ContentFromProposalType("test2", "test2", gov.ProposalTypeText),
|
||||
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)},
|
||||
addrs[0],
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
res, err := govHandler(ctx, newProposalMsg)
|
||||
require.NoError(t, err)
|
||||
|
@ -211,7 +216,8 @@ func TestTickPassedVotingPeriod(t *testing.T) {
|
|||
activeQueue.Close()
|
||||
|
||||
proposalCoins := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, sdk.TokensFromConsensusPower(5))}
|
||||
newProposalMsg := gov.NewMsgSubmitProposal(TestProposal, proposalCoins, addrs[0])
|
||||
newProposalMsg, err := simappcodec.NewMsgSubmitProposal(TestProposal, proposalCoins, addrs[0])
|
||||
require.NoError(t, err)
|
||||
|
||||
res, err := govHandler(ctx, newProposalMsg)
|
||||
require.NoError(t, err)
|
||||
|
|
|
@ -82,6 +82,7 @@ var (
|
|||
SplitInactiveProposalQueueKey = types.SplitInactiveProposalQueueKey
|
||||
SplitKeyDeposit = types.SplitKeyDeposit
|
||||
SplitKeyVote = types.SplitKeyVote
|
||||
NewMsgSubmitProposalBase = types.NewMsgSubmitProposalBase
|
||||
NewMsgSubmitProposal = types.NewMsgSubmitProposal
|
||||
NewMsgDeposit = types.NewMsgDeposit
|
||||
NewMsgVote = types.NewMsgVote
|
||||
|
@ -125,31 +126,34 @@ var (
|
|||
)
|
||||
|
||||
type (
|
||||
Keeper = keeper.Keeper
|
||||
Content = types.Content
|
||||
Handler = types.Handler
|
||||
Deposit = types.Deposit
|
||||
Deposits = types.Deposits
|
||||
GenesisState = types.GenesisState
|
||||
MsgSubmitProposal = types.MsgSubmitProposal
|
||||
MsgDeposit = types.MsgDeposit
|
||||
MsgVote = types.MsgVote
|
||||
DepositParams = types.DepositParams
|
||||
TallyParams = types.TallyParams
|
||||
VotingParams = types.VotingParams
|
||||
Params = types.Params
|
||||
Proposal = types.Proposal
|
||||
Proposals = types.Proposals
|
||||
ProposalQueue = types.ProposalQueue
|
||||
ProposalStatus = types.ProposalStatus
|
||||
TextProposal = types.TextProposal
|
||||
QueryProposalParams = types.QueryProposalParams
|
||||
QueryDepositParams = types.QueryDepositParams
|
||||
QueryVoteParams = types.QueryVoteParams
|
||||
QueryProposalsParams = types.QueryProposalsParams
|
||||
ValidatorGovInfo = types.ValidatorGovInfo
|
||||
TallyResult = types.TallyResult
|
||||
Vote = types.Vote
|
||||
Votes = types.Votes
|
||||
VoteOption = types.VoteOption
|
||||
Keeper = keeper.Keeper
|
||||
Content = types.Content
|
||||
Handler = types.Handler
|
||||
Deposit = types.Deposit
|
||||
Deposits = types.Deposits
|
||||
GenesisState = types.GenesisState
|
||||
MsgSubmitProposalI = types.MsgSubmitProposalI
|
||||
MsgSubmitProposal = types.MsgSubmitProposal
|
||||
MsgSubmitProposalBase = types.MsgSubmitProposalBase
|
||||
MsgDeposit = types.MsgDeposit
|
||||
MsgVote = types.MsgVote
|
||||
DepositParams = types.DepositParams
|
||||
TallyParams = types.TallyParams
|
||||
VotingParams = types.VotingParams
|
||||
Params = types.Params
|
||||
Proposal = types.Proposal
|
||||
Proposals = types.Proposals
|
||||
ProposalQueue = types.ProposalQueue
|
||||
ProposalStatus = types.ProposalStatus
|
||||
TextProposal = types.TextProposal
|
||||
QueryProposalParams = types.QueryProposalParams
|
||||
QueryDepositParams = types.QueryDepositParams
|
||||
QueryVoteParams = types.QueryVoteParams
|
||||
QueryProposalsParams = types.QueryProposalsParams
|
||||
ValidatorGovInfo = types.ValidatorGovInfo
|
||||
TallyResult = types.TallyResult
|
||||
Vote = types.Vote
|
||||
Votes = types.Votes
|
||||
VoteOption = types.VoteOption
|
||||
Codec = types.Codec
|
||||
)
|
||||
|
|
|
@ -94,9 +94,3 @@ func createValidators(t *testing.T, stakingHandler sdk.Handler, ctx sdk.Context,
|
|||
require.NotNil(t, res)
|
||||
}
|
||||
}
|
||||
|
||||
// ProposalEqual checks if two proposals are equal (note: slow, for tests only)
|
||||
func ProposalEqual(proposalA types.Proposal, proposalB types.Proposal) bool {
|
||||
return bytes.Equal(types.ModuleCdc.MustMarshalBinaryBare(proposalA),
|
||||
types.ModuleCdc.MustMarshalBinaryBare(proposalB))
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ func TestEqualProposals(t *testing.T) {
|
|||
|
||||
// They are similar but their IDs should be different
|
||||
require.NotEqual(t, proposal1, proposal2)
|
||||
require.False(t, ProposalEqual(proposal1, proposal2))
|
||||
require.NotEqual(t, proposal1, proposal2)
|
||||
|
||||
// Now create two genesis blocks
|
||||
state1 := gov.GenesisState{Proposals: []gov.Proposal{proposal1}}
|
||||
|
@ -136,7 +136,7 @@ func TestEqualProposals(t *testing.T) {
|
|||
proposal1.ProposalID = 55
|
||||
proposal2.ProposalID = 55
|
||||
require.Equal(t, proposal1, proposal1)
|
||||
require.True(t, ProposalEqual(proposal1, proposal2))
|
||||
require.Equal(t, proposal1, proposal2)
|
||||
|
||||
// Reassign proposals into state
|
||||
state1.Proposals[0] = proposal1
|
||||
|
|
|
@ -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,13 +29,13 @@ func NewHandler(keeper Keeper) sdk.Handler {
|
|||
}
|
||||
}
|
||||
|
||||
func handleMsgSubmitProposal(ctx sdk.Context, keeper Keeper, msg MsgSubmitProposal) (*sdk.Result, error) {
|
||||
proposal, err := keeper.SubmitProposal(ctx, msg.Content)
|
||||
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
|
||||
}
|
||||
|
||||
votingStarted, err := keeper.AddDeposit(ctx, proposal.ProposalID, msg.Proposer, msg.InitialDeposit)
|
||||
votingStarted, err := keeper.AddDeposit(ctx, proposal.ProposalID, msg.GetProposer(), msg.GetInitialDeposit())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -44,16 +44,17 @@ func handleMsgSubmitProposal(ctx sdk.Context, keeper Keeper, msg MsgSubmitPropos
|
|||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.Proposer.String()),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.GetProposer().String()),
|
||||
),
|
||||
)
|
||||
|
||||
submitEvent := sdk.NewEvent(types.EventTypeSubmitProposal, sdk.NewAttribute(types.AttributeKeyProposalType, msg.Content.ProposalType()))
|
||||
submitEvent := sdk.NewEvent(types.EventTypeSubmitProposal, sdk.NewAttribute(types.AttributeKeyProposalType, msg.GetContent().ProposalType()))
|
||||
if votingStarted {
|
||||
submitEvent = submitEvent.AppendAttributes(
|
||||
sdk.NewAttribute(types.AttributeKeyVotingPeriodStart, fmt.Sprintf("%d", proposal.ProposalID)),
|
||||
)
|
||||
}
|
||||
|
||||
ctx.EventManager().EmitEvent(submitEvent)
|
||||
|
||||
return &sdk.Result{
|
||||
|
|
|
@ -1,34 +1,23 @@
|
|||
package keeper_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp/codec"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
|
||||
simappcodec "github.com/cosmos/cosmos-sdk/simapp/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
)
|
||||
|
||||
var (
|
||||
TestProposal = types.NewTextProposal("Test", "description")
|
||||
)
|
||||
|
||||
// ProposalEqual checks if two proposals are equal (note: slow, for tests only)
|
||||
func ProposalEqual(proposalA types.Proposal, proposalB types.Proposal) bool {
|
||||
return bytes.Equal(types.ModuleCdc.MustMarshalBinaryBare(proposalA),
|
||||
types.ModuleCdc.MustMarshalBinaryBare(proposalB))
|
||||
}
|
||||
|
||||
func createValidators(ctx sdk.Context, app *simapp.SimApp, powers []int64) ([]sdk.AccAddress, []sdk.ValAddress) {
|
||||
addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, sdk.NewInt(30000000))
|
||||
valAddrs := simapp.ConvertAddrsToValAddrs(addrs)
|
||||
pks := simapp.CreateTestPubKeys(5)
|
||||
|
||||
appCodec := codec.NewAppCodec(app.Codec())
|
||||
appCodec := simappcodec.NewAppCodec(app.Codec())
|
||||
app.StakingKeeper = staking.NewKeeper(
|
||||
appCodec,
|
||||
app.GetKey(staking.StoreKey),
|
||||
|
|
|
@ -23,7 +23,7 @@ func (keeper Keeper) GetDeposit(ctx sdk.Context, proposalID uint64, depositorAdd
|
|||
// SetDeposit sets a Deposit to the gov store
|
||||
func (keeper Keeper) SetDeposit(ctx sdk.Context, deposit types.Deposit) {
|
||||
store := ctx.KVStore(keeper.storeKey)
|
||||
bz := keeper.cdc.MustMarshalBinaryLengthPrefixed(deposit)
|
||||
bz := keeper.cdc.MustMarshalBinaryLengthPrefixed(&deposit)
|
||||
store.Set(types.DepositKey(deposit.ProposalID, deposit.Depositor), bz)
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/supply/exported"
|
||||
|
@ -27,7 +26,7 @@ type Keeper struct {
|
|||
storeKey sdk.StoreKey
|
||||
|
||||
// The codec codec for binary encoding/decoding.
|
||||
cdc *codec.Codec
|
||||
cdc types.Codec
|
||||
|
||||
// Proposal router
|
||||
router types.Router
|
||||
|
@ -41,7 +40,7 @@ type Keeper struct {
|
|||
//
|
||||
// CONTRACT: the parameter Subspace must have the param key table already initialized
|
||||
func NewKeeper(
|
||||
cdc *codec.Codec, key sdk.StoreKey, paramSpace types.ParamSubspace,
|
||||
cdc types.Codec, key sdk.StoreKey, paramSpace types.ParamSubspace,
|
||||
supplyKeeper types.SupplyKeeper, sk types.StakingKeeper, rtr types.Router,
|
||||
) Keeper {
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
|
@ -50,7 +49,9 @@ func TestProposalQueues(t *testing.T) {
|
|||
|
||||
activeIterator := app.GovKeeper.ActiveProposalQueueIterator(ctx, proposal.VotingEndTime)
|
||||
require.True(t, activeIterator.Valid())
|
||||
app.Codec().UnmarshalBinaryLengthPrefixed(activeIterator.Value(), &proposalID)
|
||||
|
||||
proposalID, _ = types.SplitActiveProposalQueueKey(activeIterator.Key())
|
||||
require.Equal(t, proposalID, proposal.ProposalID)
|
||||
|
||||
activeIterator.Close()
|
||||
}
|
||||
|
|
|
@ -49,20 +49,31 @@ func (keeper Keeper) SubmitProposal(ctx sdk.Context, content types.Content) (typ
|
|||
}
|
||||
|
||||
// GetProposal get proposal from store by ProposalID
|
||||
func (keeper Keeper) GetProposal(ctx sdk.Context, proposalID uint64) (proposal types.Proposal, ok bool) {
|
||||
func (keeper Keeper) GetProposal(ctx sdk.Context, proposalID uint64) (types.Proposal, bool) {
|
||||
store := ctx.KVStore(keeper.storeKey)
|
||||
|
||||
bz := store.Get(types.ProposalKey(proposalID))
|
||||
if bz == nil {
|
||||
return
|
||||
return types.Proposal{}, false
|
||||
}
|
||||
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &proposal)
|
||||
|
||||
proposal, err := keeper.cdc.UnmarshalProposal(bz)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return proposal, true
|
||||
}
|
||||
|
||||
// SetProposal set a proposal to store
|
||||
func (keeper Keeper) SetProposal(ctx sdk.Context, proposal types.Proposal) {
|
||||
store := ctx.KVStore(keeper.storeKey)
|
||||
bz := keeper.cdc.MustMarshalBinaryLengthPrefixed(proposal)
|
||||
|
||||
bz, err := keeper.cdc.MarshalProposal(proposal)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
store.Set(types.ProposalKey(proposal.ProposalID), bz)
|
||||
}
|
||||
|
||||
|
@ -81,12 +92,15 @@ func (keeper Keeper) DeleteProposal(ctx sdk.Context, proposalID uint64) {
|
|||
// IterateProposals iterates over the all the proposals and performs a callback function
|
||||
func (keeper Keeper) IterateProposals(ctx sdk.Context, cb func(proposal types.Proposal) (stop bool)) {
|
||||
store := ctx.KVStore(keeper.storeKey)
|
||||
iterator := sdk.KVStorePrefixIterator(store, types.ProposalsKeyPrefix)
|
||||
|
||||
iterator := sdk.KVStorePrefixIterator(store, types.ProposalsKeyPrefix)
|
||||
defer iterator.Close()
|
||||
|
||||
for ; iterator.Valid(); iterator.Next() {
|
||||
var proposal types.Proposal
|
||||
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(iterator.Value(), &proposal)
|
||||
proposal, err := keeper.cdc.UnmarshalProposal(iterator.Value())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if cb(proposal) {
|
||||
break
|
||||
|
|
|
@ -6,14 +6,11 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
)
|
||||
|
||||
|
@ -29,7 +26,7 @@ func TestGetSetProposal(t *testing.T) {
|
|||
|
||||
gotProposal, ok := app.GovKeeper.GetProposal(ctx, proposalID)
|
||||
require.True(t, ok)
|
||||
require.True(t, ProposalEqual(proposal, gotProposal))
|
||||
require.True(t, proposal.Equal(gotProposal))
|
||||
}
|
||||
|
||||
func TestActivateVotingPeriod(t *testing.T) {
|
||||
|
@ -57,71 +54,26 @@ func TestActivateVotingPeriod(t *testing.T) {
|
|||
activeIterator.Close()
|
||||
}
|
||||
|
||||
type validProposal struct{}
|
||||
|
||||
func (validProposal) GetTitle() string { return "title" }
|
||||
func (validProposal) GetDescription() string { return "description" }
|
||||
func (validProposal) ProposalRoute() string { return types.RouterKey }
|
||||
func (validProposal) ProposalType() string { return types.ProposalTypeText }
|
||||
func (validProposal) String() string { return "" }
|
||||
func (validProposal) ValidateBasic() error { return nil }
|
||||
|
||||
type invalidProposalTitle1 struct{ validProposal }
|
||||
|
||||
func (invalidProposalTitle1) GetTitle() string { return "" }
|
||||
|
||||
type invalidProposalTitle2 struct{ validProposal }
|
||||
|
||||
func (invalidProposalTitle2) GetTitle() string { return strings.Repeat("1234567890", 100) }
|
||||
|
||||
type invalidProposalDesc1 struct{ validProposal }
|
||||
|
||||
func (invalidProposalDesc1) GetDescription() string { return "" }
|
||||
|
||||
type invalidProposalDesc2 struct{ validProposal }
|
||||
|
||||
func (invalidProposalDesc2) GetDescription() string { return strings.Repeat("1234567890", 1000) }
|
||||
|
||||
type invalidProposalRoute struct{ validProposal }
|
||||
type invalidProposalRoute struct{ types.TextProposal }
|
||||
|
||||
func (invalidProposalRoute) ProposalRoute() string { return "nonexistingroute" }
|
||||
|
||||
type invalidProposalValidation struct{ validProposal }
|
||||
|
||||
func (invalidProposalValidation) ValidateBasic() error {
|
||||
return errors.New("invalid proposal")
|
||||
}
|
||||
|
||||
func registerTestCodec(cdc *codec.Codec) {
|
||||
cdc.RegisterConcrete(validProposal{}, "test/validproposal", nil)
|
||||
cdc.RegisterConcrete(invalidProposalTitle1{}, "test/invalidproposalt1", nil)
|
||||
cdc.RegisterConcrete(invalidProposalTitle2{}, "test/invalidproposalt2", nil)
|
||||
cdc.RegisterConcrete(invalidProposalDesc1{}, "test/invalidproposald1", nil)
|
||||
cdc.RegisterConcrete(invalidProposalDesc2{}, "test/invalidproposald2", nil)
|
||||
cdc.RegisterConcrete(invalidProposalRoute{}, "test/invalidproposalr", nil)
|
||||
cdc.RegisterConcrete(invalidProposalValidation{}, "test/invalidproposalv", nil)
|
||||
}
|
||||
|
||||
func TestSubmitProposal(t *testing.T) {
|
||||
app := simapp.Setup(false)
|
||||
ctx := app.BaseApp.NewContext(false, abci.Header{})
|
||||
|
||||
registerTestCodec(app.Codec())
|
||||
|
||||
testCases := []struct {
|
||||
content types.Content
|
||||
expectedErr error
|
||||
}{
|
||||
{validProposal{}, nil},
|
||||
{types.TextProposal{Title: "title", Description: "description"}, nil},
|
||||
// Keeper does not check the validity of title and description, no error
|
||||
{invalidProposalTitle1{}, nil},
|
||||
{invalidProposalTitle2{}, nil},
|
||||
{invalidProposalDesc1{}, nil},
|
||||
{invalidProposalDesc2{}, nil},
|
||||
{types.TextProposal{Title: "", Description: "description"}, nil},
|
||||
{types.TextProposal{Title: strings.Repeat("1234567890", 100), Description: "description"}, nil},
|
||||
{types.TextProposal{Title: "title", Description: ""}, nil},
|
||||
{types.TextProposal{Title: "title", Description: strings.Repeat("1234567890", 1000)}, nil},
|
||||
// error only when invalid route
|
||||
{invalidProposalRoute{}, types.ErrNoProposalHandlerExists},
|
||||
// Keeper does not call ValidateBasic, msg.ValidateBasic does
|
||||
{invalidProposalValidation{}, nil},
|
||||
}
|
||||
|
||||
for i, tc := range testCases {
|
||||
|
|
|
@ -7,11 +7,11 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
simappcodec "github.com/cosmos/cosmos-sdk/simapp/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
|
@ -19,7 +19,7 @@ import (
|
|||
|
||||
const custom = "custom"
|
||||
|
||||
func getQueriedParams(t *testing.T, ctx sdk.Context, cdc *codec.Codec, 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.Codec, querier s
|
|||
}
|
||||
|
||||
func getQueriedProposals(
|
||||
t *testing.T, ctx sdk.Context, cdc *codec.Codec, 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.Codec, 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.Codec, querier
|
|||
return deposit
|
||||
}
|
||||
|
||||
func getQueriedDeposits(t *testing.T, ctx sdk.Context, cdc *codec.Codec, 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.Codec, querier
|
|||
return deposits
|
||||
}
|
||||
|
||||
func getQueriedVote(t *testing.T, ctx sdk.Context, cdc *codec.Codec, 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.Codec, querier sdk
|
|||
return vote
|
||||
}
|
||||
|
||||
func getQueriedVotes(t *testing.T, ctx sdk.Context, cdc *codec.Codec, 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}, "/"),
|
||||
|
@ -147,6 +147,7 @@ func getQueriedVotes(t *testing.T, ctx sdk.Context, cdc *codec.Codec, querier sd
|
|||
func TestQueries(t *testing.T) {
|
||||
app := simapp.Setup(false)
|
||||
ctx := app.BaseApp.NewContext(false, abci.Header{})
|
||||
appCodec := simappcodec.NewAppCodec(app.Codec())
|
||||
|
||||
querier := keeper.NewQuerier(app.GovKeeper)
|
||||
|
||||
|
@ -157,7 +158,7 @@ func TestQueries(t *testing.T) {
|
|||
|
||||
tp := TestProposal
|
||||
|
||||
depositParams, _, _ := getQueriedParams(t, ctx, app.Codec(), querier)
|
||||
depositParams, _, _ := getQueriedParams(t, ctx, appCodec, querier)
|
||||
|
||||
// TestAddrs[0] proposes (and deposits) proposals #1 and #2
|
||||
proposal1, err := app.GovKeeper.SubmitProposal(ctx, tp)
|
||||
|
@ -205,35 +206,35 @@ func TestQueries(t *testing.T) {
|
|||
deposit5.Amount = deposit5.Amount.Add(deposit3.Amount...)
|
||||
|
||||
// check deposits on proposal1 match individual deposits
|
||||
deposits := getQueriedDeposits(t, ctx, app.Codec(), querier, proposal1.ProposalID)
|
||||
deposits := getQueriedDeposits(t, ctx, appCodec, querier, proposal1.ProposalID)
|
||||
require.Len(t, deposits, 1)
|
||||
require.Equal(t, deposit1, deposits[0])
|
||||
|
||||
deposit := getQueriedDeposit(t, ctx, app.Codec(), querier, proposal1.ProposalID, TestAddrs[0])
|
||||
deposit := getQueriedDeposit(t, ctx, appCodec, querier, proposal1.ProposalID, TestAddrs[0])
|
||||
require.Equal(t, deposit1, deposit)
|
||||
|
||||
// check deposits on proposal2 match individual deposits
|
||||
deposits = getQueriedDeposits(t, ctx, app.Codec(), querier, proposal2.ProposalID)
|
||||
deposits = getQueriedDeposits(t, ctx, appCodec, querier, proposal2.ProposalID)
|
||||
require.Len(t, deposits, 2)
|
||||
// NOTE order of deposits is determined by the addresses
|
||||
require.Equal(t, deposit2, deposits[0])
|
||||
require.Equal(t, deposit4, deposits[1])
|
||||
|
||||
// check deposits on proposal3 match individual deposits
|
||||
deposits = getQueriedDeposits(t, ctx, app.Codec(), querier, proposal3.ProposalID)
|
||||
deposits = getQueriedDeposits(t, ctx, appCodec, querier, proposal3.ProposalID)
|
||||
require.Len(t, deposits, 1)
|
||||
require.Equal(t, deposit5, deposits[0])
|
||||
|
||||
deposit = getQueriedDeposit(t, ctx, app.Codec(), querier, proposal3.ProposalID, TestAddrs[1])
|
||||
deposit = getQueriedDeposit(t, ctx, appCodec, querier, proposal3.ProposalID, TestAddrs[1])
|
||||
require.Equal(t, deposit5, deposit)
|
||||
|
||||
// Only proposal #1 should be in types.Deposit Period
|
||||
proposals := getQueriedProposals(t, ctx, app.Codec(), querier, nil, nil, types.StatusDepositPeriod, 1, 0)
|
||||
proposals := getQueriedProposals(t, ctx, appCodec, querier, nil, nil, types.StatusDepositPeriod, 1, 0)
|
||||
require.Len(t, proposals, 1)
|
||||
require.Equal(t, proposal1, proposals[0])
|
||||
|
||||
// Only proposals #2 and #3 should be in Voting Period
|
||||
proposals = getQueriedProposals(t, ctx, app.Codec(), querier, nil, nil, types.StatusVotingPeriod, 1, 0)
|
||||
proposals = getQueriedProposals(t, ctx, appCodec, querier, nil, nil, types.StatusVotingPeriod, 1, 0)
|
||||
require.Len(t, proposals, 2)
|
||||
require.Equal(t, proposal2, proposals[0])
|
||||
require.Equal(t, proposal3, proposals[1])
|
||||
|
@ -249,56 +250,60 @@ func TestQueries(t *testing.T) {
|
|||
app.GovKeeper.SetVote(ctx, vote3)
|
||||
|
||||
// Test query voted by TestAddrs[0]
|
||||
proposals = getQueriedProposals(t, ctx, app.Codec(), querier, nil, TestAddrs[0], types.StatusNil, 1, 0)
|
||||
proposals = getQueriedProposals(t, ctx, appCodec, querier, nil, TestAddrs[0], types.StatusNil, 1, 0)
|
||||
require.Equal(t, proposal2, proposals[0])
|
||||
require.Equal(t, proposal3, proposals[1])
|
||||
|
||||
// Test query votes on types.Proposal 2
|
||||
votes := getQueriedVotes(t, ctx, app.Codec(), querier, proposal2.ProposalID, 1, 0)
|
||||
votes := getQueriedVotes(t, ctx, appCodec, querier, proposal2.ProposalID, 1, 0)
|
||||
require.Len(t, votes, 1)
|
||||
require.Equal(t, vote1, votes[0])
|
||||
|
||||
vote := getQueriedVote(t, ctx, app.Codec(), querier, proposal2.ProposalID, TestAddrs[0])
|
||||
vote := getQueriedVote(t, ctx, appCodec, querier, proposal2.ProposalID, TestAddrs[0])
|
||||
require.Equal(t, vote1, vote)
|
||||
|
||||
// Test query votes on types.Proposal 3
|
||||
votes = getQueriedVotes(t, ctx, app.Codec(), querier, proposal3.ProposalID, 1, 0)
|
||||
votes = getQueriedVotes(t, ctx, appCodec, querier, proposal3.ProposalID, 1, 0)
|
||||
require.Len(t, votes, 2)
|
||||
require.Equal(t, vote2, votes[0])
|
||||
require.Equal(t, vote3, votes[1])
|
||||
|
||||
// Test query all proposals
|
||||
proposals = getQueriedProposals(t, ctx, app.Codec(), querier, nil, nil, types.StatusNil, 1, 0)
|
||||
proposals = getQueriedProposals(t, ctx, appCodec, querier, nil, nil, types.StatusNil, 1, 0)
|
||||
require.Equal(t, proposal1, proposals[0])
|
||||
require.Equal(t, proposal2, proposals[1])
|
||||
require.Equal(t, proposal3, proposals[2])
|
||||
|
||||
// Test query voted by TestAddrs[1]
|
||||
proposals = getQueriedProposals(t, ctx, app.Codec(), querier, nil, TestAddrs[1], types.StatusNil, 1, 0)
|
||||
proposals = getQueriedProposals(t, ctx, appCodec, querier, nil, TestAddrs[1], types.StatusNil, 1, 0)
|
||||
require.Equal(t, proposal3.ProposalID, proposals[0].ProposalID)
|
||||
|
||||
// Test query deposited by TestAddrs[0]
|
||||
proposals = getQueriedProposals(t, ctx, app.Codec(), querier, TestAddrs[0], nil, types.StatusNil, 1, 0)
|
||||
proposals = getQueriedProposals(t, ctx, appCodec, querier, TestAddrs[0], nil, types.StatusNil, 1, 0)
|
||||
require.Equal(t, proposal1.ProposalID, proposals[0].ProposalID)
|
||||
|
||||
// Test query deposited by addr2
|
||||
proposals = getQueriedProposals(t, ctx, app.Codec(), querier, TestAddrs[1], nil, types.StatusNil, 1, 0)
|
||||
proposals = getQueriedProposals(t, ctx, appCodec, querier, TestAddrs[1], nil, types.StatusNil, 1, 0)
|
||||
require.Equal(t, proposal2.ProposalID, proposals[0].ProposalID)
|
||||
require.Equal(t, proposal3.ProposalID, proposals[1].ProposalID)
|
||||
|
||||
// Test query voted AND deposited by addr1
|
||||
proposals = getQueriedProposals(t, ctx, app.Codec(), querier, TestAddrs[0], TestAddrs[0], types.StatusNil, 1, 0)
|
||||
proposals = getQueriedProposals(t, ctx, appCodec, querier, TestAddrs[0], TestAddrs[0], types.StatusNil, 1, 0)
|
||||
require.Equal(t, proposal2.ProposalID, proposals[0].ProposalID)
|
||||
}
|
||||
|
||||
func TestPaginatedVotesQuery(t *testing.T) {
|
||||
app := simapp.Setup(false)
|
||||
ctx := app.BaseApp.NewContext(false, abci.Header{})
|
||||
appCodec := simappcodec.NewAppCodec(app.Codec())
|
||||
|
||||
proposal := types.Proposal{
|
||||
ProposalID: 100,
|
||||
Status: types.StatusVotingPeriod,
|
||||
ProposalBase: types.ProposalBase{
|
||||
ProposalID: 100,
|
||||
Status: types.StatusVotingPeriod,
|
||||
},
|
||||
}
|
||||
|
||||
app.GovKeeper.SetProposal(ctx, proposal)
|
||||
|
||||
votes := make([]types.Vote, 20)
|
||||
|
@ -318,7 +323,7 @@ func TestPaginatedVotesQuery(t *testing.T) {
|
|||
querier := keeper.NewQuerier(app.GovKeeper)
|
||||
|
||||
// keeper preserves consistent order for each query, but this is not the insertion order
|
||||
all := getQueriedVotes(t, ctx, app.Codec(), querier, proposal.ProposalID, 1, 0)
|
||||
all := getQueriedVotes(t, ctx, appCodec, querier, proposal.ProposalID, 1, 0)
|
||||
require.Equal(t, len(all), len(votes))
|
||||
|
||||
type testCase struct {
|
||||
|
@ -352,7 +357,7 @@ func TestPaginatedVotesQuery(t *testing.T) {
|
|||
} {
|
||||
tc := tc
|
||||
t.Run(tc.description, func(t *testing.T) {
|
||||
votes := getQueriedVotes(t, ctx, app.Codec(), querier, proposal.ProposalID, tc.page, tc.limit)
|
||||
votes := getQueriedVotes(t, ctx, appCodec, querier, proposal.ProposalID, tc.page, tc.limit)
|
||||
require.Equal(t, len(tc.votes), len(votes))
|
||||
for i := range votes {
|
||||
require.Equal(t, tc.votes[i], votes[i])
|
||||
|
|
|
@ -3,15 +3,13 @@ package keeper_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
)
|
||||
|
||||
func TestTallyNoOneVotes(t *testing.T) {
|
||||
|
|
|
@ -69,7 +69,7 @@ func (keeper Keeper) GetVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.A
|
|||
// SetVote sets a Vote to the gov store
|
||||
func (keeper Keeper) SetVote(ctx sdk.Context, vote types.Vote) {
|
||||
store := ctx.KVStore(keeper.storeKey)
|
||||
bz := keeper.cdc.MustMarshalBinaryLengthPrefixed(vote)
|
||||
bz := keeper.cdc.MustMarshalBinaryLengthPrefixed(&vote)
|
||||
store.Set(types.VoteKey(vote.ProposalID, vote.Voter), bz)
|
||||
}
|
||||
|
||||
|
|
|
@ -3,13 +3,12 @@ package keeper_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
"github.com/stretchr/testify/require"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestVotes(t *testing.T) {
|
||||
|
|
|
@ -4,29 +4,48 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
)
|
||||
|
||||
// module codec
|
||||
var ModuleCdc = codec.New()
|
||||
// Codec defines the interface required to serialize custom x/gov types.
|
||||
type Codec interface {
|
||||
codec.Marshaler
|
||||
|
||||
// RegisterCodec registers all the necessary types and interfaces for
|
||||
// governance.
|
||||
MarshalProposal(Proposal) ([]byte, error)
|
||||
UnmarshalProposal([]byte) (Proposal, error)
|
||||
}
|
||||
|
||||
// RegisterCodec registers all the necessary types and interfaces for the
|
||||
// governance module.
|
||||
func RegisterCodec(cdc *codec.Codec) {
|
||||
cdc.RegisterInterface((*Content)(nil), nil)
|
||||
|
||||
cdc.RegisterConcrete(MsgSubmitProposalBase{}, "cosmos-sdk/MsgSubmitProposalBase", 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.
|
||||
//
|
||||
// NOTE: This should only be used for applications that are still using a concrete
|
||||
// Amino codec for serialization.
|
||||
func RegisterProposalTypeCodec(o interface{}, name string) {
|
||||
ModuleCdc.RegisterConcrete(o, name, nil)
|
||||
amino.RegisterConcrete(o, name, nil)
|
||||
}
|
||||
|
||||
// TODO determine a good place to seal this codec
|
||||
var (
|
||||
amino = codec.New()
|
||||
|
||||
// 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.
|
||||
ModuleCdc = codec.NewHybridCodec(amino)
|
||||
)
|
||||
|
||||
func init() {
|
||||
RegisterCodec(ModuleCdc)
|
||||
RegisterCodec(amino)
|
||||
codec.RegisterCrypto(amino)
|
||||
}
|
||||
|
|
|
@ -3,29 +3,39 @@ package types
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// Deposit defines an amount deposited by an account address to an active proposal
|
||||
type Deposit struct {
|
||||
ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"` // proposalID of the proposal
|
||||
Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` // Address of the depositor
|
||||
Amount sdk.Coins `json:"amount" yaml:"amount"` // Deposit amount
|
||||
}
|
||||
|
||||
// NewDeposit creates a new Deposit instance
|
||||
func NewDeposit(proposalID uint64, depositor sdk.AccAddress, amount sdk.Coins) Deposit {
|
||||
return Deposit{proposalID, depositor, amount}
|
||||
}
|
||||
|
||||
func (d Deposit) String() string {
|
||||
return fmt.Sprintf("deposit by %s on Proposal %d is for the amount %s",
|
||||
d.Depositor, d.ProposalID, d.Amount)
|
||||
out, _ := yaml.Marshal(d)
|
||||
return string(out)
|
||||
}
|
||||
|
||||
// Deposits is a collection of Deposit objects
|
||||
type Deposits []Deposit
|
||||
|
||||
// Equal returns true if two slices (order-dependant) of deposits are equal.
|
||||
func (d Deposits) Equal(other Deposits) bool {
|
||||
if len(d) != len(other) {
|
||||
return false
|
||||
}
|
||||
|
||||
for i, deposit := range d {
|
||||
if !deposit.Equal(other[i]) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (d Deposits) String() string {
|
||||
if len(d) == 0 {
|
||||
return "[]"
|
||||
|
@ -37,12 +47,7 @@ func (d Deposits) String() string {
|
|||
return out
|
||||
}
|
||||
|
||||
// Equals returns whether two deposits are equal.
|
||||
func (d Deposit) Equals(comp Deposit) bool {
|
||||
return d.Depositor.Equals(comp.Depositor) && d.ProposalID == comp.ProposalID && d.Amount.IsEqual(comp.Amount)
|
||||
}
|
||||
|
||||
// Empty returns whether a deposit is empty.
|
||||
func (d Deposit) Empty() bool {
|
||||
return d.Equals(Deposit{})
|
||||
return d.Equal(Deposit{})
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
@ -38,11 +37,14 @@ func DefaultGenesisState() GenesisState {
|
|||
)
|
||||
}
|
||||
|
||||
// Equal checks whether two gov GenesisState structs are equivalent
|
||||
func (data GenesisState) Equal(data2 GenesisState) bool {
|
||||
b1 := ModuleCdc.MustMarshalBinaryBare(data)
|
||||
b2 := ModuleCdc.MustMarshalBinaryBare(data2)
|
||||
return bytes.Equal(b1, b2)
|
||||
func (data GenesisState) Equal(other GenesisState) bool {
|
||||
return data.StartingProposalID == other.StartingProposalID &&
|
||||
data.Deposits.Equal(other.Deposits) &&
|
||||
data.Votes.Equal(other.Votes) &&
|
||||
data.Proposals.Equal(other.Proposals) &&
|
||||
data.DepositParams.Equal(other.DepositParams) &&
|
||||
data.TallyParams.Equal(other.TallyParams) &&
|
||||
data.VotingParams.Equal(other.VotingParams)
|
||||
}
|
||||
|
||||
// IsEmpty returns true if a GenesisState is empty
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
|
@ -14,32 +14,35 @@ const (
|
|||
TypeMsgSubmitProposal = "submit_proposal"
|
||||
)
|
||||
|
||||
var _, _, _ sdk.Msg = MsgSubmitProposal{}, MsgDeposit{}, MsgVote{}
|
||||
var _, _, _ sdk.Msg = MsgSubmitProposalBase{}, MsgDeposit{}, MsgVote{}
|
||||
|
||||
// MsgSubmitProposal defines a message to create a governance proposal with a
|
||||
// given content and initial deposit
|
||||
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
|
||||
// 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 MsgSubmitProposalI interface {
|
||||
sdk.Msg
|
||||
|
||||
GetContent() Content
|
||||
GetInitialDeposit() sdk.Coins
|
||||
GetProposer() sdk.AccAddress
|
||||
}
|
||||
|
||||
// NewMsgSubmitProposal creates a new MsgSubmitProposal instance
|
||||
func NewMsgSubmitProposal(content Content, initialDeposit sdk.Coins, proposer sdk.AccAddress) MsgSubmitProposal {
|
||||
return MsgSubmitProposal{content, initialDeposit, proposer}
|
||||
// NewMsgSubmitProposalBase creates a new MsgSubmitProposalBase.
|
||||
func NewMsgSubmitProposalBase(initialDeposit sdk.Coins, proposer sdk.AccAddress) MsgSubmitProposalBase {
|
||||
return MsgSubmitProposalBase{
|
||||
InitialDeposit: initialDeposit,
|
||||
Proposer: proposer,
|
||||
}
|
||||
}
|
||||
|
||||
// Route implements Msg
|
||||
func (msg MsgSubmitProposal) Route() string { return RouterKey }
|
||||
func (msg MsgSubmitProposalBase) Route() string { return RouterKey }
|
||||
|
||||
// Type implements Msg
|
||||
func (msg MsgSubmitProposal) Type() string { return TypeMsgSubmitProposal }
|
||||
func (msg MsgSubmitProposalBase) Type() string { return TypeMsgSubmitProposal }
|
||||
|
||||
// ValidateBasic implements Msg
|
||||
func (msg MsgSubmitProposal) ValidateBasic() error {
|
||||
if msg.Content == nil {
|
||||
return sdkerrors.Wrap(ErrInvalidProposalContent, "missing content")
|
||||
}
|
||||
func (msg MsgSubmitProposalBase) ValidateBasic() error {
|
||||
if msg.Proposer.Empty() {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, msg.Proposer.String())
|
||||
}
|
||||
|
@ -49,37 +52,25 @@ func (msg MsgSubmitProposal) ValidateBasic() error {
|
|||
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()
|
||||
}
|
||||
|
||||
// String implements the Stringer interface
|
||||
func (msg MsgSubmitProposal) String() string {
|
||||
return fmt.Sprintf(`Submit Proposal Message:
|
||||
Content: %s
|
||||
Initial Deposit: %s
|
||||
`, msg.Content.String(), msg.InitialDeposit)
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSignBytes implements Msg
|
||||
func (msg MsgSubmitProposal) GetSignBytes() []byte {
|
||||
func (msg MsgSubmitProposalBase) GetSignBytes() []byte {
|
||||
bz := ModuleCdc.MustMarshalJSON(msg)
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
// GetSigners implements Msg
|
||||
func (msg MsgSubmitProposal) GetSigners() []sdk.AccAddress {
|
||||
func (msg MsgSubmitProposalBase) GetSigners() []sdk.AccAddress {
|
||||
return []sdk.AccAddress{msg.Proposer}
|
||||
}
|
||||
|
||||
// MsgDeposit defines a message to submit a deposit to an existing proposal
|
||||
type MsgDeposit struct {
|
||||
ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"` // ID of the proposal
|
||||
Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` // Address of the depositor
|
||||
Amount sdk.Coins `json:"amount" yaml:"amount"` // Coins to add to the proposal's deposit
|
||||
// String implements the Stringer interface
|
||||
func (msg MsgSubmitProposalBase) String() string {
|
||||
out, _ := yaml.Marshal(msg)
|
||||
return string(out)
|
||||
}
|
||||
|
||||
// NewMsgDeposit creates a new MsgDeposit instance
|
||||
|
@ -110,11 +101,8 @@ func (msg MsgDeposit) ValidateBasic() error {
|
|||
|
||||
// String implements the Stringer interface
|
||||
func (msg MsgDeposit) String() string {
|
||||
return fmt.Sprintf(`Deposit Message:
|
||||
Depositer: %s
|
||||
Proposal ID: %d
|
||||
Amount: %s
|
||||
`, msg.Depositor, msg.ProposalID, msg.Amount)
|
||||
out, _ := yaml.Marshal(msg)
|
||||
return string(out)
|
||||
}
|
||||
|
||||
// GetSignBytes implements Msg
|
||||
|
@ -128,13 +116,6 @@ func (msg MsgDeposit) GetSigners() []sdk.AccAddress {
|
|||
return []sdk.AccAddress{msg.Depositor}
|
||||
}
|
||||
|
||||
// MsgVote defines a message to cast a vote
|
||||
type MsgVote struct {
|
||||
ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"` // ID of the proposal
|
||||
Voter sdk.AccAddress `json:"voter" yaml:"voter"` // address of the voter
|
||||
Option VoteOption `json:"option" yaml:"option"` // option from OptionSet chosen by the voter
|
||||
}
|
||||
|
||||
// NewMsgVote creates a message to cast a vote on an active proposal
|
||||
func NewMsgVote(voter sdk.AccAddress, proposalID uint64, option VoteOption) MsgVote {
|
||||
return MsgVote{proposalID, voter, option}
|
||||
|
@ -160,10 +141,8 @@ func (msg MsgVote) ValidateBasic() error {
|
|||
|
||||
// String implements the Stringer interface
|
||||
func (msg MsgVote) String() string {
|
||||
return fmt.Sprintf(`Vote Message:
|
||||
Proposal ID: %d
|
||||
Option: %s
|
||||
`, msg.ProposalID, msg.Option)
|
||||
out, _ := yaml.Marshal(msg)
|
||||
return string(out)
|
||||
}
|
||||
|
||||
// GetSignBytes implements Msg
|
||||
|
@ -176,3 +155,61 @@ 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)
|
||||
}
|
||||
|
||||
// nolint
|
||||
func (msg MsgSubmitProposal) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.Proposer} }
|
||||
func (msg MsgSubmitProposal) Route() string { return RouterKey }
|
||||
func (msg MsgSubmitProposal) Type() string { return TypeMsgSubmitProposal }
|
||||
func (msg MsgSubmitProposal) GetContent() Content { return msg.Content }
|
||||
func (msg MsgSubmitProposal) GetInitialDeposit() sdk.Coins { return msg.InitialDeposit }
|
||||
func (msg MsgSubmitProposal) GetProposer() sdk.AccAddress { return msg.Proposer }
|
||||
|
|
|
@ -4,6 +4,8 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
@ -61,9 +63,8 @@ func DefaultDepositParams() DepositParams {
|
|||
|
||||
// String implements stringer insterface
|
||||
func (dp DepositParams) String() string {
|
||||
return fmt.Sprintf(`Deposit Params:
|
||||
Min Deposit: %s
|
||||
Max Deposit Period: %s`, dp.MinDeposit, dp.MaxDepositPeriod)
|
||||
out, _ := yaml.Marshal(dp)
|
||||
return string(out)
|
||||
}
|
||||
|
||||
// Equal checks equality of DepositParams
|
||||
|
@ -108,13 +109,15 @@ func DefaultTallyParams() TallyParams {
|
|||
return NewTallyParams(DefaultQuorum, DefaultThreshold, DefaultVeto)
|
||||
}
|
||||
|
||||
// Equal checks equality of TallyParams
|
||||
func (tp TallyParams) Equal(other TallyParams) bool {
|
||||
return tp.Quorum.Equal(other.Quorum) && tp.Threshold.Equal(other.Threshold) && tp.Veto.Equal(other.Veto)
|
||||
}
|
||||
|
||||
// String implements stringer insterface
|
||||
func (tp TallyParams) String() string {
|
||||
return fmt.Sprintf(`Tally Params:
|
||||
Quorum: %s
|
||||
Threshold: %s
|
||||
Veto: %s`,
|
||||
tp.Quorum, tp.Threshold, tp.Veto)
|
||||
out, _ := yaml.Marshal(tp)
|
||||
return string(out)
|
||||
}
|
||||
|
||||
func validateTallyParams(i interface{}) error {
|
||||
|
@ -162,10 +165,15 @@ func DefaultVotingParams() VotingParams {
|
|||
return NewVotingParams(DefaultPeriod)
|
||||
}
|
||||
|
||||
// Equal checks equality of TallyParams
|
||||
func (vp VotingParams) Equal(other VotingParams) bool {
|
||||
return vp.VotingPeriod == other.VotingPeriod
|
||||
}
|
||||
|
||||
// String implements stringer interface
|
||||
func (vp VotingParams) String() string {
|
||||
return fmt.Sprintf(`Voting Params:
|
||||
Voting Period: %s`, vp.VotingPeriod)
|
||||
out, _ := yaml.Marshal(vp)
|
||||
return string(out)
|
||||
}
|
||||
|
||||
func validateVotingParams(i interface{}) error {
|
||||
|
|
|
@ -6,6 +6,8 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
@ -17,53 +19,53 @@ const DefaultStartingProposalID uint64 = 1
|
|||
// on network changes.
|
||||
type Proposal struct {
|
||||
Content `json:"content" yaml:"content"` // Proposal content interface
|
||||
|
||||
ProposalID uint64 `json:"id" yaml:"id"` // ID of the proposal
|
||||
Status ProposalStatus `json:"proposal_status" yaml:"proposal_status"` // Status of the Proposal {Pending, Active, Passed, Rejected}
|
||||
FinalTallyResult TallyResult `json:"final_tally_result" yaml:"final_tally_result"` // Result of Tallys
|
||||
|
||||
SubmitTime time.Time `json:"submit_time" yaml:"submit_time"` // Time of the block where TxGovSubmitProposal was included
|
||||
DepositEndTime time.Time `json:"deposit_end_time" yaml:"deposit_end_time"` // Time that the Proposal would expire if deposit amount isn't met
|
||||
TotalDeposit sdk.Coins `json:"total_deposit" yaml:"total_deposit"` // Current deposit on this proposal. Initial value is set at InitialDeposit
|
||||
|
||||
VotingStartTime time.Time `json:"voting_start_time" yaml:"voting_start_time"` // Time of the block where MinDeposit was reached. -1 if MinDeposit is not reached
|
||||
VotingEndTime time.Time `json:"voting_end_time" yaml:"voting_end_time"` // Time that the VotingPeriod for this proposal will end and votes will be tallied
|
||||
ProposalBase
|
||||
}
|
||||
|
||||
// NewProposal creates a new Proposal instance
|
||||
func NewProposal(content Content, id uint64, submitTime, depositEndTime time.Time) Proposal {
|
||||
return Proposal{
|
||||
Content: content,
|
||||
ProposalID: id,
|
||||
Status: StatusDepositPeriod,
|
||||
FinalTallyResult: EmptyTallyResult(),
|
||||
TotalDeposit: sdk.NewCoins(),
|
||||
SubmitTime: submitTime,
|
||||
DepositEndTime: depositEndTime,
|
||||
Content: content,
|
||||
ProposalBase: ProposalBase{
|
||||
ProposalID: id,
|
||||
Status: StatusDepositPeriod,
|
||||
FinalTallyResult: EmptyTallyResult(),
|
||||
TotalDeposit: sdk.NewCoins(),
|
||||
SubmitTime: submitTime,
|
||||
DepositEndTime: depositEndTime,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Equal returns true if two Proposal types are equal.
|
||||
func (p Proposal) Equal(other Proposal) bool {
|
||||
return p.ProposalBase.Equal(other.ProposalBase) && p.Content.String() == other.Content.String()
|
||||
}
|
||||
|
||||
// String implements stringer interface
|
||||
func (p Proposal) String() string {
|
||||
return fmt.Sprintf(`Proposal %d:
|
||||
Title: %s
|
||||
Type: %s
|
||||
Status: %s
|
||||
Submit Time: %s
|
||||
Deposit End Time: %s
|
||||
Total Deposit: %s
|
||||
Voting Start Time: %s
|
||||
Voting End Time: %s
|
||||
Description: %s`,
|
||||
p.ProposalID, p.GetTitle(), p.ProposalType(),
|
||||
p.Status, p.SubmitTime, p.DepositEndTime,
|
||||
p.TotalDeposit, p.VotingStartTime, p.VotingEndTime, p.GetDescription(),
|
||||
)
|
||||
out, _ := yaml.Marshal(p)
|
||||
return string(out)
|
||||
}
|
||||
|
||||
// Proposals is an array of proposal
|
||||
type Proposals []Proposal
|
||||
|
||||
// Equal returns true if two slices (order-dependant) of proposals are equal.
|
||||
func (p Proposals) Equal(other Proposals) bool {
|
||||
if len(p) != len(other) {
|
||||
return false
|
||||
}
|
||||
|
||||
for i, proposal := range p {
|
||||
if !proposal.Equal(other[i]) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements stringer interface
|
||||
func (p Proposals) String() string {
|
||||
out := "ID - (Status) [Type] Title\n"
|
||||
|
@ -78,19 +80,6 @@ func (p Proposals) String() string {
|
|||
type (
|
||||
// ProposalQueue defines a queue for proposal ids
|
||||
ProposalQueue []uint64
|
||||
|
||||
// ProposalStatus is a type alias that represents a proposal status as a byte
|
||||
ProposalStatus byte
|
||||
)
|
||||
|
||||
// Valid Proposal statuses
|
||||
const (
|
||||
StatusNil ProposalStatus = 0x00
|
||||
StatusDepositPeriod ProposalStatus = 0x01
|
||||
StatusVotingPeriod ProposalStatus = 0x02
|
||||
StatusPassed ProposalStatus = 0x03
|
||||
StatusRejected ProposalStatus = 0x04
|
||||
StatusFailed ProposalStatus = 0x05
|
||||
)
|
||||
|
||||
// ProposalStatusFromString turns a string into a ProposalStatus
|
||||
|
@ -205,21 +194,14 @@ const (
|
|||
ProposalTypeText string = "Text"
|
||||
)
|
||||
|
||||
// TextProposal defines a standard text proposal whose changes need to be
|
||||
// manually updated in case of approval
|
||||
type TextProposal struct {
|
||||
Title string `json:"title" yaml:"title"`
|
||||
Description string `json:"description" yaml:"description"`
|
||||
}
|
||||
// Implements Content Interface
|
||||
var _ Content = TextProposal{}
|
||||
|
||||
// NewTextProposal creates a text proposal Content
|
||||
func NewTextProposal(title, description string) Content {
|
||||
return TextProposal{title, description}
|
||||
}
|
||||
|
||||
// Implements Content Interface
|
||||
var _ Content = TextProposal{}
|
||||
|
||||
// GetTitle returns the proposal title
|
||||
func (tp TextProposal) GetTitle() string { return tp.Title }
|
||||
|
||||
|
@ -237,10 +219,8 @@ func (tp TextProposal) ValidateBasic() error { return ValidateAbstract(tp) }
|
|||
|
||||
// String implements Stringer interface
|
||||
func (tp TextProposal) String() string {
|
||||
return fmt.Sprintf(`Text Proposal:
|
||||
Title: %s
|
||||
Description: %s
|
||||
`, tp.Title, tp.Description)
|
||||
out, _ := yaml.Marshal(tp)
|
||||
return string(out)
|
||||
}
|
||||
|
||||
var validProposalTypes = map[string]struct{}{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
@ -28,14 +28,6 @@ func NewValidatorGovInfo(address sdk.ValAddress, bondedTokens sdk.Int, delegator
|
|||
}
|
||||
}
|
||||
|
||||
// TallyResult defines a standard tally for a proposal
|
||||
type TallyResult struct {
|
||||
Yes sdk.Int `json:"yes" yaml:"yes"`
|
||||
Abstain sdk.Int `json:"abstain" yaml:"abstain"`
|
||||
No sdk.Int `json:"no" yaml:"no"`
|
||||
NoWithVeto sdk.Int `json:"no_with_veto" yaml:"no_with_veto"`
|
||||
}
|
||||
|
||||
// NewTallyResult creates a new TallyResult instance
|
||||
func NewTallyResult(yes, abstain, no, noWithVeto sdk.Int) TallyResult {
|
||||
return TallyResult{
|
||||
|
@ -71,9 +63,6 @@ func (tr TallyResult) Equals(comp TallyResult) bool {
|
|||
|
||||
// String implements stringer interface
|
||||
func (tr TallyResult) String() string {
|
||||
return fmt.Sprintf(`Tally Result:
|
||||
Yes: %s
|
||||
Abstain: %s
|
||||
No: %s
|
||||
NoWithVeto: %s`, tr.Yes, tr.Abstain, tr.No, tr.NoWithVeto)
|
||||
out, _ := yaml.Marshal(tr)
|
||||
return string(out)
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,165 @@
|
|||
syntax = "proto3";
|
||||
package cosmos_sdk.x.gov.v1;
|
||||
|
||||
import "types/types.proto";
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types";
|
||||
option (gogoproto.goproto_stringer_all) = false;
|
||||
option (gogoproto.stringer_all) = false;
|
||||
option (gogoproto.goproto_getters_all) = false;
|
||||
|
||||
// MsgSubmitProposalBase defines an sdk.Msg type that supports submitting arbitrary
|
||||
// proposal Content.
|
||||
//
|
||||
// Note, this message type provides the basis for which a true MsgSubmitProposal
|
||||
// can be constructed. Since the Content submitted in the message can be arbitrary,
|
||||
// assuming it fulfills the Content interface, it must be defined at the
|
||||
// application-level and extend MsgSubmitProposalBase.
|
||||
message MsgSubmitProposalBase {
|
||||
option (gogoproto.equal) = true;
|
||||
|
||||
repeated cosmos_sdk.v1.Coin initial_deposit = 1 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
|
||||
(gogoproto.moretags) = "yaml:\"initial_deposit\""
|
||||
];
|
||||
bytes proposer = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||
}
|
||||
|
||||
// MsgVote defines a message to cast a vote
|
||||
message MsgVote {
|
||||
option (gogoproto.equal) = true;
|
||||
|
||||
uint64 proposal_id = 1 [
|
||||
(gogoproto.customname) = "ProposalID",
|
||||
(gogoproto.moretags) = "yaml:\"proposal_id\"",
|
||||
(gogoproto.jsontag) = "proposal_id"
|
||||
];
|
||||
bytes voter = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||
VoteOption option = 3;
|
||||
}
|
||||
|
||||
// MsgDeposit defines a message to submit a deposit to an existing proposal
|
||||
message MsgDeposit {
|
||||
option (gogoproto.equal) = true;
|
||||
|
||||
uint64 proposal_id = 1 [
|
||||
(gogoproto.customname) = "ProposalID",
|
||||
(gogoproto.moretags) = "yaml:\"proposal_id\"",
|
||||
(gogoproto.jsontag) = "proposal_id"
|
||||
];
|
||||
bytes depositor = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||
repeated cosmos_sdk.v1.Coin amount = 3
|
||||
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
|
||||
}
|
||||
|
||||
// VoteOption defines a vote option
|
||||
enum VoteOption {
|
||||
option (gogoproto.enum_stringer) = false;
|
||||
option (gogoproto.goproto_enum_stringer) = false;
|
||||
option (gogoproto.goproto_enum_prefix) = false;
|
||||
|
||||
// VOTE_OPTION_UNSPECIFIED defines a no-op vote option.
|
||||
VOTE_OPTION_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "OptionEmpty"];
|
||||
// VOTE_OPTION_YES defines a yes vote option.
|
||||
VOTE_OPTION_YES = 1 [(gogoproto.enumvalue_customname) = "OptionYes"];
|
||||
// VOTE_OPTION_ABSTAIN defines an abstain vote option.
|
||||
VOTE_OPTION_ABSTAIN = 2 [(gogoproto.enumvalue_customname) = "OptionAbstain"];
|
||||
// VOTE_OPTION_NO defines a no vote option.
|
||||
VOTE_OPTION_NO = 3 [(gogoproto.enumvalue_customname) = "OptionNo"];
|
||||
// VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option.
|
||||
VOTE_OPTION_NO_WITH_VETO = 4 [(gogoproto.enumvalue_customname) = "OptionNoWithVeto"];
|
||||
}
|
||||
|
||||
// TextProposal defines a standard text proposal whose changes need to be
|
||||
// manually updated in case of approval
|
||||
message TextProposal {
|
||||
option (gogoproto.equal) = true;
|
||||
|
||||
string title = 1;
|
||||
string description = 2;
|
||||
}
|
||||
|
||||
// Deposit defines an amount deposited by an account address to an active proposal
|
||||
message Deposit {
|
||||
option (gogoproto.equal) = true;
|
||||
|
||||
uint64 proposal_id = 1 [(gogoproto.customname) = "ProposalID", (gogoproto.moretags) = "yaml:\"proposal_id\""];
|
||||
bytes depositor = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||
repeated cosmos_sdk.v1.Coin amount = 3
|
||||
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
|
||||
}
|
||||
|
||||
// ProposalBase defines the core field members of a governance proposal. It includes
|
||||
// all static fields (i.e fields excluding the dynamic Content). A full proposal
|
||||
// extends the ProposalBase with Content.
|
||||
message ProposalBase {
|
||||
option (gogoproto.equal) = true;
|
||||
option (gogoproto.goproto_stringer) = true;
|
||||
option (gogoproto.face) = true;
|
||||
|
||||
uint64 proposal_id = 1
|
||||
[(gogoproto.customname) = "ProposalID", (gogoproto.jsontag) = "id", (gogoproto.moretags) = "yaml:\"id\""];
|
||||
ProposalStatus status = 2 [(gogoproto.moretags) = "yaml:\"proposal_status\""];
|
||||
TallyResult final_tally_result = 3
|
||||
[(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"final_tally_result\""];
|
||||
google.protobuf.Timestamp submit_time = 4
|
||||
[(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"submit_time\""];
|
||||
google.protobuf.Timestamp deposit_end_time = 5
|
||||
[(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"deposit_end_time\""];
|
||||
repeated cosmos_sdk.v1.Coin total_deposit = 6 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
|
||||
(gogoproto.moretags) = "yaml:\"total_deposit\""
|
||||
];
|
||||
google.protobuf.Timestamp voting_start_time = 7
|
||||
[(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"voting_start_time\""];
|
||||
google.protobuf.Timestamp voting_end_time = 8
|
||||
[(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"voting_end_time\""];
|
||||
}
|
||||
|
||||
// ProposalStatus is a type alias that represents a proposal status as a byte
|
||||
enum ProposalStatus {
|
||||
option (gogoproto.enum_stringer) = false;
|
||||
option (gogoproto.goproto_enum_stringer) = false;
|
||||
option (gogoproto.goproto_enum_prefix) = false;
|
||||
|
||||
// PROPOSAL_STATUS_UNSPECIFIED defines the default propopsal status.
|
||||
PROPOSAL_STATUS_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "StatusNil"];
|
||||
// PROPOSAL_STATUS_DEPOSIT_PERIOD defines a proposal status during the deposit period.
|
||||
PROPOSAL_STATUS_DEPOSIT_PERIOD = 1 [(gogoproto.enumvalue_customname) = "StatusDepositPeriod"];
|
||||
// PROPOSAL_STATUS_VOTING_PERIOD defines a proposal status during the voting period.
|
||||
PROPOSAL_STATUS_VOTING_PERIOD = 2 [(gogoproto.enumvalue_customname) = "StatusVotingPeriod"];
|
||||
// PROPOSAL_STATUS_PASSED defines a proposal status of a proposal that has passed.
|
||||
PROPOSAL_STATUS_PASSED = 3 [(gogoproto.enumvalue_customname) = "StatusPassed"];
|
||||
// PROPOSAL_STATUS_REJECTED defines a proposal status of a proposal that has been rejected.
|
||||
PROPOSAL_STATUS_REJECTED = 4 [(gogoproto.enumvalue_customname) = "StatusRejected"];
|
||||
// PROPOSAL_STATUS_FAILED defines a proposal status of a proposal that has failed.
|
||||
PROPOSAL_STATUS_FAILED = 5 [(gogoproto.enumvalue_customname) = "StatusFailed"];
|
||||
}
|
||||
|
||||
// TallyResult defines a standard tally for a proposal
|
||||
message TallyResult {
|
||||
option (gogoproto.equal) = true;
|
||||
|
||||
string yes = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
|
||||
string abstain = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
|
||||
string no = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
|
||||
string no_with_veto = 4 [
|
||||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.moretags) = "yaml:\"no_with_veto\""
|
||||
];
|
||||
}
|
||||
|
||||
// Vote defines a vote on a governance proposal. A vote corresponds to a proposal
|
||||
// ID, the voter, and the vote option.
|
||||
message Vote {
|
||||
option (gogoproto.equal) = true;
|
||||
|
||||
uint64 proposal_id = 1 [(gogoproto.customname) = "ProposalID", (gogoproto.moretags) = "yaml:\"proposal_id\""];
|
||||
bytes voter = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||
VoteOption option = 3;
|
||||
}
|
|
@ -4,28 +4,39 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// Vote
|
||||
type Vote struct {
|
||||
ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"` // proposalID of the proposal
|
||||
Voter sdk.AccAddress `json:"voter" yaml:"voter"` // address of the voter
|
||||
Option VoteOption `json:"option" yaml:"option"` // option from OptionSet chosen by the voter
|
||||
}
|
||||
|
||||
// NewVote creates a new Vote instance
|
||||
func NewVote(proposalID uint64, voter sdk.AccAddress, option VoteOption) Vote {
|
||||
return Vote{proposalID, voter, option}
|
||||
}
|
||||
|
||||
func (v Vote) String() string {
|
||||
return fmt.Sprintf("voter %s voted with option %s on proposal %d", v.Voter, v.Option, v.ProposalID)
|
||||
out, _ := yaml.Marshal(v)
|
||||
return string(out)
|
||||
}
|
||||
|
||||
// Votes is a collection of Vote objects
|
||||
type Votes []Vote
|
||||
|
||||
// Equal returns true if two slices (order-dependant) of votes are equal.
|
||||
func (v Votes) Equal(other Votes) bool {
|
||||
if len(v) != len(other) {
|
||||
return false
|
||||
}
|
||||
|
||||
for i, vote := range v {
|
||||
if !vote.Equal(other[i]) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (v Votes) String() string {
|
||||
if len(v) == 0 {
|
||||
return "[]"
|
||||
|
@ -37,30 +48,11 @@ func (v Votes) String() string {
|
|||
return out
|
||||
}
|
||||
|
||||
// Equals returns whether two votes are equal.
|
||||
func (v Vote) Equals(comp Vote) bool {
|
||||
return v.Voter.Equals(comp.Voter) &&
|
||||
v.ProposalID == comp.ProposalID &&
|
||||
v.Option == comp.Option
|
||||
}
|
||||
|
||||
// Empty returns whether a vote is empty.
|
||||
func (v Vote) Empty() bool {
|
||||
return v.Equals(Vote{})
|
||||
return v.Equal(Vote{})
|
||||
}
|
||||
|
||||
// VoteOption defines a vote option
|
||||
type VoteOption byte
|
||||
|
||||
// Vote options
|
||||
const (
|
||||
OptionEmpty VoteOption = 0x00
|
||||
OptionYes VoteOption = 0x01
|
||||
OptionAbstain VoteOption = 0x02
|
||||
OptionNo VoteOption = 0x03
|
||||
OptionNoWithVeto VoteOption = 0x04
|
||||
)
|
||||
|
||||
// VoteOptionFromString returns a VoteOption from a string. It returns an error
|
||||
// if the string is invalid.
|
||||
func VoteOptionFromString(str string) (VoteOption, error) {
|
||||
|
|
|
@ -3,14 +3,15 @@ package keeper_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
cdc "github.com/cosmos/cosmos-sdk/simapp/codec"
|
||||
simappcodec "github.com/cosmos/cosmos-sdk/simapp/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -23,7 +24,7 @@ func createTestInput() (*codec.Codec, *simapp.SimApp, sdk.Context) {
|
|||
app := simapp.Setup(false)
|
||||
ctx := app.BaseApp.NewContext(false, abci.Header{})
|
||||
|
||||
appCodec := cdc.NewAppCodec(codec.New())
|
||||
appCodec := simappcodec.NewAppCodec(codec.New())
|
||||
|
||||
app.StakingKeeper = keeper.NewKeeper(
|
||||
appCodec,
|
||||
|
|
|
@ -164,32 +164,123 @@ func init() {
|
|||
func init() { proto.RegisterFile("x/upgrade/types/types.proto", fileDescriptor_2a308fd9dd71aff8) }
|
||||
|
||||
var fileDescriptor_2a308fd9dd71aff8 = []byte{
|
||||
// 364 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, 0x26, 0x62, 0xa8, 0x18, 0x5a,
|
||||
0x47, 0xa5, 0x43, 0x3b, 0xd3, 0xbd, 0x42, 0x69, 0xab, 0x4a, 0x5d, 0x90, 0x49, 0x4c, 0x62, 0x91,
|
||||
0xc4, 0x56, 0x6c, 0x5a, 0xd8, 0x3a, 0x77, 0xe2, 0x67, 0x31, 0x32, 0x32, 0xb5, 0x05, 0xfe, 0x48,
|
||||
0x95, 0x18, 0xd4, 0xaa, 0x52, 0xb7, 0x2e, 0xf6, 0xfb, 0xac, 0xf7, 0xbd, 0xf7, 0x3e, 0xdb, 0xf0,
|
||||
0xff, 0xcc, 0x9b, 0xca, 0x28, 0xa7, 0x21, 0xf3, 0xf4, 0x5c, 0x32, 0x65, 0x56, 0x22, 0x73, 0xa1,
|
||||
0x05, 0x6a, 0x04, 0x42, 0xa5, 0x42, 0x0d, 0x55, 0x38, 0x21, 0x33, 0xb2, 0xe7, 0x91, 0x87, 0xd3,
|
||||
0xe6, 0x91, 0x8e, 0x79, 0x1e, 0x0e, 0x25, 0xcd, 0xf5, 0xdc, 0x2b, 0xb9, 0x5e, 0x24, 0x22, 0xf1,
|
||||
0x81, 0x8c, 0x40, 0xb3, 0x1d, 0x09, 0x11, 0x25, 0xcc, 0x50, 0x46, 0xd3, 0xb1, 0xa7, 0x79, 0xca,
|
||||
0x94, 0xa6, 0xa9, 0x34, 0x84, 0xce, 0x13, 0x80, 0xf6, 0x20, 0xa1, 0x19, 0x42, 0xd0, 0xce, 0x68,
|
||||
0xca, 0x1c, 0xe0, 0x82, 0x6e, 0xcd, 0x2f, 0x31, 0xba, 0x80, 0x76, 0xc1, 0x77, 0x7e, 0xb9, 0xa0,
|
||||
0x5b, 0xef, 0x35, 0x89, 0x11, 0x23, 0x07, 0x31, 0x72, 0x73, 0x10, 0xeb, 0xff, 0x59, 0xbe, 0xb4,
|
||||
0xad, 0xc5, 0x6b, 0x1b, 0xf8, 0x65, 0x07, 0xfa, 0x07, 0xab, 0x31, 0xe3, 0x51, 0xac, 0x9d, 0x8a,
|
||||
0x0b, 0xba, 0x15, 0x7f, 0x5f, 0x15, 0x2e, 0x3c, 0x1b, 0x0b, 0xc7, 0x36, 0x2e, 0x05, 0xee, 0x3c,
|
||||
0x03, 0xd8, 0xb8, 0x16, 0x63, 0xfd, 0x48, 0x73, 0x76, 0x6b, 0x46, 0x1c, 0xe4, 0x42, 0x0a, 0x45,
|
||||
0x13, 0xf4, 0x17, 0xfe, 0xd6, 0x5c, 0x27, 0x87, 0x58, 0xa6, 0x40, 0x2e, 0xac, 0x87, 0x4c, 0x05,
|
||||
0x39, 0x97, 0x9a, 0x8b, 0xac, 0x8c, 0x57, 0xf3, 0x3f, 0x1f, 0xa1, 0x73, 0x68, 0xcb, 0x84, 0x66,
|
||||
0xa5, 0x7b, 0xbd, 0xd7, 0x22, 0xdf, 0xdc, 0x23, 0x29, 0x46, 0xef, 0xdb, 0x45, 0x78, 0xbf, 0x6c,
|
||||
0xe8, 0xdc, 0xc1, 0xd6, 0x25, 0xcd, 0x02, 0x96, 0xfc, 0x70, 0xa2, 0xfe, 0xd5, 0x72, 0x83, 0xad,
|
||||
0xf5, 0x06, 0x5b, 0xcb, 0x2d, 0x06, 0xab, 0x2d, 0x06, 0x6f, 0x5b, 0x0c, 0x16, 0x3b, 0x6c, 0xad,
|
||||
0x76, 0xd8, 0x5a, 0xef, 0xb0, 0x75, 0x7f, 0x1c, 0x71, 0x1d, 0x4f, 0x47, 0x24, 0x10, 0xa9, 0x67,
|
||||
0xf2, 0xee, 0xb7, 0x13, 0x15, 0x4e, 0xbc, 0x2f, 0xdf, 0x64, 0x54, 0x2d, 0x5f, 0xe1, 0xec, 0x3d,
|
||||
0x00, 0x00, 0xff, 0xff, 0x0f, 0x77, 0x53, 0x0a, 0x40, 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, 0x5b, 0x2f, 0x95, 0x2a, 0x64, 0x12, 0x93,
|
||||
0x58, 0x24, 0xb1, 0x15, 0x9b, 0x16, 0xbe, 0x40, 0xcf, 0x7c, 0x84, 0x7e, 0x1c, 0x8e, 0x1c, 0x39,
|
||||
0xb5, 0x05, 0x2e, 0xfd, 0x18, 0x55, 0xe2, 0xa0, 0x56, 0x95, 0x7a, 0xeb, 0x25, 0x79, 0xcf, 0xfa,
|
||||
0xbf, 0xff, 0xfb, 0xbd, 0x67, 0xc3, 0xcf, 0x4b, 0x7f, 0x21, 0xe3, 0x82, 0x46, 0xcc, 0xd7, 0x2b,
|
||||
0xc9, 0x94, 0xf9, 0x12, 0x59, 0x08, 0x2d, 0x50, 0x27, 0x14, 0x2a, 0x13, 0x6a, 0xa2, 0xa2, 0x39,
|
||||
0x59, 0x92, 0x5a, 0x47, 0x2e, 0xbf, 0x77, 0xbf, 0xe8, 0x84, 0x17, 0xd1, 0x44, 0xd2, 0x42, 0xaf,
|
||||
0xfc, 0x4a, 0xeb, 0xc7, 0x22, 0x16, 0x4f, 0x91, 0x31, 0xe8, 0xba, 0xb1, 0x10, 0x71, 0xca, 0x8c,
|
||||
0x64, 0xba, 0x98, 0xf9, 0x9a, 0x67, 0x4c, 0x69, 0x9a, 0x49, 0x23, 0xe8, 0x5f, 0x03, 0x68, 0x8f,
|
||||
0x53, 0x9a, 0x23, 0x04, 0xed, 0x9c, 0x66, 0xcc, 0x01, 0x1e, 0x18, 0xb4, 0x82, 0x2a, 0x46, 0xbf,
|
||||
0xa0, 0x5d, 0xea, 0x9d, 0x77, 0x1e, 0x18, 0xb4, 0x87, 0x5d, 0x62, 0xcc, 0xc8, 0xc9, 0x8c, 0xfc,
|
||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, 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
|
||||
}
|
||||
|
||||
that1, ok := that.(*SoftwareUpgradeProposal)
|
||||
if !ok {
|
||||
that2, ok := that.(SoftwareUpgradeProposal)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if this.Title != that1.Title {
|
||||
return false
|
||||
}
|
||||
if this.Description != that1.Description {
|
||||
return false
|
||||
}
|
||||
if !this.Plan.Equal(&that1.Plan) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (this *CancelSoftwareUpgradeProposal) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*CancelSoftwareUpgradeProposal)
|
||||
if !ok {
|
||||
that2, ok := that.(CancelSoftwareUpgradeProposal)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if this.Title != that1.Title {
|
||||
return false
|
||||
}
|
||||
if this.Description != that1.Description {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (m *Plan) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
|
|
|
@ -4,41 +4,47 @@ package cosmos_sdk.x.upgrade.v1;
|
|||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
option go_package = "github.com/cosmos/cosmos-sdk/x/upgrade/types";
|
||||
option go_package = "github.com/cosmos/cosmos-sdk/x/upgrade/types";
|
||||
option (gogoproto.goproto_stringer_all) = false;
|
||||
option (gogoproto.goproto_getters_all) = false;
|
||||
option (gogoproto.goproto_getters_all) = false;
|
||||
|
||||
// Plan specifies information about a planned upgrade and when it should occur
|
||||
message Plan {
|
||||
// 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
|
||||
// set in the software, it will be assumed that the software is out-of-date when the upgrade Time or Height
|
||||
// is reached and the software will exit.
|
||||
string name = 1;
|
||||
option (gogoproto.equal) = true;
|
||||
|
||||
// The time after which the upgrade must be performed.
|
||||
// Leave set to its zero value to use a pre-defined Height instead.
|
||||
google.protobuf.Timestamp time = 2 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
|
||||
// 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
|
||||
// set in the software, it will be assumed that the software is out-of-date when the upgrade Time or Height
|
||||
// is reached and the software will exit.
|
||||
string name = 1;
|
||||
|
||||
// The height at which the upgrade must be performed.
|
||||
// Only used if Time is not set.
|
||||
int64 height = 3;
|
||||
// The time after which the upgrade must be performed.
|
||||
// Leave set to its zero value to use a pre-defined Height instead.
|
||||
google.protobuf.Timestamp time = 2 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
|
||||
|
||||
// Any application specific upgrade info to be included on-chain
|
||||
// such as a git commit that validators could automatically upgrade to
|
||||
string info = 4;
|
||||
// The height at which the upgrade must be performed.
|
||||
// Only used if Time is not set.
|
||||
int64 height = 3;
|
||||
|
||||
// Any application specific upgrade info to be included on-chain
|
||||
// such as a git commit that validators could automatically upgrade to
|
||||
string info = 4;
|
||||
}
|
||||
|
||||
// SoftwareUpgradeProposal is a gov Content type for initiating a software upgrade
|
||||
message SoftwareUpgradeProposal {
|
||||
string title = 1;
|
||||
string description = 2;
|
||||
Plan plan = 3 [(gogoproto.nullable) = false];
|
||||
option (gogoproto.equal) = true;
|
||||
|
||||
string title = 1;
|
||||
string description = 2;
|
||||
Plan plan = 3 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
// SoftwareUpgradeProposal is a gov Content type for cancelling a software upgrade
|
||||
// CancelSoftwareUpgradeProposal is a gov Content type for cancelling a software upgrade
|
||||
message CancelSoftwareUpgradeProposal {
|
||||
string title = 1;
|
||||
string description = 2;
|
||||
option (gogoproto.equal) = true;
|
||||
|
||||
string title = 1;
|
||||
string description = 2;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue