x/ibc: tx client protobuf migration (#6461)

* ibc/03-connection: tx client migration

* update commands

* update ibc-transfer

* remove unused queryRoute

* initialize clientCtx
This commit is contained in:
Federico Kunze 2020-06-17 21:56:48 +02:00 committed by GitHub
parent 32278d9a2b
commit 1c8249e26d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 223 additions and 272 deletions

View File

@ -5,11 +5,10 @@ import (
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
) )
// GetQueryCmd returns the query commands for IBC fungible token transfer // GetQueryCmd returns the query commands for IBC fungible token transfer
func GetQueryCmd(cdc *codec.Codec, queryRoute string) *cobra.Command { func GetQueryCmd(clientCtx client.Context) *cobra.Command {
ics20TransferQueryCmd := &cobra.Command{ ics20TransferQueryCmd := &cobra.Command{
Use: "ibc-transfer", Use: "ibc-transfer",
Short: "IBC fungible token transfer query subcommands", Short: "IBC fungible token transfer query subcommands",
@ -19,14 +18,14 @@ func GetQueryCmd(cdc *codec.Codec, queryRoute string) *cobra.Command {
} }
ics20TransferQueryCmd.AddCommand(flags.GetCommands( ics20TransferQueryCmd.AddCommand(flags.GetCommands(
GetCmdQueryNextSequence(cdc, queryRoute), GetCmdQueryNextSequence(clientCtx),
)...) )...)
return ics20TransferQueryCmd return ics20TransferQueryCmd
} }
// GetTxCmd returns the transaction commands for IBC fungible token transfer // NewTxCmd returns the transaction commands for IBC fungible token transfer
func GetTxCmd(cdc *codec.Codec) *cobra.Command { func NewTxCmd(clientCtx client.Context) *cobra.Command {
ics20TransferTxCmd := &cobra.Command{ ics20TransferTxCmd := &cobra.Command{
Use: "ibc-transfer", Use: "ibc-transfer",
Short: "IBC fungible token transfer transaction subcommands", Short: "IBC fungible token transfer transaction subcommands",
@ -36,7 +35,7 @@ func GetTxCmd(cdc *codec.Codec) *cobra.Command {
} }
ics20TransferTxCmd.AddCommand(flags.PostCommands( ics20TransferTxCmd.AddCommand(flags.PostCommands(
GetTransferTxCmd(cdc), NewTransferTxCmd(clientCtx),
)...) )...)
return ics20TransferTxCmd return ics20TransferTxCmd

View File

@ -9,13 +9,13 @@ import (
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/client/utils" "github.com/cosmos/cosmos-sdk/x/ibc-transfer/client/utils"
) )
// GetCmdQueryNextSequence defines the command to query a next receive sequence // GetCmdQueryNextSequence defines the command to query a next receive sequence
func GetCmdQueryNextSequence(cdc *codec.Codec, queryRoute string) *cobra.Command { // TODO: move to channel
func GetCmdQueryNextSequence(clientCtx client.Context) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "next-recv [port-id] [channel-id]", Use: "next-recv [port-id] [channel-id]",
Short: "Query a next receive sequence", Short: "Query a next receive sequence",
@ -28,7 +28,8 @@ $ %s query ibc-transfer next-recv [port-id] [channel-id]
Example: fmt.Sprintf("%s query ibc-transfer next-recv [port-id] [channel-id]", version.ClientName), Example: fmt.Sprintf("%s query ibc-transfer next-recv [port-id] [channel-id]", version.ClientName),
Args: cobra.ExactArgs(2), Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.NewContext().WithCodec(cdc) clientCtx = clientCtx.Init()
portID := args[0] portID := args[0]
channelID := args[1] channelID := args[1]
prove := viper.GetBool(flags.FlagProve) prove := viper.GetBool(flags.FlagProve)

View File

@ -1,19 +1,15 @@
package cli package cli
import ( import (
"bufio"
"fmt" "fmt"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/version"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/types" "github.com/cosmos/cosmos-sdk/x/ibc-transfer/types"
) )
@ -22,17 +18,15 @@ const (
flagTimeoutTimestamp = "timeout-timestamp" flagTimeoutTimestamp = "timeout-timestamp"
) )
// GetTransferTxCmd returns the command to create a NewMsgTransfer transaction // NewTransferTxCmd returns the command to create a NewMsgTransfer transaction
func GetTransferTxCmd(cdc *codec.Codec) *cobra.Command { func NewTransferTxCmd(clientCtx client.Context) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "transfer [src-port] [src-channel] [receiver] [amount]", Use: "transfer [src-port] [src-channel] [receiver] [amount]",
Short: "Transfer a fungible token through IBC", Short: "Transfer a fungible token through IBC",
Example: fmt.Sprintf("%s tx ibc-transfer transfer [src-port] [src-channel] [receiver] [amount]", version.ClientName), Example: fmt.Sprintf("%s tx ibc-transfer transfer [src-port] [src-channel] [receiver] [amount]", version.ClientName),
Args: cobra.ExactArgs(4), Args: cobra.ExactArgs(4),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) clientCtx = clientCtx.InitWithInput(cmd.InOrStdin())
txBldr := authtypes.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
clientCtx := client.NewContextWithInput(inBuf).WithCodec(cdc).WithBroadcastMode(flags.BroadcastBlock)
sender := clientCtx.GetFromAddress() sender := clientCtx.GetFromAddress()
srcPort := args[0] srcPort := args[0]
@ -54,7 +48,7 @@ func GetTransferTxCmd(cdc *codec.Codec) *cobra.Command {
return err return err
} }
return authclient.GenerateOrBroadcastMsgs(clientCtx, txBldr, []sdk.Msg{msg}) return tx.GenerateOrBroadcastTx(clientCtx, msg)
}, },
} }
cmd.Flags().Uint64(flagTimeoutHeight, types.DefaultAbsolutePacketTimeoutHeight, "Absolute timeout block height. The timeout is disabled when set to 0.") cmd.Flags().Uint64(flagTimeoutHeight, types.DefaultAbsolutePacketTimeoutHeight, "Absolute timeout block height. The timeout is disabled when set to 0.")

View File

@ -74,12 +74,12 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout
// GetTxCmd implements AppModuleBasic interface // GetTxCmd implements AppModuleBasic interface
func (AppModuleBasic) GetTxCmd(clientCtx client.Context) *cobra.Command { func (AppModuleBasic) GetTxCmd(clientCtx client.Context) *cobra.Command {
return cli.GetTxCmd(clientCtx.Codec) return cli.NewTxCmd(clientCtx)
} }
// GetQueryCmd implements AppModuleBasic interface // GetQueryCmd implements AppModuleBasic interface
func (AppModuleBasic) GetQueryCmd(clientCtx client.Context) *cobra.Command { func (AppModuleBasic) GetQueryCmd(clientCtx client.Context) *cobra.Command {
return cli.GetQueryCmd(clientCtx.Codec, types.QuerierRoute) return cli.GetQueryCmd(clientCtx)
} }
// RegisterInterfaceTypes registers module concrete types into protobuf Any. // RegisterInterfaceTypes registers module concrete types into protobuf Any.

View File

