Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Nov 14, 2023
1 parent 77c298d commit e42c5f9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 67 deletions.
6 changes: 3 additions & 3 deletions client/v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ require (
cosmossdk.io/x/bank v0.0.0-00010101000000-000000000000
cosmossdk.io/x/gov v0.0.0-20231113122742-912390d5fc4a
cosmossdk.io/x/tx v0.12.0
github.com/chzyer/readline v1.5.1 // indirect
github.com/cockroachdb/errors v1.11.1
github.com/cosmos/cosmos-proto v1.0.0-beta.3
github.com/cosmos/cosmos-sdk v0.51.0
github.com/manifoldco/promptui v0.9.0 // indirect
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
google.golang.org/grpc v1.59.0
google.golang.org/protobuf v1.31.0
gotest.tools/v3 v3.5.1
sigs.k8s.io/yaml v1.4.0
github.com/chzyer/readline v1.5.1 // indirect
github.com/manifoldco/promptui v0.9.0 // indirect
)

require (
Expand Down Expand Up @@ -135,7 +135,7 @@ require (
github.com/spf13/afero v1.10.0 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/viper v1.17.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/stretchr/testify v1.8.4
github.com/subosito/gotenv v1.6.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
Expand Down
17 changes: 11 additions & 6 deletions x/consensus/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,17 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
Service: consensusv1.Msg_ServiceDesc.ServiceName,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "UpdateParams",
Use: "update-params-proposal [params]",
Short: "Submit a proposal to update consensus module params",
Example: fmt.Sprintf(`%s tx consensus update-params-proposal '{ params }'`, version.AppName),
PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "params"}},
GovProposal: true,
RpcMethod: "UpdateParams",
Use: "update-params-proposal [params]",
Short: "Submit a proposal to update consensus module params",
Example: fmt.Sprintf(`%s tx consensus update-params-proposal '{ params }'`, version.AppName),
PositionalArgs: []*autocliv1.PositionalArgDescriptor{
{ProtoField: "block"},
{ProtoField: "evidence"},
{ProtoField: "validator"},
{ProtoField: "abci"},
},
GovProposal: true,
},
},
},
Expand Down
9 changes: 6 additions & 3 deletions x/upgrade/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,17 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
Service: upgradev1beta1.Msg_ServiceDesc.ServiceName,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "SoftwareUpgrade",
Skip: true, // skipped because authority gated
RpcMethod: "CancelUpgrade",
Use: "cancel-upgrade-proposal",
Short: "Submit a proposal to cancel a planned chain upgrade.",
GovProposal: true,
},
{
RpcMethod: "CancelUpgrade",
RpcMethod: "SoftwareUpgrade",
Skip: true, // skipped because authority gated
},
},
EnhanceCustomCommand: true,
},
}
}
56 changes: 1 addition & 55 deletions x/upgrade/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ func GetTxCmd() *cobra.Command {

cmd.AddCommand(
NewCmdSubmitUpgradeProposal(),
NewCmdSubmitCancelUpgradeProposal(),
)

return cmd
}

// NewCmdSubmitUpgradeProposal implements a command handler for submitting a software upgrade proposal transaction.
// This commands is not migrated to autocli as it contains extra validation that is useful for submitting upgrade proposals.
func NewCmdSubmitUpgradeProposal() *cobra.Command {
cmd := &cobra.Command{
Use: "software-upgrade [name] (--upgrade-height [height]) (--upgrade-info [info]) [flags]",
Expand Down Expand Up @@ -136,60 +136,6 @@ func NewCmdSubmitUpgradeProposal() *cobra.Command {
return cmd
}

// NewCmdSubmitCancelUpgradeProposal implements a command handler for submitting a software upgrade cancel proposal transaction.
func NewCmdSubmitCancelUpgradeProposal() *cobra.Command {
cmd := &cobra.Command{
Use: "cancel-software-upgrade [flags]",
Args: cobra.ExactArgs(0),
Short: "Cancel the current software upgrade proposal",
Long: "Cancel a software upgrade along with an initial deposit.",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

proposal, err := cli.ReadGovPropFlags(clientCtx, cmd.Flags())
if err != nil {
return err
}

authority, _ := cmd.Flags().GetString(FlagAuthority)
if authority != "" {
if _, err = clientCtx.AddressCodec.StringToBytes(authority); err != nil {
return fmt.Errorf("invalid authority address: %w", err)
}
} else {
if authority, err = clientCtx.AddressCodec.BytesToString(address.Module("gov")); err != nil {
return fmt.Errorf("failed to convert authority address to string: %w", err)
}
}

if err := proposal.SetMsgs([]sdk.Msg{
&types.MsgCancelUpgrade{
Authority: authority,
},
}); err != nil {
return fmt.Errorf("failed to create cancel upgrade proposal message: %w", err)
}

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), proposal)
},
}

cmd.Flags().String(FlagAuthority, "", "The address of the upgrade module authority (defaults to gov)")

// add common proposal flags
flags.AddTxFlagsToCmd(cmd)
cli.AddGovPropFlagsToCmd(cmd)
err := cmd.MarkFlagRequired(cli.FlagTitle)
if err != nil {
panic(err)
}

return cmd
}

// getDefaultDaemonName gets the default name to use for the daemon.
// If a DAEMON_NAME env var is set, that is used.
// Otherwise, the last part of the currently running executable is used.
Expand Down

0 comments on commit e42c5f9

Please sign in to comment.