feat: add tally result grpc endpoint (#11204)
## Description Closes: #11151 --- ### 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:
parent
9ef249cd9e
commit
edef642401
File diff suppressed because it is too large
Load Diff
|
@ -46,6 +46,8 @@ type QueryClient interface {
|
|||
VotesByVoter(ctx context.Context, in *QueryVotesByVoterRequest, opts ...grpc.CallOption) (*QueryVotesByVoterResponse, error)
|
||||
// GroupsByMember queries groups by member address.
|
||||
GroupsByMember(ctx context.Context, in *QueryGroupsByMemberRequest, opts ...grpc.CallOption) (*QueryGroupsByMemberResponse, error)
|
||||
// TallyResult queries the tally of a proposal votes.
|
||||
TallyResult(ctx context.Context, in *QueryTallyResultRequest, opts ...grpc.CallOption) (*QueryTallyResultResponse, error)
|
||||
}
|
||||
|
||||
type queryClient struct {
|
||||
|
@ -164,6 +166,15 @@ func (c *queryClient) GroupsByMember(ctx context.Context, in *QueryGroupsByMembe
|
|||
return out, nil
|
||||
}
|
||||
|
||||
func (c *queryClient) TallyResult(ctx context.Context, in *QueryTallyResultRequest, opts ...grpc.CallOption) (*QueryTallyResultResponse, error) {
|
||||
out := new(QueryTallyResultResponse)
|
||||
err := c.cc.Invoke(ctx, "/cosmos.group.v1beta1.Query/TallyResult", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// QueryServer is the server API for Query service.
|
||||
// All implementations must embed UnimplementedQueryServer
|
||||
// for forward compatibility
|
||||
|
@ -192,6 +203,8 @@ type QueryServer interface {
|
|||
VotesByVoter(context.Context, *QueryVotesByVoterRequest) (*QueryVotesByVoterResponse, error)
|
||||
// GroupsByMember queries groups by member address.
|
||||
GroupsByMember(context.Context, *QueryGroupsByMemberRequest) (*QueryGroupsByMemberResponse, error)
|
||||
// TallyResult queries the tally of a proposal votes.
|
||||
TallyResult(context.Context, *QueryTallyResultRequest) (*QueryTallyResultResponse, error)
|
||||
mustEmbedUnimplementedQueryServer()
|
||||
}
|
||||
|
||||
|
@ -235,6 +248,9 @@ func (UnimplementedQueryServer) VotesByVoter(context.Context, *QueryVotesByVoter
|
|||
func (UnimplementedQueryServer) GroupsByMember(context.Context, *QueryGroupsByMemberRequest) (*QueryGroupsByMemberResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GroupsByMember not implemented")
|
||||
}
|
||||
func (UnimplementedQueryServer) TallyResult(context.Context, *QueryTallyResultRequest) (*QueryTallyResultResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method TallyResult not implemented")
|
||||
}
|
||||
func (UnimplementedQueryServer) mustEmbedUnimplementedQueryServer() {}
|
||||
|
||||
// UnsafeQueryServer may be embedded to opt out of forward compatibility for this service.
|
||||
|
@ -464,6 +480,24 @@ func _Query_GroupsByMember_Handler(srv interface{}, ctx context.Context, dec fun
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Query_TallyResult_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(QueryTallyResultRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(QueryServer).TallyResult(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/cosmos.group.v1beta1.Query/TallyResult",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(QueryServer).TallyResult(ctx, req.(*QueryTallyResultRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Query_ServiceDesc is the grpc.ServiceDesc for Query service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
|
@ -519,6 +553,10 @@ var Query_ServiceDesc = grpc.ServiceDesc{
|
|||
MethodName: "GroupsByMember",
|
||||
Handler: _Query_GroupsByMember_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "TallyResult",
|
||||
Handler: _Query_TallyResult_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cosmos/group/v1beta1/query.proto",
|
||||
|
|
|
@ -2,6 +2,7 @@ syntax = "proto3";
|
|||
|
||||
package cosmos.group.v1beta1;
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "cosmos/group/v1beta1/types.proto";
|
||||
import "cosmos/base/query/v1beta1/pagination.proto";
|
||||
|
@ -71,6 +72,11 @@ service Query {
|
|||
rpc GroupsByMember(QueryGroupsByMemberRequest) returns (QueryGroupsByMemberResponse) {
|
||||
option (google.api.http).get = "/cosmos/group/v1beta1/groups_by_member/{address}";
|
||||
};
|
||||
|
||||
// TallyResult queries the tally of a proposal votes.
|
||||
rpc TallyResult(QueryTallyResultRequest) returns (QueryTallyResultResponse) {
|
||||
option (google.api.http).get = "/cosmos/group/v1beta1/proposals/{proposal_id}/tally";
|
||||
};
|
||||
}
|
||||
|
||||
// QueryGroupInfoRequest is the Query/GroupInfo request type.
|
||||
|
@ -288,3 +294,15 @@ message QueryGroupsByMemberResponse {
|
|||
// pagination defines the pagination in the response.
|
||||
cosmos.base.query.v1beta1.PageResponse pagination = 2;
|
||||
}
|
||||
|
||||
// QueryTallyResultRequest is the Query/TallyResult request type.
|
||||
message QueryTallyResultRequest {
|
||||
// proposal_id is the unique id of a proposal.
|
||||
uint64 proposal_id = 1;
|
||||
}
|
||||
|
||||
// QueryTallyResultResponse is the Query/TallyResult response type.
|
||||
message QueryTallyResultResponse {
|
||||
// tally defines the requested tally.
|
||||
TallyResult tally = 1 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ func QueryCmd(name string) *cobra.Command {
|
|||
QueryVotesByProposalCmd(),
|
||||
QueryVotesByVoterCmd(),
|
||||
QueryGroupsByMemberCmd(),
|
||||
QueryTallyResultCmd(),
|
||||
)
|
||||
|
||||
return queryCmd
|
||||
|
@ -433,6 +434,41 @@ func QueryVotesByProposalCmd() *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
// QueryVotesByProposalCmd creates a CLI command for Query/TallyResult.
|
||||
func QueryTallyResultCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "tally-result [proposal-id]",
|
||||
Short: "Query tally result of proposal",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
proposalID, err := strconv.ParseUint(args[0], 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
queryClient := group.NewQueryClient(clientCtx)
|
||||
|
||||
res, err := queryClient.TallyResult(cmd.Context(), &group.QueryTallyResultRequest{
|
||||
ProposalId: proposalID,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
// QueryVotesByVoterCmd creates a CLI command for Query/VotesByVoter.
|
||||
func QueryVotesByVoterCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
@ -750,3 +751,114 @@ func (s *IntegrationTestSuite) TestQueryVotesByVoter() {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestTallyResult() {
|
||||
val := s.network.Validators[0]
|
||||
clientCtx := val.ClientCtx
|
||||
|
||||
member := s.voter
|
||||
|
||||
var commonFlags = []string{
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||
}
|
||||
|
||||
// create a proposal
|
||||
out, err := cli.ExecTestCLICmd(val.ClientCtx, client.MsgSubmitProposalCmd(),
|
||||
append(
|
||||
[]string{
|
||||
s.createCLIProposal(
|
||||
s.groupPolicies[0].Address, val.Address.String(),
|
||||
s.groupPolicies[0].Address, val.Address.String(),
|
||||
""),
|
||||
},
|
||||
commonFlags...,
|
||||
),
|
||||
)
|
||||
s.Require().NoError(err, out.String())
|
||||
|
||||
var txResp sdk.TxResponse
|
||||
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String())
|
||||
s.Require().Equal(uint32(0), txResp.Code, out.String())
|
||||
proposalId := s.getProposalIdFromTxResponse(txResp)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
expectErr bool
|
||||
expTallyResult group.TallyResult
|
||||
expectErrMsg string
|
||||
expectedCode uint32
|
||||
}{
|
||||
{
|
||||
"not found",
|
||||
[]string{
|
||||
"12345",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
},
|
||||
true,
|
||||
group.TallyResult{},
|
||||
"not found",
|
||||
0,
|
||||
},
|
||||
{
|
||||
"invalid proposal id",
|
||||
[]string{
|
||||
"",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
},
|
||||
true,
|
||||
group.TallyResult{},
|
||||
"strconv.ParseUint: parsing \"\": invalid syntax",
|
||||
0,
|
||||
},
|
||||
{
|
||||
"valid proposal id with no votes",
|
||||
[]string{
|
||||
proposalId,
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
},
|
||||
false,
|
||||
group.DefaultTallyResult(),
|
||||
"",
|
||||
0,
|
||||
},
|
||||
{
|
||||
"valid proposal id",
|
||||
[]string{
|
||||
"1",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
},
|
||||
false,
|
||||
group.TallyResult{
|
||||
YesCount: member.Weight,
|
||||
AbstainCount: "0",
|
||||
NoCount: "0",
|
||||
NoWithVetoCount: "0",
|
||||
},
|
||||
"",
|
||||
0,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
|
||||
s.Run(tc.name, func() {
|
||||
cmd := client.QueryTallyResultCmd()
|
||||
|
||||
out, err := cli.ExecTestCLICmd(clientCtx, cmd, tc.args)
|
||||
if tc.expectErr {
|
||||
s.Require().Contains(out.String(), tc.expectErrMsg)
|
||||
} else {
|
||||
s.Require().NoError(err, out.String())
|
||||
var tallyResultRes group.QueryTallyResultResponse
|
||||
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &tallyResultRes))
|
||||
s.Require().NotNil(tallyResultRes)
|
||||
s.Require().Equal(tc.expTallyResult, tallyResultRes.Tally)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ type IntegrationTestSuite struct {
|
|||
groupPolicies []*group.GroupPolicyInfo
|
||||
proposal *group.Proposal
|
||||
vote *group.Vote
|
||||
voter *group.Member
|
||||
}
|
||||
|
||||
const validMetadata = "metadata"
|
||||
|
@ -78,17 +79,18 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
|||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||
}
|
||||
|
||||
memberWeight := "3"
|
||||
// create a group
|
||||
validMembers := fmt.Sprintf(`
|
||||
{
|
||||
"members": [
|
||||
{
|
||||
"address": "%s",
|
||||
"weight": "3",
|
||||
"weight": "%s",
|
||||
"metadata": "%s"
|
||||
}
|
||||
]
|
||||
}`, val.Address.String(), validMetadata)
|
||||
}`, val.Address.String(), memberWeight, validMetadata)
|
||||
validMembersFile := testutil.WriteToNewTempFile(s.T(), validMembers)
|
||||
out, err := cli.ExecTestCLICmd(val.ClientCtx, client.MsgCreateGroupCmd(),
|
||||
append(
|
||||
|
@ -202,6 +204,12 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
|||
var voteRes group.QueryVoteByProposalVoterResponse
|
||||
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &voteRes))
|
||||
s.vote = voteRes.Vote
|
||||
|
||||
s.voter = &group.Member{
|
||||
Address: val.Address.String(),
|
||||
Weight: memberWeight,
|
||||
Metadata: validMetadata,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TearDownSuite() {
|
||||
|
@ -1657,7 +1665,9 @@ func (s *IntegrationTestSuite) TestTxVote() {
|
|||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||
}
|
||||
|
||||
for i := 0; i < 2; i++ {
|
||||
ids := make([]string, 4)
|
||||
|
||||
for i := 0; i < 4; i++ {
|
||||
out, err := cli.ExecTestCLICmd(val.ClientCtx, client.MsgSubmitProposalCmd(),
|
||||
append(
|
||||
[]string{
|
||||
|
@ -1670,6 +1680,11 @@ func (s *IntegrationTestSuite) TestTxVote() {
|
|||
),
|
||||
)
|
||||
s.Require().NoError(err, out.String())
|
||||
|
||||
var txResp sdk.TxResponse
|
||||
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String())
|
||||
s.Require().Equal(uint32(0), txResp.Code, out.String())
|
||||
ids[i] = s.getProposalIdFromTxResponse(txResp)
|
||||
}
|
||||
|
||||
testCases := []struct {
|
||||
|
@ -1684,7 +1699,7 @@ func (s *IntegrationTestSuite) TestTxVote() {
|
|||
"correct data",
|
||||
append(
|
||||
[]string{
|
||||
"2",
|
||||
ids[0],
|
||||
val.Address.String(),
|
||||
"VOTE_OPTION_YES",
|
||||
"",
|
||||
|
@ -1700,7 +1715,7 @@ func (s *IntegrationTestSuite) TestTxVote() {
|
|||
"with try exec",
|
||||
append(
|
||||
[]string{
|
||||
"7",
|
||||
ids[1],
|
||||
val.Address.String(),
|
||||
"VOTE_OPTION_YES",
|
||||
"",
|
||||
|
@ -1717,7 +1732,7 @@ func (s *IntegrationTestSuite) TestTxVote() {
|
|||
"with try exec, not enough yes votes for proposal to pass",
|
||||
append(
|
||||
[]string{
|
||||
"8",
|
||||
ids[2],
|
||||
val.Address.String(),
|
||||
"VOTE_OPTION_NO",
|
||||
"",
|
||||
|
@ -1734,7 +1749,7 @@ func (s *IntegrationTestSuite) TestTxVote() {
|
|||
"with amino-json",
|
||||
append(
|
||||
[]string{
|
||||
"5",
|
||||
ids[3],
|
||||
val.Address.String(),
|
||||
"VOTE_OPTION_YES",
|
||||
"",
|
||||
|
|
|
@ -305,54 +305,30 @@ func (q Keeper) getVotesByVoter(ctx sdk.Context, voter sdk.AccAddress, pageReque
|
|||
return q.voteByVoterIndex.GetPaginated(ctx.KVStore(q.key), voter.Bytes(), pageRequest)
|
||||
}
|
||||
|
||||
// Tally is a function that tallies a proposal by iterating through its votes,
|
||||
// and returns the tally result without modifying the proposal or any state.
|
||||
// TODO Merge with https://github.com/cosmos/cosmos-sdk/issues/11151
|
||||
func (q Keeper) Tally(ctx sdk.Context, p group.Proposal, groupId uint64) (group.TallyResult, error) {
|
||||
// If proposal has already been tallied and updated, then its status is
|
||||
// closed, in which case we just return the previously stored result.
|
||||
if p.Status == group.PROPOSAL_STATUS_CLOSED {
|
||||
return p.FinalTallyResult, nil
|
||||
}
|
||||
func (q Keeper) TallyResult(goCtx context.Context, request *group.QueryTallyResultRequest) (*group.QueryTallyResultResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
proposalId := request.ProposalId
|
||||
|
||||
it, err := q.voteByProposalIndex.Get(ctx.KVStore(q.key), p.Id)
|
||||
proposal, err := q.getProposal(ctx, proposalId)
|
||||
if err != nil {
|
||||
return group.TallyResult{}, err
|
||||
}
|
||||
defer it.Close()
|
||||
|
||||
tallyResult := group.DefaultTallyResult()
|
||||
|
||||
var vote group.Vote
|
||||
for {
|
||||
_, err = it.LoadNext(&vote)
|
||||
if errors.ErrORMIteratorDone.Is(err) {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
return group.TallyResult{}, err
|
||||
}
|
||||
|
||||
var member group.GroupMember
|
||||
err := q.groupMemberTable.GetOne(ctx.KVStore(q.key), orm.PrimaryKey(&group.GroupMember{
|
||||
GroupId: groupId,
|
||||
Member: &group.Member{Address: vote.Voter},
|
||||
}), &member)
|
||||
|
||||
switch {
|
||||
case sdkerrors.ErrNotFound.Is(err):
|
||||
// If the member left the group after voting, then we simply skip the
|
||||
// vote.
|
||||
continue
|
||||
case err != nil:
|
||||
// For any other errors, we stop and return the error.
|
||||
return group.TallyResult{}, err
|
||||
}
|
||||
|
||||
if err := tallyResult.Add(vote, member.Member.Weight); err != nil {
|
||||
return group.TallyResult{}, sdkerrors.Wrap(err, "add new vote")
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return tallyResult, nil
|
||||
if proposal.Status == group.PROPOSAL_STATUS_WITHDRAWN || proposal.Status == group.PROPOSAL_STATUS_ABORTED {
|
||||
return nil, sdkerrors.Wrapf(errors.ErrInvalid, "can't get the tally of a proposal with status %s", proposal.Status)
|
||||
}
|
||||
|
||||
var policyInfo group.GroupPolicyInfo
|
||||
if policyInfo, err = q.getGroupPolicyInfo(ctx, proposal.Address); err != nil {
|
||||
return nil, sdkerrors.Wrap(err, "load group policy")
|
||||
}
|
||||
|
||||
tallyResult, err := q.Tally(ctx, proposal, policyInfo.GroupId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &group.QueryTallyResultResponse{
|
||||
Tally: tallyResult,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/group"
|
||||
"github.com/cosmos/cosmos-sdk/x/group/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/group/internal/orm"
|
||||
)
|
||||
|
||||
// Tally is a function that tallies a proposal by iterating through its votes,
|
||||
// and returns the tally result without modifying the proposal or any state.
|
||||
func (q Keeper) Tally(ctx sdk.Context, p group.Proposal, groupId uint64) (group.TallyResult, error) {
|
||||
// If proposal has already been tallied and updated, then its status is
|
||||
// closed, in which case we just return the previously stored result.
|
||||
if p.Status == group.PROPOSAL_STATUS_CLOSED {
|
||||
return p.FinalTallyResult, nil
|
||||
}
|
||||
|
||||
it, err := q.voteByProposalIndex.Get(ctx.KVStore(q.key), p.Id)
|
||||
if err != nil {
|
||||
return group.TallyResult{}, err
|
||||
}
|
||||
defer it.Close()
|
||||
|
||||
tallyResult := group.DefaultTallyResult()
|
||||
|
||||
var vote group.Vote
|
||||
for {
|
||||
_, err = it.LoadNext(&vote)
|
||||
if errors.ErrORMIteratorDone.Is(err) {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
return group.TallyResult{}, err
|
||||
}
|
||||
|
||||
var member group.GroupMember
|
||||
err := q.groupMemberTable.GetOne(ctx.KVStore(q.key), orm.PrimaryKey(&group.GroupMember{
|
||||
GroupId: groupId,
|
||||
Member: &group.Member{Address: vote.Voter},
|
||||
}), &member)
|
||||
|
||||
switch {
|
||||
case sdkerrors.ErrNotFound.Is(err):
|
||||
// If the member left the group after voting, then we simply skip the
|
||||
// vote.
|
||||
continue
|
||||
case err != nil:
|
||||
// For any other errors, we stop and return the error.
|
||||
return group.TallyResult{}, err
|
||||
}
|
||||
|
||||
if err := tallyResult.Add(vote, member.Member.Weight); err != nil {
|
||||
return group.TallyResult{}, sdkerrors.Wrap(err, "add new vote")
|
||||
}
|
||||
}
|
||||
|
||||
return tallyResult, nil
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package keeper_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/group"
|
||||
)
|
||||
|
||||
func (s *TestSuite) TestTally() {
|
||||
addrs := s.addrs
|
||||
addr2 := addrs[1]
|
||||
|
||||
msgSend1 := &banktypes.MsgSend{
|
||||
FromAddress: s.groupPolicyAddr.String(),
|
||||
ToAddress: addr2.String(),
|
||||
Amount: sdk.Coins{sdk.NewInt64Coin("test", 100)},
|
||||
}
|
||||
proposers := []string{addr2.String()}
|
||||
|
||||
specs := map[string]struct {
|
||||
srcBlockTime time.Time
|
||||
setupProposal func(ctx context.Context) uint64
|
||||
expErr bool
|
||||
expTallyResult group.TallyResult
|
||||
}{
|
||||
"invalid proposal id": {
|
||||
setupProposal: func(ctx context.Context) uint64 {
|
||||
return 123
|
||||
},
|
||||
expErr: true,
|
||||
},
|
||||
"proposal with no votes": {
|
||||
setupProposal: func(ctx context.Context) uint64 {
|
||||
msgs := []sdk.Msg{msgSend1}
|
||||
return submitProposal(ctx, s, msgs, proposers)
|
||||
},
|
||||
expTallyResult: group.DefaultTallyResult(),
|
||||
},
|
||||
"withdrawn proposal": {
|
||||
setupProposal: func(ctx context.Context) uint64 {
|
||||
msgs := []sdk.Msg{msgSend1}
|
||||
proposalId := submitProposal(ctx, s, msgs, proposers)
|
||||
_, err := s.app.GroupKeeper.WithdrawProposal(ctx, &group.MsgWithdrawProposal{
|
||||
ProposalId: proposalId,
|
||||
Address: proposers[0],
|
||||
})
|
||||
s.Require().NoError(err)
|
||||
|
||||
return proposalId
|
||||
},
|
||||
expErr: true,
|
||||
},
|
||||
"proposal with some votes": {
|
||||
setupProposal: func(ctx context.Context) uint64 {
|
||||
msgs := []sdk.Msg{msgSend1}
|
||||
return submitProposalAndVote(ctx, s, msgs, proposers, group.VOTE_OPTION_YES)
|
||||
},
|
||||
expTallyResult: group.TallyResult{
|
||||
YesCount: "2",
|
||||
NoCount: "0",
|
||||
NoWithVetoCount: "0",
|
||||
AbstainCount: "0",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for msg, spec := range specs {
|
||||
spec := spec
|
||||
s.Run(msg, func() {
|
||||
sdkCtx, _ := s.sdkCtx.CacheContext()
|
||||
ctx := sdk.WrapSDKContext(sdkCtx)
|
||||
|
||||
pId := spec.setupProposal(ctx)
|
||||
req := &group.QueryTallyResultRequest{
|
||||
ProposalId: pId,
|
||||
}
|
||||
|
||||
res, err := s.keeper.TallyResult(ctx, req)
|
||||
if spec.expErr {
|
||||
s.Require().Error(err)
|
||||
} else {
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(res.Tally, spec.expTallyResult)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ import (
|
|||
fmt "fmt"
|
||||
_ "github.com/cosmos/cosmos-proto"
|
||||
query "github.com/cosmos/cosmos-sdk/types/query"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
grpc1 "github.com/gogo/protobuf/grpc"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
_ "google.golang.org/genproto/googleapis/api/annotations"
|
||||
|
@ -1287,6 +1288,98 @@ func (m *QueryGroupsByMemberResponse) GetPagination() *query.PageResponse {
|
|||
return nil
|
||||
}
|
||||
|
||||
// QueryTallyResultRequest is the Query/TallyResult request type.
|
||||
type QueryTallyResultRequest struct {
|
||||
// proposal_id is the unique id of a proposal.
|
||||
ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
|
||||
}
|
||||
|
||||
func (m *QueryTallyResultRequest) Reset() { *m = QueryTallyResultRequest{} }
|
||||
func (m *QueryTallyResultRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*QueryTallyResultRequest) ProtoMessage() {}
|
||||
func (*QueryTallyResultRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ae47912b18757b1a, []int{24}
|
||||
}
|
||||
func (m *QueryTallyResultRequest) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *QueryTallyResultRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_QueryTallyResultRequest.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *QueryTallyResultRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_QueryTallyResultRequest.Merge(m, src)
|
||||
}
|
||||
func (m *QueryTallyResultRequest) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *QueryTallyResultRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_QueryTallyResultRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_QueryTallyResultRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *QueryTallyResultRequest) GetProposalId() uint64 {
|
||||
if m != nil {
|
||||
return m.ProposalId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// QueryTallyResultResponse is the Query/TallyResult response type.
|
||||
type QueryTallyResultResponse struct {
|
||||
// tally defines the requested tally.
|
||||
Tally TallyResult `protobuf:"bytes,1,opt,name=tally,proto3" json:"tally"`
|
||||
}
|
||||
|
||||
func (m *QueryTallyResultResponse) Reset() { *m = QueryTallyResultResponse{} }
|
||||
func (m *QueryTallyResultResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*QueryTallyResultResponse) ProtoMessage() {}
|
||||
func (*QueryTallyResultResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ae47912b18757b1a, []int{25}
|
||||
}
|
||||
func (m *QueryTallyResultResponse) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *QueryTallyResultResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_QueryTallyResultResponse.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *QueryTallyResultResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_QueryTallyResultResponse.Merge(m, src)
|
||||
}
|
||||
func (m *QueryTallyResultResponse) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *QueryTallyResultResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_QueryTallyResultResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_QueryTallyResultResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *QueryTallyResultResponse) GetTally() TallyResult {
|
||||
if m != nil {
|
||||
return m.Tally
|
||||
}
|
||||
return TallyResult{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*QueryGroupInfoRequest)(nil), "cosmos.group.v1beta1.QueryGroupInfoRequest")
|
||||
proto.RegisterType((*QueryGroupInfoResponse)(nil), "cosmos.group.v1beta1.QueryGroupInfoResponse")
|
||||
|
@ -1312,85 +1405,93 @@ func init() {
|
|||
proto.RegisterType((*QueryVotesByVoterResponse)(nil), "cosmos.group.v1beta1.QueryVotesByVoterResponse")
|
||||
proto.RegisterType((*QueryGroupsByMemberRequest)(nil), "cosmos.group.v1beta1.QueryGroupsByMemberRequest")
|
||||
proto.RegisterType((*QueryGroupsByMemberResponse)(nil), "cosmos.group.v1beta1.QueryGroupsByMemberResponse")
|
||||
proto.RegisterType((*QueryTallyResultRequest)(nil), "cosmos.group.v1beta1.QueryTallyResultRequest")
|
||||
proto.RegisterType((*QueryTallyResultResponse)(nil), "cosmos.group.v1beta1.QueryTallyResultResponse")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("cosmos/group/v1beta1/query.proto", fileDescriptor_ae47912b18757b1a) }
|
||||
|
||||
var fileDescriptor_ae47912b18757b1a = []byte{
|
||||
// 1168 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xd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0x2e, 0x5b, 0x8b, 0x65, 0xea, 0x5f, 0x11, 0x98, 0x56,
|
||||
0xd4, 0x47, 0x5e, 0x37, 0x60, 0xac, 0x25, 0x5e, 0x15, 0xc8, 0xec, 0x23, 0x57, 0x26, 0xcb, 0x97,
|
||||
0x53, 0xa8, 0x89, 0xe4, 0x9a, 0xcc, 0xa0, 0x37, 0x15, 0x10, 0x9f, 0xcd, 0x84, 0x28, 0x2a, 0x27,
|
||||
0x30, 0xde, 0x4f, 0x60, 0xf4, 0xab, 0x9d, 0xb5, 0x46, 0xcb, 0x71, 0xa5, 0x48, 0x06, 0x9c, 0xb6,
|
||||
0xc2, 0xe7, 0xcc, 0x6e, 0x8a, 0xb0, 0xa1, 0x29, 0xf7, 0x39, 0x01, 0x4d, 0x85, 0x0a, 0xa5, 0xab,
|
||||
0xc0, 0x19, 0xae, 0x91, 0x54, 0x2e, 0x73, 0x78, 0x31, 0x7c, 0x78, 0xb2, 0xbd, 0x47, 0x60, 0xb6,
|
||||
0x6f, 0x6a, 0x1d, 0xdb, 0xaf, 0x8a, 0xc7, 0xff, 0x71, 0xc4, 0x7e, 0x26, 0x70, 0x39, 0x05, 0x07,
|
||||
0xea, 0xf5, 0x1a, 0x9c, 0x17, 0x40, 0xda, 0x18, 0x80, 0xba, 0xe5, 0xfc, 0x98, 0xce, 0x35, 0xe3,
|
||||
0x8b, 0x0f, 0x4f, 0xc4, 0x4f, 0x8e, 0x11, 0xf1, 0x44, 0x8c, 0xe0, 0x71, 0xca, 0x26, 0x27, 0xf1,
|
||||
0x84, 0x2a, 0x5b, 0x81, 0x29, 0x8e, 0x7d, 0xc3, 0x63, 0x6d, 0xe6, 0x5b, 0x3b, 0x52, 0xcc, 0x19,
|
||||
0x98, 0x6c, 0xe3, 0xab, 0x68, 0x28, 0x41, 0xbe, 0x5a, 0x6f, 0xe8, 0x77, 0xf0, 0x88, 0x89, 0x12,
|
||||
0x91, 0xe8, 0x75, 0x18, 0x97, 0x61, 0xb8, 0x13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ba, 0xcd, 0xab, 0xec, 0x56, 0xd6, 0x77, 0xd0, 0x03, 0x8c, 0x7a, 0xa3, 0xc2, 0xdf, 0x13,
|
||||
0x38, 0x9f, 0x74, 0x22, 0x34, 0xcf, 0xa6, 0x9d, 0xf0, 0x53, 0x5a, 0x69, 0x80, 0x0c, 0x44, 0xbb,
|
||||
0xc2, 0xd1, 0x96, 0xe9, 0x42, 0xd6, 0x3e, 0x2f, 0x0e, 0xa6, 0x68, 0xcc, 0xab, 0x2f, 0xfe, 0x7a,
|
||||
0x50, 0x24, 0xfb, 0x07, 0x45, 0xf2, 0xd7, 0x41, 0x91, 0x7c, 0x70, 0x58, 0x1c, 0xd9, 0x3f, 0x2c,
|
||||
0x8e, 0xfc, 0x79, 0x58, 0x1c, 0x79, 0xf3, 0xa9, 0xa6, 0x13, 0xbc, 0xb5, 0x5b, 0x37, 0xb6, 0x58,
|
||||
0x4b, 0xae, 0x2a, 0xfe, 0xcc, 0xfb, 0x8d, 0xb7, 0xcd, 0x77, 0xc4, 0xa2, 0xf5, 0x33, 0xfc, 0xff,
|
||||
0xa8, 0x8b, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x7f, 0x70, 0x38, 0xb6, 0x08, 0x16, 0x00, 0x00,
|
||||
// 1252 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xdd, 0x6b, 0x1c, 0x55,
|
||||
0x14, 0xcf, 0xad, 0x49, 0x93, 0x9c, 0xf4, 0x03, 0xae, 0xb1, 0x26, 0x63, 0xd9, 0xa4, 0xe3, 0x57,
|
||||
0x69, 0x9a, 0x99, 0x64, 0x63, 0xbe, 0xad, 0x98, 0x45, 0x2c, 0x11, 0x0b, 0xe9, 0x56, 0x84, 0xfa,
|
||||
0x12, 0x66, 0xb3, 0x93, 0x71, 0x70, 0x77, 0xee, 0x76, 0x67, 0x52, 0x5c, 0xc2, 0xb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 0xb7, 0xdd, 0xf2, 0x04, 0x99, 0x26,
|
||||
0x57, 0x07, 0x8b, 0xc3, 0xfc, 0x7b, 0xb3, 0xac, 0xdf, 0x82, 0x4b, 0x9d, 0x3e, 0x7e, 0x8d, 0x79,
|
||||
0xbe, 0x4d, 0x17, 0x60, 0xd0, 0xf5, 0x76, 0x19, 0x77, 0x18, 0xcb, 0x4f, 0x19, 0x2a, 0x3e, 0x8c,
|
||||
0xb6, 0x1b, 0x37, 0xd6, 0x6f, 0xc3, 0x53, 0xed, 0xed, 0xb6, 0x58, 0xc5, 0xdd, 0x69, 0x44, 0x81,
|
||||
0xe4, 0x61, 0xd8, 0x2a, 0x97, 0xeb, 0xb6, 0xef, 0xf3, 0x6d, 0x47, 0x0b, 0x13, 0xbf, 0xfe, 0x30,
|
||||
0x2b, 0x99, 0xde, 0x10, 0xbf, 0xdc, 0x09, 0xea, 0xae, 0xe7, 0x14, 0xa5, 0xa1, 0x7e, 0x17, 0x2e,
|
||||
0xab, 0xb7, 0x44, 0x9c, 0xab, 0x31, 0x9c, 0xcf, 0x26, 0xe0, 0x8c, 0x38, 0x0b, 0xb4, 0x4d, 0x98,
|
||||
0x68, 0x6f, 0x7d, 0xcb, 0xae, 0x96, 0xec, 0xba, 0x9f, 0xce, 0x19, 0x7d, 0x15, 0xa0, 0x5d, 0x96,
|
||||
0x89, 0x33, 0x3c, 0xee, 0x73, 0x32, 0x6e, 0x58, 0x43, 0x43, 0x34, 0x92, 0x0c, 0xbe, 0x65, 0x39,
|
||||
0x36, 0x6e, 0x5b, 0x8c, 0x78, 0xea, 0x5f, 0x11, 0x98, 0x54, 0xc4, 0xc7, 0xbc, 0xd6, 0x61, 0xb8,
|
||||
0x2a, 0x96, 0x26, 0xc8, 0xf4, 0x63, 0x57, 0xc7, 0xf2, 0x57, 0x12, 0x52, 0x13, 0xce, 0x45, 0xe9,
|
||||
0x41, 0x6f, 0x2a, 0x20, 0x3e, 0x9f, 0x0a, 0x51, 0x44, 0x8e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, 0x34, 0x1e, 0xda, 0x0e, 0xfd, 0xab, 0x6f, 0x1d, 0xa6,
|
||||
0x38, 0xda, 0x37, 0x59, 0x60, 0x17, 0x5a, 0x98, 0xc3, 0xaf, 0x7a, 0xd6, 0x52, 0x87, 0x07, 0xeb,
|
||||
0x7e, 0xe8, 0xc0, 0x71, 0x24, 0x1e, 0x2c, 0x6e, 0xa6, 0x17, 0xf1, 0xb0, 0x2a, 0x63, 0x22, 0x3d,
|
||||
0x06, 0x0c, 0x86, 0xc6, 0xd8, 0x21, 0x9a, 0x9a, 0x99, 0xd0, 0xa5, 0xc8, 0xed, 0xf4, 0x0f, 0x08,
|
||||
0xea, 0x89, 0x70, 0xcd, 0x2f, 0xf4, 0xdc, 0xaf, 0x7d, 0xab, 0xff, 0x43, 0x82, 0x2a, 0xe4, 0x04,
|
||||
0x10, 0xcc, 0x6c, 0x4e, 0xb0, 0x25, 0x8b, 0x9e, 0x94, 0x9a, 0x30, 0xec, 0x5f, 0xb1, 0x3f, 0x22,
|
||||
0x28, 0x63, 0x10, 0x5b, 0xac, 0xcc, 0xad, 0x2a, 0x92, 0x4c, 0x55, 0xec, 0x1b, 0x61, 0x1f, 0x4b,
|
||||
0xdd, 0x10, 0x07, 0xf5, 0xff, 0xb3, 0xf5, 0x49, 0xa7, 0x74, 0x40, 0xe9, 0x74, 0x0a, 0x86, 0xcc,
|
||||
0x17, 0x24, 0xaa, 0x9e, 0x23, 0xd0, 0x4e, 0x8d, 0xac, 0x59, 0x83, 0x27, 0x39, 0xc0, 0x37, 0xac,
|
||||
0x4a, 0x25, 0x1c, 0x7a, 0x7b, 0x95, 0x20, 0xf3, 0xd5, 0x71, 0x17, 0xbb, 0x34, 0xe6, 0x8b, 0x99,
|
||||
0xdd, 0x80, 0xa1, 0x20, 0x5c, 0xc6, 0xc1, 0xd0, 0x45, 0xe9, 0x46, 0x3c, 0x0b, 0x83, 0x07, 0x7f,
|
||||
0x4c, 0x0d, 0x14, 0x85, 0x57, 0xfe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 0x2d, 0x71, 0xcc, 0x2b, 0xa4, 0x66, 0xe2, 0x98, 0x57, 0xa9, 0xc0, 0xb4, 0x73, 0xd0, 0x02,
|
||||
0x8c, 0x7c, 0x23, 0xc3, 0xdf, 0x11, 0xb8, 0x10, 0x17, 0x48, 0x34, 0xcb, 0xd0, 0x8e, 0xc9, 0x3c,
|
||||
0x6d, 0xbe, 0x07, 0x0f, 0x44, 0xbb, 0xc2, 0xd1, 0xe6, 0xe9, 0x5c, 0xda, 0x9c, 0x17, 0x17, 0x53,
|
||||
0xa4, 0xcd, 0x1f, 0x11, 0x18, 0x8b, 0x68, 0x17, 0x3a, 0x9b, 0x10, 0xfc, 0xa4, 0xb2, 0xd2, 0x8c,
|
||||
0xac, 0xe6, 0x08, 0x74, 0x9d, 0x03, 0x5d, 0xa4, 0x0b, 0x29, 0x07, 0xb3, 0xa3, 0x83, 0xb9, 0x94,
|
||||
0x2a, 0xbc, 0x74, 0x70, 0x94, 0x23, 0x87, 0x47, 0x39, 0xf2, 0xe7, 0x51, 0x8e, 0x7c, 0x78, 0x9c,
|
||||
0x1b, 0x38, 0x3c, 0xce, 0x0d, 0xfc, 0x7e, 0x9c, 0x1b, 0x78, 0xeb, 0x19, 0xc7, 0x0d, 0xde, 0xde,
|
||||
0x2b, 0x19, 0x3b, 0xac, 0x2a, 0x37, 0x16, 0xff, 0xcc, 0xfa, 0xe5, 0x77, 0xcc, 0x77, 0x45, 0x94,
|
||||
0xd2, 0x59, 0xfe, 0xa7, 0xe8, 0x85, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0xd5, 0xf2, 0x99, 0x66,
|
||||
0x61, 0x17, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
|
@ -1429,6 +1530,8 @@ type QueryClient interface {
|
|||
VotesByVoter(ctx context.Context, in *QueryVotesByVoterRequest, opts ...grpc.CallOption) (*QueryVotesByVoterResponse, error)
|
||||
// GroupsByMember queries groups by member address.
|
||||
GroupsByMember(ctx context.Context, in *QueryGroupsByMemberRequest, opts ...grpc.CallOption) (*QueryGroupsByMemberResponse, error)
|
||||
// TallyResult queries the tally of a proposal votes.
|
||||
TallyResult(ctx context.Context, in *QueryTallyResultRequest, opts ...grpc.CallOption) (*QueryTallyResultResponse, error)
|
||||
}
|
||||
|
||||
type queryClient struct {
|
||||
|
@ -1547,6 +1650,15 @@ func (c *queryClient) GroupsByMember(ctx context.Context, in *QueryGroupsByMembe
|
|||
return out, nil
|
||||
}
|
||||
|
||||
func (c *queryClient) TallyResult(ctx context.Context, in *QueryTallyResultRequest, opts ...grpc.CallOption) (*QueryTallyResultResponse, error) {
|
||||
out := new(QueryTallyResultResponse)
|
||||
err := c.cc.Invoke(ctx, "/cosmos.group.v1beta1.Query/TallyResult", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// QueryServer is the server API for Query service.
|
||||
type QueryServer interface {
|
||||
// GroupInfo queries group info based on group id.
|
||||
|
@ -1573,6 +1685,8 @@ type QueryServer interface {
|
|||
VotesByVoter(context.Context, *QueryVotesByVoterRequest) (*QueryVotesByVoterResponse, error)
|
||||
// GroupsByMember queries groups by member address.
|
||||
GroupsByMember(context.Context, *QueryGroupsByMemberRequest) (*QueryGroupsByMemberResponse, error)
|
||||
// TallyResult queries the tally of a proposal votes.
|
||||
TallyResult(context.Context, *QueryTallyResultRequest) (*QueryTallyResultResponse, error)
|
||||
}
|
||||
|
||||
// UnimplementedQueryServer can be embedded to have forward compatible implementations.
|
||||
|
@ -1615,6 +1729,9 @@ func (*UnimplementedQueryServer) VotesByVoter(ctx context.Context, req *QueryVot
|
|||
func (*UnimplementedQueryServer) GroupsByMember(ctx context.Context, req *QueryGroupsByMemberRequest) (*QueryGroupsByMemberResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GroupsByMember not implemented")
|
||||
}
|
||||
func (*UnimplementedQueryServer) TallyResult(ctx context.Context, req *QueryTallyResultRequest) (*QueryTallyResultResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method TallyResult not implemented")
|
||||
}
|
||||
|
||||
func RegisterQueryServer(s grpc1.Server, srv QueryServer) {
|
||||
s.RegisterService(&_Query_serviceDesc, srv)
|
||||
|
@ -1836,6 +1953,24 @@ func _Query_GroupsByMember_Handler(srv interface{}, ctx context.Context, dec fun
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Query_TallyResult_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(QueryTallyResultRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(QueryServer).TallyResult(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/cosmos.group.v1beta1.Query/TallyResult",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(QueryServer).TallyResult(ctx, req.(*QueryTallyResultRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _Query_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "cosmos.group.v1beta1.Query",
|
||||
HandlerType: (*QueryServer)(nil),
|
||||
|
@ -1888,6 +2023,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{
|
|||
MethodName: "GroupsByMember",
|
||||
Handler: _Query_GroupsByMember_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "TallyResult",
|
||||
Handler: _Query_TallyResult_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "cosmos/group/v1beta1/query.proto",
|
||||
|
@ -2876,6 +3015,67 @@ func (m *QueryGroupsByMemberResponse) MarshalToSizedBuffer(dAtA []byte) (int, er
|
|||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *QueryTallyResultRequest) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *QueryTallyResultRequest) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *QueryTallyResultRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if m.ProposalId != 0 {
|
||||
i = encodeVarintQuery(dAtA, i, uint64(m.ProposalId))
|
||||
i--
|
||||
dAtA[i] = 0x8
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *QueryTallyResultResponse) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *QueryTallyResultResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *QueryTallyResultResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
{
|
||||
size, err := m.Tally.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintQuery(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintQuery(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovQuery(v)
|
||||
base := offset
|
||||
|
@ -3277,6 +3477,29 @@ func (m *QueryGroupsByMemberResponse) Size() (n int) {
|
|||
return n
|
||||
}
|
||||
|
||||
func (m *QueryTallyResultRequest) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if m.ProposalId != 0 {
|
||||
n += 1 + sovQuery(uint64(m.ProposalId))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *QueryTallyResultResponse) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = m.Tally.Size()
|
||||
n += 1 + l + sovQuery(uint64(l))
|
||||
return n
|
||||
}
|
||||
|
||||
func sovQuery(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
|
@ -5813,6 +6036,158 @@ func (m *QueryGroupsByMemberResponse) Unmarshal(dAtA []byte) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
func (m *QueryTallyResultRequest) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: QueryTallyResultRequest: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: QueryTallyResultRequest: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field ProposalId", wireType)
|
||||
}
|
||||
m.ProposalId = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.ProposalId |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipQuery(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *QueryTallyResultResponse) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: QueryTallyResultResponse: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: QueryTallyResultResponse: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Tally", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if err := m.Tally.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipQuery(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipQuery(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
|
|
|
@ -845,6 +845,60 @@ func local_request_Query_GroupsByMember_0(ctx context.Context, marshaler runtime
|
|||
|
||||
}
|
||||
|
||||
func request_Query_TallyResult_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryTallyResultRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["proposal_id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "proposal_id")
|
||||
}
|
||||
|
||||
protoReq.ProposalId, err = runtime.Uint64(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "proposal_id", err)
|
||||
}
|
||||
|
||||
msg, err := client.TallyResult(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_TallyResult_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryTallyResultRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["proposal_id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "proposal_id")
|
||||
}
|
||||
|
||||
protoReq.ProposalId, err = runtime.Uint64(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "proposal_id", err)
|
||||
}
|
||||
|
||||
msg, err := server.TallyResult(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
|
||||
// UnaryRPC :call QueryServer directly.
|
||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||
|
@ -1091,6 +1145,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
|
|||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_TallyResult_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_TallyResult_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_TallyResult_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -1372,6 +1446,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
|||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_TallyResult_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_TallyResult_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_TallyResult_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -1399,6 +1493,8 @@ var (
|
|||
pattern_Query_VotesByVoter_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "group", "v1beta1", "votes_by_voter", "voter"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_GroupsByMember_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "group", "v1beta1", "groups_by_member", "address"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Query_TallyResult_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"cosmos", "group", "v1beta1", "proposals", "proposal_id", "tally"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -1425,4 +1521,6 @@ var (
|
|||
forward_Query_VotesByVoter_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_GroupsByMember_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_TallyResult_0 = runtime.ForwardResponseMessage
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue