gpu-compute-chain/x/cosmostest/client/cli/tx_new_auction.go

58 lines
1.1 KiB
Go
Raw Normal View History

2022-08-27 14:19:03 -07:00
package cli
import (
"strconv"
"cosmos-test/x/cosmostest/types"
2022-08-27 14:19:03 -07:00
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/spf13/cobra"
)
var _ = strconv.Itoa(0)
func CmdNewAuction() *cobra.Command {
cmd := &cobra.Command{
2022-09-02 14:58:22 -07:00
Use: "new-auction [name] [description] [ceiling] [denom] [end date]",
2022-08-27 14:19:03 -07:00
Short: "Broadcast message newAuction",
2022-09-02 14:58:22 -07:00
Args: cobra.ExactArgs(5),
2022-08-27 14:19:03 -07:00
RunE: func(cmd *cobra.Command, args []string) (err error) {
argName := args[0]
argDescription := args[1]
2022-09-02 14:58:22 -07:00
argCeiling := args[2]
argDenom := args[3]
argLeaseEnd := args[4]
2022-08-27 14:19:03 -07:00
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
2022-09-02 14:58:22 -07:00
var le int
le, err = strconv.Atoi(argLeaseEnd)
if err != nil {
return err
}
2022-08-27 14:19:03 -07:00
msg := types.NewMsgNewAuction(
clientCtx.GetFromAddress().String(),
argName,
argDescription,
2022-09-02 14:58:22 -07:00
argCeiling,
argDenom,
2022-09-02 14:58:22 -07:00
uint64(le),
2022-08-27 14:19:03 -07:00
)
if err := msg.ValidateBasic(); err != nil {
return err
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}
flags.AddTxFlagsToCmd(cmd)
return cmd
}