-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathtx.go
53 lines (45 loc) · 1.38 KB
/
tx.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package cli
import (
"github.com/line/lbm-sdk/v2/client"
"github.com/line/lbm-sdk/v2/client/flags"
"github.com/line/lbm-sdk/v2/client/tx"
"github.com/line/lbm-sdk/v2/x/auth/types"
"github.com/spf13/cobra"
)
// NewTxCmd returns a root CLI command handler for all x/auth transaction commands.
func NewTxCmd() *cobra.Command {
txCmd := &cobra.Command{
Use: types.ModuleName,
Short: "Auth transaction subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
txCmd.AddCommand(NewEmptyTxCmd())
return txCmd
}
// NewEmptyTxCmd returns a CLI command handler for creating a MsgEmpty transaction.
func NewEmptyTxCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "empty [from_key_or_address]",
Short: `Empty doesn't do anything. Used to measure performance.`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
err := cmd.Flags().Set(flags.FlagFrom, args[0])
if err != nil {
return err
}
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
msg := types.NewServiceMsgEmpty(clientCtx.GetFromAddress())
if err := msg.ValidateBasic(); err != nil {
return err
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}
flags.AddTxFlagsToCmd(cmd)
return cmd
}