Skip to content

Commit

Permalink
add --no-proposal flag
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Nov 14, 2023
1 parent 17cbc97 commit e329e20
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions client/v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ The `AutoCLIOptions()` method on your module allows to specify custom commands,

:::tip
AutoCLI can create a gov proposal of any tx by simply setting the `GovProposal` field to `true` in the `autocli.RpcCommandOptions` struct.
Users can however use the `--no-proposal` flag to disable the proposal creation (which is useful if the authority isn't the gov module on a chain).
:::

### Specifying Subcommands
Expand Down
8 changes: 4 additions & 4 deletions client/v2/autocli/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
"cosmossdk.io/client/v2/autocli/flag"
"cosmossdk.io/client/v2/internal/flags"
"cosmossdk.io/client/v2/internal/util"
addresscodec "cosmossdk.io/core/address"
authtx "cosmossdk.io/x/auth/tx"
Expand Down Expand Up @@ -152,7 +153,8 @@ func (b *Builder) BuildMsgMethodCommand(descriptor protoreflect.MethodDescriptor
addressCodec := b.Builder.AddressCodec

// handle gov proposals commands
if options.GovProposal {
skipProposal, _ := cmd.Flags().GetBool(flags.FlagNoProposal)
if options.GovProposal && !skipProposal {
return b.handleGovProposal(options, cmd, input, clientCtx, addressCodec, fd)
}

Expand Down Expand Up @@ -204,9 +206,7 @@ func (b *Builder) BuildMsgMethodCommand(descriptor protoreflect.MethodDescriptor
// set gov proposal flags if command is a gov proposal
if options.GovProposal {
govcli.AddGovPropFlagsToCmd(cmd)
if err := cmd.MarkFlagRequired(govcli.FlagTitle); err != nil {
return nil, err
}
cmd.Flags().Bool(flags.FlagNoProposal, false, "Skip gov proposal and submit a normal transaction")
}

return cmd, err
Expand Down
4 changes: 4 additions & 0 deletions client/v2/internal/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const (

// FlagNoPrompt is the flag to not use a prompt for commands.
FlagNoPrompt = "no-prompt"

// FlagNoProposal is the flag convert a gov proposal command into a normal command.
// This is used to allow user of chains with custom authority to not use gov submit proposals for usual proposal commands.
FlagNoProposal = "no-proposal"
)

// List of supported output formats
Expand Down

0 comments on commit e329e20

Please sign in to comment.