From 18733a684e4d2b6d706396bf620c2c2129ff80f4 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Mon, 16 Oct 2023 15:09:06 +0200 Subject: [PATCH] feat: bring autocli module config to v0.50 (#18111) --- x/auth/autocli.go | 10 ++++- x/auth/vesting/autocli.go | 48 ++++++++++++++++++++++ x/authz/module/autocli.go | 25 +++++++++++- x/bank/autocli.go | 28 +++++++++++++ x/consensus/autocli.go | 10 ++++- x/distribution/autocli.go | 74 ++++++++++++++++++++++++++-------- x/gov/autocli.go | 50 +++++++++++++++++------ x/group/module/autocli.go | 83 ++++++++++++++++++++++++++++++++++++++- x/mint/autocli.go | 8 +++- x/staking/autocli.go | 38 ++++++++++++++++++ x/upgrade/autocli.go | 12 +++++- 11 files changed, 352 insertions(+), 34 deletions(-) create mode 100644 x/auth/vesting/autocli.go diff --git a/x/auth/autocli.go b/x/auth/autocli.go index c7b52e42e0..30f06fb593 100644 --- a/x/auth/autocli.go +++ b/x/auth/autocli.go @@ -76,6 +76,14 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, }, }, - // Tx is purposely left empty, as the only tx is MsgUpdateParams which is gov gated. + Tx: &autocliv1.ServiceCommandDescriptor{ + Service: authv1beta1.Msg_ServiceDesc.ServiceName, + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "UpdateParams", + Skip: true, // skipped because authority gated + }, + }, + }, } } diff --git a/x/auth/vesting/autocli.go b/x/auth/vesting/autocli.go new file mode 100644 index 0000000000..5ae6ff88e4 --- /dev/null +++ b/x/auth/vesting/autocli.go @@ -0,0 +1,48 @@ +package vesting + +import ( + autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" + vestingv1beta1 "cosmossdk.io/api/cosmos/vesting/v1beta1" +) + +// AutoCLIOptions implements the autocli.HasAutoCLIConfig interface. +func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { + return &autocliv1.ModuleOptions{ + Tx: &autocliv1.ServiceCommandDescriptor{ + Service: vestingv1beta1.Msg_ServiceDesc.ServiceName, + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "CreateVestingAccount", + Use: "create-vesting-account [to_address] [end_time] [amount]", + Short: "Create a new vesting account funded with an allocation of tokens.", + Long: `Create a new vesting account funded with an allocation of tokens. The +account can either be a delayed or continuous vesting account, which is determined +by the '--delayed' flag. All vesting accounts created will have their start time +set by the committed block's time. The end_time must be provided as a UNIX epoch +timestamp.`, + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "to_address"}, + {ProtoField: "end_time"}, + {ProtoField: "amount", Varargs: true}, + }, + FlagOptions: map[string]*autocliv1.FlagOptions{ + "delayed": {Name: "delayed", Usage: "Create a delayed vesting account if true"}, + }, + }, + { + RpcMethod: "CreatePermanentLockedAccount", + Use: "create-permanent-locked-account [to_address] [amount]", + Short: "Create a new permanently locked account funded with an allocation of tokens.", + Long: `Create a new account funded with an allocation of permanently locked tokens. These + tokens may be used for staking but are non-transferable. Staking rewards will acrue as liquid and transferable + tokens.`, + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "to_address"}, + {ProtoField: "amount", Varargs: true}, + }, + }, + }, + EnhanceCustomCommand: false, // use custom commands only until v0.51 + }, + } +} diff --git a/x/authz/module/autocli.go b/x/authz/module/autocli.go index 76c3cce25e..fc551183e4 100644 --- a/x/authz/module/autocli.go +++ b/x/authz/module/autocli.go @@ -47,7 +47,30 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, }, Tx: &autocliv1.ServiceCommandDescriptor{ - Service: authzv1beta1.Msg_ServiceDesc.ServiceName, + Service: authzv1beta1.Msg_ServiceDesc.ServiceName, + EnhanceCustomCommand: false, // use custom commands only until v0.51 + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "Exec", + Use: "exec [msg-json-file] --from [grantee]", + Short: "Execute tx on behalf of granter account", + Example: fmt.Sprintf("$ %s tx authz exec msg.json --from grantee\n $ %[1]s tx bank send [granter] [recipient] [amount] --generate-only | jq .body.messages > msg.json && %[1]s tx authz exec msg.json --from grantee", version.AppName), + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "msgs", Varargs: true}, + }, + }, + { + RpcMethod: "Revoke", + Use: "revoke [grantee] [msg-type-url] --from [granter]", + Short: `Revoke authorization from a granter to a grantee`, + Example: fmt.Sprintf(`%s tx authz revoke cosmos1skj.. %s --from=cosmos1skj..`, + version.AppName, bank.SendAuthorization{}.MsgTypeURL()), + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "grantee"}, + {ProtoField: "msg_type_url"}, + }, + }, + }, }, } } diff --git a/x/bank/autocli.go b/x/bank/autocli.go index 25d65feecb..7bb1b571c2 100644 --- a/x/bank/autocli.go +++ b/x/bank/autocli.go @@ -87,5 +87,33 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, }, }, + Tx: &autocliv1.ServiceCommandDescriptor{ + Service: bankv1beta1.Msg_ServiceDesc.ServiceName, + EnhanceCustomCommand: false, // use custom commands only until v0.51 + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "Send", + Use: "send [from_key_or_address] [to_address] [amount]", + Short: "Send funds from one account to another.", + Long: `Send funds from one account to another. + Note, the '--from' flag is ignored as it is implied from [from_key_or_address]. + When using '--dry-run' a key name cannot be used, only a bech32 address. + Note: multiple coins can be send by space separated.`, + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "from_address"}, {ProtoField: "to_address"}, {ProtoField: "amount", Varargs: true}}, + }, + { + RpcMethod: "UpdateParams", + Skip: true, // skipped because authority gated + }, + { + RpcMethod: "SetSendEnabled", + Skip: true, // skipped because authority gated + }, + { + RpcMethod: "Burn", + Skip: true, // skipped because available from v0.51 + }, + }, + }, } } diff --git a/x/consensus/autocli.go b/x/consensus/autocli.go index a8bb0f49c6..5a2e00900c 100644 --- a/x/consensus/autocli.go +++ b/x/consensus/autocli.go @@ -23,6 +23,14 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { "comet": cmtservice.CometBFTAutoCLIDescriptor, }, }, - // Tx is purposely left empty, as the only tx is MsgUpdateParams which is gov gated. + Tx: &autocliv1.ServiceCommandDescriptor{ + Service: consensusv1.Msg_ServiceDesc.ServiceName, + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "UpdateParams", + Skip: true, // skipped because authority gated + }, + }, + }, } } diff --git a/x/distribution/autocli.go b/x/distribution/autocli.go index 8df238c8c2..fa0d9915bc 100644 --- a/x/distribution/autocli.go +++ b/x/distribution/autocli.go @@ -2,7 +2,6 @@ package distribution import ( "fmt" - "strings" autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" distirbuitonv1beta1 "cosmossdk.io/api/cosmos/distribution/v1beta1" @@ -17,11 +16,6 @@ var ( // AutoCLIOptions implements the autocli.HasAutoCLIConfig interface. func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { - exAccAddress, err := am.ac.BytesToString([]byte("A58856F0FD53BF058B4909A21AEC019107BA6A58856F0FD53BF058B4909A21AEC019107BA6")) - if err != nil { - panic(err) - } - return &autocliv1.ModuleOptions{ Query: &autocliv1.ServiceCommandDescriptor{ Service: distirbuitonv1beta1.Query_ServiceDesc.ServiceName, @@ -35,9 +29,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { RpcMethod: "ValidatorDistributionInfo", Use: "validator-distribution-info [validator]", Short: "Query validator distribution info", - Example: fmt.Sprintf(`Example: $ %s query distribution validator-distribution-info %s`, - version.AppName, exAccAddress, - ), + Example: fmt.Sprintf(`Example: $ %s query distribution validator-distribution-info [validator-address]`, version.AppName), PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "validator_address"}, @@ -77,14 +69,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { Use: "rewards [delegator-addr] [validator-addr]", Short: "Query all distribution delegator rewards or rewards from a particular validator", Long: "Query all rewards earned by a delegator, optionally restrict to rewards from a single validator.", - Example: strings.TrimSpace( - fmt.Sprintf(` -$ %s query distribution rewards %s -$ %s query distribution rewards %s [validator-address] -`, - version.AppName, exAccAddress, version.AppName, exAccAddress, - ), - ), + Example: fmt.Sprintf("$ %s query distribution rewards [delegator-address] [validator-address]", version.AppName), PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "delegator_address"}, {ProtoField: "validator_address"}, @@ -100,6 +85,61 @@ $ %s query distribution rewards %s [validator-address] }, Tx: &autocliv1.ServiceCommandDescriptor{ Service: distirbuitonv1beta1.Msg_ServiceDesc.ServiceName, + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "SetWithdrawAddress", + Use: "set-withdraw-addr [withdraw-addr]", + Short: "Change the default withdraw address for rewards associated with an address", + Example: fmt.Sprintf("%s tx distribution set-withdraw-addr cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p --from mykey", version.AppName), + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "withdraw_address"}, + }, + }, + { + RpcMethod: "WithdrawDelegatorReward", + Use: "withdraw-rewards [validator-addr]", + Short: "Withdraw rewards from a given delegation address", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "validator_address"}, + }, + }, + { + RpcMethod: "WithdrawValidatorCommission", + Use: "withdraw-validator-commission [validator-addr]", + Short: "Withdraw commissions from a validator address (must be a validator operator)", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "validator_address"}, + }, + }, + { + RpcMethod: "DepositValidatorRewardsPool", + Use: "fund-validator-rewards-pool [validator-addr] [amount]", + Short: "Fund the validator rewards pool with the specified amount", + Example: fmt.Sprintf("%s tx distribution fund-validator-rewards-pool cosmosvaloper1x20lytyf6zkcrv5edpkfkn8sz578qg5sqfyqnp 100uatom --from mykey", version.AppName), + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "validator_address"}, + {ProtoField: "amount", Varargs: true}, + }, + }, + { + RpcMethod: "FundCommunityPool", + Use: "fund-community-pool [amount]", + Short: "Funds the community pool with the specified amount", + Example: fmt.Sprintf(`$ %s tx distribution fund-community-pool 100uatom --from mykey`, version.AppName), + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "amount", Varargs: true}, + }, + }, + { + RpcMethod: "UpdateParams", + Skip: true, // skipped because authority gated + }, + { + RpcMethod: "CommunityPoolSpend", + Skip: true, // skipped because authority gated + }, + }, + EnhanceCustomCommand: false, // use custom commands only until v0.51 }, } } diff --git a/x/gov/autocli.go b/x/gov/autocli.go index bd1ba2a1f5..86edefa256 100644 --- a/x/gov/autocli.go +++ b/x/gov/autocli.go @@ -5,7 +5,6 @@ import ( autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" govv1 "cosmossdk.io/api/cosmos/gov/v1" - govv1beta1 "cosmossdk.io/api/cosmos/gov/v1beta1" "github.com/cosmos/cosmos-sdk/version" ) @@ -91,22 +90,51 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { Short: "Query the current chain constitution", }, }, - // map v1beta1 as a sub-command - SubCommands: map[string]*autocliv1.ServiceCommandDescriptor{ - "v1beta1": { - Service: govv1beta1.Query_ServiceDesc.ServiceName, - }, - }, EnhanceCustomCommand: true, // We still have manual commands in gov that we want to keep }, Tx: &autocliv1.ServiceCommandDescriptor{ Service: govv1.Msg_ServiceDesc.ServiceName, - // map v1beta1 as a sub-command - SubCommands: map[string]*autocliv1.ServiceCommandDescriptor{ - "v1beta1": { - Service: govv1beta1.Msg_ServiceDesc.ServiceName, + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "Deposit", + Use: "deposit [proposal-id] [deposit]", + Short: "Deposit tokens for an active proposal", + Long: fmt.Sprintf(`Submit a deposit for an active proposal. You can find the proposal-id by running "%s query gov proposals"`, version.AppName), + Example: fmt.Sprintf(`$ %s tx gov deposit 1 10stake --from mykey`, version.AppName), + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "proposal_id"}, + {ProtoField: "amount", Varargs: true}, + }, + }, + { + RpcMethod: "CancelProposal", + Use: "cancel-proposal [proposal-id]", + Short: "Cancel governance proposal before the voting period ends. Must be signed by the proposal creator.", + Example: fmt.Sprintf(`$ %s tx gov cancel-proposal 1 --from mykey`, version.AppName), + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "proposal_id"}, + }, + }, + { + RpcMethod: "Vote", + Use: "vote [proposal-id] [option]", + Short: "Vote for an active proposal, options: yes/no/no-with-veto/abstain", + Long: fmt.Sprintf(`Submit a vote for an active proposal. Use the --metadata to optionally give a reason. You can find the proposal-id by running "%s query gov proposals"`, version.AppName), + Example: fmt.Sprintf("$ %s tx gov vote 1 yes --from mykey", version.AppName), + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "proposal_id"}, + {ProtoField: "option"}, + }, + FlagOptions: map[string]*autocliv1.FlagOptions{ + "metadata": {Name: "metadata", Usage: "Add a description to the vote"}, + }, + }, + { + RpcMethod: "UpdateParams", + Skip: true, // skipped because authority gated }, }, + EnhanceCustomCommand: false, // use custom commands only until v0.51 }, } } diff --git a/x/group/module/autocli.go b/x/group/module/autocli.go index 071e33b51b..f5386f91ef 100644 --- a/x/group/module/autocli.go +++ b/x/group/module/autocli.go @@ -124,7 +124,88 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, }, Tx: &autocliv1.ServiceCommandDescriptor{ - Service: groupv1.Query_ServiceDesc.ServiceName, + Service: groupv1.Msg_ServiceDesc.ServiceName, + EnhanceCustomCommand: false, // use custom commands only until v0.51 + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "UpdateGroupAdmin", + Use: "update-group-admin [admin] [group-id] [new-admin]", + Short: "Update a group's admin", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "admin"}, {ProtoField: "group_id"}, {ProtoField: "new_admin"}, + }, + }, + { + RpcMethod: "UpdateGroupMetadata", + Use: "update-group-metadata [admin] [group-id] [metadata]", + Short: "Update a group's metadata", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "admin"}, {ProtoField: "group_id"}, {ProtoField: "metadata"}, + }, + }, + { + RpcMethod: "UpdateGroupPolicyAdmin", + Use: "update-group-policy-admin [admin] [group-policy-account] [new-admin]", + Short: "Update a group policy admin", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "admin"}, {ProtoField: "group_policy_address"}, {ProtoField: "new_admin"}, + }, + }, + { + RpcMethod: "UpdateGroupPolicyMetadata", + Use: "update-group-policy-metadata [admin] [group-policy-account] [new-metadata]", + Short: "Update a group policy metadata", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "admin"}, {ProtoField: "group_policy_address"}, {ProtoField: "metadata"}, + }, + }, + { + RpcMethod: "WithdrawProposal", + Use: "withdraw-proposal [proposal-id] [group-policy-admin-or-proposer]", + Short: "Withdraw a submitted proposal", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "proposal_id"}, {ProtoField: "address"}, + }, + }, + { + RpcMethod: "Vote", + Use: "vote [proposal-id] [voter] [vote-option] [metadata]", + Long: `Vote on a proposal. + Parameters: + proposal-id: unique ID of the proposal + voter: voter account addresses. + vote-option: choice of the voter(s) + VOTE_OPTION_UNSPECIFIED: no-op + VOTE_OPTION_NO: no + VOTE_OPTION_YES: yes + VOTE_OPTION_ABSTAIN: abstain + VOTE_OPTION_NO_WITH_VETO: no-with-veto + Metadata: metadata for the vote +`, + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "proposal_id"}, {ProtoField: "voter"}, {ProtoField: "option"}, {ProtoField: "metadata"}, + }, + FlagOptions: map[string]*autocliv1.FlagOptions{ + "exec": {Name: "exec", DefaultValue: "", Usage: "Set to 'try' for trying to execute proposal immediately after voting"}, + }, + }, + { + RpcMethod: "Exec", + Use: "exec [proposal-id]", + Short: "Execute a proposal", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "proposal_id"}, + }, + }, + { + RpcMethod: "LeaveGroup", + Use: "leave-group [member-address] [group-id]", + Short: "Remove member from the group", + PositionalArgs: []*autocliv1.PositionalArgDescriptor{ + {ProtoField: "address"}, {ProtoField: "group_id"}, + }, + }, + }, }, } } diff --git a/x/mint/autocli.go b/x/mint/autocli.go index 2f3bcb28c6..8ac35d04b6 100644 --- a/x/mint/autocli.go +++ b/x/mint/autocli.go @@ -28,7 +28,13 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, }, Tx: &autocliv1.ServiceCommandDescriptor{ - Service: mintv1beta1.Query_ServiceDesc.ServiceName, + Service: mintv1beta1.Msg_ServiceDesc.ServiceName, + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "UpdateParams", + Skip: true, // skipped because authority gated + }, + }, }, } } diff --git a/x/staking/autocli.go b/x/staking/autocli.go index fc7ba40703..8a5ca421b7 100644 --- a/x/staking/autocli.go +++ b/x/staking/autocli.go @@ -142,6 +142,44 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, Tx: &autocliv1.ServiceCommandDescriptor{ Service: stakingv1beta.Msg_ServiceDesc.ServiceName, + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "Delegate", + Use: "delegate [validator-addr] [amount] --from [delegator_address]", + Short: "Delegate liquid tokens to a validator", + Long: "Delegate an amount of liquid coins to a validator from your wallet.", + Example: fmt.Sprintf("%s tx staking delegate cosmosvaloper... 1000stake --from mykey", version.AppName), + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "validator_address"}, {ProtoField: "amount"}}, + }, + { + RpcMethod: "BeginRedelegate", + Use: "redelegate [src-validator-addr] [dst-validator-addr] [amount] --from [delegator]", + Short: "Generate multisig signatures for transactions generated offline", + Long: "Redelegate an amount of illiquid staking tokens from one validator to another.", + Example: fmt.Sprintf(`%s tx staking redelegate cosmosvaloper... cosmosvaloper... 100stake --from mykey`, version.AppName), + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "validator_src_address"}, {ProtoField: "validator_dst_address"}, {ProtoField: "amount"}}, + }, + { + RpcMethod: "Undelegate", + Use: "unbond [validator-addr] [amount] --from [delegator_address]", + Short: "Unbond shares from a validator", + Long: "Unbond an amount of bonded shares from a validator.", + Example: fmt.Sprintf(`%s tx staking unbond cosmosvaloper... 100stake --from mykey`, version.AppName), + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "validator_address"}, {ProtoField: "amount"}}, + }, + { + RpcMethod: "CancelUnbondingDelegation", + Use: "cancel-unbond [validator-addr] [amount] [creation-height]", + Short: "Cancel unbonding delegation and delegate back to the validator", + Example: fmt.Sprintf(`%s tx staking cancel-unbond cosmosvaloper... 100stake 2 --from mykey`, version.AppName), + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "validator_address"}, {ProtoField: "amount"}, {ProtoField: "creation_height"}}, + }, + { + RpcMethod: "UpdateParams", + Skip: true, // skipped because authority gated + }, + }, + EnhanceCustomCommand: false, // use custom commands only until v0.51 }, } } diff --git a/x/upgrade/autocli.go b/x/upgrade/autocli.go index 7c295f30a5..45d076c75e 100644 --- a/x/upgrade/autocli.go +++ b/x/upgrade/autocli.go @@ -47,7 +47,17 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, }, Tx: &autocliv1.ServiceCommandDescriptor{ - Service: upgradev1beta1.Query_ServiceDesc.ServiceName, + Service: upgradev1beta1.Msg_ServiceDesc.ServiceName, + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + { + RpcMethod: "SoftwareUpgrade", + Skip: true, // skipped because authority gated + }, + { + RpcMethod: "CancelUpgrade", + Skip: true, // skipped because authority gated + }, + }, }, } }