mirror of
https://github.com/onsonr/sonr.git
synced 2025-03-10 21:09:11 +00:00
70 lines
1.6 KiB
Go
70 lines
1.6 KiB
Go
package cli
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
"github.com/cosmos/cosmos-sdk/client/tx"
|
|
|
|
"github.com/onsonr/sonr/x/service/types"
|
|
)
|
|
|
|
// !NOTE: Must enable in module.go (disabled in favor of autocli.go)
|
|
|
|
// NewTxCmd returns a root CLI command handler for certain modules
|
|
// transaction commands.
|
|
func NewTxCmd() *cobra.Command {
|
|
txCmd := &cobra.Command{
|
|
Use: types.ModuleName,
|
|
Short: types.ModuleName + " subcommands.",
|
|
DisableFlagParsing: true,
|
|
SuggestionsMinimumDistance: 2,
|
|
RunE: client.ValidateCmd,
|
|
}
|
|
|
|
txCmd.AddCommand(
|
|
MsgUpdateParams(),
|
|
)
|
|
return txCmd
|
|
}
|
|
|
|
// Returns a CLI command handler for registering a
|
|
// contract for the module.
|
|
func MsgUpdateParams() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "update-params [some-value]",
|
|
Short: "Update the params (must be submitted from the authority)",
|
|
Args: cobra.ExactArgs(1),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
cliCtx, err := client.GetClientTxContext(cmd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
senderAddress := cliCtx.GetFromAddress()
|
|
|
|
// someValue, err := strconv.ParseBool(args[0])
|
|
// if err != nil {
|
|
// return err
|
|
// }
|
|
//
|
|
msg := &types.MsgUpdateParams{
|
|
Authority: senderAddress.String(),
|
|
Params: types.Params{
|
|
// SomeValue: someValue,
|
|
},
|
|
}
|
|
|
|
if err := msg.Validate(); err != nil {
|
|
return err
|
|
}
|
|
|
|
return tx.GenerateOrBroadcastTxCLI(cliCtx, cmd.Flags(), msg)
|
|
},
|
|
}
|
|
|
|
flags.AddTxFlagsToCmd(cmd)
|
|
return cmd
|
|
}
|