@ -5,13 +5,13 @@ import (
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
) )
// GetQueryCmd returns the query commands for IBC clients // GetQueryCmd returns the query commands for IBC clients
func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { func GetQueryCmd(clientCtx client.Context) *cobra.Command {
ics02ClientQueryCmd := &cobra.Command{ ics02ClientQueryCmd := &cobra.Command{
Use: "client", Use: types.SubModuleName,
Short: "IBC client query subcommands", Short: "IBC client query subcommands",
DisableFlagParsing: true, DisableFlagParsing: true,
SuggestionsMinimumDistance: 2, SuggestionsMinimumDistance: 2,
@ -19,12 +19,12 @@ func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command {
} }
ics02ClientQueryCmd.AddCommand(flags.GetCommands( ics02ClientQueryCmd.AddCommand(flags.GetCommands(
GetCmdQueryClientStates(queryRoute, cdc), GetCmdQueryClientStates(clientCtx),
GetCmdQueryClientState(queryRoute, cdc), GetCmdQueryClientState(clientCtx),
GetCmdQueryConsensusState(queryRoute, cdc), GetCmdQueryConsensusState(clientCtx),
GetCmdQueryHeader(cdc), GetCmdQueryHeader(clientCtx),
GetCmdNodeConsensusState(queryRoute, cdc), GetCmdNodeConsensusState(clientCtx),
GetCmdQueryPath(queryRoute, cdc), GetCmdQueryPath(clientCtx),
)...) )...)
return ics02ClientQueryCmd return ics02ClientQueryCmd
} }

View File

@ -11,7 +11,6 @@ import (
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/client/utils" "github.com/cosmos/cosmos-sdk/x/ibc/02-client/client/utils"
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
@ -19,7 +18,7 @@ import (
// GetCmdQueryClientStates defines the command to query all the light clients // GetCmdQueryClientStates defines the command to query all the light clients
// that this chain mantains. // that this chain mantains.
func GetCmdQueryClientStates(queryRoute string, cdc *codec.Codec) *cobra.Command { func GetCmdQueryClientStates(clientCtx client.Context) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "states", Use: "states",
Short: "Query all available light clients", Short: "Query all available light clients",
@ -32,7 +31,8 @@ $ %s query ibc client states
), ),
Example: fmt.Sprintf("%s query ibc client states", version.ClientName), Example: fmt.Sprintf("%s query ibc client states", version.ClientName),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.NewContext().WithCodec(cdc) clientCtx = clientCtx.Init()
page := viper.GetInt(flags.FlagPage) page := viper.GetInt(flags.FlagPage)
limit := viper.GetInt(flags.FlagLimit) limit := viper.GetInt(flags.FlagLimit)
@ -52,7 +52,7 @@ $ %s query ibc client states
// GetCmdQueryClientState defines the command to query the state of a client with // GetCmdQueryClientState defines the command to query the state of a client with
// a given id as defined in https://github.com/cosmos/ics/tree/master/spec/ics-002-client-semantics#query // a given id as defined in https://github.com/cosmos/ics/tree/master/spec/ics-002-client-semantics#query
func GetCmdQueryClientState(queryRoute string, cdc *codec.Codec) *cobra.Command { func GetCmdQueryClientState(clientCtx client.Context) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "state [client-id]", Use: "state [client-id]",
Short: "Query a client state", Short: "Query a client state",
@ -65,7 +65,8 @@ $ %s query ibc client state [client-id]
), ),
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.NewContext().WithCodec(cdc) clientCtx = clientCtx.Init()
clientID := args[0] clientID := args[0]
if strings.TrimSpace(clientID) == "" { if strings.TrimSpace(clientID) == "" {
return errors.New("client ID can't be blank") return errors.New("client ID can't be blank")
@ -88,7 +89,7 @@ $ %s query ibc client state [client-id]
// GetCmdQueryConsensusState defines the command to query the consensus state of // GetCmdQueryConsensusState defines the command to query the consensus state of
// the chain as defined in https://github.com/cosmos/ics/tree/master/spec/ics-002-client-semantics#query // the chain as defined in https://github.com/cosmos/ics/tree/master/spec/ics-002-client-semantics#query
func GetCmdQueryConsensusState(queryRoute string, cdc *codec.Codec) *cobra.Command { func GetCmdQueryConsensusState(clientCtx client.Context) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "consensus-state [client-id] [height]", Use: "consensus-state [client-id] [height]",
Short: "Query the consensus state of a client at a given height", Short: "Query the consensus state of a client at a given height",
@ -96,7 +97,8 @@ func GetCmdQueryConsensusState(queryRoute string, cdc *codec.Codec) *cobra.Comma
Example: fmt.Sprintf("%s query ibc client consensus-state [client-id] [height]", version.ClientName), Example: fmt.Sprintf("%s query ibc client consensus-state [client-id] [height]", version.ClientName),
Args: cobra.ExactArgs(2), Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.NewContext().WithCodec(cdc) clientCtx = clientCtx.Init()
clientID := args[0] clientID := args[0]
if strings.TrimSpace(clientID) == "" { if strings.TrimSpace(clientID) == "" {
return errors.New("client ID can't be blank") return errors.New("client ID can't be blank")
@ -123,14 +125,14 @@ func GetCmdQueryConsensusState(queryRoute string, cdc *codec.Codec) *cobra.Comma
} }
// GetCmdQueryHeader defines the command to query the latest header on the chain // GetCmdQueryHeader defines the command to query the latest header on the chain
func GetCmdQueryHeader(cdc *codec.Codec) *cobra.Command { func GetCmdQueryHeader(clientCtx client.Context) *cobra.Command {
return &cobra.Command{ return &cobra.Command{
Use: "header", Use: "header",
Short: "Query the latest header of the running chain", Short: "Query the latest header of the running chain",
Long: "Query the latest Tendermint header of the running chain", Long: "Query the latest Tendermint header of the running chain",
Example: fmt.Sprintf("%s query ibc client header", version.ClientName), Example: fmt.Sprintf("%s query ibc client header", version.ClientName),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.NewContext().WithCodec(cdc) clientCtx = clientCtx.Init()
header, height, err := utils.QueryTendermintHeader(clientCtx) header, height, err := utils.QueryTendermintHeader(clientCtx)
if err != nil { if err != nil {
@ -145,7 +147,7 @@ func GetCmdQueryHeader(cdc *codec.Codec) *cobra.Command {
// GetCmdNodeConsensusState defines the command to query the latest consensus state of a node // GetCmdNodeConsensusState defines the command to query the latest consensus state of a node
// The result is feed to client creation // The result is feed to client creation
func GetCmdNodeConsensusState(queryRoute string, cdc *codec.Codec) *cobra.Command { func GetCmdNodeConsensusState(clientCtx client.Context) *cobra.Command {
return &cobra.Command{ return &cobra.Command{
Use: "node-state", Use: "node-state",
Short: "Query a node consensus state", Short: "Query a node consensus state",
@ -158,7 +160,7 @@ $ %s query ibc client node-state
), ),
Args: cobra.ExactArgs(0), Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.NewContext().WithCodec(cdc) clientCtx = clientCtx.Init()
state, height, err := utils.QueryNodeConsensusState(clientCtx) state, height, err := utils.QueryNodeConsensusState(clientCtx)
if err != nil { if err != nil {
@ -172,14 +174,15 @@ $ %s query ibc client node-state
} }
// GetCmdQueryPath defines the command to query the commitment path. // GetCmdQueryPath defines the command to query the commitment path.
func GetCmdQueryPath(storeName string, cdc *codec.Codec) *cobra.Command { func GetCmdQueryPath(clientCtx client.Context) *cobra.Command {
return &cobra.Command{ return &cobra.Command{
Use: "path", Use: "path",
Short: "Query the commitment path of the running chain", Short: "Query the commitment path of the running chain",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
clienCtx := client.NewContext().WithCodec(cdc) clientCtx = clientCtx.Init()
path := commitmenttypes.NewMerklePrefix([]byte("ibc")) path := commitmenttypes.NewMerklePrefix([]byte("ibc"))
return clienCtx.PrintOutput(path) return clientCtx.PrintOutput(path)
}, },
} }
} }

View File

@ -13,6 +13,6 @@ const (
) )
// RegisterRoutes - Central function to define routes that get registered by the main application // RegisterRoutes - Central function to define routes that get registered by the main application
func RegisterRoutes(clientCtx client.Context, r *mux.Router, queryRoute string) { func RegisterRoutes(clientCtx client.Context, r *mux.Router) {
registerQueryRoutes(clientCtx, r) registerQueryRoutes(clientCtx, r)
} }

View File

@ -1,13 +1,10 @@
package client package client
import ( import (
"fmt"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/client/cli" "github.com/cosmos/cosmos-sdk/x/ibc/02-client/client/cli"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/client/rest" "github.com/cosmos/cosmos-sdk/x/ibc/02-client/client/rest"
) )
@ -18,11 +15,11 @@ func Name() string {
} }
// RegisterRESTRoutes registers the REST routes for the IBC client // RegisterRESTRoutes registers the REST routes for the IBC client
func RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router, queryRoute string) { func RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
rest.RegisterRoutes(clientCtx, rtr, fmt.Sprintf("%s/%s", queryRoute, SubModuleName)) rest.RegisterRoutes(clientCtx, rtr)
} }
// GetQueryCmd returns no root query command for the IBC client // GetQueryCmd returns no root query command for the IBC client
func GetQueryCmd(cdc *codec.Codec, queryRoute string) *cobra.Command { func GetQueryCmd(clientCtx client.Context) *cobra.Command {
return cli.GetQueryCmd(fmt.Sprintf("%s/%s", queryRoute, SubModuleName), cdc) return cli.GetQueryCmd(clientCtx)
} }

View File

@ -3,39 +3,43 @@ package cli
import ( import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
) )
// GetQueryCmd returns the query commands for IBC connections // GetQueryCmd returns the query commands for IBC connections
func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { func GetQueryCmd(clientCtx client.Context) *cobra.Command {
ics03ConnectionQueryCmd := &cobra.Command{ ics03ConnectionQueryCmd := &cobra.Command{
Use: "connection", Use: types.SubModuleName,
Short: "IBC connection query subcommands", Short: "IBC connection query subcommands",
DisableFlagParsing: true, DisableFlagParsing: true,
SuggestionsMinimumDistance: 2, SuggestionsMinimumDistance: 2,
} }
ics03ConnectionQueryCmd.AddCommand(flags.GetCommands( ics03ConnectionQueryCmd.AddCommand(flags.GetCommands(
GetCmdQueryConnections(queryRoute, cdc), GetCmdQueryConnections(clientCtx),
GetCmdQueryConnection(queryRoute, cdc), GetCmdQueryConnection(clientCtx),
)...) )...)
return ics03ConnectionQueryCmd return ics03ConnectionQueryCmd
} }
// GetTxCmd returns the transaction commands for IBC connections // NewTxCmd returns a CLI command handler for all x/ibc connection transaction commands.
func GetTxCmd(storeKey string, cdc *codec.Codec) *cobra.Command { func NewTxCmd(clientCtx client.Context) *cobra.Command {
ics03ConnectionTxCmd := &cobra.Command{ ics03ConnectionTxCmd := &cobra.Command{
Use: "connection", Use: types.SubModuleName,
Short: "IBC connection transaction subcommands", Short: "IBC connection transaction subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
} }
ics03ConnectionTxCmd.AddCommand(flags.PostCommands( ics03ConnectionTxCmd.AddCommand(flags.PostCommands(
GetCmdConnectionOpenInit(storeKey, cdc), NewConnectionOpenInitCmd(clientCtx),
GetCmdConnectionOpenTry(storeKey, cdc), NewConnectionOpenTryCmd(clientCtx),
GetCmdConnectionOpenAck(storeKey, cdc), NewConnectionOpenAckCmd(clientCtx),
GetCmdConnectionOpenConfirm(storeKey, cdc), NewConnectionOpenConfirmCmd(clientCtx),
)...) )...)
return ics03ConnectionTxCmd return ics03ConnectionTxCmd

View File

@ -9,14 +9,13 @@ import (
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/version" "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/client/utils"
) )
// GetCmdQueryConnections defines the command to query all the connection ends // GetCmdQueryConnections defines the command to query all the connection ends
// that this chain mantains. // that this chain mantains.
func GetCmdQueryConnections(queryRoute string, cdc *codec.Codec) *cobra.Command { func GetCmdQueryConnections(clientCtx client.Context) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "connections", Use: "connections",
Short: "Query all available light clients", Short: "Query all available light clients",
@ -30,7 +29,8 @@ $ %s query ibc connection connections
Example: fmt.Sprintf("%s query ibc connection connections", version.ClientName), Example: fmt.Sprintf("%s query ibc connection connections", version.ClientName),
Args: cobra.NoArgs, Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, _ []string) error { RunE: func(cmd *cobra.Command, _ []string) error {
clientCtx := client.NewContext().WithCodec(cdc) clientCtx = clientCtx.Init()
page := viper.GetInt(flags.FlagPage) page := viper.GetInt(flags.FlagPage)
limit := viper.GetInt(flags.FlagLimit) limit := viper.GetInt(flags.FlagLimit)
@ -50,7 +50,7 @@ $ %s query ibc connection connections
} }
// GetCmdQueryConnection defines the command to query a connection end // GetCmdQueryConnection defines the command to query a connection end
func GetCmdQueryConnection(queryRoute string, cdc *codec.Codec) *cobra.Command { func GetCmdQueryConnection(clientCtx client.Context) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "end [connection-id]", Use: "end [connection-id]",
Short: "Query stored connection end", Short: "Query stored connection end",
@ -63,7 +63,8 @@ $ %s query ibc connection end [connection-id]
Example: fmt.Sprintf("%s query ibc connection end [connection-id]", version.ClientName), Example: fmt.Sprintf("%s query ibc connection end [connection-id]", version.ClientName),
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.NewContext().WithCodec(cdc) clientCtx = clientCtx.Init()
connectionID := args[0] connectionID := args[0]
prove := viper.GetBool(flags.FlagProve) prove := viper.GetBool(flags.FlagProve)
@ -82,7 +83,7 @@ $ %s query ibc connection end [connection-id]
} }
// GetCmdQueryAllClientConnections defines the command to query a all the client connection paths. // GetCmdQueryAllClientConnections defines the command to query a all the client connection paths.
func GetCmdQueryAllClientConnections(queryRoute string, cdc *codec.Codec) *cobra.Command { func GetCmdQueryAllClientConnections(clientCtx client.Context) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "paths", Use: "paths",
Short: "Query all stored client connection paths", Short: "Query all stored client connection paths",
@ -95,7 +96,8 @@ $ %s query ibc connection paths
Example: fmt.Sprintf("%s query ibc connection paths", version.ClientName), Example: fmt.Sprintf("%s query ibc connection paths", version.ClientName),
Args: cobra.NoArgs, Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, _ []string) error { RunE: func(cmd *cobra.Command, _ []string) error {
clientCtx := client.NewContext().WithCodec(cdc) clientCtx = clientCtx.Init()
page := viper.GetInt(flags.FlagPage) page := viper.GetInt(flags.FlagPage)
limit := viper.GetInt(flags.FlagLimit) limit := viper.GetInt(flags.FlagLimit)
@ -115,7 +117,7 @@ $ %s query ibc connection paths
} }
// GetCmdQueryClientConnections defines the command to query a client connections // GetCmdQueryClientConnections defines the command to query a client connections
func GetCmdQueryClientConnections(queryRoute string, cdc *codec.Codec) *cobra.Command { func GetCmdQueryClientConnections(clientCtx client.Context) *cobra.Command {
return &cobra.Command{ return &cobra.Command{
Use: "path [client-id]", Use: "path [client-id]",
Short: "Query stored client connection paths", Short: "Query stored client connection paths",
@ -128,7 +130,8 @@ $ %s query ibc connection path [client-id]
Example: fmt.Sprintf("%s query ibc connection path [client-id]", version.ClientName), Example: fmt.Sprintf("%s query ibc connection path [client-id]", version.ClientName),
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.NewContext().WithCodec(cdc) clientCtx = clientCtx.Init()
clientID := args[0] clientID := args[0]
prove := viper.GetBool(flags.FlagProve) prove := viper.GetBool(flags.FlagProve)

View File

@ -1,53 +1,33 @@
package cli package cli
import ( import (
"bufio"
"fmt" "fmt"
"strings" "strings"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/version"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/ibc/03-connection/client/utils" "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/client/utils"
"github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types" "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
) )
// Connection Handshake flags // NewConnectionOpenInitCmd defines the command to initialize a connection on
const (
FlagNode1 = "node1"
FlagNode2 = "node2"
FlagFrom1 = "from1"
FlagFrom2 = "from2"
FlagChainID2 = "chain-id2"
)
// GetCmdConnectionOpenInit defines the command to initialize a connection on
// chain A with a given counterparty chain B // chain A with a given counterparty chain B
func GetCmdConnectionOpenInit(storeKey string, cdc *codec.Codec) *cobra.Command { func NewConnectionOpenInitCmd(clientCtx client.Context) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: strings.TrimSpace(`open-init [connection-id] [client-id] [counterparty-connection-id] [counterparty-client-id] [path/to/counterparty_prefix.json]`), Use: "open-init [connection-id] [client-id] [counterparty-connection-id] [counterparty-client-id] [path/to/counterparty_prefix.json]",
Short: "initialize connection on chain A", Short: "Initialize connection on chain A",
Long: strings.TrimSpace( Long: "Initialize a connection on chain A with a given counterparty chain B",
fmt.Sprintf(`initialize a connection on chain A with a given counterparty chain B: Example: fmt.Sprintf(
"%s tx %s %s open-init [connection-id] [client-id] [counterparty-connection-id] [counterparty-client-id] [path/to/counterparty_prefix.json]",
Example: version.ClientName, host.ModuleName, types.SubModuleName,
$ %s tx ibc connection open-init [connection-id] [client-id] \
[counterparty-connection-id] [counterparty-client-id] \
[path/to/counterparty_prefix.json]
`, version.ClientName),
), ),
Args: cobra.ExactArgs(5), Args: cobra.ExactArgs(5),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) clientCtx = clientCtx.InitWithInput(cmd.InOrStdin())
txBldr := authtypes.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
clientCtx := client.NewContextWithInput(inBuf).WithCodec(cdc)
connectionID := args[0] connectionID := args[0]
clientID := args[1] clientID := args[1]
@ -68,37 +48,31 @@ $ %s tx ibc connection open-init [connection-id] [client-id] \
return err return err
} }
return authclient.GenerateOrBroadcastMsgs(clientCtx, txBldr, []sdk.Msg{msg}) return tx.GenerateOrBroadcastTx(clientCtx, msg)
}, },
} }
return cmd return cmd
} }
// GetCmdConnectionOpenTry defines the command to relay a try open a connection on // NewConnectionOpenTryCmd defines the command to relay a try open a connection on
// chain B // chain B
func GetCmdConnectionOpenTry(storeKey string, cdc *codec.Codec) *cobra.Command { func NewConnectionOpenTryCmd(clientCtx client.Context) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: strings.TrimSpace(`open-try [connection-id] [client-id] Use: strings.TrimSpace(`open-try [connection-id] [client-id]
[counterparty-connection-id] [counterparty-client-id] [path/to/counterparty_prefix.json] [counterparty-connection-id] [counterparty-client-id] [path/to/counterparty_prefix.json]
[counterparty-versions] [path/to/proof_init.json] [path/to/proof_consensus.json]`), [counterparty-versions] [path/to/proof_init.json] [path/to/proof_consensus.json]`),
Short: "initiate connection handshake between two chains", Short: "initiate connection handshake between two chains",
Long: strings.TrimSpace( Long: "Initialize a connection on chain A with a given counterparty chain B",
fmt.Sprintf(`initialize a connection on chain A with a given counterparty chain B: Example: fmt.Sprintf(
`%s tx %s %s open-try connection-id] [client-id] \
Example:
$ %s tx ibc connection open-try connection-id] [client-id] \
[counterparty-connection-id] [counterparty-client-id] [path/to/counterparty_prefix.json] \ [counterparty-connection-id] [counterparty-client-id] [path/to/counterparty_prefix.json] \
[counterparty-versions] [path/to/proof_init.json] [path/tp/proof_consensus.json] [counterparty-versions] [path/to/proof_init.json] [path/tp/proof_consensus.json]`,
`, version.ClientName), version.ClientName, host.ModuleName, types.SubModuleName,
), ),
Args: cobra.ExactArgs(8), Args: cobra.ExactArgs(8),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) clientCtx = clientCtx.InitWithInput(cmd.InOrStdin())
txBldr := authtypes.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
clientCtx := client.NewContextWithInput(inBuf).
WithCodec(cdc).
WithHeight(viper.GetInt64(flags.FlagHeight))
connectionID := args[0] connectionID := args[0]
clientID := args[1] clientID := args[1]
@ -139,31 +113,27 @@ $ %s tx ibc connection open-try connection-id] [client-id] \
return err return err
} }
return authclient.GenerateOrBroadcastMsgs(clientCtx, txBldr, []sdk.Msg{msg}) return tx.GenerateOrBroadcastTx(clientCtx, msg)
}, },
} }
return cmd return cmd
} }
// GetCmdConnectionOpenAck defines the command to relay the acceptance of a // NewConnectionOpenAckCmd defines the command to relay the acceptance of a
// connection open attempt from chain B to chain A // connection open attempt from chain B to chain A
func GetCmdConnectionOpenAck(storeKey string, cdc *codec.Codec) *cobra.Command { func NewConnectionOpenAckCmd(clientCtx client.Context) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "open-ack [connection-id] [path/to/proof_try.json] [path/to/proof_consensus.json] [version]", Use: "open-ack [connection-id] [path/to/proof_try.json] [path/to/proof_consensus.json] [version]",
Short: "relay the acceptance of a connection open attempt from chain B to chain A", Short: "relay the acceptance of a connection open attempt",
Long: strings.TrimSpace( Long: "Relay the acceptance of a connection open attempt from chain B to chain A",
fmt.Sprintf(`relay the acceptance of a connection open attempt from chain B to chain A: Example: fmt.Sprintf(
"%s tx %s %s open-ack [connection-id] [path/to/proof_try.json] [path/to/proof_consensus.json] [version]",
Example: version.ClientName, host.ModuleName, types.SubModuleName,
$ %s tx ibc connection open-ack [connection-id] [path/to/proof_try.json] [path/to/proof_consensus.json] [version]
`, version.ClientName),
), ),
Args: cobra.ExactArgs(4), Args: cobra.ExactArgs(4),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) clientCtx = clientCtx.InitWithInput(cmd.InOrStdin())
txBldr := authtypes.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
clientCtx := client.NewContextWithInput(inBuf).WithCodec(cdc)
connectionID := args[0] connectionID := args[0]
@ -194,33 +164,27 @@ $ %s tx ibc connection open-ack [connection-id] [path/to/proof_try.json] [path/t
return err return err
} }
return authclient.GenerateOrBroadcastMsgs(clientCtx, txBldr, []sdk.Msg{msg}) return tx.GenerateOrBroadcastTx(clientCtx, msg)
}, },
} }
return cmd return cmd
} }
// GetCmdConnectionOpenConfirm defines the command to initialize a connection on // NewConnectionOpenConfirmCmd defines the command to initialize a connection on
// chain A with a given counterparty chain B // chain A with a given counterparty chain B
func GetCmdConnectionOpenConfirm(storeKey string, cdc *codec.Codec) *cobra.Command { func NewConnectionOpenConfirmCmd(clientCtx client.Context) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "open-confirm [connection-id] [path/to/proof_ack.json]", Use: "open-confirm [connection-id] [path/to/proof_ack.json]",
Short: "confirm to chain B that connection is open on chain A", Short: "confirm to chain B that connection is open on chain A",
Long: strings.TrimSpace( Long: "Confirm to chain B that connection is open on chain A",
fmt.Sprintf(`confirm to chain B that connection is open on chain A: Example: fmt.Sprintf(
"%s tx %s %s open-confirm [connection-id] [path/to/proof_ack.json]",
Example: version.ClientName, host.ModuleName, types.SubModuleName,
$ %s tx ibc connection open-confirm [connection-id] [path/to/proof_ack.json]
`, version.ClientName),
), ),
Args: cobra.ExactArgs(2), Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) clientCtx = clientCtx.InitWithInput(cmd.InOrStdin())
txBldr := authtypes.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
clientCtx := client.NewContextWithInput(inBuf).
WithCodec(cdc).
WithHeight(viper.GetInt64(flags.FlagHeight))
connectionID := args[0] connectionID := args[0]
@ -242,7 +206,7 @@ $ %s tx ibc connection open-confirm [connection-id] [path/to/proof_ack.json]
return err return err
} }
return authclient.GenerateOrBroadcastMsgs(clientCtx, txBldr, []sdk.Msg{msg}) return tx.GenerateOrBroadcastTx(clientCtx, msg)
}, },
} }

