cliutil

package
v0.0.0-...-9d0abdd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 9, 2020 License: BSD-2-Clause Imports: 12 Imported by: 18

Documentation

Index

Constants

View Source
const FlagGenerateUnsignedTx = "generate-unsigned-tx"

Variables

View Source
var CliQuery = func(cdc *codec.Codec, path string, param interface{}) error {
	var bz []byte
	var err error
	bz = nil
	if param != nil {
		bz, err = cdc.MarshalJSON(param)
		if err != nil {
			return err
		}
	}

	cliCtx := context.NewCLIContext().WithCodec(cdc)
	res, _, err := cliCtx.QueryWithData(path, bz)
	if err != nil {
		return err
	}
	fmt.Println(string(res))
	return nil
}
View Source
var CliRunCommand = func(cdc *codec.Codec, msg MsgWithAccAddress) error {
	cliCtx := context.NewCLIContext().WithCodec(cdc)
	senderAddr := cliCtx.GetFromAddress()
	msg.SetAccAddress(senderAddr)
	if err := msg.ValidateBasic(); err != nil {
		return err
	}
	txBldr := auth.NewTxBuilderFromCLI().WithTxEncoder(utils.GetTxEncoder(cdc))
	generateUnsignedTx := viper.GetBool(FlagGenerateUnsignedTx)
	if generateUnsignedTx {
		return PrintUnsignedTx(cliCtx, txBldr, []sdk.Msg{msg}, senderAddr)
	}
	return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
}

Functions

func PrintUnsignedTx

func PrintUnsignedTx(cliCtx context.CLIContext, txBldr authtypes.TxBuilder, msgs []sdk.Msg, from sdk.AccAddress) error

func SetViperWithArgs

func SetViperWithArgs(args []string)

func TestQueryCmd

func TestQueryCmd(t *testing.T, cmdFactory func() *cobra.Command,
	args string, expectedPath string, expectedParam interface{})

func TestTxCmd

func TestTxCmd(t *testing.T, cmdFactory func() *cobra.Command,
	args string, expectedMsg interface{})

Types

type MsgWithAccAddress

type MsgWithAccAddress interface {
	sdk.Msg
	SetAccAddress(address sdk.AccAddress)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL