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