View File

@ -12,11 +12,11 @@ import (
"github.com/cosmos/cosmos-sdk/x/ibc/03-connection/client/utils" "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/client/utils"
) )
func registerQueryRoutes(clientCtx client.Context, r *mux.Router, queryRoute string) { func registerQueryRoutes(clientCtx client.Context, r *mux.Router) {
r.HandleFunc("/ibc/connections", queryConnectionsHandlerFn(clientCtx)).Methods("GET") r.HandleFunc("/ibc/connections", queryConnectionsHandlerFn(clientCtx)).Methods("GET")
r.HandleFunc(fmt.Sprintf("/ibc/connections/{%s}", RestConnectionID), queryConnectionHandlerFn(clientCtx, queryRoute)).Methods("GET") r.HandleFunc(fmt.Sprintf("/ibc/connections/{%s}", RestConnectionID), queryConnectionHandlerFn(clientCtx)).Methods("GET")
r.HandleFunc("/ibc/clients/connections", queryClientsConnectionsHandlerFn(clientCtx)).Methods("GET") r.HandleFunc("/ibc/clients/connections", queryClientsConnectionsHandlerFn(clientCtx)).Methods("GET")
r.HandleFunc(fmt.Sprintf("/ibc/clients/{%s}/connections", RestClientID), queryClientConnectionsHandlerFn(clientCtx, queryRoute)).Methods("GET") r.HandleFunc(fmt.Sprintf("/ibc/clients/{%s}/connections", RestClientID), queryClientConnectionsHandlerFn(clientCtx)).Methods("GET")
} }
// queryConnectionsHandlerFn implements connections querying route // queryConnectionsHandlerFn implements connections querying route
@ -64,7 +64,7 @@ func queryClientsConnectionsHandlerFn(clientCtx client.Context) http.HandlerFunc
// @Failure 400 {object} rest.ErrorResponse "Invalid connection id" // @Failure 400 {object} rest.ErrorResponse "Invalid connection id"
// @Failure 500 {object} rest.ErrorResponse "Internal Server Error" // @Failure 500 {object} rest.ErrorResponse "Internal Server Error"
// @Router /ibc/connections/{connection-id} [get] // @Router /ibc/connections/{connection-id} [get]
func queryConnectionHandlerFn(clientCtx client.Context, _ string) http.HandlerFunc { func queryConnectionHandlerFn(clientCtx client.Context) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r) vars := mux.Vars(r)
connectionID := vars[RestConnectionID] connectionID := vars[RestConnectionID]
@ -131,7 +131,7 @@ func queryConnectionsHandlerFn(clientCtx client.Context) http.HandlerFunc {
// @Failure 400 {object} rest.ErrorResponse "Invalid client id" // @Failure 400 {object} rest.ErrorResponse "Invalid client id"
// @Failure 500 {object} rest.ErrorResponse "Internal Server Error" // @Failure 500 {object} rest.ErrorResponse "Internal Server Error"
// @Router /ibc/clients/{client-id}/connections [get] // @Router /ibc/clients/{client-id}/connections [get]
func queryClientConnectionsHandlerFn(clientCtx client.Context, _ string) http.HandlerFunc { func queryClientConnectionsHandlerFn(clientCtx client.Context) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r) vars := mux.Vars(r)
clientID := vars[RestClientID] clientID := vars[RestClientID]

View File

@ -14,8 +14,8 @@ const (
) )
// RegisterRoutes - Central function to define routes that get registered by the main application // RegisterRoutes - Central function to define routes that get registered by the main application
func RegisterRoutes(clientCtx client.Context, r *mux.Router, queryRoute string) { func RegisterRoutes(clientCtx client.Context, r *mux.Router) {
registerQueryRoutes(clientCtx, r, queryRoute) registerQueryRoutes(clientCtx, r)
registerTxRoutes(clientCtx, r) registerTxRoutes(clientCtx, r)
} }

