Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update TX CLI help #2222

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 26 additions & 18 deletions x/ccv/provider/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func NewAssignConsumerKeyCmd() *cobra.Command {
return err
}

signer := clientCtx.GetFromAddress().String()
submitter := clientCtx.GetFromAddress().String()
txf, err := tx.NewFactoryCLI(clientCtx, cmd.Flags())
if err != nil {
return err
Expand All @@ -66,7 +66,7 @@ func NewAssignConsumerKeyCmd() *cobra.Command {

providerValAddr := clientCtx.GetFromAddress()

msg, err := types.NewMsgAssignConsumerKey(args[0], sdk.ValAddress(providerValAddr), args[1], signer)
msg, err := types.NewMsgAssignConsumerKey(args[0], sdk.ValAddress(providerValAddr), args[1], submitter)
if err != nil {
return err
}
Expand Down Expand Up @@ -224,7 +224,7 @@ changed by updating the consumer chain.
Example:
%s tx provider create-consumer [path/to/create_consumer.json] --from node0 --home ../node0 --chain-id $CID

where create_consumer.json content:
where create_consumer.json has the following structure:
{
"chain_id": "consu",
"metadata": {
Expand Down Expand Up @@ -259,6 +259,9 @@ where create_consumer.json content:
}
}

Note that both 'chain_id' and 'metadata' are mandatory;
and both 'initialization_parameters' and 'power_shaping_parameters' are optional.
The parameters not provided are set to their zero value.
`, version.AppName)),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -273,7 +276,7 @@ where create_consumer.json content:
}
txf = txf.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever)

signer := clientCtx.GetFromAddress().String()
submitter := clientCtx.GetFromAddress().String()

consCreateJson, err := os.ReadFile(args[0])
if err != nil {
Expand All @@ -284,7 +287,7 @@ where create_consumer.json content:
return fmt.Errorf("consumer data unmarshalling failed: %w", err)
}

msg, err := types.NewMsgCreateConsumer(signer, consCreate.ChainId, consCreate.Metadata, consCreate.InitializationParameters, consCreate.PowerShapingParameters)
msg, err := types.NewMsgCreateConsumer(submitter, consCreate.ChainId, consCreate.Metadata, consCreate.InitializationParameters, consCreate.PowerShapingParameters)
if err != nil {
return err
}
Expand Down Expand Up @@ -312,10 +315,9 @@ func NewUpdateConsumerCmd() *cobra.Command {
Note that only the owner of the chain can initialize it.

Example:
%s tx provider update-consumer [path/to/consumer-update.json] --from node0 --home ../node0 --chain-id $CID

where consumer-update.json contains parameters for 'power_shaping', 'initialization' and 'metadata':
%s tx provider update-consumer [path/to/consumer-update.json] --from node0 --home ../node0 --chain-id $CID

where create_consumer.json has the following structure:
{
"consumer_id": "0",
"new_owner_address": "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn",
Expand Down Expand Up @@ -350,6 +352,12 @@ Example:
"allow_inactive_vals": false
}
}

Note that only 'consumer_id' is mandatory. The others are optional.
Not providing one of them will leave the existing values unchanged.
Providing one of 'metadata', 'initialization_parameters' or 'power_shaping_parameters',
will update all the containing fields.
If one of the fields is missing, it will be set to its zero value.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Later when you do NewMsgUpdateConsumer(signer, ...), can we rename signer to owner internally? The same way you did the renaming of signer to submitter for MsgCreateConsumer?

`, version.AppName)),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -364,7 +372,7 @@ Example:
}
txf = txf.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever)

signer := clientCtx.GetFromAddress().String()
owner := clientCtx.GetFromAddress().String()

consUpdateJson, err := os.ReadFile(args[0])
if err != nil {
Expand All @@ -380,7 +388,7 @@ Example:
return fmt.Errorf("consumer_id can't be empty")
}

msg, err := types.NewMsgUpdateConsumer(signer, consUpdate.ConsumerId, consUpdate.NewOwnerAddress, consUpdate.Metadata, consUpdate.InitializationParameters, consUpdate.PowerShapingParameters)
msg, err := types.NewMsgUpdateConsumer(owner, consUpdate.ConsumerId, consUpdate.NewOwnerAddress, consUpdate.Metadata, consUpdate.InitializationParameters, consUpdate.PowerShapingParameters)
if err != nil {
return err
}
Expand Down Expand Up @@ -421,10 +429,10 @@ Example:
}
txf = txf.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever)

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

msg, err := types.NewMsgRemoveConsumer(signer, consumerId)
msg, err := types.NewMsgRemoveConsumer(owner, consumerId)
if err != nil {
return err
}
Expand Down Expand Up @@ -471,8 +479,8 @@ func NewOptInCmd() *cobra.Command {
consumerPubKey = ""
}

signer := clientCtx.GetFromAddress().String()
msg, err := types.NewMsgOptIn(args[0], sdk.ValAddress(providerValAddr), consumerPubKey, signer)
submitter := clientCtx.GetFromAddress().String()
msg, err := types.NewMsgOptIn(args[0], sdk.ValAddress(providerValAddr), consumerPubKey, submitter)
if err != nil {
return err
}
Expand Down Expand Up @@ -510,8 +518,8 @@ func NewOptOutCmd() *cobra.Command {

providerValAddr := clientCtx.GetFromAddress()

signer := clientCtx.GetFromAddress().String()
msg, err := types.NewMsgOptOut(args[0], sdk.ValAddress(providerValAddr), signer)
submitter := clientCtx.GetFromAddress().String()
msg, err := types.NewMsgOptOut(args[0], sdk.ValAddress(providerValAddr), submitter)
if err != nil {
return err
}
Expand Down Expand Up @@ -559,8 +567,8 @@ func NewSetConsumerCommissionRateCmd() *cobra.Command {
if err != nil {
return err
}
signer := clientCtx.GetFromAddress().String()
msg := types.NewMsgSetConsumerCommissionRate(args[0], commission, sdk.ValAddress(providerValAddr), signer)
submitter := clientCtx.GetFromAddress().String()
msg := types.NewMsgSetConsumerCommissionRate(args[0], commission, sdk.ValAddress(providerValAddr), submitter)
if err := msg.ValidateBasic(); err != nil {
return err
}
Expand Down
Loading