Help us shape the future of Go! Take the 2026 Go Developer Survey

transactions

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:              "transactions",
	Short:            "Utilities to send transactions",
	TraverseChildren: true,
}
View Source
var GetCommand = &command.Command{
	Cmd: &cobra.Command{
		Use:     "get <tx_id>",
		Aliases: []string{"status"},
		Short:   "Get the transaction by ID",
		Args:    cobra.ExactArgs(1),
	},
	Flags: &getFlags,
	Run: func(
		cmd *cobra.Command,
		args []string,
		globalFlags command.GlobalFlags,
		services *services.Services,
	) (command.Result, error) {
		if cmd.CalledAs() == "status" {
			fmt.Println("⚠️  DEPRECATION WARNING: use \"flow transactions get\" instead")
		}

		tx, result, err := services.Transactions.GetStatus(
			args[0],
			getFlags.Sealed,
		)
		if err != nil {
			return nil, err
		}

		return &TransactionResult{
			result: result,
			tx:     tx,
			code:   getFlags.Code,
		}, nil
	},
}
View Source
var SendCommand = &command.Command{
	Cmd: &cobra.Command{
		Use:     "send <filename>",
		Short:   "Send a transaction",
		Args:    cobra.MaximumNArgs(1),
		Example: `flow transactions send tx.cdc --arg String:"Hello world"`,
	},
	Flags: &sendFlags,
	Run: func(
		cmd *cobra.Command,
		args []string,
		globalFlags command.GlobalFlags,
		services *services.Services,
	) (command.Result, error) {
		if sendFlags.Results {
			fmt.Println("⚠️  DEPRECATION WARNING: all transactions will provide results")
		}

		if sendFlags.Args != "" {
			fmt.Println("⚠️  DEPRECATION WARNING: use arg flag in Type:Value format or arg-json for JSON format")

			if len(sendFlags.Arg) == 0 && sendFlags.ArgsJSON == "" {
				sendFlags.ArgsJSON = sendFlags.Args
			}
		}

		filename := ""
		if len(args) == 1 {
			filename = args[0]
		} else if sendFlags.Code != "" {
			fmt.Println("⚠️  DEPRECATION WARNING: use filename as a command argument <filename>")
			filename = sendFlags.Code
		} else {
			return nil, fmt.Errorf("provide a valide filename command argument")
		}

		tx, result, err := services.Transactions.Send(
			filename,
			sendFlags.Signer,
			sendFlags.Arg,
			sendFlags.ArgsJSON,
		)
		if err != nil {
			return nil, err
		}

		return &TransactionResult{
			result: result,
			tx:     tx,
		}, nil
	},
}

Functions

This section is empty.

Types

type TransactionResult

type TransactionResult struct {
	// contains filtered or unexported fields
}

TransactionResult represent result from all account commands

func (*TransactionResult) JSON

func (r *TransactionResult) JSON() interface{}

JSON convert result to JSON

func (*TransactionResult) Oneliner

func (r *TransactionResult) Oneliner() string

Oneliner show result as one liner grep friendly

func (*TransactionResult) String

func (r *TransactionResult) String() string

String convert result to string

Jump to

Keyboard shortcuts

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