Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(x/gov): refactor q gov proposer #18025

Merged
merged 2 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* (x/staking/keeper) [#]18049(https://github.com/cosmos/cosmos-sdk/pull/18049) return early if Slash encounters zero tokens to burn.
* (x/gov) [#18025](https://github.com/cosmos/cosmos-sdk/pull/18025) Improve `<appd> q gov proposer` by querying directly a proposal instead of tx events. It is an alias of `q gov proposal` as the proposer is a field of the proposal.
* (x/staking/keeper) [#18049](https://github.com/cosmos/cosmos-sdk/pull/18049) return early if Slash encounters zero tokens to burn.
* (x/staking/keeper) [#18035](https://github.com/cosmos/cosmos-sdk/pull/18035) Hoisted out of the redelegation loop, the non-changing validator and delegator addresses parsing.
* (keyring) [#17913](https://github.com/cosmos/cosmos-sdk/pull/17913) Add `NewAutoCLIKeyring` for creating an AutoCLI keyring from a SDK keyring.
* (codec) [#17913](https://github.com/cosmos/cosmos-sdk/pull/17913) `codectypes.NewAnyWithValue` supports proto v2 messages.
Expand Down
56 changes: 0 additions & 56 deletions tests/e2e/gov/query.go

This file was deleted.

1 change: 1 addition & 0 deletions x/gov/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
{
RpcMethod: "Proposal",
Use: "proposal [proposal-id]",
Alias: []string{"proposer"},
Short: "Query details of a single proposal",
Example: fmt.Sprintf("%s query gov proposal 1", version.AppName),
PositionalArgs: []*autocliv1.PositionalArgDescriptor{
Expand Down
74 changes: 0 additions & 74 deletions x/gov/client/cli/query.go

This file was deleted.

23 changes: 0 additions & 23 deletions x/gov/client/utils/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,29 +160,6 @@ func QueryVoteByTxQuery(clientCtx client.Context, params v1.QueryVoteParams) ([]
return nil, fmt.Errorf("address '%s' did not vote on proposalID %d", params.Voter, params.ProposalID)
}

// QueryProposerByTxQuery will query for a proposer of a governance proposal by ID.
func QueryProposerByTxQuery(clientCtx client.Context, proposalID uint64) (Proposer, error) {
q := fmt.Sprintf("%s.%s='%d'", types.EventTypeSubmitProposal, types.AttributeKeyProposalID, proposalID)
searchResult, err := authtx.QueryTxsByEvents(clientCtx, defaultPage, defaultLimit, q, "")
if err != nil {
return Proposer{}, err
}

for _, info := range searchResult.Txs {
for _, msg := range info.GetTx().GetMsgs() {
// there should only be a single proposal under the given conditions
if subMsg, ok := msg.(*v1beta1.MsgSubmitProposal); ok {
return NewProposer(proposalID, subMsg.Proposer), nil
}
if subMsg, ok := msg.(*v1.MsgSubmitProposal); ok {
return NewProposer(proposalID, subMsg.Proposer), nil
}
}
}

return Proposer{}, fmt.Errorf("failed to find the proposer for proposalID %d", proposalID)
}

// convertVote converts a MsgVoteWeighted into a *v1.Vote.
func convertVote(v *v1beta1.MsgVoteWeighted) *v1.Vote {
opts := make([]*v1.WeightedVoteOption, len(v.Options))
Expand Down
6 changes: 0 additions & 6 deletions x/gov/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,6 @@ func (ab AppModuleBasic) GetTxCmd() *cobra.Command {
return cli.NewTxCmd(legacyProposalCLIHandlers)
}

// GetQueryCmd returns the custom query commands for the gov modules.
// This command will be enhanced by AutoCLI as defined in the AutoCLIOptions() method.
func (ab AppModuleBasic) GetQueryCmd() *cobra.Command {
return cli.GetCustomQueryCmd(ab.ac)
}

func getProposalCLIHandlers(handlers []govclient.ProposalHandler) []*cobra.Command {
proposalCLIHandlers := make([]*cobra.Command, 0, len(handlers))
for _, proposalHandler := range handlers {
Expand Down
Loading