-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
x/{gov,params,upgrade,distribution} CLI: In-Process test & use grpc query service #6664
Merged
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
5128147
refactor CLI to use grpc query service
amaury1093 6acad21
In process CLI for gov
amaury1093 a5971cb
ReadQueryCommandFlags
amaury1093 14b5036
gov tx
amaury1093 f7349d6
Merge branch 'master' into am-cli-params-distrib
amaury1093 eb73cbd
Fix compiler errors
amaury1093 8a22b96
Merge branch 'master' into am-cli-params-distrib
amaury1093 adac5e1
Formatting
amaury1093 05f47f5
Merge branch 'master' into am-cli-params-distrib
amaury1093 b1fa4e3
x/distribution: use gRPC query
amaury1093 1012219
Consistent
amaury1093 4e53b36
Fix x/distrib test
amaury1093 8ed2fd7
Merge branch 'master' into am-cli-params-distrib
amaury1093 94e37d0
Update x/gov
amaury1093 a4f391a
Merge branch 'master' into am-cli-params-distrib
amaury1093 439990e
Add ReadQueryCommandFlags
amaury1093 d078b57
Fix lint
amaury1093 ac7790c
Revert x/params
amaury1093 5296f58
x/params use grpc query
amaury1093 fbb02ae
Merge branch 'master' into am-cli-params-distrib
amaury1093 0c3f42a
Fix tests
amaury1093 49903f0
Merge branch 'master' into am-cli-params-distrib
amaury1093 eaffb1a
Use page request
amaury1093 b40b391
Merge branch 'master' into am-cli-params-distrib
amaury1093 5f50a1e
Merge branch 'master' into am-cli-params-distrib
amaury1093 cacf3b7
Merge branch 'master' into am-cli-params-distrib
amaury1093 bda7a4e
Merge branch 'master' into am-cli-params-distrib
amaury1093 96dff3e
Merge branch 'master' into am-cli-params-distrib
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Use page request
- Loading branch information
commit eaffb1af84d342a5efb04ddb953c0124a54a329f
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ import ( | |
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/flags" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/query" | ||
"github.com/cosmos/cosmos-sdk/version" | ||
gcutils "github.com/cosmos/cosmos-sdk/x/gov/client/utils" | ||
"github.com/cosmos/cosmos-sdk/x/gov/types" | ||
|
@@ -137,13 +136,15 @@ $ %s query gov proposals --page=2 --limit=100 | |
} | ||
queryClient := types.NewQueryClient(clientCtx) | ||
|
||
pageReq := client.ReadPageRequest(cmd.Flags()) | ||
|
||
res, err := queryClient.Proposals( | ||
context.Background(), | ||
&types.QueryProposalsRequest{ | ||
ProposalStatus: proposalStatus, | ||
Voter: voterAddr, | ||
Depositor: depositorAddr, | ||
Req: &query.PageRequest{}, | ||
Req: pageReq, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto |
||
}, | ||
) | ||
if err != nil { | ||
|
@@ -161,6 +162,7 @@ $ %s query gov proposals --page=2 --limit=100 | |
cmd.Flags().String(flagDepositor, "", "(optional) filter by proposals deposited on by depositor") | ||
cmd.Flags().String(flagVoter, "", "(optional) filter by proposals voted on by voted") | ||
cmd.Flags().String(flagStatus, "", "(optional) filter proposals by proposal status, status: deposit_period/voting_period/passed/rejected") | ||
flags.AddPaginationFlagsToCmd(cmd, "proposals") | ||
flags.AddQueryFlagsToCmd(cmd) | ||
|
||
return cmd | ||
|
@@ -297,9 +299,11 @@ $ %[1]s query gov votes 1 --page=2 --limit=100 | |
|
||
} | ||
|
||
pageReq := client.ReadPageRequest(cmd.Flags()) | ||
|
||
res, err := queryClient.Votes( | ||
context.Background(), | ||
&types.QueryVotesRequest{ProposalId: proposalID, Req: &query.PageRequest{}}, | ||
&types.QueryVotesRequest{ProposalId: proposalID, Req: pageReq}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto |
||
) | ||
if err != nil { | ||
return err | ||
|
@@ -310,6 +314,10 @@ $ %[1]s query gov votes 1 --page=2 --limit=100 | |
}, | ||
} | ||
|
||
// Deprecated, remove line when removing FlagPage altogether. | ||
cmd.Flags().Int(flags.FlagPage, 1, "pagination page of proposals to to query for") | ||
|
||
flags.AddPaginationFlagsToCmd(cmd, "votes") | ||
flags.AddQueryFlagsToCmd(cmd) | ||
|
||
return cmd | ||
|
@@ -438,9 +446,11 @@ $ %s query gov deposits 1 | |
return clientCtx.PrintOutput(dep) | ||
} | ||
|
||
pageReq := client.ReadPageRequest(cmd.Flags()) | ||
|
||
res, err := queryClient.Deposits( | ||
context.Background(), | ||
&types.QueryDepositsRequest{ProposalId: proposalID, Req: &query.PageRequest{}}, | ||
&types.QueryDepositsRequest{ProposalId: proposalID, Req: pageReq}, | ||
) | ||
if err != nil { | ||
return err | ||
|
@@ -450,6 +460,7 @@ $ %s query gov deposits 1 | |
}, | ||
} | ||
|
||
flags.AddPaginationFlagsToCmd(cmd, "deposits") | ||
flags.AddQueryFlagsToCmd(cmd) | ||
|
||
return cmd | ||
|
@@ -533,28 +544,38 @@ $ %s query gov params | |
if err != nil { | ||
return err | ||
} | ||
queryClient := types.NewQueryClient(clientCtx) | ||
|
||
tp, _, err := clientCtx.QueryWithData(fmt.Sprintf("custom/%s/params/tallying", types.QuerierRoute), nil) | ||
// Query store for all 3 params | ||
votingRes, err := queryClient.Params( | ||
context.Background(), | ||
&types.QueryParamsRequest{ParamsType: "voting"}, | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
dp, _, err := clientCtx.QueryWithData(fmt.Sprintf("custom/%s/params/deposit", types.QuerierRoute), nil) | ||
|
||
tallyRes, err := queryClient.Params( | ||
context.Background(), | ||
&types.QueryParamsRequest{ParamsType: "tallying"}, | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
vp, _, err := clientCtx.QueryWithData(fmt.Sprintf("custom/%s/params/voting", types.QuerierRoute), nil) | ||
|
||
depositRes, err := queryClient.Params( | ||
context.Background(), | ||
&types.QueryParamsRequest{ParamsType: "deposit"}, | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
var tallyParams types.TallyParams | ||
clientCtx.JSONMarshaler.MustUnmarshalJSON(tp, &tallyParams) | ||
var depositParams types.DepositParams | ||
clientCtx.JSONMarshaler.MustUnmarshalJSON(dp, &depositParams) | ||
var votingParams types.VotingParams | ||
clientCtx.JSONMarshaler.MustUnmarshalJSON(vp, &votingParams) | ||
|
||
return clientCtx.PrintOutput(types.NewParams(votingParams, tallyParams, depositParams)) | ||
return clientCtx.PrintOutput(types.NewParams( | ||
votingRes.GetVotingParams(), | ||
tallyRes.GetTallyParams(), | ||
depositRes.GetDepositParams(), | ||
)) | ||
}, | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't catch this before but page parameters should not be called
req
. I would just usepage
or something like that. This can be fixed separate from this PR but it should be addressed before release. /cc @sahith-narahari @anilcse @atheeshp