Skip to content

Commit

Permalink
cli changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bermuell committed Aug 29, 2024
1 parent 8db2423 commit 0173c0d
Showing 1 changed file with 12 additions and 27 deletions.
39 changes: 12 additions & 27 deletions x/ccv/provider/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,9 @@ func NewUpdateConsumerCmd() *cobra.Command {
Note that only the owner of the chain can initialize it.
Example:
%s tx provider update-consumer [consumer-id] [owner-address] [path/to/metadata.json] [path/to/initialization-parameters.json] [path/to/power-shaping-parameters.json] --from node0 --home ../node0 --chain-id $CID
%s tx provider update-consumer [path/to/consumer-update.json] --from node0 --home ../node0 --chain-id $CID
`, version.AppName)),
Args: cobra.ExactArgs(5),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
Expand All @@ -293,37 +293,22 @@ Example:
txf = txf.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever)

signer := clientCtx.GetFromAddress().String()
consumerId := args[0]
ownerAddress := args[1]

metadata := types.ConsumerMetadata{}
metadataJson, err := os.ReadFile(args[2])
consUpdateJson, err := os.ReadFile(args[0])
if err != nil {
return err
}
if err = json.Unmarshal(metadataJson, &metadata); err != nil {
return fmt.Errorf("metadata unmarshalling failed: %w", err)
}

initializationParameters := types.ConsumerInitializationParameters{}
initializationParametersJson, err := os.ReadFile(args[3])
if err != nil {
return err
}
if err = json.Unmarshal(initializationParametersJson, &initializationParameters); err != nil {
return fmt.Errorf("initialization parameters unmarshalling failed: %w", err)
consUpdate := types.MsgUpdateConsumer{}
if err = json.Unmarshal(consUpdateJson, &consUpdate); err != nil {
return fmt.Errorf("consumer data unmarshalling failed: %w", err)
}

powerShapingParameters := types.PowerShapingParameters{}
powerShapingParametersJson, err := os.ReadFile(args[4])
if err != nil {
return err
}
if err = json.Unmarshal(powerShapingParametersJson, &powerShapingParameters); err != nil {
return fmt.Errorf("power-shaping parameters unmarshalling failed: %w", err)
if strings.TrimSpace(consUpdate.ConsumerId) == "" {
return fmt.Errorf("consumer_id can't be empty")
}

msg, err := types.NewMsgUpdateConsumer(signer, consumerId, ownerAddress, &metadata, &initializationParameters, &powerShapingParameters)
msg, err := types.NewMsgUpdateConsumer(signer, consUpdate.ConsumerId, consUpdate.NewOwnerAddress, consUpdate.Metadata, consUpdate.InitializationParameters, consUpdate.PowerShapingParameters)
if err != nil {
return err
}
Expand Down Expand Up @@ -397,7 +382,7 @@ Example:

func NewOptInCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "opt-in [consumer-chain-id] [consumer-pubkey]",
Use: "opt-in [consumer-id] [consumer-pubkey]",
Short: "opts in validator to the consumer chain, and if given uses the " +
"provided consensus public key for this consumer chain",
Args: cobra.RangeArgs(1, 2),
Expand Down Expand Up @@ -445,7 +430,7 @@ func NewOptInCmd() *cobra.Command {

func NewOptOutCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "opt-out [consumer-chain-id]",
Use: "opt-out [consumer-id]",
Short: "opts out validator from this consumer chain",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -484,7 +469,7 @@ func NewOptOutCmd() *cobra.Command {

func NewSetConsumerCommissionRateCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "set-consumer-commission-rate [consumer-chain-id] [commission-rate]",
Use: "set-consumer-commission-rate [consumer-id] [commission-rate]",
Short: "set a per-consumer chain commission",
Long: strings.TrimSpace(
fmt.Sprintf(`Note that the "commission-rate" argument is a fraction and should be in the range [0,1].
Expand Down

0 comments on commit 0173c0d

Please sign in to comment.