From b8317c2e34001e08626a8e39f35ac1e57c4738a3 Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 21 Jul 2020 13:39:43 +0530 Subject: [PATCH 1/4] updated pagination flags --- x/ibc/03-connection/client/cli/query.go | 12 ++------ x/ibc/04-channel/client/cli/query.go | 38 ++++++------------------- 2 files changed, 10 insertions(+), 40 deletions(-) diff --git a/x/ibc/03-connection/client/cli/query.go b/x/ibc/03-connection/client/cli/query.go index d25eb8cea74e..c0cc5d47b4e7 100644 --- a/x/ibc/03-connection/client/cli/query.go +++ b/x/ibc/03-connection/client/cli/query.go @@ -8,7 +8,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/client/utils" "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" @@ -33,14 +32,8 @@ func GetCmdQueryConnections() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) - offset, _ := cmd.Flags().GetInt(flags.FlagPage) - limit, _ := cmd.Flags().GetInt(flags.FlagLimit) - req := &types.QueryConnectionsRequest{ - Pagination: &query.PageRequest{ - Offset: uint64(offset), - Limit: uint64(limit), - }, + Pagination: client.ReadPageRequest(cmd.Flags()), } res, err := queryClient.Connections(context.Background(), req) @@ -52,9 +45,8 @@ func GetCmdQueryConnections() *cobra.Command { }, } - cmd.Flags().Int(flags.FlagPage, 1, "pagination page of light clients to to query for") - cmd.Flags().Int(flags.FlagLimit, 100, "pagination limit of light clients to query for") flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "connection ends") return cmd } diff --git a/x/ibc/04-channel/client/cli/query.go b/x/ibc/04-channel/client/cli/query.go index 5bf57cd90a7c..1cdb6a341fa4 100644 --- a/x/ibc/04-channel/client/cli/query.go +++ b/x/ibc/04-channel/client/cli/query.go @@ -9,7 +9,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/client/utils" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" @@ -38,14 +37,8 @@ func GetCmdQueryChannels() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) - offset, _ := cmd.Flags().GetInt(flags.FlagPage) - limit, _ := cmd.Flags().GetInt(flags.FlagLimit) - req := &types.QueryChannelsRequest{ - Pagination: &query.PageRequest{ - Offset: uint64(offset), - Limit: uint64(limit), - }, + Pagination: client.ReadPageRequest(cmd.Flags()), } res, err := queryClient.Channels(context.Background(), req) @@ -58,9 +51,8 @@ func GetCmdQueryChannels() *cobra.Command { }, } - cmd.Flags().Int(flags.FlagPage, 1, "pagination page of light clients to to query for") - cmd.Flags().Int(flags.FlagLimit, 100, "pagination limit of light clients to query for") flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "channels") return cmd } @@ -119,15 +111,9 @@ func GetCmdQueryConnectionChannels() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) - offset, _ := cmd.Flags().GetInt(flags.FlagPage) - limit, _ := cmd.Flags().GetInt(flags.FlagLimit) - req := &types.QueryConnectionChannelsRequest{ Connection: args[0], - Pagination: &query.PageRequest{ - Offset: uint64(offset), - Limit: uint64(limit), - }, + Pagination: client.ReadPageRequest(cmd.Flags()), } res, err := queryClient.ConnectionChannels(context.Background(), req) @@ -140,9 +126,8 @@ func GetCmdQueryConnectionChannels() *cobra.Command { }, } - cmd.Flags().Int(flags.FlagPage, 1, "pagination page of light clients to to query for") - cmd.Flags().Int(flags.FlagLimit, 100, "pagination limit of light clients to query for") flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "channels associated with a connection") return cmd } @@ -197,16 +182,10 @@ func GetCmdQueryPacketCommitments() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) - offset, _ := cmd.Flags().GetInt(flags.FlagPage) - limit, _ := cmd.Flags().GetInt(flags.FlagLimit) - req := &types.QueryPacketCommitmentsRequest{ - PortID: args[0], - ChannelID: args[1], - Pagination: &query.PageRequest{ - Offset: uint64(offset), - Limit: uint64(limit), - }, + PortID: args[0], + ChannelID: args[1], + Pagination: client.ReadPageRequest(cmd.Flags()), } res, err := queryClient.PacketCommitments(context.Background(), req) @@ -219,9 +198,8 @@ func GetCmdQueryPacketCommitments() *cobra.Command { }, } - cmd.Flags().Int(flags.FlagPage, 1, "pagination page of light clients to to query for") - cmd.Flags().Int(flags.FlagLimit, 100, "pagination limit of light clients to query for") flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "packet commitments associated with a channel") return cmd } From c3f46d3c19b3286c483664fcebb28f0d1f5df41a Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 21 Jul 2020 14:33:00 +0530 Subject: [PATCH 2/4] updated all balances pagination flags --- x/bank/client/cli/query.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/x/bank/client/cli/query.go b/x/bank/client/cli/query.go index d34e7f3c7013..1dec6c2d480c 100644 --- a/x/bank/client/cli/query.go +++ b/x/bank/client/cli/query.go @@ -10,7 +10,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" "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -61,11 +60,6 @@ Example: return err } - denom, err := cmd.Flags().GetString(FlagDenom) - if err != nil { - return err - } - queryClient := types.NewQueryClient(clientCtx) addr, err := sdk.AccAddressFromBech32(args[0]) @@ -73,7 +67,8 @@ Example: return err } - pageReq := &query.PageRequest{} + pageReq := client.ReadPageRequest(cmd.Flags()) + denom := string(pageReq.Key) if denom == "" { params := types.NewQueryAllBalancesRequest(addr, pageReq) @@ -94,8 +89,8 @@ Example: }, } - cmd.Flags().String(FlagDenom, "", "The specific balance denomination to query for") flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "all balances") return cmd } From be23523ca1d2bac2c889c59e0de12156799bc2bd Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 21 Jul 2020 14:37:54 +0530 Subject: [PATCH 3/4] updated all balances --- x/bank/client/cli/query.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/x/bank/client/cli/query.go b/x/bank/client/cli/query.go index 1dec6c2d480c..95c070abd7f2 100644 --- a/x/bank/client/cli/query.go +++ b/x/bank/client/cli/query.go @@ -60,6 +60,11 @@ Example: return err } + denom, err := cmd.Flags().GetString(FlagDenom) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) addr, err := sdk.AccAddressFromBech32(args[0]) @@ -68,7 +73,6 @@ Example: } pageReq := client.ReadPageRequest(cmd.Flags()) - denom := string(pageReq.Key) if denom == "" { params := types.NewQueryAllBalancesRequest(addr, pageReq) @@ -89,6 +93,7 @@ Example: }, } + cmd.Flags().String(FlagDenom, "", "The specific balance denomination to query for") flags.AddQueryFlagsToCmd(cmd) flags.AddPaginationFlagsToCmd(cmd, "all balances") From a27142a1713d044f1522651999ee97a819181a2f Mon Sep 17 00:00:00 2001 From: atheesh Date: Tue, 21 Jul 2020 20:49:33 +0530 Subject: [PATCH 4/4] some doc updates --- x/gov/client/cli/query.go | 2 +- x/ibc/02-client/client/cli/query.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x/gov/client/cli/query.go b/x/gov/client/cli/query.go index 413029abafab..0538345825c9 100644 --- a/x/gov/client/cli/query.go +++ b/x/gov/client/cli/query.go @@ -315,7 +315,7 @@ $ %[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") + cmd.Flags().Int(flags.FlagPage, 1, "pagination page of proposals to query for") flags.AddPaginationFlagsToCmd(cmd, "votes") flags.AddQueryFlagsToCmd(cmd) diff --git a/x/ibc/02-client/client/cli/query.go b/x/ibc/02-client/client/cli/query.go index 83ce8a4864f8..17fb9e7e8537 100644 --- a/x/ibc/02-client/client/cli/query.go +++ b/x/ibc/02-client/client/cli/query.go @@ -45,7 +45,7 @@ func GetCmdQueryClientStates() *cobra.Command { }, } - cmd.Flags().Int(flags.FlagPage, 1, "pagination page of light clients to to query for") + cmd.Flags().Int(flags.FlagPage, 1, "pagination page of light clients to query for") cmd.Flags().Int(flags.FlagLimit, 100, "pagination limit of light clients to query for") flags.AddQueryFlagsToCmd(cmd)