cli

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetQueryCmd

func GetQueryCmd() *cobra.Command

GetQueryCmd returns the parent command for all the module's CLI query commands.

func GetTxCmd

func GetTxCmd() *cobra.Command

GetTxCmd returns the transaction commands for the module.

func NewCreateWalletCmd

func NewCreateWalletCmd() *cobra.Command

func NewSignTransactionCmd

func NewSignTransactionCmd() *cobra.Command
func NewCreateTransactionCmd() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "create-transaction [wallet] [receiver] [coins]",
		Short: "Creates transaction for multisig wallet to send coins. Transaction sender must be in wallet owners",
		Long: fmt.Sprintf(`Creates new transaction to send coins from multisignature wallet to receiver.

Coins must be comma separated coins.

Example: $ %s tx %s create-transaction dx1..wallet dx1..receiver 1000del,200tony --from mykey`, config.AppBinName, types.ModuleName),

		Args: cobra.ExactArgs(3),
		RunE: func(cmd *cobra.Command, args []string) error {
			clientCtx, err := client.GetClientTxContext(cmd)
			if err != nil {
				return err
			}

			var (
				from        = clientCtx.GetFromAddress()
				wallet      = args[0]
				receiver    = args[1]
				coinsString = args[2]
			)

			if _, err := sdk.AccAddressFromBech32(wallet); err != nil {
				return fmt.Errorf("invalid wallet address %s: %s", wallet, err.Error())
			}

			if _, err := sdk.AccAddressFromBech32(receiver); err != nil {
				return fmt.Errorf("invalid receiver address %s: %s", receiver, err.Error())
			}

			coins, err := sdk.ParseCoinsNormalized(coinsString)
			if err != nil {
				return fmt.Errorf("error whil parse coins %s: %s", coinsString, err.Error())
			}

			msg := types.NewMsgCreateTransaction(from, wallet, receiver, coins)
			err = msg.ValidateBasic()
			if err != nil {
				return err
			}

			return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
		},
	}

	flags.AddTxFlagsToCmd(cmd)
	// workaround for cosmos
	cmd.Flags().String(flags.FlagChainID, "", "network chain id")

	_ = cmd.MarkFlagRequired(flags.FlagFrom) // nolint:errcheck

	return cmd
}

Types

This section is empty.

Jump to

Keyboard shortcuts

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