parent
c8c0a22721
commit
35522022d4
|
@ -12878,7 +12878,7 @@ type QueryGroupInfoResponse struct {
|
|||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// info is the GroupInfo for the group.
|
||||
// info is the GroupInfo of the group.
|
||||
Info *GroupInfo `protobuf:"bytes,1,opt,name=info,proto3" json:"info,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -12952,7 +12952,7 @@ type QueryGroupPolicyInfoResponse struct {
|
|||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// info is the GroupPolicyInfo for the group policy.
|
||||
// info is the GroupPolicyInfo of the group policy.
|
||||
Info *GroupPolicyInfo `protobuf:"bytes,1,opt,name=info,proto3" json:"info,omitempty"`
|
||||
}
|
||||
|
||||
|
|
|
@ -26,13 +26,13 @@ type QueryClient interface {
|
|||
GroupInfo(ctx context.Context, in *QueryGroupInfoRequest, opts ...grpc.CallOption) (*QueryGroupInfoResponse, error)
|
||||
// GroupPolicyInfo queries group policy info based on account address of group policy.
|
||||
GroupPolicyInfo(ctx context.Context, in *QueryGroupPolicyInfoRequest, opts ...grpc.CallOption) (*QueryGroupPolicyInfoResponse, error)
|
||||
// GroupMembers queries members of a group
|
||||
// GroupMembers queries members of a group by group id.
|
||||
GroupMembers(ctx context.Context, in *QueryGroupMembersRequest, opts ...grpc.CallOption) (*QueryGroupMembersResponse, error)
|
||||
// GroupsByAdmin queries groups by admin address.
|
||||
GroupsByAdmin(ctx context.Context, in *QueryGroupsByAdminRequest, opts ...grpc.CallOption) (*QueryGroupsByAdminResponse, error)
|
||||
// GroupPoliciesByGroup queries group policies by group id.
|
||||
GroupPoliciesByGroup(ctx context.Context, in *QueryGroupPoliciesByGroupRequest, opts ...grpc.CallOption) (*QueryGroupPoliciesByGroupResponse, error)
|
||||
// GroupsByAdmin queries group policies by admin address.
|
||||
// GroupPoliciesByAdmin queries group policies by admin address.
|
||||
GroupPoliciesByAdmin(ctx context.Context, in *QueryGroupPoliciesByAdminRequest, opts ...grpc.CallOption) (*QueryGroupPoliciesByAdminResponse, error)
|
||||
// Proposal queries a proposal based on proposal id.
|
||||
Proposal(ctx context.Context, in *QueryProposalRequest, opts ...grpc.CallOption) (*QueryProposalResponse, error)
|
||||
|
@ -40,7 +40,7 @@ type QueryClient interface {
|
|||
ProposalsByGroupPolicy(ctx context.Context, in *QueryProposalsByGroupPolicyRequest, opts ...grpc.CallOption) (*QueryProposalsByGroupPolicyResponse, error)
|
||||
// VoteByProposalVoter queries a vote by proposal id and voter.
|
||||
VoteByProposalVoter(ctx context.Context, in *QueryVoteByProposalVoterRequest, opts ...grpc.CallOption) (*QueryVoteByProposalVoterResponse, error)
|
||||
// VotesByProposal queries a vote by proposal.
|
||||
// VotesByProposal queries a vote by proposal id.
|
||||
VotesByProposal(ctx context.Context, in *QueryVotesByProposalRequest, opts ...grpc.CallOption) (*QueryVotesByProposalResponse, error)
|
||||
// VotesByVoter queries a vote by voter.
|
||||
VotesByVoter(ctx context.Context, in *QueryVotesByVoterRequest, opts ...grpc.CallOption) (*QueryVotesByVoterResponse, error)
|
||||
|
@ -187,13 +187,13 @@ type QueryServer interface {
|
|||
GroupInfo(context.Context, *QueryGroupInfoRequest) (*QueryGroupInfoResponse, error)
|
||||
// GroupPolicyInfo queries group policy info based on account address of group policy.
|
||||
GroupPolicyInfo(context.Context, *QueryGroupPolicyInfoRequest) (*QueryGroupPolicyInfoResponse, error)
|
||||
// GroupMembers queries members of a group
|
||||
// GroupMembers queries members of a group by group id.
|
||||
GroupMembers(context.Context, *QueryGroupMembersRequest) (*QueryGroupMembersResponse, error)
|
||||
// GroupsByAdmin queries groups by admin address.
|
||||
GroupsByAdmin(context.Context, *QueryGroupsByAdminRequest) (*QueryGroupsByAdminResponse, error)
|
||||
// GroupPoliciesByGroup queries group policies by group id.
|
||||
GroupPoliciesByGroup(context.Context, *QueryGroupPoliciesByGroupRequest) (*QueryGroupPoliciesByGroupResponse, error)
|
||||
// GroupsByAdmin queries group policies by admin address.
|
||||
// GroupPoliciesByAdmin queries group policies by admin address.
|
||||
GroupPoliciesByAdmin(context.Context, *QueryGroupPoliciesByAdminRequest) (*QueryGroupPoliciesByAdminResponse, error)
|
||||
// Proposal queries a proposal based on proposal id.
|
||||
Proposal(context.Context, *QueryProposalRequest) (*QueryProposalResponse, error)
|
||||
|
@ -201,7 +201,7 @@ type QueryServer interface {
|
|||
ProposalsByGroupPolicy(context.Context, *QueryProposalsByGroupPolicyRequest) (*QueryProposalsByGroupPolicyResponse, error)
|
||||
// VoteByProposalVoter queries a vote by proposal id and voter.
|
||||
VoteByProposalVoter(context.Context, *QueryVoteByProposalVoterRequest) (*QueryVoteByProposalVoterResponse, error)
|
||||
// VotesByProposal queries a vote by proposal.
|
||||
// VotesByProposal queries a vote by proposal id.
|
||||
VotesByProposal(context.Context, *QueryVotesByProposalRequest) (*QueryVotesByProposalResponse, error)
|
||||
// VotesByVoter queries a vote by voter.
|
||||
VotesByVoter(context.Context, *QueryVotesByVoterRequest) (*QueryVotesByVoterResponse, error)
|
||||
|
|
|
@ -14339,7 +14339,7 @@ type MsgUpdateGroupPolicyMetadata struct {
|
|||
Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"`
|
||||
// group_policy_address is the account address of group policy.
|
||||
GroupPolicyAddress string `protobuf:"bytes,2,opt,name=group_policy_address,json=groupPolicyAddress,proto3" json:"group_policy_address,omitempty"`
|
||||
// metadata is the updated group policy metadata.
|
||||
// metadata is the group policy metadata to be updated.
|
||||
Metadata string `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -14422,7 +14422,7 @@ type MsgSubmitProposal struct {
|
|||
// proposers are the account addresses of the proposers.
|
||||
// Proposers signatures will be counted as yes votes.
|
||||
Proposers []string `protobuf:"bytes,2,rep,name=proposers,proto3" json:"proposers,omitempty"`
|
||||
// metadata is any arbitrary metadata to attached to the proposal.
|
||||
// metadata is any arbitrary metadata attached to the proposal.
|
||||
Metadata string `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||
// messages is a list of `sdk.Msg`s that will be executed if the proposal passes.
|
||||
Messages []*anypb.Any `protobuf:"bytes,4,rep,name=messages,proto3" json:"messages,omitempty"`
|
||||
|
@ -14609,7 +14609,7 @@ type MsgVote struct {
|
|||
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
|
||||
// option is the voter's choice on the proposal.
|
||||
Option VoteOption `protobuf:"varint,3,opt,name=option,proto3,enum=cosmos.group.v1.VoteOption" json:"option,omitempty"`
|
||||
// metadata is any arbitrary metadata to attached to the vote.
|
||||
// metadata is any arbitrary metadata attached to the vote.
|
||||
Metadata string `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||
// exec defines whether the proposal should be executed
|
||||
// immediately after voting or not.
|
||||
|
|
|
@ -7534,7 +7534,7 @@ func (x *MemberRequest) GetMetadata() string {
|
|||
|
||||
// ThresholdDecisionPolicy is a decision policy where a proposal passes when it
|
||||
// satisfies the two following conditions:
|
||||
// 1. The sum of all `YES` voters' weights is greater or equal than the defined
|
||||
// 1. The sum of all `YES` voter's weights is greater or equal than the defined
|
||||
// `threshold`.
|
||||
// 2. The voting and execution periods of the proposal respect the parameters
|
||||
// given by `windows`.
|
||||
|
@ -7595,7 +7595,7 @@ type PercentageDecisionPolicy struct {
|
|||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// percentage is the minimum percentage the weighted sum of `YES` votes must
|
||||
// percentage is the minimum percentage of the weighted sum of `YES` votes must
|
||||
// meet for a proposal to succeed.
|
||||
Percentage string `protobuf:"bytes,1,opt,name=percentage,proto3" json:"percentage,omitempty"`
|
||||
// windows defines the different windows for voting and execution.
|
||||
|
@ -7836,7 +7836,7 @@ type GroupPolicyInfo struct {
|
|||
GroupId uint64 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"`
|
||||
// admin is the account address of the group admin.
|
||||
Admin string `protobuf:"bytes,3,opt,name=admin,proto3" json:"admin,omitempty"`
|
||||
// metadata is any arbitrary metadata to attached to the group policy.
|
||||
// metadata is any arbitrary metadata attached to the group policy.
|
||||
Metadata string `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||
// version is used to track changes to a group's GroupPolicyInfo structure that
|
||||
// would create a different result on a running proposal.
|
||||
|
@ -7929,7 +7929,7 @@ type Proposal struct {
|
|||
Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
// group_policy_address is the account address of group policy.
|
||||
GroupPolicyAddress string `protobuf:"bytes,2,opt,name=group_policy_address,json=groupPolicyAddress,proto3" json:"group_policy_address,omitempty"`
|
||||
// metadata is any arbitrary metadata to attached to the proposal.
|
||||
// metadata is any arbitrary metadata attached to the proposal.
|
||||
Metadata string `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||
// proposers are the account addresses of the proposers.
|
||||
Proposers []string `protobuf:"bytes,4,rep,name=proposers,proto3" json:"proposers,omitempty"`
|
||||
|
@ -8142,7 +8142,7 @@ type Vote struct {
|
|||
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
|
||||
// option is the voter's choice on the proposal.
|
||||
Option VoteOption `protobuf:"varint,3,opt,name=option,proto3,enum=cosmos.group.v1.VoteOption" json:"option,omitempty"`
|
||||
// metadata is any arbitrary metadata to attached to the vote.
|
||||
// metadata is any arbitrary metadata attached to the vote.
|
||||
Metadata string `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||
// submit_time is the timestamp when the vote was submitted.
|
||||
SubmitTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=submit_time,json=submitTime,proto3" json:"submit_time,omitempty"`
|
||||
|
|
|
@ -25,7 +25,7 @@ service Query {
|
|||
option (google.api.http).get = "/cosmos/group/v1/group_policy_info/{address}";
|
||||
};
|
||||
|
||||
// GroupMembers queries members of a group
|
||||
// GroupMembers queries members of a group by group id.
|
||||
rpc GroupMembers(QueryGroupMembersRequest) returns (QueryGroupMembersResponse) {
|
||||
option (google.api.http).get = "/cosmos/group/v1/group_members/{group_id}";
|
||||
};
|
||||
|
@ -40,7 +40,7 @@ service Query {
|
|||
option (google.api.http).get = "/cosmos/group/v1/group_policies_by_group/{group_id}";
|
||||
};
|
||||
|
||||
// GroupsByAdmin queries group policies by admin address.
|
||||
// GroupPoliciesByAdmin queries group policies by admin address.
|
||||
rpc GroupPoliciesByAdmin(QueryGroupPoliciesByAdminRequest) returns (QueryGroupPoliciesByAdminResponse) {
|
||||
option (google.api.http).get = "/cosmos/group/v1/group_policies_by_admin/{admin}";
|
||||
};
|
||||
|
@ -60,7 +60,7 @@ service Query {
|
|||
option (google.api.http).get = "/cosmos/group/v1/vote_by_proposal_voter/{proposal_id}/{voter}";
|
||||
};
|
||||
|
||||
// VotesByProposal queries a vote by proposal.
|
||||
// VotesByProposal queries a vote by proposal id.
|
||||
rpc VotesByProposal(QueryVotesByProposalRequest) returns (QueryVotesByProposalResponse) {
|
||||
option (google.api.http).get = "/cosmos/group/v1/votes_by_proposal/{proposal_id}";
|
||||
};
|
||||
|
@ -87,35 +87,30 @@ service Query {
|
|||
|
||||
// QueryGroupInfoRequest is the Query/GroupInfo request type.
|
||||
message QueryGroupInfoRequest {
|
||||
|
||||
// group_id is the unique ID of the group.
|
||||
uint64 group_id = 1;
|
||||
}
|
||||
|
||||
// QueryGroupInfoResponse is the Query/GroupInfo response type.
|
||||
message QueryGroupInfoResponse {
|
||||
|
||||
// info is the GroupInfo for the group.
|
||||
// info is the GroupInfo of the group.
|
||||
GroupInfo info = 1;
|
||||
}
|
||||
|
||||
// QueryGroupPolicyInfoRequest is the Query/GroupPolicyInfo request type.
|
||||
message QueryGroupPolicyInfoRequest {
|
||||
|
||||
// address is the account address of the group policy.
|
||||
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
}
|
||||
|
||||
// QueryGroupPolicyInfoResponse is the Query/GroupPolicyInfo response type.
|
||||
message QueryGroupPolicyInfoResponse {
|
||||
|
||||
// info is the GroupPolicyInfo for the group policy.
|
||||
// info is the GroupPolicyInfo of the group policy.
|
||||
GroupPolicyInfo info = 1;
|
||||
}
|
||||
|
||||
// QueryGroupMembersRequest is the Query/GroupMembers request type.
|
||||
message QueryGroupMembersRequest {
|
||||
|
||||
// group_id is the unique ID of the group.
|
||||
uint64 group_id = 1;
|
||||
|
||||
|
@ -125,7 +120,6 @@ message QueryGroupMembersRequest {
|
|||
|
||||
// QueryGroupMembersResponse is the Query/GroupMembersResponse response type.
|
||||
message QueryGroupMembersResponse {
|
||||
|
||||
// members are the members of the group with given group_id.
|
||||
repeated GroupMember members = 1;
|
||||
|
||||
|
@ -135,7 +129,6 @@ message QueryGroupMembersResponse {
|
|||
|
||||
// QueryGroupsByAdminRequest is the Query/GroupsByAdmin request type.
|
||||
message QueryGroupsByAdminRequest {
|
||||
|
||||
// admin is the account address of a group's admin.
|
||||
string admin = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
|
||||
|
@ -145,7 +138,6 @@ message QueryGroupsByAdminRequest {
|
|||
|
||||
// QueryGroupsByAdminResponse is the Query/GroupsByAdminResponse response type.
|
||||
message QueryGroupsByAdminResponse {
|
||||
|
||||
// groups are the groups info with the provided admin.
|
||||
repeated GroupInfo groups = 1;
|
||||
|
||||
|
@ -155,7 +147,6 @@ message QueryGroupsByAdminResponse {
|
|||
|
||||
// QueryGroupPoliciesByGroupRequest is the Query/GroupPoliciesByGroup request type.
|
||||
message QueryGroupPoliciesByGroupRequest {
|
||||
|
||||
// group_id is the unique ID of the group policy's group.
|
||||
uint64 group_id = 1;
|
||||
|
||||
|
@ -165,7 +156,6 @@ message QueryGroupPoliciesByGroupRequest {
|
|||
|
||||
// QueryGroupPoliciesByGroupResponse is the Query/GroupPoliciesByGroup response type.
|
||||
message QueryGroupPoliciesByGroupResponse {
|
||||
|
||||
// group_policies are the group policies info associated with the provided group.
|
||||
repeated GroupPolicyInfo group_policies = 1;
|
||||
|
||||
|
@ -175,7 +165,6 @@ message QueryGroupPoliciesByGroupResponse {
|
|||
|
||||
// QueryGroupPoliciesByAdminRequest is the Query/GroupPoliciesByAdmin request type.
|
||||
message QueryGroupPoliciesByAdminRequest {
|
||||
|
||||
// admin is the admin address of the group policy.
|
||||
string admin = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
|
||||
|
@ -185,7 +174,6 @@ message QueryGroupPoliciesByAdminRequest {
|
|||
|
||||
// QueryGroupPoliciesByAdminResponse is the Query/GroupPoliciesByAdmin response type.
|
||||
message QueryGroupPoliciesByAdminResponse {
|
||||
|
||||
// group_policies are the group policies info with provided admin.
|
||||
repeated GroupPolicyInfo group_policies = 1;
|
||||
|
||||
|
@ -195,21 +183,18 @@ message QueryGroupPoliciesByAdminResponse {
|
|||
|
||||
// QueryProposalRequest is the Query/Proposal request type.
|
||||
message QueryProposalRequest {
|
||||
|
||||
// proposal_id is the unique ID of a proposal.
|
||||
uint64 proposal_id = 1;
|
||||
}
|
||||
|
||||
// QueryProposalResponse is the Query/Proposal response type.
|
||||
message QueryProposalResponse {
|
||||
|
||||
// proposal is the proposal info.
|
||||
Proposal proposal = 1;
|
||||
}
|
||||
|
||||
// QueryProposalsByGroupPolicyRequest is the Query/ProposalByGroupPolicy request type.
|
||||
message QueryProposalsByGroupPolicyRequest {
|
||||
|
||||
// address is the account address of the group policy related to proposals.
|
||||
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
|
||||
|
@ -219,7 +204,6 @@ message QueryProposalsByGroupPolicyRequest {
|
|||
|
||||
// QueryProposalsByGroupPolicyResponse is the Query/ProposalByGroupPolicy response type.
|
||||
message QueryProposalsByGroupPolicyResponse {
|
||||
|
||||
// proposals are the proposals with given group policy.
|
||||
repeated Proposal proposals = 1;
|
||||
|
||||
|
@ -229,7 +213,6 @@ message QueryProposalsByGroupPolicyResponse {
|
|||
|
||||
// QueryVoteByProposalVoterRequest is the Query/VoteByProposalVoter request type.
|
||||
message QueryVoteByProposalVoterRequest {
|
||||
|
||||
// proposal_id is the unique ID of a proposal.
|
||||
uint64 proposal_id = 1;
|
||||
|
||||
|
@ -239,14 +222,12 @@ message QueryVoteByProposalVoterRequest {
|
|||
|
||||
// QueryVoteByProposalVoterResponse is the Query/VoteByProposalVoter response type.
|
||||
message QueryVoteByProposalVoterResponse {
|
||||
|
||||
// vote is the vote with given proposal_id and voter.
|
||||
Vote vote = 1;
|
||||
}
|
||||
|
||||
// QueryVotesByProposalRequest is the Query/VotesByProposal request type.
|
||||
message QueryVotesByProposalRequest {
|
||||
|
||||
// proposal_id is the unique ID of a proposal.
|
||||
uint64 proposal_id = 1;
|
||||
|
||||
|
@ -256,7 +237,6 @@ message QueryVotesByProposalRequest {
|
|||
|
||||
// QueryVotesByProposalResponse is the Query/VotesByProposal response type.
|
||||
message QueryVotesByProposalResponse {
|
||||
|
||||
// votes are the list of votes for given proposal_id.
|
||||
repeated Vote votes = 1;
|
||||
|
||||
|
@ -275,7 +255,6 @@ message QueryVotesByVoterRequest {
|
|||
|
||||
// QueryVotesByVoterResponse is the Query/VotesByVoter response type.
|
||||
message QueryVotesByVoterResponse {
|
||||
|
||||
// votes are the list of votes by given voter.
|
||||
repeated Vote votes = 1;
|
||||
|
||||
|
|
|
@ -257,7 +257,7 @@ message MsgUpdateGroupPolicyMetadata {
|
|||
// group_policy_address is the account address of group policy.
|
||||
string group_policy_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
|
||||
// metadata is the updated group policy metadata.
|
||||
// metadata is the group policy metadata to be updated.
|
||||
string metadata = 3;
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,7 @@ message MsgSubmitProposal {
|
|||
// Proposers signatures will be counted as yes votes.
|
||||
repeated string proposers = 2;
|
||||
|
||||
// metadata is any arbitrary metadata to attached to the proposal.
|
||||
// metadata is any arbitrary metadata attached to the proposal.
|
||||
string metadata = 3;
|
||||
|
||||
// messages is a list of `sdk.Msg`s that will be executed if the proposal passes.
|
||||
|
@ -337,13 +337,14 @@ message MsgVote {
|
|||
|
||||
// proposal is the unique ID of the proposal.
|
||||
uint64 proposal_id = 1;
|
||||
|
||||
// voter is the voter account address.
|
||||
string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
|
||||
// option is the voter's choice on the proposal.
|
||||
VoteOption option = 3;
|
||||
|
||||
// metadata is any arbitrary metadata to attached to the vote.
|
||||
// metadata is any arbitrary metadata attached to the vote.
|
||||
string metadata = 4;
|
||||
|
||||
// exec defines whether the proposal should be executed
|
||||
|
|
|
@ -47,7 +47,7 @@ message MemberRequest {
|
|||
|
||||
// ThresholdDecisionPolicy is a decision policy where a proposal passes when it
|
||||
// satisfies the two following conditions:
|
||||
// 1. The sum of all `YES` voters' weights is greater or equal than the defined
|
||||
// 1. The sum of all `YES` voter's weights is greater or equal than the defined
|
||||
// `threshold`.
|
||||
// 2. The voting and execution periods of the proposal respect the parameters
|
||||
// given by `windows`.
|
||||
|
@ -73,7 +73,7 @@ message PercentageDecisionPolicy {
|
|||
option (cosmos_proto.implements_interface) = "DecisionPolicy";
|
||||
option (amino.name) = "cosmos-sdk/PercentageDecisionPolicy";
|
||||
|
||||
// percentage is the minimum percentage the weighted sum of `YES` votes must
|
||||
// percentage is the minimum percentage of the weighted sum of `YES` votes must
|
||||
// meet for a proposal to succeed.
|
||||
string percentage = 1;
|
||||
|
||||
|
@ -174,7 +174,7 @@ message GroupPolicyInfo {
|
|||
// admin is the account address of the group admin.
|
||||
string admin = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
|
||||
// metadata is any arbitrary metadata to attached to the group policy.
|
||||
// metadata is any arbitrary metadata attached to the group policy.
|
||||
string metadata = 4;
|
||||
|
||||
// version is used to track changes to a group's GroupPolicyInfo structure that
|
||||
|
@ -202,7 +202,7 @@ message Proposal {
|
|||
// group_policy_address is the account address of group policy.
|
||||
string group_policy_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
|
||||
// metadata is any arbitrary metadata to attached to the proposal.
|
||||
// metadata is any arbitrary metadata attached to the proposal.
|
||||
string metadata = 3;
|
||||
|
||||
// proposers are the account addresses of the proposers.
|
||||
|
@ -319,7 +319,7 @@ message Vote {
|
|||
// option is the voter's choice on the proposal.
|
||||
VoteOption option = 3;
|
||||
|
||||
// metadata is any arbitrary metadata to attached to the vote.
|
||||
// metadata is any arbitrary metadata attached to the vote.
|
||||
string metadata = 4;
|
||||
|
||||
// submit_time is the timestamp when the vote was submitted.
|
||||
|
|
|
@ -6,14 +6,15 @@ import (
|
|||
"os"
|
||||
"sort"
|
||||
|
||||
"github.com/manifoldco/promptui"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
"github.com/manifoldco/promptui"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -28,7 +29,7 @@ type proposalType struct {
|
|||
Msg sdk.Msg
|
||||
}
|
||||
|
||||
// Prompt the proposal type values and return the proposal and its metadata
|
||||
// Prompt the proposal type values and return the proposal and its metadata.
|
||||
func (p *proposalType) Prompt(cdc codec.Codec) (*Proposal, govtypes.ProposalMetadata, error) {
|
||||
proposal := &Proposal{}
|
||||
|
||||
|
@ -146,6 +147,7 @@ func NewCmdDraftProposal() *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
// writeFile writes the input to the file.
|
||||
func writeFile(fileName string, input any) error {
|
||||
raw, err := json.MarshalIndent(input, "", " ")
|
||||
if err != nil {
|
||||
|
|
|
@ -3,10 +3,11 @@ package cli
|
|||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/x/group"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// QueryCmd returns the cli query commands for the group module.
|
||||
|
@ -434,7 +435,7 @@ func QueryVotesByProposalCmd() *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
// QueryVotesByProposalCmd creates a CLI command for Query/TallyResult.
|
||||
// QueryTallyResultCmd creates a CLI command for Query/TallyResult.
|
||||
func QueryTallyResultCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "tally-result [proposal-id]",
|
||||
|
|
|
@ -0,0 +1,513 @@
|
|||
package cli_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/group/client/cli"
|
||||
)
|
||||
|
||||
func (s *CLITestSuite) TestQueryGroupInfo() {
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
expCmdOutput string
|
||||
}{
|
||||
{
|
||||
name: "invalid id",
|
||||
args: []string{"invalid id"},
|
||||
expCmdOutput: `[invalid id]`,
|
||||
},
|
||||
{
|
||||
name: "json output",
|
||||
args: []string{"1", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
expCmdOutput: `[1 --output=json]`,
|
||||
},
|
||||
{
|
||||
name: "text output",
|
||||
args: []string{"1", fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
expCmdOutput: `[1 --output=text]`,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
cmd := cli.QueryGroupInfoCmd()
|
||||
|
||||
ctx := svrcmd.CreateExecuteContext(context.Background())
|
||||
|
||||
cmd.SetOut(io.Discard)
|
||||
s.Require().NotNil(cmd)
|
||||
|
||||
cmd.SetContext(ctx)
|
||||
cmd.SetArgs(tc.args)
|
||||
s.Require().NoError(client.SetCmdClientContextHandler(s.baseCtx, cmd))
|
||||
|
||||
s.Require().Contains(fmt.Sprint(cmd), "group-info [id] [] [] Query for group info by group id")
|
||||
s.Require().Contains(fmt.Sprint(cmd), tc.expCmdOutput)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *CLITestSuite) TestQueryGroupPolicyInfo() {
|
||||
accounts := testutil.CreateKeyringAccounts(s.T(), s.kr, 1)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
expCmdOutput string
|
||||
}{
|
||||
{
|
||||
name: "json output",
|
||||
args: []string{accounts[0].Address.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
expCmdOutput: fmt.Sprintf("%s --output=json", accounts[0].Address.String()),
|
||||
},
|
||||
{
|
||||
name: "text output",
|
||||
args: []string{accounts[0].Address.String(), fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
expCmdOutput: fmt.Sprintf("%s --output=text", accounts[0].Address.String()),
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
cmd := cli.QueryGroupPolicyInfoCmd()
|
||||
|
||||
ctx := svrcmd.CreateExecuteContext(context.Background())
|
||||
|
||||
cmd.SetOut(io.Discard)
|
||||
s.Require().NotNil(cmd)
|
||||
|
||||
cmd.SetContext(ctx)
|
||||
cmd.SetArgs(tc.args)
|
||||
s.Require().NoError(client.SetCmdClientContextHandler(s.baseCtx, cmd))
|
||||
|
||||
s.Require().Contains(fmt.Sprint(cmd), "group-policy-info [group-policy-account] [] [] Query for group policy info by account address of group policy")
|
||||
s.Require().Contains(fmt.Sprint(cmd), tc.expCmdOutput)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *CLITestSuite) TestQueryGroupMembers() {
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
expCmdOutput string
|
||||
}{
|
||||
{
|
||||
name: "json output",
|
||||
args: []string{"1", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
expCmdOutput: "1 --output=json",
|
||||
},
|
||||
{
|
||||
name: "text output",
|
||||
args: []string{"1", fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
expCmdOutput: "1 --output=text",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
cmd := cli.QueryGroupMembersCmd()
|
||||
|
||||
ctx := svrcmd.CreateExecuteContext(context.Background())
|
||||
|
||||
cmd.SetOut(io.Discard)
|
||||
s.Require().NotNil(cmd)
|
||||
|
||||
cmd.SetContext(ctx)
|
||||
cmd.SetArgs(tc.args)
|
||||
s.Require().NoError(client.SetCmdClientContextHandler(s.baseCtx, cmd))
|
||||
|
||||
s.Require().Contains(fmt.Sprint(cmd), "group-members [id] [] [] Query for group members by group id with pagination flags")
|
||||
s.Require().Contains(fmt.Sprint(cmd), tc.expCmdOutput)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *CLITestSuite) TestQueryGroupsByAdmin() {
|
||||
accounts := testutil.CreateKeyringAccounts(s.T(), s.kr, 1)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
expCmdOutput string
|
||||
}{
|
||||
{
|
||||
name: "json output",
|
||||
args: []string{accounts[0].Address.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
expCmdOutput: fmt.Sprintf("%s --output=json", accounts[0].Address.String()),
|
||||
},
|
||||
{
|
||||
name: "text output",
|
||||
args: []string{accounts[0].Address.String(), fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
expCmdOutput: fmt.Sprintf("%s --output=text", accounts[0].Address.String()),
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
cmd := cli.QueryGroupsByAdminCmd()
|
||||
|
||||
ctx := svrcmd.CreateExecuteContext(context.Background())
|
||||
|
||||
cmd.SetOut(io.Discard)
|
||||
s.Require().NotNil(cmd)
|
||||
|
||||
cmd.SetContext(ctx)
|
||||
cmd.SetArgs(tc.args)
|
||||
s.Require().NoError(client.SetCmdClientContextHandler(s.baseCtx, cmd))
|
||||
|
||||
s.Require().Contains(fmt.Sprint(cmd), "groups-by-admin [admin] [] [] Query for groups by admin account address with pagination flags")
|
||||
s.Require().Contains(fmt.Sprint(cmd), tc.expCmdOutput)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *CLITestSuite) TestQueryGroupPoliciesByGroup() {
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
expCmdOutput string
|
||||
}{
|
||||
{
|
||||
name: "json output",
|
||||
args: []string{"1", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
expCmdOutput: "1 --output=json",
|
||||
},
|
||||
{
|
||||
name: "text output",
|
||||
args: []string{"1", fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
expCmdOutput: "1 --output=text",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
cmd := cli.QueryGroupPoliciesByGroupCmd()
|
||||
|
||||
ctx := svrcmd.CreateExecuteContext(context.Background())
|
||||
|
||||
cmd.SetOut(io.Discard)
|
||||
s.Require().NotNil(cmd)
|
||||
|
||||
cmd.SetContext(ctx)
|
||||
cmd.SetArgs(tc.args)
|
||||
s.Require().NoError(client.SetCmdClientContextHandler(s.baseCtx, cmd))
|
||||
|
||||
s.Require().Contains(fmt.Sprint(cmd), "group-policies-by-group [group-id] [] [] Query for group policies by group id with pagination flags")
|
||||
s.Require().Contains(fmt.Sprint(cmd), tc.expCmdOutput)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *CLITestSuite) TestQueryGroupPoliciesByAdmin() {
|
||||
accounts := testutil.CreateKeyringAccounts(s.T(), s.kr, 1)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
expCmdOutput string
|
||||
}{
|
||||
{
|
||||
name: "json output",
|
||||
args: []string{accounts[0].Address.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
expCmdOutput: fmt.Sprintf("%s --output=json", accounts[0].Address.String()),
|
||||
},
|
||||
{
|
||||
name: "text output",
|
||||
args: []string{accounts[0].Address.String(), fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
expCmdOutput: fmt.Sprintf("%s --output=text", accounts[0].Address.String()),
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
cmd := cli.QueryGroupPoliciesByAdminCmd()
|
||||
|
||||
ctx := svrcmd.CreateExecuteContext(context.Background())
|
||||
|
||||
cmd.SetOut(io.Discard)
|
||||
s.Require().NotNil(cmd)
|
||||
|
||||
cmd.SetContext(ctx)
|
||||
cmd.SetArgs(tc.args)
|
||||
s.Require().NoError(client.SetCmdClientContextHandler(s.baseCtx, cmd))
|
||||
|
||||
s.Require().Contains(fmt.Sprint(cmd), "group-policies-by-admin [admin] [] [] Query for group policies by admin account address with pagination flags")
|
||||
s.Require().Contains(fmt.Sprint(cmd), tc.expCmdOutput)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *CLITestSuite) TestQueryProposal() {
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
expCmdOutput string
|
||||
}{
|
||||
{
|
||||
name: "json output",
|
||||
args: []string{"1", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
expCmdOutput: "1 --output=json",
|
||||
},
|
||||
{
|
||||
name: "text output",
|
||||
args: []string{"1", fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
expCmdOutput: "1 --output=text",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
cmd := cli.QueryProposalCmd()
|
||||
|
||||
ctx := svrcmd.CreateExecuteContext(context.Background())
|
||||
|
||||
cmd.SetOut(io.Discard)
|
||||
s.Require().NotNil(cmd)
|
||||
|
||||
cmd.SetContext(ctx)
|
||||
cmd.SetArgs(tc.args)
|
||||
s.Require().NoError(client.SetCmdClientContextHandler(s.baseCtx, cmd))
|
||||
|
||||
s.Require().Contains(fmt.Sprint(cmd), "proposal [id] [] [] Query for proposal by id")
|
||||
s.Require().Contains(fmt.Sprint(cmd), tc.expCmdOutput)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *CLITestSuite) TestQueryProposalsByGroupPolicy() {
|
||||
accounts := testutil.CreateKeyringAccounts(s.T(), s.kr, 1)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
expCmdOutput string
|
||||
}{
|
||||
{
|
||||
name: "json output",
|
||||
args: []string{accounts[0].Address.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
expCmdOutput: fmt.Sprintf("%s --output=json", accounts[0].Address.String()),
|
||||
},
|
||||
{
|
||||
name: "text output",
|
||||
args: []string{accounts[0].Address.String(), fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
expCmdOutput: fmt.Sprintf("%s --output=text", accounts[0].Address.String()),
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
cmd := cli.QueryProposalsByGroupPolicyCmd()
|
||||
|
||||
ctx := svrcmd.CreateExecuteContext(context.Background())
|
||||
|
||||
cmd.SetOut(io.Discard)
|
||||
s.Require().NotNil(cmd)
|
||||
|
||||
cmd.SetContext(ctx)
|
||||
cmd.SetArgs(tc.args)
|
||||
s.Require().NoError(client.SetCmdClientContextHandler(s.baseCtx, cmd))
|
||||
|
||||
s.Require().Contains(fmt.Sprint(cmd), "proposals-by-group-policy [group-policy-account] [] [] Query for proposals by account address of group policy with pagination flags")
|
||||
s.Require().Contains(fmt.Sprint(cmd), tc.expCmdOutput)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *CLITestSuite) TestQueryVoteByProposalVoter() {
|
||||
accounts := testutil.CreateKeyringAccounts(s.T(), s.kr, 1)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
expCmdOutput string
|
||||
}{
|
||||
{
|
||||
name: "json output",
|
||||
args: []string{"1", accounts[0].Address.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
expCmdOutput: fmt.Sprintf("1 %s --output=json", accounts[0].Address.String()),
|
||||
},
|
||||
{
|
||||
name: "text output",
|
||||
args: []string{"1", accounts[0].Address.String(), fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
expCmdOutput: fmt.Sprintf("1 %s --output=text", accounts[0].Address.String()),
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
cmd := cli.QueryVoteByProposalVoterCmd()
|
||||
|
||||
ctx := svrcmd.CreateExecuteContext(context.Background())
|
||||
|
||||
cmd.SetOut(io.Discard)
|
||||
s.Require().NotNil(cmd)
|
||||
|
||||
cmd.SetContext(ctx)
|
||||
cmd.SetArgs(tc.args)
|
||||
s.Require().NoError(client.SetCmdClientContextHandler(s.baseCtx, cmd))
|
||||
|
||||
s.Require().Contains(fmt.Sprint(cmd), "vote [proposal-id] [voter] [] [] Query for vote by proposal id and voter account address")
|
||||
s.Require().Contains(fmt.Sprint(cmd), tc.expCmdOutput)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *CLITestSuite) TestQueryVotesByProposal() {
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
expCmdOutput string
|
||||
}{
|
||||
{
|
||||
name: "json output",
|
||||
args: []string{"1", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
expCmdOutput: "1 --output=json",
|
||||
},
|
||||
{
|
||||
name: "text output",
|
||||
args: []string{"1", fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
expCmdOutput: "1 --output=text",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
cmd := cli.QueryVotesByProposalCmd()
|
||||
|
||||
ctx := svrcmd.CreateExecuteContext(context.Background())
|
||||
|
||||
cmd.SetOut(io.Discard)
|
||||
s.Require().NotNil(cmd)
|
||||
|
||||
cmd.SetContext(ctx)
|
||||
cmd.SetArgs(tc.args)
|
||||
s.Require().NoError(client.SetCmdClientContextHandler(s.baseCtx, cmd))
|
||||
|
||||
s.Require().Contains(fmt.Sprint(cmd), "votes-by-proposal [proposal-id] [] [] Query for votes by proposal id with pagination flags")
|
||||
s.Require().Contains(fmt.Sprint(cmd), tc.expCmdOutput)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *CLITestSuite) TestQueryTallyResult() {
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
expCmdOutput string
|
||||
}{
|
||||
{
|
||||
name: "json output",
|
||||
args: []string{"1", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
expCmdOutput: "1 --output=json",
|
||||
},
|
||||
{
|
||||
name: "text output",
|
||||
args: []string{"1", fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
expCmdOutput: "1 --output=text",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
cmd := cli.QueryTallyResultCmd()
|
||||
|
||||
ctx := svrcmd.CreateExecuteContext(context.Background())
|
||||
|
||||
cmd.SetOut(io.Discard)
|
||||
s.Require().NotNil(cmd)
|
||||
|
||||
cmd.SetContext(ctx)
|
||||
cmd.SetArgs(tc.args)
|
||||
s.Require().NoError(client.SetCmdClientContextHandler(s.baseCtx, cmd))
|
||||
|
||||
s.Require().Contains(fmt.Sprint(cmd), "tally-result [proposal-id] [] [] Query tally result of proposal")
|
||||
s.Require().Contains(fmt.Sprint(cmd), tc.expCmdOutput)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *CLITestSuite) TestQueryVotesByVoter() {
|
||||
accounts := testutil.CreateKeyringAccounts(s.T(), s.kr, 1)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
expCmdOutput string
|
||||
}{
|
||||
{
|
||||
name: "json output",
|
||||
args: []string{accounts[0].Address.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
expCmdOutput: fmt.Sprintf("%s --output=json", accounts[0].Address.String()),
|
||||
},
|
||||
{
|
||||
name: "text output",
|
||||
args: []string{accounts[0].Address.String(), fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
expCmdOutput: fmt.Sprintf("%s --output=text", accounts[0].Address.String()),
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
cmd := cli.QueryVotesByVoterCmd()
|
||||
|
||||
ctx := svrcmd.CreateExecuteContext(context.Background())
|
||||
|
||||
cmd.SetOut(io.Discard)
|
||||
s.Require().NotNil(cmd)
|
||||
|
||||
cmd.SetContext(ctx)
|
||||
cmd.SetArgs(tc.args)
|
||||
s.Require().NoError(client.SetCmdClientContextHandler(s.baseCtx, cmd))
|
||||
|
||||
s.Require().Contains(fmt.Sprint(cmd), "votes-by-voter [voter] [] [] Query for votes by voter account address with pagination flags")
|
||||
s.Require().Contains(fmt.Sprint(cmd), tc.expCmdOutput)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *CLITestSuite) TestQueryGroupsByMembers() {
|
||||
accounts := testutil.CreateKeyringAccounts(s.T(), s.kr, 1)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
expCmdOutput string
|
||||
}{
|
||||
{
|
||||
name: "json output",
|
||||
args: []string{accounts[0].Address.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
expCmdOutput: fmt.Sprintf("%s --output=json", accounts[0].Address.String()),
|
||||
},
|
||||
{
|
||||
name: "text output",
|
||||
args: []string{accounts[0].Address.String(), fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
expCmdOutput: fmt.Sprintf("%s --output=text", accounts[0].Address.String()),
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
cmd := cli.QueryGroupsByMemberCmd()
|
||||
|
||||
ctx := svrcmd.CreateExecuteContext(context.Background())
|
||||
|
||||
cmd.SetOut(io.Discard)
|
||||
s.Require().NotNil(cmd)
|
||||
|
||||
cmd.SetContext(ctx)
|
||||
cmd.SetArgs(tc.args)
|
||||
s.Require().NoError(client.SetCmdClientContextHandler(s.baseCtx, cmd))
|
||||
|
||||
s.Require().Contains(fmt.Sprint(cmd), "groups-by-member [address] [] [] Query for groups by member address with pagination flags")
|
||||
s.Require().Contains(fmt.Sprint(cmd), tc.expCmdOutput)
|
||||
})
|
||||
}
|
||||
}
|
|
@ -508,7 +508,7 @@ func MsgUpdateGroupPolicyDecisionPolicyCmd() *cobra.Command {
|
|||
return cmd
|
||||
}
|
||||
|
||||
// MsgUpdateGroupPolicyMetadataCmd creates a CLI command for Msg/MsgUpdateGroupPolicyMetadata.
|
||||
// MsgUpdateGroupPolicyMetadataCmd creates a CLI command for Msg/UpdateGroupPolicyMetadata.
|
||||
func MsgUpdateGroupPolicyMetadataCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "update-group-policy-metadata [admin] [group-policy-account] [new-metadata]",
|
||||
|
@ -736,7 +736,7 @@ Parameters:
|
|||
return cmd
|
||||
}
|
||||
|
||||
// MsgExecCmd creates a CLI command for Msg/MsgExec.
|
||||
// MsgExecCmd creates a CLI command for Msg/Exec.
|
||||
func MsgExecCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "exec [proposal-id]",
|
||||
|
|
|
@ -36,10 +36,10 @@ var tooLongMetadata = strings.Repeat("A", 256)
|
|||
type CLITestSuite struct {
|
||||
suite.Suite
|
||||
|
||||
kr keyring.Keyring
|
||||
encCfg testutilmod.TestEncodingConfig
|
||||
baseCtx client.Context
|
||||
|
||||
kr keyring.Keyring
|
||||
encCfg testutilmod.TestEncodingConfig
|
||||
baseCtx client.Context
|
||||
clientCtx client.Context
|
||||
group *group.GroupInfo
|
||||
commonFlags []string
|
||||
}
|
||||
|
@ -77,10 +77,10 @@ func (s *CLITestSuite) SetupSuite() {
|
|||
})
|
||||
return s.baseCtx.WithClient(c)
|
||||
}
|
||||
clientCtx := ctxGen().WithOutput(&outBuf)
|
||||
s.clientCtx = ctxGen().WithOutput(&outBuf)
|
||||
|
||||
// create a new account
|
||||
info, _, err := clientCtx.Keyring.NewMnemonic("NewValidator", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1)
|
||||
info, _, err := s.clientCtx.Keyring.NewMnemonic("NewValidator", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1)
|
||||
s.Require().NoError(err)
|
||||
|
||||
pk, err := info.GetPubKey()
|
||||
|
@ -88,7 +88,7 @@ func (s *CLITestSuite) SetupSuite() {
|
|||
|
||||
account := sdk.AccAddress(pk.Address())
|
||||
_, err = clitestutil.MsgSendExec(
|
||||
clientCtx,
|
||||
s.clientCtx,
|
||||
val.Address,
|
||||
account,
|
||||
sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(2000))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
|
@ -110,7 +110,7 @@ func (s *CLITestSuite) SetupSuite() {
|
|||
]
|
||||
}`, val.Address.String(), memberWeight, validMetadata)
|
||||
validMembersFile := testutil.WriteToNewTempFile(s.T(), validMembers)
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, groupcli.MsgCreateGroupCmd(),
|
||||
out, err := clitestutil.ExecTestCLICmd(s.clientCtx, groupcli.MsgCreateGroupCmd(),
|
||||
append(
|
||||
[]string{
|
||||
val.Address.String(),
|
||||
|
@ -123,7 +123,7 @@ func (s *CLITestSuite) SetupSuite() {
|
|||
|
||||
s.Require().NoError(err, out.String())
|
||||
txResp := sdk.TxResponse{}
|
||||
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String())
|
||||
s.Require().NoError(s.clientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String())
|
||||
s.Require().Equal(uint32(0), txResp.Code, out.String())
|
||||
|
||||
s.group = &group.GroupInfo{Id: 1, Admin: val.Address.String(), Metadata: validMetadata, TotalWeight: "3", Version: 1}
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/group"
|
||||
)
|
||||
|
||||
// parseDecisionPolicy reads and parses the decision policy.
|
||||
func parseDecisionPolicy(cdc codec.Codec, decisionPolicyFile string) (group.DecisionPolicy, error) {
|
||||
if decisionPolicyFile == "" {
|
||||
return nil, fmt.Errorf("decision policy is required")
|
||||
|
@ -28,6 +29,7 @@ func parseDecisionPolicy(cdc codec.Codec, decisionPolicyFile string) (group.Deci
|
|||
return policy, nil
|
||||
}
|
||||
|
||||
// parseMembers reads and parses the members.
|
||||
func parseMembers(membersFile string) ([]group.MemberRequest, error) {
|
||||
members := group.MemberRequests{}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ func RegisterLegacyAminoCodec(cdc *codectypes.LegacyAmino) {
|
|||
legacy.RegisterAminoMsg(cdc, &MsgLeaveGroup{}, "cosmos-sdk/group/MsgLeaveGroup")
|
||||
}
|
||||
|
||||
// RegisterInterfaces registers the interfaces types with the interface registry.
|
||||
func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
|
||||
registry.RegisterImplementations((*sdk.Msg)(nil),
|
||||
&MsgCreateGroup{},
|
||||
|
|
|
@ -12,6 +12,8 @@ func NewGenesisState() *GenesisState {
|
|||
return &GenesisState{}
|
||||
}
|
||||
|
||||
// Validate performs basic genesis state validation returning an error upon any
|
||||
// failure.
|
||||
func (s GenesisState) Validate() error {
|
||||
groups := make(map[uint64]GroupInfo)
|
||||
groupPolicies := make(map[string]GroupPolicyInfo)
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/group"
|
||||
)
|
||||
|
||||
// InitGenesis initializes the group module's genesis state.
|
||||
func (k Keeper) InitGenesis(ctx types.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
|
||||
var genesisState group.GenesisState
|
||||
cdc.MustUnmarshalJSON(data, &genesisState)
|
||||
|
@ -42,6 +43,7 @@ func (k Keeper) InitGenesis(ctx types.Context, cdc codec.JSONCodec, data json.Ra
|
|||
return []abci.ValidatorUpdate{}
|
||||
}
|
||||
|
||||
// ExportGenesis returns the group module's exported genesis.
|
||||
func (k Keeper) ExportGenesis(ctx types.Context, cdc codec.JSONCodec) *group.GenesisState {
|
||||
genesisState := group.NewGenesisState()
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ func (k Keeper) GroupInfo(goCtx context.Context, request *group.QueryGroupInfoRe
|
|||
return &group.QueryGroupInfoResponse{Info: &groupInfo}, nil
|
||||
}
|
||||
|
||||
// getGroupInfo gets the group info of the given group id.
|
||||
func (k Keeper) getGroupInfo(ctx sdk.Context, id uint64) (group.GroupInfo, error) {
|
||||
var obj group.GroupInfo
|
||||
_, err := k.groupTable.GetOne(ctx.KVStore(k.key), id, &obj)
|
||||
|
@ -45,6 +46,7 @@ func (k Keeper) GroupPolicyInfo(goCtx context.Context, request *group.QueryGroup
|
|||
return &group.QueryGroupPolicyInfoResponse{Info: &groupPolicyInfo}, nil
|
||||
}
|
||||
|
||||
// getGroupPolicyInfo gets the group policy info of the given account address.
|
||||
func (k Keeper) getGroupPolicyInfo(ctx sdk.Context, accountAddress string) (group.GroupPolicyInfo, error) {
|
||||
var obj group.GroupPolicyInfo
|
||||
return obj, k.groupPolicyTable.GetOne(ctx.KVStore(k.key), orm.PrimaryKey(&group.GroupPolicyInfo{Address: accountAddress}), &obj)
|
||||
|
@ -71,6 +73,7 @@ func (k Keeper) GroupMembers(goCtx context.Context, request *group.QueryGroupMem
|
|||
}, nil
|
||||
}
|
||||
|
||||
// getGroupMembers returns an iterator for the given group id and page request.
|
||||
func (k Keeper) getGroupMembers(ctx sdk.Context, id uint64, pageRequest *query.PageRequest) (orm.Iterator, error) {
|
||||
return k.groupMemberByGroupIndex.GetPaginated(ctx.KVStore(k.key), id, pageRequest)
|
||||
}
|
||||
|
@ -99,6 +102,7 @@ func (k Keeper) GroupsByAdmin(goCtx context.Context, request *group.QueryGroupsB
|
|||
}, nil
|
||||
}
|
||||
|
||||
// getGroupsByAdmin returns an iterator for the given admin account address and page request.
|
||||
func (k Keeper) getGroupsByAdmin(ctx sdk.Context, admin sdk.AccAddress, pageRequest *query.PageRequest) (orm.Iterator, error) {
|
||||
return k.groupByAdminIndex.GetPaginated(ctx.KVStore(k.key), admin.Bytes(), pageRequest)
|
||||
}
|
||||
|
@ -124,6 +128,7 @@ func (k Keeper) GroupPoliciesByGroup(goCtx context.Context, request *group.Query
|
|||
}, nil
|
||||
}
|
||||
|
||||
// getGroupPoliciesByGroup returns an iterator for the given group id and page request.
|
||||
func (k Keeper) getGroupPoliciesByGroup(ctx sdk.Context, id uint64, pageRequest *query.PageRequest) (orm.Iterator, error) {
|
||||
return k.groupPolicyByGroupIndex.GetPaginated(ctx.KVStore(k.key), id, pageRequest)
|
||||
}
|
||||
|
@ -153,6 +158,7 @@ func (k Keeper) GroupPoliciesByAdmin(goCtx context.Context, request *group.Query
|
|||
}, nil
|
||||
}
|
||||
|
||||
// getGroupPoliciesByAdmin returns an iterator for the given admin account address and page request.
|
||||
func (k Keeper) getGroupPoliciesByAdmin(ctx sdk.Context, admin sdk.AccAddress, pageRequest *query.PageRequest) (orm.Iterator, error) {
|
||||
return k.groupPolicyByAdminIndex.GetPaginated(ctx.KVStore(k.key), admin.Bytes(), pageRequest)
|
||||
}
|
||||
|
@ -169,7 +175,7 @@ func (k Keeper) Proposal(goCtx context.Context, request *group.QueryProposalRequ
|
|||
return &group.QueryProposalResponse{Proposal: &proposal}, nil
|
||||
}
|
||||
|
||||
// Proposal queries all proposals of a group policy.
|
||||
// ProposalsByGroupPolicy queries all proposals of a group policy.
|
||||
func (k Keeper) ProposalsByGroupPolicy(goCtx context.Context, request *group.QueryProposalsByGroupPolicyRequest) (*group.QueryProposalsByGroupPolicyResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
addr, err := sdk.AccAddressFromBech32(request.Address)
|
||||
|
@ -193,10 +199,12 @@ func (k Keeper) ProposalsByGroupPolicy(goCtx context.Context, request *group.Que
|
|||
}, nil
|
||||
}
|
||||
|
||||
// getProposalsByGroupPolicy returns an iterator for the given account address and page request.
|
||||
func (k Keeper) getProposalsByGroupPolicy(ctx sdk.Context, account sdk.AccAddress, pageRequest *query.PageRequest) (orm.Iterator, error) {
|
||||
return k.proposalByGroupPolicyIndex.GetPaginated(ctx.KVStore(k.key), account.Bytes(), pageRequest)
|
||||
}
|
||||
|
||||
// getProposal gets the proposal info of the given proposal id.
|
||||
func (k Keeper) getProposal(ctx sdk.Context, proposalID uint64) (group.Proposal, error) {
|
||||
var p group.Proposal
|
||||
if _, err := k.proposalTable.GetOne(ctx.KVStore(k.key), proposalID, &p); err != nil {
|
||||
|
@ -243,7 +251,7 @@ func (k Keeper) VotesByProposal(goCtx context.Context, request *group.QueryVotes
|
|||
}, nil
|
||||
}
|
||||
|
||||
// VotesByProposal queries all votes of a voter.
|
||||
// VotesByVoter queries all votes of a voter.
|
||||
func (k Keeper) VotesByVoter(goCtx context.Context, request *group.QueryVotesByVoterRequest) (*group.QueryVotesByVoterResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
addr, err := sdk.AccAddressFromBech32(request.Voter)
|
||||
|
@ -305,15 +313,18 @@ func (k Keeper) GroupsByMember(goCtx context.Context, request *group.QueryGroups
|
|||
}, nil
|
||||
}
|
||||
|
||||
// getVote gets the vote info for the given proposal id and voter address.
|
||||
func (k Keeper) getVote(ctx sdk.Context, proposalID uint64, voter sdk.AccAddress) (group.Vote, error) {
|
||||
var v group.Vote
|
||||
return v, k.voteTable.GetOne(ctx.KVStore(k.key), orm.PrimaryKey(&group.Vote{ProposalId: proposalID, Voter: voter.String()}), &v)
|
||||
}
|
||||
|
||||
// getVotesByProposal returns an iterator for the given proposal id and page request.
|
||||
func (k Keeper) getVotesByProposal(ctx sdk.Context, proposalID uint64, pageRequest *query.PageRequest) (orm.Iterator, error) {
|
||||
return k.voteByProposalIndex.GetPaginated(ctx.KVStore(k.key), proposalID, pageRequest)
|
||||
}
|
||||
|
||||
// getVotesByVoter returns an iterator for the given voter address and page request.
|
||||
func (k Keeper) getVotesByVoter(ctx sdk.Context, voter sdk.AccAddress, pageRequest *query.PageRequest) (orm.Iterator, error) {
|
||||
return k.voteByVoterIndex.GetPaginated(ctx.KVStore(k.key), voter.Bytes(), pageRequest)
|
||||
}
|
||||
|
|
|
@ -106,6 +106,9 @@ func (s *TestSuite) SetupTest() {
|
|||
s.Require().NoError(err)
|
||||
s.setNextAccount()
|
||||
|
||||
groupSeq := s.groupKeeper.GetGroupSequence(s.sdkCtx)
|
||||
s.Require().Equal(groupSeq, uint64(1))
|
||||
|
||||
policyRes, err := s.groupKeeper.CreateGroupPolicy(s.ctx, policyReq)
|
||||
s.Require().NoError(err)
|
||||
s.policy = policy
|
||||
|
|
|
@ -5,6 +5,8 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/group/keeper"
|
||||
)
|
||||
|
||||
// EndBlocker called at every block, updates proposal's `FinalTallyResult` and
|
||||
// prunes expired proposals.
|
||||
func EndBlocker(ctx sdk.Context, k keeper.Keeper) {
|
||||
if err := k.TallyProposalsAtVPEnd(ctx); err != nil {
|
||||
panic(err)
|
||||
|
|
|
@ -82,7 +82,7 @@ func (m MsgUpdateGroupAdmin) GetSigners() []sdk.AccAddress {
|
|||
return []sdk.AccAddress{admin}
|
||||
}
|
||||
|
||||
// ValidateBasic does a sanity check on the provided data
|
||||
// ValidateBasic does a sanity check on the provided data.
|
||||
func (m MsgUpdateGroupAdmin) ValidateBasic() error {
|
||||
if m.GroupId == 0 {
|
||||
return sdkerrors.Wrap(errors.ErrEmpty, "group id")
|
||||
|
@ -104,6 +104,7 @@ func (m MsgUpdateGroupAdmin) ValidateBasic() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// GetGroupID gets the group id of the MsgUpdateGroupAdmin.
|
||||
func (m *MsgUpdateGroupAdmin) GetGroupID() uint64 {
|
||||
return m.GroupId
|
||||
}
|
||||
|
@ -143,6 +144,7 @@ func (m MsgUpdateGroupMetadata) ValidateBasic() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// GetGroupID gets the group id of the MsgUpdateGroupMetadata.
|
||||
func (m *MsgUpdateGroupMetadata) GetGroupID() uint64 {
|
||||
return m.GroupId
|
||||
}
|
||||
|
@ -191,6 +193,7 @@ func (m MsgUpdateGroupMembers) ValidateBasic() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// GetGroupID gets the group id of the MsgUpdateGroupMembers.
|
||||
func (m *MsgUpdateGroupMembers) GetGroupID() uint64 {
|
||||
return m.GroupId
|
||||
}
|
||||
|
@ -216,6 +219,7 @@ func NewMsgCreateGroupWithPolicy(admin string, members []MemberRequest, groupMet
|
|||
return m, nil
|
||||
}
|
||||
|
||||
// GetDecisionPolicy gets the decision policy of MsgCreateGroupWithPolicy.
|
||||
func (m *MsgCreateGroupWithPolicy) GetDecisionPolicy() (DecisionPolicy, error) {
|
||||
decisionPolicy, ok := m.DecisionPolicy.GetCachedValue().(DecisionPolicy)
|
||||
if !ok {
|
||||
|
@ -224,6 +228,7 @@ func (m *MsgCreateGroupWithPolicy) GetDecisionPolicy() (DecisionPolicy, error) {
|
|||
return decisionPolicy, nil
|
||||
}
|
||||
|
||||
// SetDecisionPolicy sets the decision policy for MsgCreateGroupWithPolicy.
|
||||
func (m *MsgCreateGroupWithPolicy) SetDecisionPolicy(decisionPolicy DecisionPolicy) error {
|
||||
any, err := types.NewAnyWithValue(decisionPolicy)
|
||||
if err != nil {
|
||||
|
@ -382,6 +387,7 @@ func NewMsgUpdateGroupPolicyDecisionPolicy(admin sdk.AccAddress, address sdk.Acc
|
|||
return m, nil
|
||||
}
|
||||
|
||||
// SetDecisionPolicy sets the decision policy for MsgUpdateGroupPolicyDecisionPolicy.
|
||||
func (m *MsgUpdateGroupPolicyDecisionPolicy) SetDecisionPolicy(decisionPolicy DecisionPolicy) error {
|
||||
msg, ok := decisionPolicy.(proto.Message)
|
||||
if !ok {
|
||||
|
@ -441,6 +447,7 @@ func (m MsgUpdateGroupPolicyDecisionPolicy) ValidateBasic() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// GetDecisionPolicy gets the decision policy of MsgUpdateGroupPolicyDecisionPolicy.
|
||||
func (m *MsgUpdateGroupPolicyDecisionPolicy) GetDecisionPolicy() (DecisionPolicy, error) {
|
||||
decisionPolicy, ok := m.DecisionPolicy.GetCachedValue().(DecisionPolicy)
|
||||
if !ok {
|
||||
|
@ -512,18 +519,22 @@ func NewMsgCreateGroupPolicy(admin sdk.AccAddress, group uint64, metadata string
|
|||
return m, nil
|
||||
}
|
||||
|
||||
// GetAdmin gets the admin of MsgCreateGroupPolicy.
|
||||
func (m *MsgCreateGroupPolicy) GetAdmin() string {
|
||||
return m.Admin
|
||||
}
|
||||
|
||||
// GetGroupID gets the group id of MsgCreateGroupPolicy.
|
||||
func (m *MsgCreateGroupPolicy) GetGroupID() uint64 {
|
||||
return m.GroupId
|
||||
}
|
||||
|
||||
// GetMetadata gets the metadata of MsgCreateGroupPolicy.
|
||||
func (m *MsgCreateGroupPolicy) GetMetadata() string {
|
||||
return m.Metadata
|
||||
}
|
||||
|
||||
// GetDecisionPolicy gets the decision policy of MsgCreateGroupPolicy.
|
||||
func (m *MsgCreateGroupPolicy) GetDecisionPolicy() (DecisionPolicy, error) {
|
||||
decisionPolicy, ok := m.DecisionPolicy.GetCachedValue().(DecisionPolicy)
|
||||
if !ok {
|
||||
|
@ -532,6 +543,7 @@ func (m *MsgCreateGroupPolicy) GetDecisionPolicy() (DecisionPolicy, error) {
|
|||
return decisionPolicy, nil
|
||||
}
|
||||
|
||||
// SetDecisionPolicy sets the decision policy of MsgCreateGroupPolicy.
|
||||
func (m *MsgCreateGroupPolicy) SetDecisionPolicy(decisionPolicy DecisionPolicy) error {
|
||||
any, err := types.NewAnyWithValue(decisionPolicy)
|
||||
if err != nil {
|
||||
|
|
|
@ -6,10 +6,12 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/types/tx"
|
||||
)
|
||||
|
||||
// GetMsgs unpacks p.Messages Any's into sdk.Msg's
|
||||
func (p *Proposal) GetMsgs() ([]sdk.Msg, error) {
|
||||
return tx.GetMsgs(p.Messages, "proposal")
|
||||
}
|
||||
|
||||
// SetMsgs packs msgs into Any's
|
||||
func (p *Proposal) SetMsgs(msgs []sdk.Msg) error {
|
||||
anys, err := tx.SetMsgs(msgs)
|
||||
if err != nil {
|
||||
|
|
|
@ -80,7 +80,7 @@ func (m *QueryGroupInfoRequest) GetGroupId() uint64 {
|
|||
|
||||
// QueryGroupInfoResponse is the Query/GroupInfo response type.
|
||||
type QueryGroupInfoResponse struct {
|
||||
// info is the GroupInfo for the group.
|
||||
// info is the GroupInfo of the group.
|
||||
Info *GroupInfo `protobuf:"bytes,1,opt,name=info,proto3" json:"info,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ func (m *QueryGroupPolicyInfoRequest) GetAddress() string {
|
|||
|
||||
// QueryGroupPolicyInfoResponse is the Query/GroupPolicyInfo response type.
|
||||
type QueryGroupPolicyInfoResponse struct {
|
||||
// info is the GroupPolicyInfo for the group policy.
|
||||
// info is the GroupPolicyInfo of the group policy.
|
||||
Info *GroupPolicyInfo `protobuf:"bytes,1,opt,name=info,proto3" json:"info,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -1512,13 +1512,13 @@ type QueryClient interface {
|
|||
GroupInfo(ctx context.Context, in *QueryGroupInfoRequest, opts ...grpc.CallOption) (*QueryGroupInfoResponse, error)
|
||||
// GroupPolicyInfo queries group policy info based on account address of group policy.
|
||||
GroupPolicyInfo(ctx context.Context, in *QueryGroupPolicyInfoRequest, opts ...grpc.CallOption) (*QueryGroupPolicyInfoResponse, error)
|
||||
// GroupMembers queries members of a group
|
||||
// GroupMembers queries members of a group by group id.
|
||||
GroupMembers(ctx context.Context, in *QueryGroupMembersRequest, opts ...grpc.CallOption) (*QueryGroupMembersResponse, error)
|
||||
// GroupsByAdmin queries groups by admin address.
|
||||
GroupsByAdmin(ctx context.Context, in *QueryGroupsByAdminRequest, opts ...grpc.CallOption) (*QueryGroupsByAdminResponse, error)
|
||||
// GroupPoliciesByGroup queries group policies by group id.
|
||||
GroupPoliciesByGroup(ctx context.Context, in *QueryGroupPoliciesByGroupRequest, opts ...grpc.CallOption) (*QueryGroupPoliciesByGroupResponse, error)
|
||||
// GroupsByAdmin queries group policies by admin address.
|
||||
// GroupPoliciesByAdmin queries group policies by admin address.
|
||||
GroupPoliciesByAdmin(ctx context.Context, in *QueryGroupPoliciesByAdminRequest, opts ...grpc.CallOption) (*QueryGroupPoliciesByAdminResponse, error)
|
||||
// Proposal queries a proposal based on proposal id.
|
||||
Proposal(ctx context.Context, in *QueryProposalRequest, opts ...grpc.CallOption) (*QueryProposalResponse, error)
|
||||
|
@ -1526,7 +1526,7 @@ type QueryClient interface {
|
|||
ProposalsByGroupPolicy(ctx context.Context, in *QueryProposalsByGroupPolicyRequest, opts ...grpc.CallOption) (*QueryProposalsByGroupPolicyResponse, error)
|
||||
// VoteByProposalVoter queries a vote by proposal id and voter.
|
||||
VoteByProposalVoter(ctx context.Context, in *QueryVoteByProposalVoterRequest, opts ...grpc.CallOption) (*QueryVoteByProposalVoterResponse, error)
|
||||
// VotesByProposal queries a vote by proposal.
|
||||
// VotesByProposal queries a vote by proposal id.
|
||||
VotesByProposal(ctx context.Context, in *QueryVotesByProposalRequest, opts ...grpc.CallOption) (*QueryVotesByProposalResponse, error)
|
||||
// VotesByVoter queries a vote by voter.
|
||||
VotesByVoter(ctx context.Context, in *QueryVotesByVoterRequest, opts ...grpc.CallOption) (*QueryVotesByVoterResponse, error)
|
||||
|
@ -1671,13 +1671,13 @@ type QueryServer interface {
|
|||
GroupInfo(context.Context, *QueryGroupInfoRequest) (*QueryGroupInfoResponse, error)
|
||||
// GroupPolicyInfo queries group policy info based on account address of group policy.
|
||||
GroupPolicyInfo(context.Context, *QueryGroupPolicyInfoRequest) (*QueryGroupPolicyInfoResponse, error)
|
||||
// GroupMembers queries members of a group
|
||||
// GroupMembers queries members of a group by group id.
|
||||
GroupMembers(context.Context, *QueryGroupMembersRequest) (*QueryGroupMembersResponse, error)
|
||||
// GroupsByAdmin queries groups by admin address.
|
||||
GroupsByAdmin(context.Context, *QueryGroupsByAdminRequest) (*QueryGroupsByAdminResponse, error)
|
||||
// GroupPoliciesByGroup queries group policies by group id.
|
||||
GroupPoliciesByGroup(context.Context, *QueryGroupPoliciesByGroupRequest) (*QueryGroupPoliciesByGroupResponse, error)
|
||||
// GroupsByAdmin queries group policies by admin address.
|
||||
// GroupPoliciesByAdmin queries group policies by admin address.
|
||||
GroupPoliciesByAdmin(context.Context, *QueryGroupPoliciesByAdminRequest) (*QueryGroupPoliciesByAdminResponse, error)
|
||||
// Proposal queries a proposal based on proposal id.
|
||||
Proposal(context.Context, *QueryProposalRequest) (*QueryProposalResponse, error)
|
||||
|
@ -1685,7 +1685,7 @@ type QueryServer interface {
|
|||
ProposalsByGroupPolicy(context.Context, *QueryProposalsByGroupPolicyRequest) (*QueryProposalsByGroupPolicyResponse, error)
|
||||
// VoteByProposalVoter queries a vote by proposal id and voter.
|
||||
VoteByProposalVoter(context.Context, *QueryVoteByProposalVoterRequest) (*QueryVoteByProposalVoterResponse, error)
|
||||
// VotesByProposal queries a vote by proposal.
|
||||
// VotesByProposal queries a vote by proposal id.
|
||||
VotesByProposal(context.Context, *QueryVotesByProposalRequest) (*QueryVotesByProposalResponse, error)
|
||||
// VotesByVoter queries a vote by voter.
|
||||
VotesByVoter(context.Context, *QueryVotesByVoterRequest) (*QueryVotesByVoterResponse, error)
|
||||
|
|
|
@ -865,7 +865,7 @@ type MsgUpdateGroupPolicyMetadata struct {
|
|||
Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"`
|
||||
// group_policy_address is the account address of group policy.
|
||||
GroupPolicyAddress string `protobuf:"bytes,2,opt,name=group_policy_address,json=groupPolicyAddress,proto3" json:"group_policy_address,omitempty"`
|
||||
// metadata is the updated group policy metadata.
|
||||
// metadata is the group policy metadata to be updated.
|
||||
Metadata string `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -967,7 +967,7 @@ type MsgSubmitProposal struct {
|
|||
// proposers are the account addresses of the proposers.
|
||||
// Proposers signatures will be counted as yes votes.
|
||||
Proposers []string `protobuf:"bytes,2,rep,name=proposers,proto3" json:"proposers,omitempty"`
|
||||
// metadata is any arbitrary metadata to attached to the proposal.
|
||||
// metadata is any arbitrary metadata attached to the proposal.
|
||||
Metadata string `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||
// messages is a list of `sdk.Msg`s that will be executed if the proposal passes.
|
||||
Messages []*types.Any `protobuf:"bytes,4,rep,name=messages,proto3" json:"messages,omitempty"`
|
||||
|
@ -1156,7 +1156,7 @@ type MsgVote struct {
|
|||
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
|
||||
// option is the voter's choice on the proposal.
|
||||
Option VoteOption `protobuf:"varint,3,opt,name=option,proto3,enum=cosmos.group.v1.VoteOption" json:"option,omitempty"`
|
||||
// metadata is any arbitrary metadata to attached to the vote.
|
||||
// metadata is any arbitrary metadata attached to the vote.
|
||||
Metadata string `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||
// exec defines whether the proposal should be executed
|
||||
// immediately after voting or not.
|
||||
|
|
|
@ -52,14 +52,17 @@ func NewThresholdDecisionPolicy(threshold string, votingPeriod time.Duration, mi
|
|||
return &ThresholdDecisionPolicy{threshold, &DecisionPolicyWindows{votingPeriod, minExecutionPeriod}}
|
||||
}
|
||||
|
||||
// GetVotingPeriod returns the voitng period of ThresholdDecisionPolicy
|
||||
func (p ThresholdDecisionPolicy) GetVotingPeriod() time.Duration {
|
||||
return p.Windows.VotingPeriod
|
||||
}
|
||||
|
||||
// GetMinExecutionPeriod returns the minimum execution period of ThresholdDecisionPolicy
|
||||
func (p ThresholdDecisionPolicy) GetMinExecutionPeriod() time.Duration {
|
||||
return p.Windows.MinExecutionPeriod
|
||||
}
|
||||
|
||||
// ValidateBasic does basic validation on ThresholdDecisionPolicy
|
||||
func (p ThresholdDecisionPolicy) ValidateBasic() error {
|
||||
if _, err := math.NewPositiveDecFromString(p.Threshold); err != nil {
|
||||
return sdkerrors.Wrap(err, "threshold")
|
||||
|
@ -154,14 +157,17 @@ func NewPercentageDecisionPolicy(percentage string, votingPeriod time.Duration,
|
|||
return &PercentageDecisionPolicy{percentage, &DecisionPolicyWindows{votingPeriod, executionPeriod}}
|
||||
}
|
||||
|
||||
// GetVotingPeriod returns the voitng period of PercentageDecisionPolicy
|
||||
func (p PercentageDecisionPolicy) GetVotingPeriod() time.Duration {
|
||||
return p.Windows.VotingPeriod
|
||||
}
|
||||
|
||||
// GetMinExecutionPeriod returns the minimum execution period of PercentageDecisionPolicy
|
||||
func (p PercentageDecisionPolicy) GetMinExecutionPeriod() time.Duration {
|
||||
return p.Windows.MinExecutionPeriod
|
||||
}
|
||||
|
||||
// ValidateBasic does basic validation on PercentageDecisionPolicy
|
||||
func (p PercentageDecisionPolicy) ValidateBasic() error {
|
||||
percentage, err := math.NewPositiveDecFromString(p.Percentage)
|
||||
if err != nil {
|
||||
|
@ -178,6 +184,7 @@ func (p PercentageDecisionPolicy) ValidateBasic() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Validate validates the policy against the group.
|
||||
func (p *PercentageDecisionPolicy) Validate(g GroupInfo, config Config) error {
|
||||
if p.Windows.MinExecutionPeriod > p.Windows.VotingPeriod+config.MaxExecutionPeriod {
|
||||
return sdkerrors.Wrap(errors.ErrInvalid, "min_execution_period should be smaller than voting_period + max_execution_period")
|
||||
|
@ -254,6 +261,7 @@ func NewGroupPolicyInfo(address sdk.AccAddress, group uint64, admin sdk.AccAddre
|
|||
return p, nil
|
||||
}
|
||||
|
||||
// SetDecisionPolicy sets the decision policy for GroupPolicyInfo.
|
||||
func (g *GroupPolicyInfo) SetDecisionPolicy(decisionPolicy DecisionPolicy) error {
|
||||
any, err := codectypes.NewAnyWithValue(decisionPolicy)
|
||||
if err != nil {
|
||||
|
@ -263,6 +271,7 @@ func (g *GroupPolicyInfo) SetDecisionPolicy(decisionPolicy DecisionPolicy) error
|
|||
return nil
|
||||
}
|
||||
|
||||
// GetDecisionPolicy gets the decision policy of GroupPolicyInfo
|
||||
func (g GroupPolicyInfo) GetDecisionPolicy() (DecisionPolicy, error) {
|
||||
decisionPolicy, ok := g.DecisionPolicy.GetCachedValue().(DecisionPolicy)
|
||||
if !ok {
|
||||
|
@ -282,6 +291,7 @@ func (g GroupInfo) PrimaryKeyFields() []interface{} {
|
|||
return []interface{}{g.Id}
|
||||
}
|
||||
|
||||
// ValidateBasic does basic validation on group info.
|
||||
func (g GroupInfo) ValidateBasic() error {
|
||||
if g.Id == 0 {
|
||||
return sdkerrors.Wrap(errors.ErrEmpty, "group's GroupId")
|
||||
|
@ -311,6 +321,7 @@ func (g Proposal) PrimaryKeyFields() []interface{} {
|
|||
return []interface{}{g.Id}
|
||||
}
|
||||
|
||||
// ValidateBasic does basic validation on group policy info.
|
||||
func (g GroupPolicyInfo) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(g.Admin)
|
||||
if err != nil {
|
||||
|
@ -344,6 +355,7 @@ func (g GroupMember) PrimaryKeyFields() []interface{} {
|
|||
return []interface{}{g.GroupId, addr.Bytes()}
|
||||
}
|
||||
|
||||
// ValidateBasic does basic validation on group member.
|
||||
func (g GroupMember) ValidateBasic() error {
|
||||
if g.GroupId == 0 {
|
||||
return sdkerrors.Wrap(errors.ErrEmpty, "group member's group id")
|
||||
|
@ -368,6 +380,7 @@ func MemberToMemberRequest(m *Member) MemberRequest {
|
|||
}
|
||||
}
|
||||
|
||||
// ValidateBasic does basic validation on proposal.
|
||||
func (g Proposal) ValidateBasic() error {
|
||||
if g.Id == 0 {
|
||||
return sdkerrors.Wrap(errors.ErrEmpty, "proposal id")
|
||||
|
@ -409,6 +422,7 @@ func (v Vote) PrimaryKeyFields() []interface{} {
|
|||
|
||||
var _ orm.Validateable = Vote{}
|
||||
|
||||
// ValidateBasic does basic validation on vote.
|
||||
func (v Vote) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(v.Voter)
|
||||
if err != nil {
|
||||
|
@ -503,6 +517,7 @@ func (t *TallyResult) operation(vote Vote, weight string, op operation) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// GetYesCount returns the number of yes counts from tally result.
|
||||
func (t TallyResult) GetYesCount() (math.Dec, error) {
|
||||
yesCount, err := math.NewNonNegativeDecFromString(t.YesCount)
|
||||
if err != nil {
|
||||
|
@ -511,6 +526,7 @@ func (t TallyResult) GetYesCount() (math.Dec, error) {
|
|||
return yesCount, nil
|
||||
}
|
||||
|
||||
// GetNoCount returns the number of no counts from tally result.
|
||||
func (t TallyResult) GetNoCount() (math.Dec, error) {
|
||||
noCount, err := math.NewNonNegativeDecFromString(t.NoCount)
|
||||
if err != nil {
|
||||
|
@ -519,6 +535,7 @@ func (t TallyResult) GetNoCount() (math.Dec, error) {
|
|||
return noCount, nil
|
||||
}
|
||||
|
||||
// GetAbstainCount returns the number of abstain counts from tally result.
|
||||
func (t TallyResult) GetAbstainCount() (math.Dec, error) {
|
||||
abstainCount, err := math.NewNonNegativeDecFromString(t.AbstainCount)
|
||||
if err != nil {
|
||||
|
@ -527,6 +544,7 @@ func (t TallyResult) GetAbstainCount() (math.Dec, error) {
|
|||
return abstainCount, nil
|
||||
}
|
||||
|
||||
// GetNoWithVetoCount returns the number of no with veto counts from tally result.
|
||||
func (t TallyResult) GetNoWithVetoCount() (math.Dec, error) {
|
||||
vetoCount, err := math.NewNonNegativeDecFromString(t.NoWithVetoCount)
|
||||
if err != nil {
|
||||
|
|
|
@ -298,7 +298,7 @@ func (m *MemberRequest) GetMetadata() string {
|
|||
|
||||
// ThresholdDecisionPolicy is a decision policy where a proposal passes when it
|
||||
// satisfies the two following conditions:
|
||||
// 1. The sum of all `YES` voters' weights is greater or equal than the defined
|
||||
// 1. The sum of all `YES` voter's weights is greater or equal than the defined
|
||||
// `threshold`.
|
||||
// 2. The voting and execution periods of the proposal respect the parameters
|
||||
// given by `windows`.
|
||||
|
@ -364,7 +364,7 @@ func (m *ThresholdDecisionPolicy) GetWindows() *DecisionPolicyWindows {
|
|||
// 2. The voting and execution periods of the proposal respect the parameters
|
||||
// given by `windows`.
|
||||
type PercentageDecisionPolicy struct {
|
||||
// percentage is the minimum percentage the weighted sum of `YES` votes must
|
||||
// percentage is the minimum percentage of the weighted sum of `YES` votes must
|
||||
// meet for a proposal to succeed.
|
||||
Percentage string `protobuf:"bytes,1,opt,name=percentage,proto3" json:"percentage,omitempty"`
|
||||
// windows defines the different windows for voting and execution.
|
||||
|
@ -641,7 +641,7 @@ type GroupPolicyInfo struct {
|
|||
GroupId uint64 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"`
|
||||
// admin is the account address of the group admin.
|
||||
Admin string `protobuf:"bytes,3,opt,name=admin,proto3" json:"admin,omitempty"`
|
||||
// metadata is any arbitrary metadata to attached to the group policy.
|
||||
// metadata is any arbitrary metadata attached to the group policy.
|
||||
Metadata string `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||
// version is used to track changes to a group's GroupPolicyInfo structure that
|
||||
// would create a different result on a running proposal.
|
||||
|
@ -694,7 +694,7 @@ type Proposal struct {
|
|||
Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
// group_policy_address is the account address of group policy.
|
||||
GroupPolicyAddress string `protobuf:"bytes,2,opt,name=group_policy_address,json=groupPolicyAddress,proto3" json:"group_policy_address,omitempty"`
|
||||
// metadata is any arbitrary metadata to attached to the proposal.
|
||||
// metadata is any arbitrary metadata attached to the proposal.
|
||||
Metadata string `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||
// proposers are the account addresses of the proposers.
|
||||
Proposers []string `protobuf:"bytes,4,rep,name=proposers,proto3" json:"proposers,omitempty"`
|
||||
|
@ -813,7 +813,7 @@ type Vote struct {
|
|||
Voter string `protobuf:"bytes,2,opt,name=voter,proto3" json:"voter,omitempty"`
|
||||
// option is the voter's choice on the proposal.
|
||||
Option VoteOption `protobuf:"varint,3,opt,name=option,proto3,enum=cosmos.group.v1.VoteOption" json:"option,omitempty"`
|
||||
// metadata is any arbitrary metadata to attached to the vote.
|
||||
// metadata is any arbitrary metadata attached to the vote.
|
||||
Metadata string `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"`
|
||||
// submit_time is the timestamp when the vote was submitted.
|
||||
SubmitTime time.Time `protobuf:"bytes,5,opt,name=submit_time,json=submitTime,proto3,stdtime" json:"submit_time"`
|
||||
|
|
Loading…
Reference in New Issue