feat: implement new gov msg & query servers (#10868)
## Description Ref: #9438 This PR performs the major work of swapping out the v1beta1 msg server and query server for the new one which can process a proposal as an array of messages. This PR still retains the legacy servers which simply wrap around the new ones, providing the same interface as before. In order to keep backwards compatibility, a new msg, `MsgExecLegacyContent` has been created which allows `Content` to become a `Msg` type and still be used as part of the new implementation. --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
This commit is contained in:
+1101
-127
File diff suppressed because it is too large
Load Diff
@@ -24,6 +24,9 @@ const _ = grpc.SupportPackageIsVersion7
|
||||
type MsgClient interface {
|
||||
// SubmitProposal defines a method to create new proposal given a content.
|
||||
SubmitProposal(ctx context.Context, in *MsgSubmitProposal, opts ...grpc.CallOption) (*MsgSubmitProposalResponse, error)
|
||||
// ExecLegacyContent defines a Msg to be in included in a MsgSubmitProposal
|
||||
// to execute a legacy content-based proposal.
|
||||
ExecLegacyContent(ctx context.Context, in *MsgExecLegacyContent, opts ...grpc.CallOption) (*MsgExecLegacyContentResponse, error)
|
||||
// Vote defines a method to add a vote on a specific proposal.
|
||||
Vote(ctx context.Context, in *MsgVote, opts ...grpc.CallOption) (*MsgVoteResponse, error)
|
||||
// VoteWeighted defines a method to add a weighted vote on a specific proposal.
|
||||
@@ -51,6 +54,15 @@ func (c *msgClient) SubmitProposal(ctx context.Context, in *MsgSubmitProposal, o
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *msgClient) ExecLegacyContent(ctx context.Context, in *MsgExecLegacyContent, opts ...grpc.CallOption) (*MsgExecLegacyContentResponse, error) {
|
||||
out := new(MsgExecLegacyContentResponse)
|
||||
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta2.Msg/ExecLegacyContent", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *msgClient) Vote(ctx context.Context, in *MsgVote, opts ...grpc.CallOption) (*MsgVoteResponse, error) {
|
||||
out := new(MsgVoteResponse)
|
||||
err := c.cc.Invoke(ctx, "/cosmos.gov.v1beta2.Msg/Vote", in, out, opts...)
|
||||
@@ -84,6 +96,9 @@ func (c *msgClient) Deposit(ctx context.Context, in *MsgDeposit, opts ...grpc.Ca
|
||||
type MsgServer interface {
|
||||
// SubmitProposal defines a method to create new proposal given a content.
|
||||
SubmitProposal(context.Context, *MsgSubmitProposal) (*MsgSubmitProposalResponse, error)
|
||||
// ExecLegacyContent defines a Msg to be in included in a MsgSubmitProposal
|
||||
// to execute a legacy content-based proposal.
|
||||
ExecLegacyContent(context.Context, *MsgExecLegacyContent) (*MsgExecLegacyContentResponse, error)
|
||||
// Vote defines a method to add a vote on a specific proposal.
|
||||
Vote(context.Context, *MsgVote) (*MsgVoteResponse, error)
|
||||
// VoteWeighted defines a method to add a weighted vote on a specific proposal.
|
||||
@@ -102,6 +117,9 @@ type UnimplementedMsgServer struct {
|
||||
func (UnimplementedMsgServer) SubmitProposal(context.Context, *MsgSubmitProposal) (*MsgSubmitProposalResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SubmitProposal not implemented")
|
||||
}
|
||||
func (UnimplementedMsgServer) ExecLegacyContent(context.Context, *MsgExecLegacyContent) (*MsgExecLegacyContentResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ExecLegacyContent not implemented")
|
||||
}
|
||||
func (UnimplementedMsgServer) Vote(context.Context, *MsgVote) (*MsgVoteResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Vote not implemented")
|
||||
}
|
||||
@@ -142,6 +160,24 @@ func _Msg_SubmitProposal_Handler(srv interface{}, ctx context.Context, dec func(
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Msg_ExecLegacyContent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MsgExecLegacyContent)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MsgServer).ExecLegacyContent(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/cosmos.gov.v1beta2.Msg/ExecLegacyContent",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MsgServer).ExecLegacyContent(ctx, req.(*MsgExecLegacyContent))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Msg_Vote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MsgVote)
|
||||
if err := dec(in); err != nil {
|
||||
@@ -207,6 +243,10 @@ var Msg_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "SubmitProposal",
|
||||
Handler: _Msg_SubmitProposal_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ExecLegacyContent",
|
||||
Handler: _Msg_ExecLegacyContent_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Vote",
|
||||
Handler: _Msg_Vote_Handler,
|
||||
|
||||
Reference in New Issue
Block a user