* Use service Msgs in CLI tx commands * Update comment * Gracefully support amino signing * CLI to use svc msg * Fix lint * Use fq method name in events * Update tests * Fix quering events * Add docs * Fix test build * Fix events * Fix search for events * Handle old andd new event quering * Use merge events * Better encCfg * Add page in search * Fix tests * Update test and comments * Update x/auth/legacy/legacytx/stdsign.go Co-authored-by: atheeshp <59333759+atheeshp@users.noreply.github.com> * Fix conflict for weighted vote * Make CopyTx actually run * Fix CopyTx * Fix test * Add changelog entry * Remove useless code * Add msgs tests * Remove testing proto Msg via CLI * Fix lint * Fix test * Implement GetSignBytes on ServiceMsg * Fix %T Co-authored-by: atheeshp <59333759+atheeshp@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
89 lines
2.5 KiB
Go
89 lines
2.5 KiB
Go
package cli
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
"github.com/cosmos/cosmos-sdk/client/tx"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/cosmos/cosmos-sdk/types/msgservice"
|
|
"github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
|
|
)
|
|
|
|
// Transaction command flags
|
|
const (
|
|
FlagDelayed = "delayed"
|
|
)
|
|
|
|
// GetTxCmd returns vesting module's transaction commands.
|
|
func GetTxCmd() *cobra.Command {
|
|
txCmd := &cobra.Command{
|
|
Use: types.ModuleName,
|
|
Short: "Vesting transaction subcommands",
|
|
DisableFlagParsing: true,
|
|
SuggestionsMinimumDistance: 2,
|
|
RunE: client.ValidateCmd,
|
|
}
|
|
|
|
txCmd.AddCommand(
|
|
NewMsgCreateVestingAccountCmd(),
|
|
)
|
|
|
|
return txCmd
|
|
}
|
|
|
|
// NewMsgCreateVestingAccountCmd returns a CLI command handler for creating a
|
|
// MsgCreateVestingAccount transaction.
|
|
func NewMsgCreateVestingAccountCmd() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "create-vesting-account [to_address] [amount] [end_time]",
|
|
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 accouts created will have their start time
|
|
set by the committed block's time. The end_time must be provided as a UNIX epoch
|
|
timestamp.`,
|
|
Args: cobra.ExactArgs(3),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
clientCtx, err := client.GetClientTxContext(cmd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
toAddr, err := sdk.AccAddressFromBech32(args[0])
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
amount, err := sdk.ParseCoinsNormalized(args[1])
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
endTime, err := strconv.ParseInt(args[2], 10, 64)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
delayed, _ := cmd.Flags().GetBool(FlagDelayed)
|
|
|
|
msg := types.NewMsgCreateVestingAccount(clientCtx.GetFromAddress(), toAddr, amount, endTime, delayed)
|
|
svcMsgClientConn := &msgservice.ServiceMsgClientConn{}
|
|
msgClient := types.NewMsgClient(svcMsgClientConn)
|
|
_, err = msgClient.CreateVestingAccount(cmd.Context(), msg)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), svcMsgClientConn.GetMsgs()...)
|
|
},
|
|
}
|
|
|
|
cmd.Flags().Bool(FlagDelayed, false, "Create a delayed vesting account if true")
|
|
flags.AddTxFlagsToCmd(cmd)
|
|
|
|
return cmd
|
|
}
|