Skip to content

Commit

Permalink
feat: bring autocli module config to v0.50 (#18111)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Oct 16, 2023
1 parent 9c2c424 commit 18733a6
Show file tree
Hide file tree
Showing 11 changed files with 352 additions and 34 deletions.
10 changes: 9 additions & 1 deletion x/auth/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
},
},
}
}
48 changes: 48 additions & 0 deletions x/auth/vesting/autocli.go
Original file line number Diff line number Diff line change
@@ -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
},
}
}
25 changes: 24 additions & 1 deletion x/authz/module/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
},
},
},
},
}
}
28 changes: 28 additions & 0 deletions x/bank/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
},
},
}
}
10 changes: 9 additions & 1 deletion x/consensus/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
},
},
}
}
74 changes: 57 additions & 17 deletions x/distribution/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package distribution

import (
"fmt"
"strings"

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
distirbuitonv1beta1 "cosmossdk.io/api/cosmos/distribution/v1beta1"
Expand All @@ -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,
Expand All @@ -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"},
Expand Down Expand Up @@ -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"},
Expand All @@ -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
},
}
}
50 changes: 39 additions & 11 deletions x/gov/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
},
}
}
Loading

0 comments on commit 18733a6

Please sign in to comment.