Merge PR #6608: ibc: remove viper from CLI
This commit is contained in:
parent
d0cabdeb88
commit
fd9cdb8ba7
|
@ -5,7 +5,6 @@ import (
|
||||||
"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/flags"
|
||||||
|
@ -32,7 +31,7 @@ $ %s query ibc-transfer next-recv [port-id] [channel-id]
|
||||||
|
|
||||||
portID := args[0]
|
portID := args[0]
|
||||||
channelID := args[1]
|
channelID := args[1]
|
||||||
prove := viper.GetBool(flags.FlagProve)
|
prove, _ := cmd.Flags().GetBool(flags.FlagProve)
|
||||||
|
|
||||||
sequenceRes, err := utils.QueryNextSequenceRecv(clientCtx, portID, channelID, prove)
|
sequenceRes, err := utils.QueryNextSequenceRecv(clientCtx, portID, channelID, prove)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -43,6 +42,7 @@ $ %s query ibc-transfer next-recv [port-id] [channel-id]
|
||||||
return clientCtx.PrintOutput(sequenceRes)
|
return clientCtx.PrintOutput(sequenceRes)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results")
|
cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"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/tx"
|
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||||
|
@ -38,8 +37,8 @@ func NewTransferTxCmd(clientCtx client.Context) *cobra.Command {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
timeoutHeight := viper.GetUint64(flagTimeoutHeight)
|
timeoutHeight, _ := cmd.Flags().GetUint64(flagTimeoutHeight)
|
||||||
timeoutTimestamp := viper.GetUint64(flagTimeoutHeight)
|
timeoutTimestamp, _ := cmd.Flags().GetUint64(flagTimeoutHeight)
|
||||||
|
|
||||||
msg := types.NewMsgTransfer(
|
msg := types.NewMsgTransfer(
|
||||||
srcPort, srcChannel, coins, sender, receiver, timeoutHeight, timeoutTimestamp,
|
srcPort, srcChannel, coins, sender, receiver, timeoutHeight, timeoutTimestamp,
|
||||||
|
@ -51,7 +50,9 @@ func NewTransferTxCmd(clientCtx client.Context) *cobra.Command {
|
||||||
return tx.GenerateOrBroadcastTx(clientCtx, 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.")
|
||||||
cmd.Flags().Uint64(flagTimeoutTimestamp, types.DefaultAbsolutePacketTimeoutTimestamp, "Absolute timeout timestamp in nanoseconds. The timeout is disabled when set to 0.")
|
cmd.Flags().Uint64(flagTimeoutTimestamp, types.DefaultAbsolutePacketTimeoutTimestamp, "Absolute timeout timestamp in nanoseconds. The timeout is disabled when set to 0.")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"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/flags"
|
||||||
|
@ -33,8 +32,8 @@ $ %s query ibc client states
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
clientCtx = clientCtx.Init()
|
clientCtx = clientCtx.Init()
|
||||||
|
|
||||||
page := viper.GetInt(flags.FlagPage)
|
page, _ := cmd.Flags().GetInt(flags.FlagPage)
|
||||||
limit := viper.GetInt(flags.FlagLimit)
|
limit, _ := cmd.Flags().GetInt(flags.FlagLimit)
|
||||||
|
|
||||||
clientStates, height, err := utils.QueryAllClientStates(clientCtx, page, limit)
|
clientStates, height, err := utils.QueryAllClientStates(clientCtx, page, limit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -45,8 +44,10 @@ $ %s query ibc client states
|
||||||
return clientCtx.PrintOutput(clientStates)
|
return clientCtx.PrintOutput(clientStates)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flags().Int(flags.FlagPage, 1, "pagination page of light clients to to query for")
|
cmd.Flags().Int(flags.FlagPage, 1, "pagination page of light clients to to query for")
|
||||||
cmd.Flags().Int(flags.FlagLimit, 100, "pagination limit of light clients to query for")
|
cmd.Flags().Int(flags.FlagLimit, 100, "pagination limit of light clients to query for")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +73,7 @@ $ %s query ibc client state [client-id]
|
||||||
return errors.New("client ID can't be blank")
|
return errors.New("client ID can't be blank")
|
||||||
}
|
}
|
||||||
|
|
||||||
prove := viper.GetBool(flags.FlagProve)
|
prove, _ := cmd.Flags().GetBool(flags.FlagProve)
|
||||||
|
|
||||||
clientStateRes, err := utils.QueryClientState(clientCtx, clientID, prove)
|
clientStateRes, err := utils.QueryClientState(clientCtx, clientID, prove)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -83,6 +84,7 @@ $ %s query ibc client state [client-id]
|
||||||
return clientCtx.PrintOutput(clientStateRes)
|
return clientCtx.PrintOutput(clientStateRes)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results")
|
cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results")
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
@ -109,7 +111,7 @@ func GetCmdQueryConsensusState(clientCtx client.Context) *cobra.Command {
|
||||||
return fmt.Errorf("expected integer height, got: %s", args[1])
|
return fmt.Errorf("expected integer height, got: %s", args[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
prove := viper.GetBool(flags.FlagProve)
|
prove, _ := cmd.Flags().GetBool(flags.FlagProve)
|
||||||
|
|
||||||
csRes, err := utils.QueryConsensusState(clientCtx, clientID, height, prove)
|
csRes, err := utils.QueryConsensusState(clientCtx, clientID, height, prove)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -120,6 +122,7 @@ func GetCmdQueryConsensusState(clientCtx client.Context) *cobra.Command {
|
||||||
return clientCtx.PrintOutput(csRes)
|
return clientCtx.PrintOutput(csRes)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results")
|
cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results")
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"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/flags"
|
||||||
|
@ -31,8 +30,8 @@ $ %s query ibc connection connections
|
||||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||||
clientCtx = clientCtx.Init()
|
clientCtx = clientCtx.Init()
|
||||||
|
|
||||||
page := viper.GetInt(flags.FlagPage)
|
page, _ := cmd.Flags().GetInt(flags.FlagPage)
|
||||||
limit := viper.GetInt(flags.FlagLimit)
|
limit, _ := cmd.Flags().GetInt(flags.FlagLimit)
|
||||||
|
|
||||||
connections, height, err := utils.QueryAllConnections(clientCtx, page, limit)
|
connections, height, err := utils.QueryAllConnections(clientCtx, page, limit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -43,6 +42,7 @@ $ %s query ibc connection connections
|
||||||
return clientCtx.PrintOutput(connections)
|
return clientCtx.PrintOutput(connections)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flags().Int(flags.FlagPage, 1, "pagination page of light clients to to query for")
|
cmd.Flags().Int(flags.FlagPage, 1, "pagination page of light clients to to query for")
|
||||||
cmd.Flags().Int(flags.FlagLimit, 100, "pagination limit of light clients to query for")
|
cmd.Flags().Int(flags.FlagLimit, 100, "pagination limit of light clients to query for")
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ $ %s query ibc connection end [connection-id]
|
||||||
clientCtx = clientCtx.Init()
|
clientCtx = clientCtx.Init()
|
||||||
|
|
||||||
connectionID := args[0]
|
connectionID := args[0]
|
||||||
prove := viper.GetBool(flags.FlagProve)
|
prove, _ := cmd.Flags().GetBool(flags.FlagProve)
|
||||||
|
|
||||||
connRes, err := utils.QueryConnection(clientCtx, connectionID, prove)
|
connRes, err := utils.QueryConnection(clientCtx, connectionID, prove)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -77,6 +77,7 @@ $ %s query ibc connection end [connection-id]
|
||||||
return clientCtx.PrintOutput(connRes)
|
return clientCtx.PrintOutput(connRes)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results")
|
cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
@ -98,8 +99,8 @@ $ %s query ibc connection paths
|
||||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||||
clientCtx = clientCtx.Init()
|
clientCtx = clientCtx.Init()
|
||||||
|
|
||||||
page := viper.GetInt(flags.FlagPage)
|
page, _ := cmd.Flags().GetInt(flags.FlagPage)
|
||||||
limit := viper.GetInt(flags.FlagLimit)
|
limit, _ := cmd.Flags().GetInt(flags.FlagLimit)
|
||||||
|
|
||||||
connectionPaths, height, err := utils.QueryAllClientConnectionPaths(clientCtx, page, limit)
|
connectionPaths, height, err := utils.QueryAllClientConnectionPaths(clientCtx, page, limit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -110,6 +111,7 @@ $ %s query ibc connection paths
|
||||||
return clientCtx.PrintOutput(connectionPaths)
|
return clientCtx.PrintOutput(connectionPaths)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flags().Int(flags.FlagPage, 1, "pagination page of light clients to to query for")
|
cmd.Flags().Int(flags.FlagPage, 1, "pagination page of light clients to to query for")
|
||||||
cmd.Flags().Int(flags.FlagLimit, 100, "pagination limit of light clients to query for")
|
cmd.Flags().Int(flags.FlagLimit, 100, "pagination limit of light clients to query for")
|
||||||
|
|
||||||
|
@ -133,7 +135,7 @@ $ %s query ibc connection path [client-id]
|
||||||
clientCtx = clientCtx.Init()
|
clientCtx = clientCtx.Init()
|
||||||
|
|
||||||
clientID := args[0]
|
clientID := args[0]
|
||||||
prove := viper.GetBool(flags.FlagProve)
|
prove, _ := cmd.Flags().GetBool(flags.FlagProve)
|
||||||
|
|
||||||
connPathsRes, err := utils.QueryClientConnections(clientCtx, clientID, prove)
|
connPathsRes, err := utils.QueryClientConnections(clientCtx, clientID, prove)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"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/flags"
|
||||||
|
@ -29,7 +28,7 @@ func GetCmdQueryChannel(clientCtx client.Context) *cobra.Command {
|
||||||
|
|
||||||
portID := args[0]
|
portID := args[0]
|
||||||
channelID := args[1]
|
channelID := args[1]
|
||||||
prove := viper.GetBool(flags.FlagProve)
|
prove, _ := cmd.Flags().GetBool(flags.FlagProve)
|
||||||
|
|
||||||
channelRes, err := utils.QueryChannel(clientCtx, portID, channelID, prove)
|
channelRes, err := utils.QueryChannel(clientCtx, portID, channelID, prove)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/pflag"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||||
|
@ -33,8 +33,8 @@ func NewChannelOpenInitCmd(clientCtx client.Context) *cobra.Command {
|
||||||
counterpartyPortID := args[2]
|
counterpartyPortID := args[2]
|
||||||
counterpartyChannelID := args[3]
|
counterpartyChannelID := args[3]
|
||||||
hops := strings.Split(args[4], "/")
|
hops := strings.Split(args[4], "/")
|
||||||
order := channelOrder()
|
order := channelOrder(cmd.Flags())
|
||||||
version := viper.GetString(FlagIBCVersion)
|
version, _ := cmd.Flags().GetString(FlagIBCVersion)
|
||||||
|
|
||||||
msg := types.NewMsgChannelOpenInit(
|
msg := types.NewMsgChannelOpenInit(
|
||||||
portID, channelID, version, order, hops,
|
portID, channelID, version, order, hops,
|
||||||
|
@ -68,8 +68,10 @@ func NewChannelOpenTryCmd(clientCtx client.Context) *cobra.Command {
|
||||||
counterpartyPortID := args[2]
|
counterpartyPortID := args[2]
|
||||||
counterpartyChannelID := args[3]
|
counterpartyChannelID := args[3]
|
||||||
hops := strings.Split(args[4], "/")
|
hops := strings.Split(args[4], "/")
|
||||||
order := channelOrder()
|
order := channelOrder(cmd.Flags())
|
||||||
version := viper.GetString(FlagIBCVersion) // TODO: diferenciate between channel and counterparty versions
|
|
||||||
|
// TODO: Differentiate between channel and counterparty versions.
|
||||||
|
version, _ := cmd.Flags().GetString(FlagIBCVersion)
|
||||||
|
|
||||||
proofInit, err := connectionutils.ParseProof(clientCtx.Codec, args[5])
|
proofInit, err := connectionutils.ParseProof(clientCtx.Codec, args[5])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -93,6 +95,7 @@ func NewChannelOpenTryCmd(clientCtx client.Context) *cobra.Command {
|
||||||
return tx.GenerateOrBroadcastTx(clientCtx, 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")
|
||||||
cmd.Flags().String(FlagIBCVersion, "1.0.0", "supported IBC version")
|
cmd.Flags().String(FlagIBCVersion, "1.0.0", "supported IBC version")
|
||||||
|
|
||||||
|
@ -110,7 +113,9 @@ func NewChannelOpenAckCmd(clientCtx client.Context) *cobra.Command {
|
||||||
|
|
||||||
portID := args[0]
|
portID := args[0]
|
||||||
channelID := args[1]
|
channelID := args[1]
|
||||||
version := viper.GetString(FlagIBCVersion) // TODO: diferenciate between channel and counterparty versions
|
|
||||||
|
// TODO: Differentiate between channel and counterparty versions.
|
||||||
|
version, _ := cmd.Flags().GetString(FlagIBCVersion)
|
||||||
|
|
||||||
proofTry, err := connectionutils.ParseProof(clientCtx.Codec, args[5])
|
proofTry, err := connectionutils.ParseProof(clientCtx.Codec, args[5])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -132,7 +137,9 @@ func NewChannelOpenAckCmd(clientCtx client.Context) *cobra.Command {
|
||||||
return tx.GenerateOrBroadcastTx(clientCtx, 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,9 +233,10 @@ func NewChannelCloseConfirmCmd(clientCtx client.Context) *cobra.Command {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func channelOrder() types.Order {
|
func channelOrder(fs *pflag.FlagSet) types.Order {
|
||||||
if viper.GetBool(FlagOrdered) {
|
if ordered, _ := fs.GetBool(FlagOrdered); ordered {
|
||||||
return types.ORDERED
|
return types.ORDERED
|
||||||
}
|
}
|
||||||
|
|
||||||
return types.UNORDERED
|
return types.UNORDERED
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
|
||||||
|
|
||||||
tmmath "github.com/tendermint/tendermint/libs/math"
|
tmmath "github.com/tendermint/tendermint/libs/math"
|
||||||
lite "github.com/tendermint/tendermint/lite2"
|
lite "github.com/tendermint/tendermint/lite2"
|
||||||
|
@ -70,7 +69,7 @@ func GetCmdCreateClient(cdc *codec.Codec) *cobra.Command {
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
lvl := viper.GetString(flagTrustLevel)
|
lvl, _ := cmd.Flags().GetString(flagTrustLevel)
|
||||||
|
|
||||||
if lvl == "default" {
|
if lvl == "default" {
|
||||||
trustLevel = lite.DefaultTrustLevel
|
trustLevel = lite.DefaultTrustLevel
|
||||||
|
@ -96,7 +95,7 @@ func GetCmdCreateClient(cdc *codec.Codec) *cobra.Command {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
spc := viper.GetString(flagProofSpecs)
|
spc, _ := cmd.Flags().GetString(flagProofSpecs)
|
||||||
if spc == "default" {
|
if spc == "default" {
|
||||||
specs = commitmenttypes.GetSDKSpecs()
|
specs = commitmenttypes.GetSDKSpecs()
|
||||||
} else if err := cdc.UnmarshalJSON([]byte(spc), &specs); err != nil {
|
} else if err := cdc.UnmarshalJSON([]byte(spc), &specs); err != nil {
|
||||||
|
@ -121,8 +120,10 @@ func GetCmdCreateClient(cdc *codec.Codec) *cobra.Command {
|
||||||
return authclient.GenerateOrBroadcastMsgs(clientCtx, txBldr, []sdk.Msg{msg})
|
return authclient.GenerateOrBroadcastMsgs(clientCtx, txBldr, []sdk.Msg{msg})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flags().String(flagTrustLevel, "default", "light client trust level fraction for header updates")
|
cmd.Flags().String(flagTrustLevel, "default", "light client trust level fraction for header updates")
|
||||||
cmd.Flags().String(flagProofSpecs, "default", "proof specs format to be used for verification")
|
cmd.Flags().String(flagProofSpecs, "default", "proof specs format to be used for verification")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue