Skip to content

feat(x): enable autocli for txs in modules #24387

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (server) [#24072](https://github.com/cosmos/cosmos-sdk/pull/24072) Return BlockHeader by shallow copy in server Context.
* (x/bank) [#24053](https://github.com/cosmos/cosmos-sdk/pull/24053) Resolve a foot-gun by swapping send restrictions check in `InputOutputCoins` before coin deduction.
* (codec/types) [#24336](https://github.com/cosmos/cosmos-sdk/pull/24336) Most types definitions were moved to `github.com/cosmos/gogoproto/types/any` with aliases to these left in `codec/types` so that there should be no breakage to existing code. This allows protobuf generated code to optionally reference the SDK's custom `Any` type without a direct dependency on the SDK. This can be done by changing the `protoc` `M` parameter for `any.proto` to `Mgoogle/protobuf/any.proto=github.com/cosmos/gogoproto/types/any`.
* [#24387](https://github.com/cosmos/cosmos-sdk/pull/24387) Add commands for all proposals thanks to AutoCLI. Additionally, improve UX commands thanks to AutoCLI:
* f.e `<appd> tx bank send alice $(simd keys show bob -a) 100stake` can be directly `<appd> tx bank send alice bob 100stake` now. This is true for all fields that take an address.

### API Breaking Changes

Expand Down
3 changes: 2 additions & 1 deletion x/auth/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
},
},
Tx: &autocliv1.ServiceCommandDescriptor{
Service: authv1beta1.Msg_ServiceDesc.ServiceName,
Service: authv1beta1.Msg_ServiceDesc.ServiceName,
EnhanceCustomCommand: true,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "UpdateParams",
Expand Down
4 changes: 2 additions & 2 deletions x/auth/vesting/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (
func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
return &autocliv1.ModuleOptions{
Tx: &autocliv1.ServiceCommandDescriptor{
Service: vestingv1beta1.Msg_ServiceDesc.ServiceName,
Service: vestingv1beta1.Msg_ServiceDesc.ServiceName,
EnhanceCustomCommand: true,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "CreateVestingAccount",
Expand Down Expand Up @@ -41,7 +42,6 @@ These tokens may be used for staking but are non-transferable. Staking rewards w
},
},
},
EnhanceCustomCommand: false, // use custom commands only until v0.51
},
}
}
9 changes: 5 additions & 4 deletions x/auth/vesting/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ func GetTxCmd(ac address.Codec) *cobra.Command {
}

txCmd.AddCommand(
NewMsgCreateVestingAccountCmd(ac),
NewMsgCreatePermanentLockedAccountCmd(ac),
NewMsgCreatePeriodicVestingAccountCmd(ac),
)

