11package cli
22
33import (
4- "encoding/hex"
54 "fmt"
6- "strings"
75
86 "github.com/spf13/cobra"
97
@@ -12,38 +10,32 @@ import (
1210 "github.com/cosmos/cosmos-sdk/client/tx"
1311 "github.com/cosmos/cosmos-sdk/version"
1412
15- commitmenttypesv2 "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types/v2"
1613 "github.com/cosmos/ibc-go/v9/modules/core/exported"
1714 "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types"
1815)
1916
2017// newProvideCounterpartyCmd defines the command to provide the counterparty to an IBC client.
2118func newProvideCounterpartyCmd () * cobra.Command {
2219 cmd := & cobra.Command {
23- Use : "provide-counterparty [client -identifier] [counterparty-client -identifier] [counterparty-merkle-path-prefix ]" ,
24- Args : cobra .ExactArgs (3 ),
25- Short : "provide the counterparty to an IBC client " ,
26- Long : `Provide the counterparty to an IBC client specified by its client ID.
20+ Use : "provide-counterparty [channel -identifier] [counterparty-channel -identifier]" ,
21+ Args : cobra .ExactArgs (2 ),
22+ Short : "provide the counterparty channel to an IBC channel end " ,
23+ Long : `Provide the counterparty to an IBC channel end specified by its channel ID.
2724The [counterparty-merkle-path-prefix] is a comma-separated list of hex-encoded strings.` ,
28- Example : fmt .Sprintf ("%s tx %s %s provide-counterparty 07-tendermint-0 07-tendermint-1 696263,657572656b61 " , version .AppName , exported .ModuleName , types .SubModuleName ),
25+ Example : fmt .Sprintf ("%s tx %s %s provide-counterparty channel-0 channel-1 " , version .AppName , exported .ModuleName , types .SubModuleName ),
2926 RunE : func (cmd * cobra.Command , args []string ) error {
3027 clientCtx , err := client .GetClientTxContext (cmd )
3128 if err != nil {
3229 return err
3330 }
3431
35- clientIdentifier := args [0 ]
36- counterpartyClientIdentifier := args [1 ]
37- counterpartyMerklePathPrefix , err := parseMerklePathPrefix (args [2 ])
38- if err != nil {
39- return err
40- }
32+ channelID := args [0 ]
33+ counterpartyChannelID := args [1 ]
4134
42- counterparty := types .NewCounterparty (clientIdentifier , counterpartyClientIdentifier , counterpartyMerklePathPrefix )
4335 msg := types.MsgProvideCounterparty {
44- ChannelId : clientIdentifier ,
45- Counterparty : counterparty ,
46- Signer : clientCtx .GetFromAddress ().String (),
36+ ChannelId : channelID ,
37+ CounterpartyChannelId : counterpartyChannelID ,
38+ Signer : clientCtx .GetFromAddress ().String (),
4739 }
4840 return tx .GenerateOrBroadcastTxCLI (clientCtx , cmd .Flags (), & msg )
4941 },
@@ -52,18 +44,3 @@ The [counterparty-merkle-path-prefix] is a comma-separated list of hex-encoded s
5244 flags .AddTxFlagsToCmd (cmd )
5345 return cmd
5446}
55-
56- // parseMerklePathPrefix parses a comma-separated list of hex-encoded strings into a MerklePath.
57- func parseMerklePathPrefix (merklePathPrefixString string ) (commitmenttypesv2.MerklePath , error ) {
58- var keyPath [][]byte
59- hexPrefixes := strings .Split (merklePathPrefixString , "," )
60- for _ , hexPrefix := range hexPrefixes {
61- prefix , err := hex .DecodeString (hexPrefix )
62- if err != nil {
63- return commitmenttypesv2.MerklePath {}, fmt .Errorf ("invalid hex merkle path prefix: %w" , err )
64- }
65- keyPath = append (keyPath , prefix )
66- }
67-
68- return commitmenttypesv2.MerklePath {KeyPath : keyPath }, nil
69- }
0 commit comments