View File

@ -1,13 +1,10 @@
package connection package connection
import ( import (
"fmt"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/x/ibc/03-connection/client/cli" "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/client/cli"
"github.com/cosmos/cosmos-sdk/x/ibc/03-connection/client/rest" "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/client/rest"
) )
@ -18,16 +15,16 @@ func Name() string {
} }
// GetTxCmd returns the root tx command for the IBC connections. // GetTxCmd returns the root tx command for the IBC connections.
func GetTxCmd(cdc *codec.Codec, storeKey string) *cobra.Command { func GetTxCmd(clientCtx client.Context) *cobra.Command {
return cli.GetTxCmd(fmt.Sprintf("%s/%s", storeKey, SubModuleName), cdc) return cli.NewTxCmd(clientCtx)
} }
// GetQueryCmd returns no root query command for the IBC connections. // GetQueryCmd returns no root query command for the IBC connections.
func GetQueryCmd(cdc *codec.Codec, queryRoute string) *cobra.Command { func GetQueryCmd(clientCtx client.Context) *cobra.Command {
return cli.GetQueryCmd(fmt.Sprintf("%s/%s", queryRoute, SubModuleName), cdc) return cli.GetQueryCmd(clientCtx)
} }
// RegisterRESTRoutes registers the REST routes for the IBC connections. // RegisterRESTRoutes registers the REST routes for the IBC connections.
func RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router, queryRoute string) { func RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
rest.RegisterRoutes(clientCtx, rtr, fmt.Sprintf("%s/%s", queryRoute, SubModuleName)) rest.RegisterRoutes(clientCtx, rtr)
} }

