Skip to content

Commit

Permalink
Impl tx, flags
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel committed Oct 31, 2022
1 parent 2e055c3 commit 2c42f87
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
13 changes: 10 additions & 3 deletions x/ccv/provider/client/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
)

const (
FlagChainId = "validator"
FlagConsumerChainId = "validator"
FlagAddressValidator = "validator"
FlagPubKey = "pubkey"
FlagConsumerPubKey = "pubkey"
FlagNodeID = "node-id"
FlagIP = "ip"
)
Expand All @@ -24,6 +24,13 @@ func init() {
// FlagSetPublicKey Returns the flagset for Public Key related operations.
func FlagSetPublicKey() *flag.FlagSet {
fs := flag.NewFlagSet("", flag.ContinueOnError)
fs.String(FlagPubKey, "", "The validator's Protobuf JSON encoded public key")
fs.String(FlagConsumerPubKey, "", "The Protobuf JSON encoded public key to use for the consumer chain")
return fs
}

// FlagSetPublicKey Returns the flagset for Public Key related operations.
func FlagSetConsumerChainId() *flag.FlagSet {
fs := flag.NewFlagSet("", flag.ContinueOnError)
fs.String(FlagConsumerChainId, "", "The chainId of the consumer chain")
return fs
}
16 changes: 9 additions & 7 deletions x/ccv/provider/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func GetTxCmd() *cobra.Command {

func NewDesignateConsensusKeyForConsumerChainCmd() *cobra.Command {
cmd := &cobra.Command{
Use: ":TODO:",
Short: ":TODO:",
Use: "designate-consensus-key [consumer-chain-id] [consumer-pubkey]",
Short: "designate a consensus public key to use for a consumer chain",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
Expand All @@ -51,22 +51,24 @@ func NewDesignateConsensusKeyForConsumerChainCmd() *cobra.Command {
},
}

cmd.Flags().AddFlagSet(FlagSetConsumerChainId())
cmd.Flags().AddFlagSet(FlagSetPublicKey())

// TODO: ip, nodeid flags?
cmd.Flags().String(FlagIP, "", fmt.Sprintf("The node's public IP. It takes effect only when used in combination with --%s", flags.FlagGenerateOnly))
cmd.Flags().String(FlagNodeID, "", "The node's ID")
flags.AddTxFlagsToCmd(cmd)

// TODO: what else?
_ = cmd.MarkFlagRequired(flags.FlagFrom)
_ = cmd.MarkFlagRequired(FlagPubKey)
_ = cmd.MarkFlagRequired(FlagConsumerChainId)
_ = cmd.MarkFlagRequired(FlagConsumerPubKey)

return cmd
}

func newBuildDesignateConsensusKeyForConsumerChainMsg(clientCtx client.Context, txf tx.Factory, fs *flag.FlagSet) (tx.Factory, *types.MsgDesignateConsensusKeyForConsumerChain, error) {

providerValAddr := clientCtx.GetFromAddress()
consumerPubKeyStr, err := fs.GetString(FlagPubKey)
consumerPubKeyStr, err := fs.GetString(FlagConsumerPubKey)
if err != nil {
return txf, nil, err
}
Expand All @@ -76,7 +78,7 @@ func newBuildDesignateConsensusKeyForConsumerChainMsg(clientCtx client.Context,
return txf, nil, err
}

chainId, _ := fs.GetString(FlagChainId)
chainId, _ := fs.GetString(FlagConsumerChainId)

msg, err := types.NewMsgDesignateConsensusKeyForConsumerChain(chainId, sdk.ValAddress(providerValAddr), consumerPubKey)
if err != nil {
Expand Down

0 comments on commit 2c42f87

Please sign in to comment.