Add pagination flags to x{ibc, bank} (#6804)

* 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>
This commit is contained in:
atheeshp 2020-07-21 21:06:45 +05:30 committed by GitHub
parent 61d69a978f
commit 9ee14ee985
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 44 deletions

View File

@ -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"
)
@ -73,7 +72,7 @@ Example:
return err
}
pageReq := &query.PageRequest{}
pageReq := client.ReadPageRequest(cmd.Flags())
if denom == "" {
params := types.NewQueryAllBalancesRequest(addr, pageReq)
@ -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
}

View File

@ -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)

View File

@ -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)

View File

@ -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
}

View File

@ -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
}