cmd

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: MIT Imports: 6 Imported by: 5 modules, 12 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cmd contains useful utilities for commands that interact with the Ethereum blockchain.

Index

Constants

View Source
const (

	// SubmitFlag allows for urfave/cli definition and lookup of a boolean
	// `--submit` command-line flag indicating that a given contract interaction
	// should be submitted as a paid, mutating interaction to the configured
	// Ethereum chain.
	SubmitFlag string = "submit"
)

Variables

View Source
var (
	// TransactionFlagValue allows for reading the transaction hash flag
	// included in ConstFlags, which represents a transaction hash from which to
	// retrieve an already-executed contract interaction. The value, if that
	// flag is passed on the command line, is stored in this variable.
	TransactionFlagValue *flag.TransactionHash = &flag.TransactionHash{}
	// BlockFlagValue allows for reading the block flag included in ConstFlags,
	// which represents the block at which to execute a contract interaction.
	// The value, if that flag is passed on the command line, is stored in this
	// variable.
	BlockFlagValue *flag.Uint256 = &flag.Uint256{}
	// ValueFlagValue allows for reading the value flag included in
	// PayableFlags, which represents an amount of ETH to send with a contract
	// interaction. The value, if that flag is passed on the command line, is
	// stored in this variable.
	ValueFlagValue *flag.Uint256 = &flag.Uint256{}

	// DefaultMiningCheckInterval is the default interval in which transaction
	// mining status is checked. If the transaction is not mined within this
	// time, the gas price is increased and transaction is resubmitted.
	// This value can be overwritten in the configuration file.
	DefaultMiningCheckInterval = 60 * time.Second

	// DefaultMaxGasPrice specifies the default maximum gas price the client is
	// willing to pay for the transaction to be mined. The offered transaction
	// gas price can not be higher than the max gas price value. If the maximum
	// allowed gas price is reached, no further resubmission attempts are
	// performed. This value can be overwritten in the configuration file.
	DefaultMaxGasPrice = big.NewInt(500000000000) // 500 Gwei
)
View Source
var (
	// ConstFlags provides a slice of flags useful for constant contract
	// interactions, meaning contract interactions that do not require
	// transaction submission and are used for inspecting chain state. These
	// flags include the --block flag to check an interaction's result value at
	// a specific block and the --transaction flag to check an interaction's
	// already-evaluated result value from a given transaction.
	ConstFlags = []cli.Flag{
		&cli.GenericFlag{
			Name:  blockFlag + ", " + blockShort,
			Usage: "Retrieve the result of calling this method on `BLOCK`.",
			Value: BlockFlagValue,
		},
		&cli.GenericFlag{
			Name:  transactionFlag + ", " + transactionShort,
			Usage: "Retrieve the already-evaluated result of this method in `TRANSACTION`.",
			Value: TransactionFlagValue,
		},
	}
	// NonConstFlags provides a slice of flags useful for non-constant contract
	// interactions, meaning contract interactions that can be submitted as
	// transactions and are used for modifying chain state. These flags include
	// the --submit flag to submit an interaction as a transaction, as well as
	// all flags in ConstFlags.
	NonConstFlags = append(
		[]cli.Flag{
			&cli.BoolFlag{
				Name:  SubmitFlag + ", " + submitShort,
				Usage: "Submit this call as a gas-spending network transaction.",
			},
		},
		ConstFlags...,
	)
	// PayableFlags provides a slice of flags useful for payable contract
	// interactions, meaning contract interactions that can be submitted as
	// transactions and are used for modifying chain state with a payload that
	// includes ETH. These flags include the --value flag to specify the ETH
	// amount to send with the interaction, as well as all flags in
	// NonConstFlags.
	PayableFlags = append(
		[]cli.Flag{
			&cli.GenericFlag{
				Name:  valueFlag + ", " + valueShort,
				Usage: "Send `VALUE` ether with this call.",
				Value: ValueFlagValue,
			},
		},
		NonConstFlags...,
	)
)
View Source
var (
	// NonConstArgsChecker runs any validation of parameters needed for a
	// command that will submit a mutating transaction to an Ethereum node. In
	// particular, it will disallow const arguments like --block and
	// --transaction if --submit is specified.
	NonConstArgsChecker = submittedArgChecker
	// PayableArgsChecker runs any validation of parameters needed for a
	// command that will submit a payable transaction to an Ethereum node. In
	// particular, it will disallow const arguments like --block and
	// --transaction if --submit is specified, and will also ensure that the
	// call includes specifies a --value.
	PayableArgsChecker = NonConstArgsChecker.AndThen(valueArgChecker)
)
View Source
var AvailableCommands []cli.Command

AvailableCommands is the exported list of generated commands that can be installed on a CLI app. Generated contract command files set up init functions that add the contract's command and subcommands to this global variable, and any top-level command that wishes to include these commands can reference this variable and expect it to contain all generated contract commands.

Functions

func ArgCountChecker

func ArgCountChecker(expectedArgCount int) func(*cli.Context) error

ArgCountChecker provides a consistent error in case the number of arguments passed on the command-line is incorrect.

func PrintOutput

func PrintOutput(output interface{})

PrintOutput provides for custom command-line-friendly ways of printing addresses (as hex) and transaction and related hashes (also as hex). It falls back on a standard Println for other types.

Types

type ComposableArgChecker

type ComposableArgChecker cli.BeforeFunc

ComposableArgChecker is a type that allows multiple urfave/cli BeforeFuncs to be chained. See AndThen for more.

func (ComposableArgChecker) AndThen

AndThen on a ComposableArgChecker allows composing a ComposableArgChecker with another one, such that this ComposableArgChecker runs and, if it succeeds, the nextChecker runs.

As an example, this allows for two BeforeFuncs to be composed as:

ComposableArgChecker(checkFlagAValue).AndThen(ComposableArgChecker(checkFlagBValue))

The resulting ComposableArgChecker will run checkFlagAValue and, if it passes, checkFlagBValue.

Directories

Path Synopsis
Package flag contains helpers for accepting Ethereum data types as command-line parameters, including transaction hashes as hex and uint256s in either hex or decimal form.
Package flag contains helpers for accepting Ethereum data types as command-line parameters, including transaction hashes as hex and uint256s in either hex or decimal form.

Jump to

Keyboard shortcuts

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