View File

@ -3,41 +3,51 @@ package cli
import ( import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
) )
// GetQueryCmd returns the query commands for IBC channels // GetQueryCmd returns the query commands for IBC channels
func GetQueryCmd(storeKey string, cdc *codec.Codec) *cobra.Command { func GetQueryCmd(clientCtx client.Context) *cobra.Command {
ics04ChannelQueryCmd := &cobra.Command{ ics04ChannelQueryCmd := &cobra.Command{
Use: types.SubModuleName, Use: types.SubModuleName,
Short: "IBC channel query subcommands", Short: "IBC channel query subcommands",
DisableFlagParsing: true, DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
} }
ics04ChannelQueryCmd.AddCommand(flags.GetCommands( ics04ChannelQueryCmd.AddCommand(flags.GetCommands(
GetCmdQueryChannel(storeKey, cdc), // TODO: Query all channels
GetCmdQueryChannelClientState(cdc), GetCmdQueryChannel(clientCtx),
// TODO: Query channels from a connection
GetCmdQueryChannelClientState(clientCtx),
// TODO: Query all packet commitments
// TODO: Query unrelayed packet ACKS
// TODO: Query unrelayed packet sends
)...) )...)
return ics04ChannelQueryCmd return ics04ChannelQueryCmd
} }
// GetTxCmd returns the transaction commands for IBC channels // NewTxCmd returns a CLI command handler for all x/ibc channel transaction commands.
func GetTxCmd(storeKey string, cdc *codec.Codec) *cobra.Command { func NewTxCmd(clientCtx client.Context) *cobra.Command {
ics04ChannelTxCmd := &cobra.Command{ ics04ChannelTxCmd := &cobra.Command{
Use: types.SubModuleName, Use: types.SubModuleName,
Short: "IBC channel transaction subcommands", Short: "IBC channel transaction subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
} }
ics04ChannelTxCmd.AddCommand(flags.PostCommands( ics04ChannelTxCmd.AddCommand(flags.PostCommands(
GetMsgChannelOpenInitCmd(storeKey, cdc), NewChannelOpenInitCmd(clientCtx),
GetMsgChannelOpenTryCmd(storeKey, cdc), NewChannelOpenTryCmd(clientCtx),
GetMsgChannelOpenAckCmd(storeKey, cdc), NewChannelOpenAckCmd(clientCtx),
GetMsgChannelOpenConfirmCmd(storeKey, cdc), NewChannelOpenConfirmCmd(clientCtx),
GetMsgChannelCloseInitCmd(storeKey, cdc), NewChannelCloseInitCmd(clientCtx),
GetMsgChannelCloseConfirmCmd(storeKey, cdc), NewChannelCloseConfirmCmd(clientCtx),
)...) )...)
return ics04ChannelTxCmd return ics04ChannelTxCmd

View File

@ -2,33 +2,31 @@ package cli
import ( import (
"fmt" "fmt"
"strings"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/version" "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/client/utils"
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
) )
// GetCmdQueryChannel defines the command to query a channel end // GetCmdQueryChannel defines the command to query a channel end
func GetCmdQueryChannel(queryRoute string, cdc *codec.Codec) *cobra.Command { func GetCmdQueryChannel(clientCtx client.Context) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "end [port-id] [channel-id]", Use: "end [port-id] [channel-id]",
Short: "Query a channel end", Short: "Query a channel end",
Long: strings.TrimSpace(fmt.Sprintf(`Query an IBC channel end Long: "Query an IBC channel end from a port and channel identifiers",
Example: fmt.Sprintf(
Example: "%s query %s %s end [port-id] [channel-id]", version.ClientName, host.ModuleName, types.SubModuleName,
$ %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),
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.NewContext().WithCodec(cdc) clientCtx = clientCtx.Init()
portID := args[0] portID := args[0]
channelID := args[1] channelID := args[1]
prove := viper.GetBool(flags.FlagProve) prove := viper.GetBool(flags.FlagProve)
@ -48,7 +46,7 @@ $ %s query ibc channel end [port-id] [channel-id]
} }
// GetCmdQueryChannelClientState defines the command to query a client state from a channel // GetCmdQueryChannelClientState defines the command to query a client state from a channel
func GetCmdQueryChannelClientState(cdc *codec.Codec) *cobra.Command { func GetCmdQueryChannelClientState(clientCtx client.Context) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "client-state [port-id] [channel-id]", Use: "client-state [port-id] [channel-id]",
Short: "Query the client state associated with a channel", Short: "Query the client state associated with a channel",
@ -56,7 +54,8 @@ func GetCmdQueryChannelClientState(cdc *codec.Codec) *cobra.Command {
Example: fmt.Sprintf("%s query ibc channel client-state [port-id] [channel-id]", version.ClientName), Example: fmt.Sprintf("%s query ibc channel client-state [port-id] [channel-id]", version.ClientName),
Args: cobra.ExactArgs(2), Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.NewContext().WithCodec(cdc) clientCtx = clientCtx.Init()
portID := args[0] portID := args[0]
channelID := args[1] channelID := args[1]

View File

@ -1,7 +1,6 @@
package cli package cli
import ( import (
"bufio"
"strconv" "strconv"
"strings" "strings"
@ -9,10 +8,7 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
connectionutils "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/client/utils" connectionutils "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/client/utils"
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
) )
@ -23,16 +19,14 @@ const (
FlagIBCVersion = "ibc-version" FlagIBCVersion = "ibc-version"
) )
// GetMsgChannelOpenInitCmd returns the command to create a MsgChannelOpenInit transaction // NewChannelOpenInitCmd returns the command to create a MsgChannelOpenInit transaction
func GetMsgChannelOpenInitCmd(storeKey string, cdc *codec.Codec) *cobra.Command { func NewChannelOpenInitCmd(clientCtx client.Context) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "open-init [port-id] [channel-id] [counterparty-port-id] [counterparty-channel-id] [connection-hops]", Use: "open-init [port-id] [channel-id] [counterparty-port-id] [counterparty-channel-id] [connection-hops]",
Short: "Creates and sends a ChannelOpenInit message", Short: "Creates and sends a ChannelOpenInit message",
Args: cobra.ExactArgs(5), Args: cobra.ExactArgs(5),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) clientCtx = clientCtx.InitWithInput(cmd.InOrStdin())
txBldr := authtypes.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
clientCtx := client.NewContextWithInput(inBuf).WithCodec(cdc)
portID := args[0] portID := args[0]
channelID := args[1] channelID := args[1]
@ -50,7 +44,7 @@ func GetMsgChannelOpenInitCmd(storeKey string, cdc *codec.Codec) *cobra.Command
return err return err
} }
return authclient.GenerateOrBroadcastMsgs(clientCtx, txBldr, []sdk.Msg{msg}) return tx.GenerateOrBroadcastTx(clientCtx, msg)
}, },
} }
@ -60,16 +54,14 @@ func GetMsgChannelOpenInitCmd(storeKey string, cdc *codec.Codec) *cobra.Command
return cmd return cmd
} }
// GetMsgChannelOpenTryCmd returns the command to create a MsgChannelOpenTry transaction // NewChannelOpenTryCmd returns the command to create a MsgChannelOpenTry transaction
func GetMsgChannelOpenTryCmd(storeKey string, cdc *codec.Codec) *cobra.Command { func NewChannelOpenTryCmd(clientCtx client.Context) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "open-try [port-id] [channel-id] [counterparty-port-id] [counterparty-channel-id] [connection-hops] [/path/to/proof_init.json] [proof-height]", Use: "open-try [port-id] [channel-id] [counterparty-port-id] [counterparty-channel-id] [connection-hops] [/path/to/proof_init.json] [proof-height]",
Short: "Creates and sends a ChannelOpenTry message", Short: "Creates and sends a ChannelOpenTry message",
Args: cobra.ExactArgs(7), Args: cobra.ExactArgs(7),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) clientCtx = clientCtx.InitWithInput(cmd.InOrStdin())
txBldr := authtypes.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
clientCtx := client.NewContextWithInput(inBuf).WithCodec(cdc)
portID := args[0] portID := args[0]
channelID := args[1] channelID := args[1]
@ -98,7 +90,7 @@ func GetMsgChannelOpenTryCmd(storeKey string, cdc *codec.Codec) *cobra.Command {
return err return err
} }
return authclient.GenerateOrBroadcastMsgs(clientCtx, txBldr, []sdk.Msg{msg}) return tx.GenerateOrBroadcastTx(clientCtx, msg)
}, },
} }
cmd.Flags().Bool(FlagOrdered, true, "Pass flag for opening ordered channels") cmd.Flags().Bool(FlagOrdered, true, "Pass flag for opening ordered channels")
@ -107,16 +99,14 @@ func GetMsgChannelOpenTryCmd(storeKey string, cdc *codec.Codec) *cobra.Command {
return cmd return cmd
} }
// GetMsgChannelOpenAckCmd returns the command to create a MsgChannelOpenAck transaction // NewChannelOpenAckCmd returns the command to create a MsgChannelOpenAck transaction
func GetMsgChannelOpenAckCmd(storeKey string, cdc *codec.Codec) *cobra.Command { func NewChannelOpenAckCmd(clientCtx client.Context) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "open-ack [port-id] [channel-id] [/path/to/proof_try.json] [proof-height]", Use: "open-ack [port-id] [channel-id] [/path/to/proof_try.json] [proof-height]",
Short: "Creates and sends a ChannelOpenAck message", Short: "Creates and sends a ChannelOpenAck message",
Args: cobra.ExactArgs(4), Args: cobra.ExactArgs(4),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) clientCtx = clientCtx.InitWithInput(cmd.InOrStdin())
txBldr := authtypes.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
clientCtx := client.NewContextWithInput(inBuf).WithCodec(cdc)
portID := args[0] portID := args[0]
channelID := args[1] channelID := args[1]
@ -139,23 +129,21 @@ func GetMsgChannelOpenAckCmd(storeKey string, cdc *codec.Codec) *cobra.Command {
return err return err
} }
return authclient.GenerateOrBroadcastMsgs(clientCtx, txBldr, []sdk.Msg{msg}) return tx.GenerateOrBroadcastTx(clientCtx, msg)
}, },
} }
cmd.Flags().String(FlagIBCVersion, "1.0.0", "supported IBC version") cmd.Flags().String(FlagIBCVersion, "1.0.0", "supported IBC version")
return cmd return cmd
} }
// GetMsgChannelOpenConfirmCmd returns the command to create a MsgChannelOpenConfirm transaction // NewChannelOpenConfirmCmd returns the command to create a MsgChannelOpenConfirm transaction
func GetMsgChannelOpenConfirmCmd(storeKey string, cdc *codec.Codec) *cobra.Command { func NewChannelOpenConfirmCmd(clientCtx client.Context) *cobra.Command {
return &cobra.Command{ return &cobra.Command{
Use: "open-confirm [port-id] [channel-id] [/path/to/proof_ack.json] [proof-height]", Use: "open-confirm [port-id] [channel-id] [/path/to/proof_ack.json] [proof-height]",
Short: "Creates and sends a ChannelOpenConfirm message", Short: "Creates and sends a ChannelOpenConfirm message",
Args: cobra.ExactArgs(4), Args: cobra.ExactArgs(4),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) clientCtx = clientCtx.InitWithInput(cmd.InOrStdin())
txBldr := authtypes.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
clientCtx := client.NewContextWithInput(inBuf).WithCodec(cdc)
portID := args[0] portID := args[0]
channelID := args[1] channelID := args[1]
@ -177,21 +165,19 @@ func GetMsgChannelOpenConfirmCmd(storeKey string, cdc *codec.Codec) *cobra.Comma
return err return err
} }
return authclient.GenerateOrBroadcastMsgs(clientCtx, txBldr, []sdk.Msg{msg}) return tx.GenerateOrBroadcastTx(clientCtx, msg)
}, },
} }
} }
// GetMsgChannelCloseInitCmd returns the command to create a MsgChannelCloseInit transaction // NewChannelCloseInitCmd returns the command to create a MsgChannelCloseInit transaction
func GetMsgChannelCloseInitCmd(storeKey string, cdc *codec.Codec) *cobra.Command { func NewChannelCloseInitCmd(clientCtx client.Context) *cobra.Command {
return &cobra.Command{ return &cobra.Command{
Use: "close-init [port-id] [channel-id]", Use: "close-init [port-id] [channel-id]",
Short: "Creates and sends a ChannelCloseInit message", Short: "Creates and sends a ChannelCloseInit message",
Args: cobra.ExactArgs(2), Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) clientCtx = clientCtx.InitWithInput(cmd.InOrStdin())
txBldr := authtypes.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
clientCtx := client.NewContextWithInput(inBuf).WithCodec(cdc)
portID := args[0] portID := args[0]
channelID := args[1] channelID := args[1]
@ -201,21 +187,19 @@ func GetMsgChannelCloseInitCmd(storeKey string, cdc *codec.Codec) *cobra.Command
return err return err
} }
return authclient.GenerateOrBroadcastMsgs(clientCtx, txBldr, []sdk.Msg{msg}) return tx.GenerateOrBroadcastTx(clientCtx, msg)
}, },
} }
} }
// GetMsgChannelCloseConfirmCmd returns the command to create a MsgChannelCloseConfirm transaction // NewChannelCloseConfirmCmd returns the command to create a MsgChannelCloseConfirm transaction
func GetMsgChannelCloseConfirmCmd(storeKey string, cdc *codec.Codec) *cobra.Command { func NewChannelCloseConfirmCmd(clientCtx client.Context) *cobra.Command {
return &cobra.Command{ return &cobra.Command{
Use: "close-confirm [port-id] [channel-id] [/path/to/proof_init.json] [proof-height]", Use: "close-confirm [port-id] [channel-id] [/path/to/proof_init.json] [proof-height]",
Short: "Creates and sends a ChannelCloseConfirm message", Short: "Creates and sends a ChannelCloseConfirm message",
Args: cobra.ExactArgs(4), Args: cobra.ExactArgs(4),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) clientCtx = clientCtx.InitWithInput(cmd.InOrStdin())
txBldr := authtypes.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
clientCtx := client.NewContextWithInput(inBuf).WithCodec(cdc)
portID := args[0] portID := args[0]
channelID := args[1] channelID := args[1]
@ -237,7 +221,7 @@ func GetMsgChannelCloseConfirmCmd(storeKey string, cdc *codec.Codec) *cobra.Comm
return err return err
} }
return authclient.GenerateOrBroadcastMsgs(clientCtx, txBldr, []sdk.Msg{msg}) return tx.GenerateOrBroadcastTx(clientCtx, msg)
}, },
} }
} }

View File

@ -1,13 +1,10 @@
package channel package channel
import ( import (
"fmt"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/client/cli" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/client/cli"
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/client/rest" "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/client/rest"
) )
@ -17,17 +14,17 @@ func Name() string {
return SubModuleName return SubModuleName
} }
// RegisterRESTRoutes registers the REST routes for the IBC channel
func RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router, queryRoute string) {
rest.RegisterRoutes(clientCtx, rtr)
}
// GetTxCmd returns the root tx command for the IBC connections. // GetTxCmd returns the root tx command for the IBC connections.
func GetTxCmd(cdc *codec.Codec, storeKey string) *cobra.Command { func GetTxCmd(clientCtx client.Context) *cobra.Command {
return cli.GetTxCmd(fmt.Sprintf("%s/%s", storeKey, SubModuleName), cdc) return cli.NewTxCmd(clientCtx)
} }
// GetQueryCmd returns no root query command for the IBC connections. // GetQueryCmd returns no root query command for the IBC connections.
func GetQueryCmd(cdc *codec.Codec, queryRoute string) *cobra.Command { func GetQueryCmd(clientCtx client.Context) *cobra.Command {
return cli.GetQueryCmd(fmt.Sprintf("%s/%s", queryRoute, SubModuleName), cdc) return cli.GetQueryCmd(clientCtx)
}
// RegisterRESTRoutes registers the REST routes for the IBC channel
func RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
rest.RegisterRoutes(clientCtx, rtr)
} }

View File

@ -21,7 +21,7 @@ const (
) )
// RegisterRoutes - Central function to define routes that get registered by the main application // RegisterRoutes - Central function to define routes that get registered by the main application
func RegisterRoutes(clientCtx client.Context, r *mux.Router, queryRoute string) { func RegisterRoutes(clientCtx client.Context, r *mux.Router) {
registerTxRoutes(clientCtx, r) registerTxRoutes(clientCtx, r)
} }

View File

@ -19,8 +19,8 @@ func Name() string {
} }
// RegisterRESTRoutes registers the REST routes for the IBC client // RegisterRESTRoutes registers the REST routes for the IBC client
func RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router, queryRoute string) { func RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
rest.RegisterRoutes(clientCtx, rtr, fmt.Sprintf("%s/%s", queryRoute, types.SubModuleName)) rest.RegisterRoutes(clientCtx, rtr)
} }
// GetTxCmd returns the root tx command for the IBC client // GetTxCmd returns the root tx command for the IBC client

View File

@ -8,7 +8,7 @@ import (
) )
// RegisterRoutes - Central function to define routes that get registered by the main application // RegisterRoutes - Central function to define routes that get registered by the main application
func RegisterRoutes(clientCtx client.Context, r *mux.Router, queryRoute string) { func RegisterRoutes(clientCtx client.Context, r *mux.Router) {
registerTxRoutes(clientCtx, r) registerTxRoutes(clientCtx, r)
} }

View File

@ -19,8 +19,8 @@ func Name() string {
} }
// RegisterRESTRoutes registers the REST routes for the IBC localhost client // RegisterRESTRoutes registers the REST routes for the IBC localhost client
func RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router, queryRoute string) { func RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
rest.RegisterRoutes(clientCtx, rtr, fmt.Sprintf("%s/%s", queryRoute, types.SubModuleName)) rest.RegisterRoutes(clientCtx, rtr)
} }
// GetTxCmd returns the root tx command for the IBC localhost client // GetTxCmd returns the root tx command for the IBC localhost client

View File

@ -5,7 +5,6 @@ import (
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
ibcclient "github.com/cosmos/cosmos-sdk/x/ibc/02-client" ibcclient "github.com/cosmos/cosmos-sdk/x/ibc/02-client"
connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection" connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection"
channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel" channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel"
@ -15,7 +14,7 @@ import (
) )
// GetTxCmd returns the transaction commands for this module // GetTxCmd returns the transaction commands for this module
func GetTxCmd(storeKey string, cdc *codec.Codec) *cobra.Command { func GetTxCmd(clientCtx client.Context) *cobra.Command {
ibcTxCmd := &cobra.Command{ ibcTxCmd := &cobra.Command{
Use: host.ModuleName, Use: host.ModuleName,
Short: "IBC transaction subcommands", Short: "IBC transaction subcommands",
@ -25,16 +24,16 @@ func GetTxCmd(storeKey string, cdc *codec.Codec) *cobra.Command {
} }
ibcTxCmd.AddCommand(flags.PostCommands( ibcTxCmd.AddCommand(flags.PostCommands(
tmclient.GetTxCmd(cdc, storeKey), tmclient.GetTxCmd(clientCtx.Codec, host.StoreKey),
localhost.GetTxCmd(cdc, storeKey), localhost.GetTxCmd(clientCtx.Codec, host.StoreKey),
connection.GetTxCmd(cdc, storeKey), connection.GetTxCmd(clientCtx),
channel.GetTxCmd(cdc, storeKey), channel.GetTxCmd(clientCtx),
)...) )...)
return ibcTxCmd return ibcTxCmd
} }
// GetQueryCmd returns the cli query commands for this module // GetQueryCmd returns the cli query commands for this module
func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { func GetQueryCmd(clientCtx client.Context) *cobra.Command {
// Group ibc queries under a subcommand // Group ibc queries under a subcommand
ibcQueryCmd := &cobra.Command{ ibcQueryCmd := &cobra.Command{
Use: host.ModuleName, Use: host.ModuleName,
@ -45,9 +44,9 @@ func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command {
} }
ibcQueryCmd.AddCommand(flags.GetCommands( ibcQueryCmd.AddCommand(flags.GetCommands(
ibcclient.GetQueryCmd(cdc, queryRoute), ibcclient.GetQueryCmd(clientCtx),
connection.GetQueryCmd(cdc, queryRoute), connection.GetQueryCmd(clientCtx),
channel.GetQueryCmd(cdc, queryRoute), channel.GetQueryCmd(clientCtx),
)...) )...)
return ibcQueryCmd return ibcQueryCmd
} }

View File

@ -4,7 +4,7 @@ import (
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
client2 "github.com/cosmos/cosmos-sdk/x/ibc/02-client" ibcclient "github.com/cosmos/cosmos-sdk/x/ibc/02-client"
connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection" connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection"
channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel" channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel"
tendermint "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint" tendermint "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint"
@ -13,9 +13,9 @@ import (
// RegisterRoutes - Central function to define routes that get registered by the main application // RegisterRoutes - Central function to define routes that get registered by the main application
func RegisterRoutes(clientCtx client.Context, r *mux.Router, queryRoute string) { func RegisterRoutes(clientCtx client.Context, r *mux.Router, queryRoute string) {
client2.RegisterRESTRoutes(clientCtx, r, queryRoute) ibcclient.RegisterRESTRoutes(clientCtx, r)
tendermint.RegisterRESTRoutes(clientCtx, r, queryRoute) tendermint.RegisterRESTRoutes(clientCtx, r)
localhost.RegisterRESTRoutes(clientCtx, r, queryRoute) localhost.RegisterRESTRoutes(clientCtx, r)
connection.RegisterRESTRoutes(clientCtx, r, queryRoute) connection.RegisterRESTRoutes(clientCtx, r)
channel.RegisterRESTRoutes(clientCtx, r, queryRoute) channel.RegisterRESTRoutes(clientCtx, r)
} }

View File

@ -70,12 +70,12 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout
// GetTxCmd returns the root tx command for the ibc module. // GetTxCmd returns the root tx command for the ibc module.
func (AppModuleBasic) GetTxCmd(clientCtx client.Context) *cobra.Command { func (AppModuleBasic) GetTxCmd(clientCtx client.Context) *cobra.Command {
return cli.GetTxCmd(host.StoreKey, clientCtx.Codec) return cli.GetTxCmd(clientCtx)
} }
// GetQueryCmd returns no root query command for the ibc module. // GetQueryCmd returns no root query command for the ibc module.
func (AppModuleBasic) GetQueryCmd(clientCtx client.Context) *cobra.Command { func (AppModuleBasic) GetQueryCmd(clientCtx client.Context) *cobra.Command {
return cli.GetQueryCmd(host.QuerierRoute, clientCtx.Codec) return cli.GetQueryCmd(clientCtx)
} }
// RegisterInterfaceTypes registers module concrete types into protobuf Any. // RegisterInterfaceTypes registers module concrete types into protobuf Any.