/
cli_tx.go
52 lines (43 loc) · 1.48 KB
/
cli_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
package types
import (
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils"
)
// GetTxCmd generates the entrypoint for the strongforce module
func GetTxCmd(cdc *codec.Codec) *cobra.Command {
strongforceTxCmd := &cobra.Command{
Use: ModuleName,
Short: "Strongforce transaction subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
strongforceTxCmd.AddCommand(client.PostCommands(
GetCmdExecuteAction(cdc),
)...)
return strongforceTxCmd
}
// GetCmdExecuteAction is the CLI command for sending a ExecuteAction transaction
func GetCmdExecuteAction(cdc *codec.Codec) *cobra.Command {
return &cobra.Command{
Use: "execute-action [name] [value]",
Short: "execute an action",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
cliCtx := context.NewCLIContext().WithCodec(cdc)
//.WithAccountDecoder(cdc)
txBldr := auth.NewTxBuilderFromCLI().WithTxEncoder(utils.GetTxEncoder(cdc))
msg := NewMsgExecuteAction(cliCtx.GetFromAddress(), []byte(args[0]))
err := msg.ValidateBasic()
if err != nil {
return err
}
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []types.Msg{msg})
},
}
}