Skip to content

Commit

Permalink
refactoring proposal cmds to route to protorev, deprecating proposal …
Browse files Browse the repository at this point in the history
…handler inside of modules.go
  • Loading branch information
davidterpay committed Dec 27, 2022
1 parent db95371 commit 6d0df06
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 46 deletions.
3 changes: 0 additions & 3 deletions app/keepers/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
poolincentives "github.com/osmosis-labs/osmosis/v13/x/pool-incentives"
poolincentivesclient "github.com/osmosis-labs/osmosis/v13/x/pool-incentives/client"
"github.com/osmosis-labs/osmosis/v13/x/protorev"
protorevclient "github.com/osmosis-labs/osmosis/v13/x/protorev/client"
superfluid "github.com/osmosis-labs/osmosis/v13/x/superfluid"
superfluidclient "github.com/osmosis-labs/osmosis/v13/x/superfluid/client"
swaprouter "github.com/osmosis-labs/osmosis/v13/x/swaprouter/module"
Expand Down Expand Up @@ -70,8 +69,6 @@ var AppModuleBasics = []module.AppModuleBasic{
poolincentivesclient.ReplacePoolIncentivesHandler,
ibcclientclient.UpdateClientProposalHandler,
ibcclientclient.UpgradeProposalHandler,
protorevclient.SetProtoRevAdminAccountProposalHandler,
protorevclient.SetProtoRevEnabledProposalHandler,
superfluidclient.SetSuperfluidAssetsProposalHandler,
superfluidclient.RemoveSuperfluidAssetsProposalHandler,
superfluidclient.UpdateUnpoolWhitelistProposalHandler,
Expand Down
27 changes: 21 additions & 6 deletions x/protorev/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,36 @@ import (
"strconv"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/gov/client/cli"
"github.com/spf13/cobra"

govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"

"github.com/osmosis-labs/osmosis/v13/osmoutils/osmocli"
"github.com/osmosis-labs/osmosis/v13/x/protorev/types"

sdk "github.com/cosmos/cosmos-sdk/types"
)

func NewCmdTx() *cobra.Command {
txCmd := osmocli.TxIndexCmd(types.ModuleName)
txCmd.AddCommand(
CmdSetProtoRevAdminAccountProposal(),
CmdSetProtoRevEnabledProposal(),
)
return txCmd
}

// CmdSetProtoRevAdminAccountProposal implements the command to submit a SetProtoRevAdminAccountProposal
func CmdSetProtoRevAdminAccountProposal() *cobra.Command {
cmd := &cobra.Command{
Use: "set-protorev-admin-account-proposal [sdk.AccAddress]",
Args: cobra.ExactArgs(1),
Short: "submit a set protorev admin account proposal",
Long: "submit a set protorev admin proposal followed by an sdk.AccAddress of the new admin account.",
Example: fmt.Sprintf(`$ %s tx gov submit-proposal set-protorev-admin-account osmo123... --from mykey`, version.AppName),
Short: "submit a set protorev admin account proposal to set the admin account for x/protorev",
Example: fmt.Sprintf(`$ %s tx protorev set-protorev-admin-account osmo123... --from mykey`, version.AppName),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
Expand Down Expand Up @@ -71,6 +81,9 @@ func CmdSetProtoRevAdminAccountProposal() *cobra.Command {
cmd.Flags().String(cli.FlagTitle, "", "title of proposal")
cmd.Flags().String(cli.FlagDescription, "", "description of proposal")
cmd.Flags().String(cli.FlagDeposit, "", "deposit of proposal")
flags.AddTxFlagsToCmd(cmd)
_ = cmd.MarkFlagRequired(cli.FlagTitle)
_ = cmd.MarkFlagRequired(cli.FlagDescription)

return cmd
}
Expand All @@ -80,9 +93,8 @@ func CmdSetProtoRevEnabledProposal() *cobra.Command {
cmd := &cobra.Command{
Use: "set-protorev-enabled-proposal [boolean]",
Args: cobra.ExactArgs(1),
Short: "Submit a SetProtoRevEnabled proposal",
Long: "Submit a SetProtoRevEnabled proposal followed by a boolean of whether or not the protocol should be enabled.",
Example: fmt.Sprintf(`$ %s tx gov submit-proposal set-protorev-enabled true --from mykey`, version.AppName),
Short: "submit a set protorev enabled proposal to enable or disable the protocol",
Example: fmt.Sprintf(`$ %s tx protorev set-protorev-enabled true --from mykey`, version.AppName),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
Expand Down Expand Up @@ -134,6 +146,9 @@ func CmdSetProtoRevEnabledProposal() *cobra.Command {
cmd.Flags().String(cli.FlagTitle, "", "title of proposal")
cmd.Flags().String(cli.FlagDescription, "", "description of proposal")
cmd.Flags().String(cli.FlagDeposit, "", "deposit of proposal")
flags.AddTxFlagsToCmd(cmd)
_ = cmd.MarkFlagRequired(cli.FlagTitle)
_ = cmd.MarkFlagRequired(cli.FlagDescription)

return cmd
}
36 changes: 0 additions & 36 deletions x/protorev/client/proposal_handler.go

This file was deleted.

3 changes: 2 additions & 1 deletion x/protorev/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"

"github.com/osmosis-labs/osmosis/v13/x/protorev/client/cli"
"github.com/osmosis-labs/osmosis/v13/x/protorev/keeper"
"github.com/osmosis-labs/osmosis/v13/x/protorev/types"
)
Expand Down Expand Up @@ -78,7 +79,7 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r

// GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module
func (a AppModuleBasic) GetTxCmd() *cobra.Command {
return nil
return cli.NewCmdTx()
}

// GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module
Expand Down

0 comments on commit 6d0df06

Please sign in to comment.