Skip to content

Commit

Permalink
Add pagination flags to x{ibc, bank} (cosmos#6804)
Browse files Browse the repository at this point in the history
* updated pagination flags

* updated all balances pagination flags

* updated all balances

* some doc updates

Co-authored-by: Anil Kumar Kammari <anil@vitwit.com>
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
  • Loading branch information
3 people authored and chengwenxi committed Jul 22, 2020
1 parent 1107e37 commit ef80f41
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 44 deletions.
4 changes: 2 additions & 2 deletions x/bank/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -73,7 +72,7 @@ Example:
return err
}

pageReq := &query.PageRequest{}
pageReq := client.ReadPageRequest(cmd.Flags())
if denom == "" {
params := types.NewQueryAllBalancesRequest(addr, pageReq)

Expand All @@ -96,6 +95,7 @@ Example:

cmd.Flags().String(FlagDenom, "", "The specific balance denomination to query for")
flags.AddQueryFlagsToCmd(cmd)
flags.AddPaginationFlagsToCmd(cmd, "all balances")

return cmd
}
Expand Down
2 changes: 1 addition & 1 deletion x/gov/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion x/ibc/02-client/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 2 additions & 10 deletions x/ibc/03-connection/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand All @@ -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
}
Expand Down
38 changes: 8 additions & 30 deletions x/ibc/04-channel/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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
}
Expand Down Expand Up @@ -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)
Expand All @@ -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
}
Expand Down Expand Up @@ -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)
Expand All @@ -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
}
Expand Down

0 comments on commit ef80f41

Please sign in to comment.