Expand All @@ -44,6 +42,8 @@ func GetTxCmd(ac address.Codec) *cobra.Command {

// NewMsgCreateVestingAccountCmd returns a CLI command handler for creating a
// MsgCreateVestingAccount transaction.
// Deprecated: This command is deprecated and will be removed in a future release.
// The module is using its AutoCLI command instead.
func NewMsgCreateVestingAccountCmd(ac address.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "create-vesting-account [to_address] [amount] [end_time]",
Expand Down Expand Up @@ -91,8 +91,9 @@ timestamp.`,
return cmd
}

// NewMsgCreatePermanentLockedAccountCmd returns a CLI command handler for creating a
// MsgCreatePermanentLockedAccount transaction.
// NewMsgCreatePermanentLockedAccountCmd returns a CLI command handler for creating a MsgCreatePermanentLockedAccount transaction.
// Deprecated: This command is deprecated and will be removed in a future release.
// The module is using its AutoCLI command instead.
func NewMsgCreatePermanentLockedAccountCmd(ac address.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "create-permanent-locked-account [to_address] [amount]",
Expand Down
3 changes: 2 additions & 1 deletion x/authz/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func GetTxCmd(ac address.Codec) *cobra.Command {

AuthorizationTxCmd.AddCommand(
NewCmdGrantAuthorization(ac),
NewCmdRevokeAuthorization(ac),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should NewCmdExecAuthorization also be removed, since its in the autocli?

Copy link
Member Author

@julienrbrt julienrbrt Apr 14, 2025

Choose a reason for hiding this comment

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

Not yet because there's a small UX improvement in AutoCLI that changes the command UX. In the AutoCLI command you just need to pass the msg json while in the current command you were required to pass a tx JSON. So for 0.53 makes sense to not remove it yet. But afterwards it should be yeah

NewCmdExecAuthorization(),
)

Expand Down Expand Up @@ -229,6 +228,8 @@ func getExpireTime(cmd *cobra.Command) (*time.Time, error) {
}

// NewCmdRevokeAuthorization returns a CLI command handler for creating a MsgRevoke transaction.
// Deprecated: This command is deprecated and will be removed in a future release.
// The module is using its AutoCLI command instead.
func NewCmdRevokeAuthorization(ac address.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "revoke [grantee] [msg-type-url] --from=[granter]",
Expand Down
2 changes: 1 addition & 1 deletion x/authz/module/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
},
Tx: &autocliv1.ServiceCommandDescriptor{
Service: authzv1beta1.Msg_ServiceDesc.ServiceName,
EnhanceCustomCommand: false, // use custom commands only until v0.51
EnhanceCustomCommand: true,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "Exec",
Expand Down
4 changes: 3 additions & 1 deletion x/bank/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ func NewTxCmd(ac address.Codec) *cobra.Command {
}

txCmd.AddCommand(
NewSendTxCmd(ac),
NewMultiSendTxCmd(ac),
)

return txCmd
}

// NewSendTxCmd returns a CLI command handler for creating a MsgSend transaction.
// Deprecated: The module uses the AutoCLI generated command with a better UX.
// This command should be removed in the future, but this requires reworking the
// bank send helper: the solution is here: https://github.com/cosmos/cosmos-sdk/pull/17868.
func NewSendTxCmd(ac address.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "send [from_key_or_address] [to_address] [amount]",
Expand Down
3 changes: 2 additions & 1 deletion x/circuit/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
},
},
Tx: &autocliv1.ServiceCommandDescriptor{
Service: circuitv1.Msg_ServiceDesc.ServiceName,
Service: circuitv1.Msg_ServiceDesc.ServiceName,
EnhanceCustomCommand: true,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "AuthorizeCircuitBreaker",
Expand Down
3 changes: 2 additions & 1 deletion x/consensus/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
},
},
Tx: &autocliv1.ServiceCommandDescriptor{
Service: consensusv1.Msg_ServiceDesc.ServiceName,
Service: consensusv1.Msg_ServiceDesc.ServiceName,
EnhanceCustomCommand: true,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "UpdateParams",
Expand Down
3 changes: 2 additions & 1 deletion x/crisis/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (
func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
return &autocliv1.ModuleOptions{
Tx: &autocliv1.ServiceCommandDescriptor{
Service: crisisv1beta1.Msg_ServiceDesc.ServiceName,
Service: crisisv1beta1.Msg_ServiceDesc.ServiceName,
EnhanceCustomCommand: true,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "VerifyInvariant",
Expand Down
4 changes: 2 additions & 2 deletions x/distribution/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
},
},
Tx: &autocliv1.ServiceCommandDescriptor{
Service: distributionv1beta1.Msg_ServiceDesc.ServiceName,
Service: distributionv1beta1.Msg_ServiceDesc.ServiceName,
EnhanceCustomCommand: true,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "SetWithdrawAddress",
Expand Down Expand Up @@ -154,7 +155,6 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
GovProposal: true,
},
},
EnhanceCustomCommand: true,
},
}
}
12 changes: 8 additions & 4 deletions x/distribution/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ func NewTxCmd(valAc, ac address.Codec) *cobra.Command {
}

distTxCmd.AddCommand(
NewWithdrawRewardsCmd(valAc, ac),
NewWithdrawAllRewardsCmd(valAc, ac),
NewSetWithdrawAddrCmd(ac),
NewFundCommunityPoolCmd(ac),
NewDepositValidatorRewardsPoolCmd(valAc, ac),
)

return distTxCmd
Expand Down Expand Up @@ -72,6 +68,8 @@ func newSplitAndApply(
}

// NewWithdrawRewardsCmd returns a CLI command handler for creating a MsgWithdrawDelegatorReward transaction.
// Deprecated: This command is deprecated and will be removed in a future release.
// The module is using its AutoCLI command instead.
func NewWithdrawRewardsCmd(valCodec, ac address.Codec) *cobra.Command {
bech32PrefixValAddr := sdk.GetConfig().GetBech32ValidatorAddrPrefix()

Expand Down Expand Up @@ -185,6 +183,8 @@ $ %[1]s tx distribution withdraw-all-rewards --from mykey
}

// NewSetWithdrawAddrCmd returns a CLI command handler for creating a MsgSetWithdrawAddress transaction.
// Deprecated: This command is deprecated and will be removed in a future release.
// The module is using its AutoCLI command instead.
func NewSetWithdrawAddrCmd(ac address.Codec) *cobra.Command {
bech32PrefixAccAddr := sdk.GetConfig().GetBech32AccountAddrPrefix()

Expand Down Expand Up @@ -224,6 +224,8 @@ $ %s tx distribution set-withdraw-addr %s1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
}

// NewFundCommunityPoolCmd returns a CLI command handler for creating a MsgFundCommunityPool transaction.
// Deprecated: This command is deprecated and will be removed in a future release.
// The module is using its AutoCLI command instead.
func NewFundCommunityPoolCmd(ac address.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "fund-community-pool [amount]",
Expand Down Expand Up @@ -265,6 +267,8 @@ $ %s tx distribution fund-community-pool 100uatom --from mykey

// NewDepositValidatorRewardsPoolCmd returns a CLI command handler for creating
// a MsgDepositValidatorRewardsPool transaction.
// Deprecated: This command is deprecated and will be removed in a future release.
// The module is using its AutoCLI command instead.
func NewDepositValidatorRewardsPoolCmd(valCodec, ac address.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "fund-validator-rewards-pool [val_addr] [amount]",
Expand Down
4 changes: 2 additions & 2 deletions x/feegrant/module/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
},
},
Tx: &autocliv1.ServiceCommandDescriptor{
Service: feegrantv1beta1.Msg_ServiceDesc.ServiceName,
Service: feegrantv1beta1.Msg_ServiceDesc.ServiceName,
EnhanceCustomCommand: true,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "RevokeAllowance",
Expand All @@ -68,7 +69,6 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
Example: fmt.Sprintf(`$ %s tx feegrant prune --from [mykey]`, version.AppName),
},
},
EnhanceCustomCommand: true,
},
}
}
4 changes: 2 additions & 2 deletions x/gov/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
EnhanceCustomCommand: true, // We still have manual commands in gov that we want to keep
},
Tx: &autocliv1.ServiceCommandDescriptor{
Service: govv1.Msg_ServiceDesc.ServiceName,
EnhanceCustomCommand: true,
Service: govv1.Msg_ServiceDesc.ServiceName,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "Deposit",
Expand Down Expand Up @@ -140,7 +141,6 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
GovProposal: true,
},
},
EnhanceCustomCommand: false, // use custom commands only until v0.51
},
}
}
9 changes: 6 additions & 3 deletions x/gov/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,9 @@ func NewTxCmd(legacyPropCmds []*cobra.Command) *cobra.Command {
}

govTxCmd.AddCommand(
NewCmdDeposit(),
NewCmdVote(),
NewCmdWeightedVote(),
NewCmdSubmitProposal(),
NewCmdDraftProposal(),
NewCmdCancelProposal(),

// Deprecated
cmdSubmitLegacyProp,
Expand Down Expand Up @@ -155,6 +152,8 @@ metadata example:
}

// NewCmdCancelProposal implements submitting a cancel proposal transaction command.
// Deprecated: This command is deprecated and will be removed in a future release.
// The module is using its AutoCLI command instead.
func NewCmdCancelProposal() *cobra.Command {
cmd := &cobra.Command{
Use: "cancel-proposal [proposal-id]",
Expand Down Expand Up @@ -254,6 +253,8 @@ $ %s tx gov submit-legacy-proposal --title="Test Proposal" --description="My awe
}

// NewCmdDeposit implements depositing tokens for an active proposal.
// Deprecated: This command is deprecated and will be removed in a future release.
// The module is using its AutoCLI command instead.
func NewCmdDeposit() *cobra.Command {
cmd := &cobra.Command{
Use: "deposit [proposal-id] [deposit]",
Expand Down Expand Up @@ -302,6 +303,8 @@ $ %s tx gov deposit 1 10stake --from mykey
}

// NewCmdVote implements creating a new vote command.
// Deprecated: This command is deprecated and will be removed in a future release.
// The module is using its AutoCLI command instead.
func NewCmdVote() *cobra.Command {
cmd := &cobra.Command{
Use: "vote [proposal-id] [option]",
Expand Down
24 changes: 16 additions & 8 deletions x/group/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,11 @@ func TxCmd(name string, ac address.Codec) *cobra.Command {

txCmd.AddCommand(
MsgCreateGroupCmd(),
MsgUpdateGroupAdminCmd(),
MsgUpdateGroupMetadataCmd(),
MsgUpdateGroupMembersCmd(),
MsgCreateGroupWithPolicyCmd(),
MsgCreateGroupPolicyCmd(),
MsgUpdateGroupPolicyAdminCmd(),
MsgUpdateGroupPolicyDecisionPolicyCmd(ac),
MsgUpdateGroupPolicyMetadataCmd(),
MsgWithdrawProposalCmd(),
MsgSubmitProposalCmd(),
MsgVoteCmd(),
MsgExecCmd(),
MsgLeaveGroupCmd(),
NewCmdDraftProposal(),
)

Expand Down Expand Up @@ -197,6 +189,8 @@ Set a member's weight to "0" to delete it.
}

// MsgUpdateGroupAdminCmd creates a CLI command for Msg/UpdateGroupAdmin.
// Deprecated: This command is deprecated and will be removed in a future release.
// The module is using its AutoCLI command instead.
func MsgUpdateGroupAdminCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "update-group-admin [admin] [group-id] [new-admin]",
Expand Down Expand Up @@ -241,6 +235,8 @@ func MsgUpdateGroupAdminCmd() *cobra.Command {
}

// MsgUpdateGroupMetadataCmd creates a CLI command for Msg/UpdateGroupMetadata.
// Deprecated: This command is deprecated and will be removed in a future release.
// The module is using its AutoCLI command instead.
func MsgUpdateGroupMetadataCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "update-group-metadata [admin] [group-id] [metadata]",
Expand Down Expand Up @@ -458,6 +454,8 @@ Here, we can use percentage decision policy when needed, where 0 < percentage <=
}

// MsgUpdateGroupPolicyAdminCmd creates a CLI command for Msg/UpdateGroupPolicyAdmin.
// Deprecated: This command is deprecated and will be removed in a future release.
// The module is using its AutoCLI command instead.
func MsgUpdateGroupPolicyAdminCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "update-group-policy-admin [admin] [group-policy-account] [new-admin]",
Expand Down Expand Up @@ -538,6 +536,8 @@ func MsgUpdateGroupPolicyDecisionPolicyCmd(ac address.Codec) *cobra.Command {
}

// MsgUpdateGroupPolicyMetadataCmd creates a CLI command for Msg/UpdateGroupPolicyMetadata.
// Deprecated: This command is deprecated and will be removed in a future release.
// The module is using its AutoCLI command instead.
func MsgUpdateGroupPolicyMetadataCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "update-group-policy-metadata [admin] [group-policy-account] [new-metadata]",
Expand Down Expand Up @@ -661,6 +661,8 @@ metadata example:
}

// MsgWithdrawProposalCmd creates a CLI command for Msg/WithdrawProposal.
// Deprecated: This command is deprecated and will be removed in a future release.
// The module is using its AutoCLI command instead.
func MsgWithdrawProposalCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "withdraw-proposal [proposal-id] [group-policy-admin-or-proposer]",
Expand Down Expand Up @@ -707,6 +709,8 @@ Parameters:
}

// MsgVoteCmd creates a CLI command for Msg/Vote.
// Deprecated: This command is deprecated and will be removed in a future release.
// The module is using its AutoCLI command instead.
func MsgVoteCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "vote [proposal-id] [voter] [vote-option] [metadata]",
Expand Down Expand Up @@ -767,6 +771,8 @@ Parameters:
}

// MsgExecCmd creates a CLI command for Msg/Exec.
// Deprecated: This command is deprecated and will be removed in a future release.
// The module is using its AutoCLI command instead.
func MsgExecCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "exec [proposal-id]",
Expand Down Expand Up @@ -798,6 +804,8 @@ func MsgExecCmd() *cobra.Command {
}

// MsgLeaveGroupCmd creates a CLI command for Msg/LeaveGroup.
// Deprecated: This command is deprecated and will be removed in a future release.
// The module is using its AutoCLI command instead.
func MsgLeaveGroupCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "leave-group [member-address] [group-id]",
Expand Down
2 changes: 1 addition & 1 deletion x/group/module/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
},
Tx: &autocliv1.ServiceCommandDescriptor{
Service: groupv1.Msg_ServiceDesc.ServiceName,
EnhanceCustomCommand: false, // use custom commands only until v0.51
EnhanceCustomCommand: true,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "UpdateGroupAdmin",
Expand Down
3 changes: 2 additions & 1 deletion x/mint/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
},
},
Tx: &autocliv1.ServiceCommandDescriptor{
Service: mintv1beta1.Msg_ServiceDesc.ServiceName,
Service: mintv1beta1.Msg_ServiceDesc.ServiceName,
EnhanceCustomCommand: true,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "UpdateParams",
Expand Down
Loading
Loading