Skip to content

Commit

Permalink
Remove flag offset (cosmos#875)
Browse files Browse the repository at this point in the history
* Remove flag offset

* Correct example of command query txs

Co-authored-by: shaneing <[email protected]>
  • Loading branch information
shaneing and shaneing authored Jul 29, 2022
1 parent e1c8740 commit d7bb7dc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
5 changes: 0 additions & 5 deletions cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const (
flagVersion = "version"
flagDebugAddr = "debug-addr"
flagOverwriteConfig = "overwrite"
flagOffset = "offset"
flagLimit = "limit"
flagHeight = "height"
flagPage = "page"
Expand Down Expand Up @@ -73,7 +72,6 @@ func heightFlag(v *viper.Viper, cmd *cobra.Command) *cobra.Command {
func paginationFlags(v *viper.Viper, cmd *cobra.Command, query string) *cobra.Command {
cmd.Flags().Uint64(flagPage, 1, fmt.Sprintf("pagination page of %s to query for. This sets offset to a multiple of limit", query))
cmd.Flags().String(flagPageKey, "", fmt.Sprintf("pagination page-key of %s to query for", query))
cmd.Flags().Uint64(flagOffset, 0, fmt.Sprintf("pagination offset of %s to query for", query))
cmd.Flags().Uint64(flagLimit, 100, fmt.Sprintf("pagination limit of %s to query for", query))
cmd.Flags().Bool(flagCountTotal, false, fmt.Sprintf("count total number of records in %s to query for", query))
cmd.Flags().Bool(flagReverse, false, "results are sorted in descending order")
Expand All @@ -84,9 +82,6 @@ func paginationFlags(v *viper.Viper, cmd *cobra.Command, query string) *cobra.Co
if err := v.BindPFlag(flagPageKey, cmd.Flags().Lookup(flagPageKey)); err != nil {
panic(err)
}
if err := v.BindPFlag(flagOffset, cmd.Flags().Lookup(flagOffset)); err != nil {
panic(err)
}
if err := v.BindPFlag(flagLimit, cmd.Flags().Lookup(flagLimit)); err != nil {
panic(err)
}
Expand Down
1 change: 0 additions & 1 deletion cmd/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
// This allows us to avoid directly depending on the `sdk/client/flags` package inside of our cmd package.
func TestFlagEqualityAgainstSDK(t *testing.T) {
require.Equal(t, flagHome, flags.FlagHome)
require.Equal(t, flagOffset, flags.FlagOffset)
require.Equal(t, flagLimit, flags.FlagLimit)
require.Equal(t, flagHeight, flags.FlagHeight)
require.Equal(t, flagPage, flags.FlagPage)
Expand Down
6 changes: 3 additions & 3 deletions cmd/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ documents its respective events under 'cosmos-sdk/x/{module}/spec/xx_events.md'.
),
Args: withUsage(cobra.ExactArgs(2)),
Example: strings.TrimSpace(fmt.Sprintf(`
$ %s query txs ibc-0 "message.action=transfer" --offset 1 --limit 10
$ %s query txs ibc-0 "message.action=transfer" --page 1 --limit 10
$ %s q txs ibc-0 "message.action=transfer"`,
appName, appName,
)),
Expand All @@ -171,7 +171,7 @@ $ %s q txs ibc-0 "message.action=transfer"`,
return errChainNotFound(args[0])
}

offset, err := cmd.Flags().GetUint64(flagOffset)
page, err := cmd.Flags().GetUint64(flagPage)
if err != nil {
return err
}
Expand All @@ -181,7 +181,7 @@ $ %s q txs ibc-0 "message.action=transfer"`,
return err
}

txs, err := chain.ChainProvider.QueryTxs(cmd.Context(), int(offset), int(limit), []string{args[1]})
txs, err := chain.ChainProvider.QueryTxs(cmd.Context(), int(page), int(limit), []string{args[1]})
if err != nil {
return err
}
Expand Down

0 comments on commit d7bb7dc

Please sign in to comment.