* Refactor CliContext as Context
* Fix lint issues
* Fix goimports
* Fix gov tests
* Resolved ci-lint issues
* Add changelog
* Rename cliCtx to clientCtx
* Fix mocks and routes
* Add changelog
* Update changelog
* Apply suggestions from code review
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
* merge client/rpc/ro{ot,utes}.go
* Update docs
* client/rpc: remove redundant client/rpc.RegisterRPCRoutes
* regenerate mocks
* Update ADRs
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
49 lines
1.3 KiB
Go
49 lines
1.3 KiB
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/viper"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
"github.com/cosmos/cosmos-sdk/version"
|
|
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/client/utils"
|
|
)
|
|
|
|
// GetCmdQueryChannel defines the command to query a channel end
|
|
func GetCmdQueryChannel(queryRoute string, cdc *codec.Codec) *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "end [port-id] [channel-id]",
|
|
Short: "Query a channel end",
|
|
Long: strings.TrimSpace(fmt.Sprintf(`Query an IBC channel end
|
|
|
|
Example:
|
|
$ %s query ibc channel end [port-id] [channel-id]
|
|
`, version.ClientName),
|
|
),
|
|
Example: fmt.Sprintf("%s query ibc channel end [port-id] [channel-id]", version.ClientName),
|
|
Args: cobra.ExactArgs(2),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
clientCtx := client.NewContext().WithCodec(cdc)
|
|
portID := args[0]
|
|
channelID := args[1]
|
|
prove := viper.GetBool(flags.FlagProve)
|
|
|
|
channelRes, err := utils.QueryChannel(clientCtx, portID, channelID, prove)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
clientCtx = clientCtx.WithHeight(int64(channelRes.ProofHeight))
|
|
return clientCtx.PrintOutput(channelRes)
|
|
},
|
|
}
|
|
cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results")
|
|
|
|
return cmd
|
|
}
|