diff --git a/CHANGELOG.md b/CHANGELOG.md index edda2d7a867..696cc07cf81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,8 +36,9 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] -### API Breaking +### API Breaking +* (modules/core) [\#109](https://github.com/cosmos/ibc-go/pull/109) Remove connection and channel handshake CLI commands. * (modules) [\#107](https://github.com/cosmos/ibc-go/pull/107) Modify OnRecvPacket callback to return an acknowledgement which indicates if it is successful or not. Callback state changes are discarded for unsuccessful acknowledgements only. * (modules) [\#108](https://github.com/cosmos/ibc-go/pull/108) All message constructors take the signer as a string to prevent upstream bugs. The `String()` function for an SDK Acc Address relies on external context. diff --git a/go.mod b/go.mod index 7cf8a7b5a4b..f9c9b147f21 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,6 @@ require ( github.com/rakyll/statik v0.1.7 github.com/spf13/cast v1.3.1 github.com/spf13/cobra v1.1.3 - github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.7.1 github.com/stretchr/testify v1.7.0 github.com/tendermint/tendermint v0.34.8 diff --git a/modules/core/03-connection/client/cli/cli.go b/modules/core/03-connection/client/cli/cli.go index a70240559fd..743ca49ebdb 100644 --- a/modules/core/03-connection/client/cli/cli.go +++ b/modules/core/03-connection/client/cli/cli.go @@ -3,7 +3,6 @@ package cli import ( "github.com/spf13/cobra" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/ibc-go/modules/core/03-connection/types" ) @@ -24,23 +23,3 @@ func GetQueryCmd() *cobra.Command { return queryCmd } - -// NewTxCmd returns a CLI command handler for all x/ibc connection transaction commands. -func NewTxCmd() *cobra.Command { - txCmd := &cobra.Command{ - Use: types.SubModuleName, - Short: "IBC connection transaction subcommands", - DisableFlagParsing: true, - SuggestionsMinimumDistance: 2, - RunE: client.ValidateCmd, - } - - txCmd.AddCommand( - NewConnectionOpenInitCmd(), - NewConnectionOpenTryCmd(), - NewConnectionOpenAckCmd(), - NewConnectionOpenConfirmCmd(), - ) - - return txCmd -} diff --git a/modules/core/03-connection/client/cli/tx.go b/modules/core/03-connection/client/cli/tx.go deleted file mode 100644 index df396c8b578..00000000000 --- a/modules/core/03-connection/client/cli/tx.go +++ /dev/null @@ -1,348 +0,0 @@ -package cli - -import ( - "fmt" - "io/ioutil" - "strings" - - "github.com/pkg/errors" - "github.com/spf13/cobra" - - "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" - "github.com/cosmos/cosmos-sdk/types/msgservice" - "github.com/cosmos/cosmos-sdk/version" - clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types" - "github.com/cosmos/ibc-go/modules/core/03-connection/client/utils" - "github.com/cosmos/ibc-go/modules/core/03-connection/types" - host "github.com/cosmos/ibc-go/modules/core/24-host" -) - -const ( - flagVersionIdentifier = "version-identifier" - flagVersionFeatures = "version-features" - flagDelayPeriod = "delay-period" -) - -// NewConnectionOpenInitCmd defines the command to initialize a connection on -// chain A with a given counterparty chain B -func NewConnectionOpenInitCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "open-init [client-id] [counterparty-client-id] [path/to/counterparty_prefix.json]", - Short: "Initialize connection on chain A", - Long: `Initialize a connection on chain A with a given counterparty chain B. - - 'version-identifier' flag can be a single pre-selected version identifier to be used in the handshake. - - 'version-features' flag can be a list of features separated by commas to accompany the version identifier.`, - Example: fmt.Sprintf( - "%s tx %s %s open-init [client-id] [counterparty-client-id] [path/to/counterparty_prefix.json] --version-identifier=\"1.0\" --version-features=\"ORDER_UNORDERED\" --delay-period=500", - version.AppName, host.ModuleName, types.SubModuleName, - ), - Args: cobra.ExactArgs(3), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - clientID := args[0] - counterpartyClientID := args[1] - - counterpartyPrefix, err := utils.ParsePrefix(clientCtx.LegacyAmino, args[2]) - if err != nil { - return err - } - - var version *types.Version - versionIdentifier, _ := cmd.Flags().GetString(flagVersionIdentifier) - - if versionIdentifier != "" { - var features []string - - versionFeatures, _ := cmd.Flags().GetString(flagVersionFeatures) - if versionFeatures != "" { - features = strings.Split(versionFeatures, ",") - } - - version = types.NewVersion(versionIdentifier, features) - } - - delayPeriod, err := cmd.Flags().GetUint64(flagDelayPeriod) - if err != nil { - return err - } - - msg := types.NewMsgConnectionOpenInit( - clientID, counterpartyClientID, - counterpartyPrefix, version, delayPeriod, clientCtx.GetFromAddress().String(), - ) - - svcMsgClientConn := &msgservice.ServiceMsgClientConn{} - msgClient := types.NewMsgClient(svcMsgClientConn) - _, err = msgClient.ConnectionOpenInit(cmd.Context(), msg) - if err != nil { - return err - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), svcMsgClientConn.GetMsgs()...) - }, - } - - // NOTE: we should use empty default values since the user may not want to select a version - // at this step in the handshake. - cmd.Flags().String(flagVersionIdentifier, "", "version identifier to be used in the connection handshake version negotiation") - cmd.Flags().String(flagVersionFeatures, "", "version features list separated by commas without spaces. The features must function with the version identifier.") - cmd.Flags().Uint64(flagDelayPeriod, 0, "delay period that must pass before packet verification can pass against a consensus state") - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -// NewConnectionOpenTryCmd defines the command to relay a try open a connection on -// chain B -func NewConnectionOpenTryCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: strings.TrimSpace(`open-try [connection-id] [client-id] -[counterparty-connection-id] [counterparty-client-id] [path/to/counterparty_prefix.json] [path/to/client_state.json] -[path/to/counterparty_version1.json,path/to/counterparty_version2.json...] [consensus-height] [proof-height] [path/to/proof_init.json] [path/to/proof_client.json] [path/to/proof_consensus.json]`), - Short: "initiate connection handshake between two chains", - Long: "Initialize a connection on chain A with a given counterparty chain B. Provide counterparty versions separated by commas", - Example: fmt.Sprintf( - `%s tx %s %s open-try connection-id] [client-id] \ -[counterparty-connection-id] [counterparty-client-id] [path/to/counterparty_prefix.json] [path/to/client_state.json]\ -[counterparty-versions] [consensus-height] [proof-height] [path/to/proof_init.json] [path/to/proof_client.json] [path/to/proof_consensus.json]`, - version.AppName, host.ModuleName, types.SubModuleName, - ), - Args: cobra.ExactArgs(12), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - connectionID := args[0] - clientID := args[1] - counterpartyConnectionID := args[2] - counterpartyClientID := args[3] - - counterpartyPrefix, err := utils.ParsePrefix(clientCtx.LegacyAmino, args[4]) - if err != nil { - return err - } - - counterpartyClient, err := utils.ParseClientState(clientCtx.LegacyAmino, args[5]) - if err != nil { - return err - } - - cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry) - - versionsStr := strings.Split(args[6], ",") - counterpartyVersions := make([]*types.Version, len(versionsStr)) - - for _, ver := range versionsStr { - - // attempt to unmarshal version - version := &types.Version{} - if err := cdc.UnmarshalJSON([]byte(ver), version); err != nil { - - // check for file path if JSON input is not provided - contents, err := ioutil.ReadFile(ver) - if err != nil { - return errors.Wrap(err, "neither JSON input nor path to .json file for version were provided") - } - - if err := cdc.UnmarshalJSON(contents, version); err != nil { - return errors.Wrap(err, "error unmarshalling version file") - } - } - } - - consensusHeight, err := clienttypes.ParseHeight(args[7]) - if err != nil { - return err - } - proofHeight, err := clienttypes.ParseHeight(args[8]) - if err != nil { - return err - } - - proofInit, err := utils.ParseProof(clientCtx.LegacyAmino, args[9]) - if err != nil { - return err - } - - proofClient, err := utils.ParseProof(clientCtx.LegacyAmino, args[10]) - if err != nil { - return err - } - - proofConsensus, err := utils.ParseProof(clientCtx.LegacyAmino, args[11]) - if err != nil { - return err - } - - delayPeriod, err := cmd.Flags().GetUint64(flagDelayPeriod) - if err != nil { - return err - } - - msg := types.NewMsgConnectionOpenTry( - connectionID, clientID, counterpartyConnectionID, counterpartyClientID, - counterpartyClient, counterpartyPrefix, counterpartyVersions, delayPeriod, - proofInit, proofClient, proofConsensus, proofHeight, - consensusHeight, clientCtx.GetFromAddress().String(), - ) - - svcMsgClientConn := &msgservice.ServiceMsgClientConn{} - msgClient := types.NewMsgClient(svcMsgClientConn) - _, err = msgClient.ConnectionOpenTry(cmd.Context(), msg) - if err != nil { - return err - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), svcMsgClientConn.GetMsgs()...) - }, - } - - cmd.Flags().Uint64(flagDelayPeriod, 0, "delay period that must pass before packet verification can pass against a consensus state") - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -// NewConnectionOpenAckCmd defines the command to relay the acceptance of a -// connection open attempt from chain B to chain A -func NewConnectionOpenAckCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: `open-ack [connection-id] [counterparty-connection-id] [path/to/client_state.json] [consensus-height] [proof-height] - [path/to/proof_try.json] [path/to/proof_client.json] [path/to/proof_consensus.json] [version]`, - Short: "relay the acceptance of a connection open attempt", - Long: "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] [counterparty-connection-id] [path/to/client_state.json] [consensus-height] [proof-height] - [path/to/proof_try.json] [path/to/proof_client.json] [path/to/proof_consensus.json] [version]`, - version.AppName, host.ModuleName, types.SubModuleName, - ), - Args: cobra.ExactArgs(9), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - connectionID := args[0] - counterpartyConnectionID := args[1] - - counterpartyClient, err := utils.ParseClientState(clientCtx.LegacyAmino, args[2]) - if err != nil { - return err - } - - consensusHeight, err := clienttypes.ParseHeight(args[3]) - if err != nil { - return err - } - proofHeight, err := clienttypes.ParseHeight(args[4]) - if err != nil { - return err - } - - proofTry, err := utils.ParseProof(clientCtx.LegacyAmino, args[5]) - if err != nil { - return err - } - - proofClient, err := utils.ParseProof(clientCtx.LegacyAmino, args[6]) - if err != nil { - return err - } - - proofConsensus, err := utils.ParseProof(clientCtx.LegacyAmino, args[7]) - if err != nil { - return err - } - - cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry) - - // attempt to unmarshal version - version := &types.Version{} - if err := cdc.UnmarshalJSON([]byte(args[8]), version); err != nil { - - // check for file path if JSON input is not provided - contents, err := ioutil.ReadFile(args[8]) - if err != nil { - return errors.Wrap(err, "neither JSON input nor path to .json file for version were provided") - } - - if err := cdc.UnmarshalJSON(contents, version); err != nil { - return errors.Wrap(err, "error unmarshalling version file") - } - } - - msg := types.NewMsgConnectionOpenAck( - connectionID, counterpartyConnectionID, counterpartyClient, proofTry, proofClient, proofConsensus, proofHeight, - consensusHeight, version, clientCtx.GetFromAddress().String(), - ) - - svcMsgClientConn := &msgservice.ServiceMsgClientConn{} - msgClient := types.NewMsgClient(svcMsgClientConn) - _, err = msgClient.ConnectionOpenAck(cmd.Context(), msg) - if err != nil { - return err - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), svcMsgClientConn.GetMsgs()...) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -// NewConnectionOpenConfirmCmd defines the command to initialize a connection on -// chain A with a given counterparty chain B -func NewConnectionOpenConfirmCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "open-confirm [connection-id] [proof-height] [path/to/proof_ack.json]", - Short: "confirm to chain B that connection is open on chain A", - Long: "Confirm to chain B that connection is open on chain A", - Example: fmt.Sprintf( - "%s tx %s %s open-confirm [connection-id] [proof-height] [path/to/proof_ack.json]", - version.AppName, host.ModuleName, types.SubModuleName, - ), - Args: cobra.ExactArgs(3), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - connectionID := args[0] - proofHeight, err := clienttypes.ParseHeight(args[1]) - if err != nil { - return err - } - - proofAck, err := utils.ParseProof(clientCtx.LegacyAmino, args[2]) - if err != nil { - return err - } - - msg := types.NewMsgConnectionOpenConfirm( - connectionID, proofAck, proofHeight, clientCtx.GetFromAddress().String(), - ) - - svcMsgClientConn := &msgservice.ServiceMsgClientConn{} - msgClient := types.NewMsgClient(svcMsgClientConn) - _, err = msgClient.ConnectionOpenConfirm(cmd.Context(), msg) - if err != nil { - return err - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), svcMsgClientConn.GetMsgs()...) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} diff --git a/modules/core/03-connection/module.go b/modules/core/03-connection/module.go index c0bbc68f229..d4c344fa723 100644 --- a/modules/core/03-connection/module.go +++ b/modules/core/03-connection/module.go @@ -13,11 +13,6 @@ func Name() string { return types.SubModuleName } -// GetTxCmd returns the root tx command for the IBC connections. -func GetTxCmd() *cobra.Command { - return cli.NewTxCmd() -} - // GetQueryCmd returns the root query command for the IBC connections. func GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() diff --git a/modules/core/04-channel/client/cli/cli.go b/modules/core/04-channel/client/cli/cli.go index 2786f233a8e..3335f379f35 100644 --- a/modules/core/04-channel/client/cli/cli.go +++ b/modules/core/04-channel/client/cli/cli.go @@ -45,14 +45,7 @@ func NewTxCmd() *cobra.Command { RunE: client.ValidateCmd, } - txCmd.AddCommand( - NewChannelOpenInitCmd(), - NewChannelOpenTryCmd(), - NewChannelOpenAckCmd(), - NewChannelOpenConfirmCmd(), - NewChannelCloseInitCmd(), - NewChannelCloseConfirmCmd(), - ) + txCmd.AddCommand() return txCmd } diff --git a/modules/core/04-channel/client/cli/tx.go b/modules/core/04-channel/client/cli/tx.go deleted file mode 100644 index c76c02f32a3..00000000000 --- a/modules/core/04-channel/client/cli/tx.go +++ /dev/null @@ -1,288 +0,0 @@ -package cli - -import ( - "strings" - - "github.com/spf13/cobra" - "github.com/spf13/pflag" - - "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/types/msgservice" - ibctransfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types" - clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types" - connectionutils "github.com/cosmos/ibc-go/modules/core/03-connection/client/utils" - "github.com/cosmos/ibc-go/modules/core/04-channel/types" -) - -// IBC Channel flags -const ( - FlagOrdered = "ordered" - FlagIBCVersion = "ibc-version" -) - -// NewChannelOpenInitCmd returns the command to create a MsgChannelOpenInit transaction -func NewChannelOpenInitCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "open-init [port-id] [counterparty-port-id] [connection-hops]", - Short: "Creates and sends a ChannelOpenInit message", - Args: cobra.ExactArgs(3), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - portID := args[0] - counterpartyPortID := args[1] - hops := strings.Split(args[2], "/") - order := channelOrder(cmd.Flags()) - version, _ := cmd.Flags().GetString(FlagIBCVersion) - - msg := types.NewMsgChannelOpenInit( - portID, version, order, hops, - counterpartyPortID, clientCtx.GetFromAddress().String(), - ) - svcMsgClientConn := &msgservice.ServiceMsgClientConn{} - msgClient := types.NewMsgClient(svcMsgClientConn) - _, err = msgClient.ChannelOpenInit(cmd.Context(), msg) - if err != nil { - return err - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), svcMsgClientConn.GetMsgs()...) - }, - } - - cmd.Flags().Bool(FlagOrdered, true, "Pass flag for opening ordered channels") - cmd.Flags().String(FlagIBCVersion, ibctransfertypes.Version, "IBC application version") - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -// NewChannelOpenTryCmd returns the command to create a MsgChannelOpenTry transaction -func NewChannelOpenTryCmd() *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]", - Short: "Creates and sends a ChannelOpenTry message", - Args: cobra.ExactArgs(7), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - portID := args[0] - channelID := args[1] - counterpartyPortID := args[2] - counterpartyChannelID := args[3] - hops := strings.Split(args[4], "/") - order := channelOrder(cmd.Flags()) - - // TODO: Differentiate between channel and counterparty versions. - version, _ := cmd.Flags().GetString(FlagIBCVersion) - - proofInit, err := connectionutils.ParseProof(clientCtx.LegacyAmino, args[5]) - if err != nil { - return err - } - - proofHeight, err := clienttypes.ParseHeight(args[6]) - if err != nil { - return err - } - - msg := types.NewMsgChannelOpenTry( - portID, channelID, version, order, hops, - counterpartyPortID, counterpartyChannelID, version, - proofInit, proofHeight, clientCtx.GetFromAddress().String(), - ) - svcMsgClientConn := &msgservice.ServiceMsgClientConn{} - msgClient := types.NewMsgClient(svcMsgClientConn) - _, err = msgClient.ChannelOpenTry(cmd.Context(), msg) - if err != nil { - return err - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), svcMsgClientConn.GetMsgs()...) - }, - } - - cmd.Flags().Bool(FlagOrdered, true, "Pass flag for opening ordered channels") - cmd.Flags().String(FlagIBCVersion, ibctransfertypes.Version, "IBC application version") - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -// NewChannelOpenAckCmd returns the command to create a MsgChannelOpenAck transaction -func NewChannelOpenAckCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "open-ack [port-id] [channel-id] [counterparty-channel-id] [/path/to/proof_try.json] [proof-height]", - Short: "Creates and sends a ChannelOpenAck message", - Args: cobra.ExactArgs(5), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - portID := args[0] - channelID := args[1] - counterpartyChannelID := args[2] - - // TODO: Differentiate between channel and counterparty versions. - version, _ := cmd.Flags().GetString(FlagIBCVersion) - - proofTry, err := connectionutils.ParseProof(clientCtx.LegacyAmino, args[3]) - if err != nil { - return err - } - - proofHeight, err := clienttypes.ParseHeight(args[4]) - if err != nil { - return err - } - - msg := types.NewMsgChannelOpenAck( - portID, channelID, counterpartyChannelID, version, proofTry, proofHeight, clientCtx.GetFromAddress().String(), - ) - svcMsgClientConn := &msgservice.ServiceMsgClientConn{} - msgClient := types.NewMsgClient(svcMsgClientConn) - _, err = msgClient.ChannelOpenAck(cmd.Context(), msg) - if err != nil { - return err - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), svcMsgClientConn.GetMsgs()...) - }, - } - cmd.Flags().String(FlagIBCVersion, ibctransfertypes.Version, "IBC application version") - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -// NewChannelOpenConfirmCmd returns the command to create a MsgChannelOpenConfirm transaction -func NewChannelOpenConfirmCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "open-confirm [port-id] [channel-id] [/path/to/proof_ack.json] [proof-height]", - Short: "Creates and sends a ChannelOpenConfirm message", - Args: cobra.ExactArgs(4), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - portID := args[0] - channelID := args[1] - - proofAck, err := connectionutils.ParseProof(clientCtx.LegacyAmino, args[2]) - if err != nil { - return err - } - - proofHeight, err := clienttypes.ParseHeight(args[3]) - if err != nil { - return err - } - - msg := types.NewMsgChannelOpenConfirm( - portID, channelID, proofAck, proofHeight, clientCtx.GetFromAddress().String(), - ) - svcMsgClientConn := &msgservice.ServiceMsgClientConn{} - msgClient := types.NewMsgClient(svcMsgClientConn) - _, err = msgClient.ChannelOpenConfirm(cmd.Context(), msg) - if err != nil { - return err - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), svcMsgClientConn.GetMsgs()...) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -// NewChannelCloseInitCmd returns the command to create a MsgChannelCloseInit transaction -func NewChannelCloseInitCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "close-init [port-id] [channel-id]", - Short: "Creates and sends a ChannelCloseInit message", - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - portID := args[0] - channelID := args[1] - - msg := types.NewMsgChannelCloseInit(portID, channelID, clientCtx.GetFromAddress().String()) - svcMsgClientConn := &msgservice.ServiceMsgClientConn{} - msgClient := types.NewMsgClient(svcMsgClientConn) - _, err = msgClient.ChannelCloseInit(cmd.Context(), msg) - if err != nil { - return err - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), svcMsgClientConn.GetMsgs()...) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -// NewChannelCloseConfirmCmd returns the command to create a MsgChannelCloseConfirm transaction -func NewChannelCloseConfirmCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "close-confirm [port-id] [channel-id] [/path/to/proof_init.json] [proof-height]", - Short: "Creates and sends a ChannelCloseConfirm message", - Args: cobra.ExactArgs(4), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - portID := args[0] - channelID := args[1] - - proofInit, err := connectionutils.ParseProof(clientCtx.LegacyAmino, args[2]) - if err != nil { - return err - } - - proofHeight, err := clienttypes.ParseHeight(args[3]) - if err != nil { - return err - } - - msg := types.NewMsgChannelCloseConfirm( - portID, channelID, proofInit, proofHeight, clientCtx.GetFromAddress().String(), - ) - svcMsgClientConn := &msgservice.ServiceMsgClientConn{} - msgClient := types.NewMsgClient(svcMsgClientConn) - _, err = msgClient.ChannelCloseConfirm(cmd.Context(), msg) - if err != nil { - return err - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), svcMsgClientConn.GetMsgs()...) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func channelOrder(fs *pflag.FlagSet) types.Order { - if ordered, _ := fs.GetBool(FlagOrdered); ordered { - return types.ORDERED - } - - return types.UNORDERED -} diff --git a/modules/core/client/cli/cli.go b/modules/core/client/cli/cli.go index 4a7054fbe6b..687806b1c15 100644 --- a/modules/core/client/cli/cli.go +++ b/modules/core/client/cli/cli.go @@ -22,7 +22,6 @@ func GetTxCmd() *cobra.Command { ibcTxCmd.AddCommand( ibcclient.GetTxCmd(), - connection.GetTxCmd(), channel.GetTxCmd(), ) diff --git a/testing/sdk_test.go b/testing/sdk_test.go index 2136dd07547..2375a2bcbb2 100644 --- a/testing/sdk_test.go +++ b/testing/sdk_test.go @@ -29,7 +29,6 @@ import ( dbm "github.com/tendermint/tm-db" ibcclientcli "github.com/cosmos/ibc-go/modules/core/02-client/client/cli" - ibccli "github.com/cosmos/ibc-go/modules/core/04-channel/client/cli" "github.com/cosmos/ibc-go/testing/simapp" ) @@ -202,6 +201,11 @@ func (s *IntegrationTestSuite) TestLegacyRestErrMessages() { `{"@type":"/ibc.lightclients.solomachine.v1.ClientState","sequence":"1","frozen_sequence":"0","consensus_state":{"public_key":{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AtK50+5pJOoaa04qqAqrnyAqsYrwrR/INnA6UPIaYZlp"},"diversifier":"testing","timestamp":"10"},"allow_update_after_proposal":false}`, ) + badClientStateJSON := testutil.WriteToNewTempFile( + s.T(), + `{"@type":"/ibc.lightclients.solomachine.v1.ClientState","sequence":"1","frozen_sequence":"0","consensus_state":{"public_key":{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AtK50+5pJOoaa04qqAqrnyAqsYrwrR/INnA6UPIaYZlp"},"diversifier":"DIFFERENT","timestamp":"10"},"allow_update_after_proposal":false}`, + ) + // Write consensus json to temp file, used for an IBC message. // Generated by printing the result of cdc.MarshalIntefaceJSON on // a solo machine consensus state @@ -218,10 +222,10 @@ func (s *IntegrationTestSuite) TestLegacyRestErrMessages() { }{ { "Failing IBC message", - ibccli.NewChannelCloseInitCmd(), + ibcclientcli.NewCreateClientCmd(), []string{ - "121", // dummy port-id - "channel-0", // dummy channel-id + badClientStateJSON.Name(), // path to client state json + consensusJSON.Name(), // path to consensus json, fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), @@ -229,7 +233,7 @@ func (s *IntegrationTestSuite) TestLegacyRestErrMessages() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=foobar", flags.FlagMemo), }, - uint32(7), + uint32(8), }, { "Successful IBC message",