txs

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

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

Go to latest
Published: Jul 2, 2019 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagName      = "name"
	FlagNoSign    = "no-sign"
	FlagIn        = "in"
	FlagPrepare   = "prepare"
	FlagAddress   = "address"
	FlagType      = "type"
	FlagNonce     = "nonce"
	FlagVMChainId = "vm-chain-id"
)

nolint

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "tx",
	Short: "Post tx from json input",
	RunE:  doRawTx,
}

RootCmd represents the base command when called without any subcommands

Functions

func DoTx

func DoTx(tx sdk.Tx) (err error)

DoTx is a helper function for the lazy :)

It uses only public functions and goes through the standard sequence of wrapping the tx with middleware layers, signing it, either preparing it, or posting it and displaying the result.

If you want a non-standard flow, just call the various functions directly. eg. if you already set the middleware layers in your code, or want to output in another format.

func GetSigner

func GetSigner() common.Address

func OutputTx

func OutputTx(res *ctypes.ResultBroadcastTxCommit) error

OutputTx validates if success and prints the tx result to stdout

func OutputTxSync

func OutputTxSync(res *ctypes.ResultBroadcastTx) error

func PostTx

func PostTx(tx sdk.Tx) (*ctypes.ResultBroadcastTxCommit, error)

PostTx does all work once we construct a proper struct it validates the data, signs if needed, transforms to bytes, and posts to the node.

func PostTxSync

func PostTxSync(tx sdk.Tx) (*ctypes.ResultBroadcastTx, error)

PostTx does all work once we construct a proper struct it validates the data, signs if needed, transforms to bytes, and posts to the node.

func PrepareOrPostTx

func PrepareOrPostTx(tx sdk.Tx) (*ctypes.ResultBroadcastTxCommit, error)

PrepareOrPostTx checks the flags to decide to prepare the tx for future multisig, or to post it to the node. Returns error on any failure. If no error and the result is nil, it means it already wrote to file, no post, no need to do more.

func PrepareOrPostTxSync

func PrepareOrPostTxSync(tx sdk.Tx) (*ctypes.ResultBroadcastTx, error)

func PrepareTx

func PrepareTx(tx sdk.Tx) (bool, error)

PrepareTx checks for FlagPrepare and if set, write the tx as json to the specified location for later multi-sig. Returns true if it handled the tx (no futher work required), false if it did nothing (and we should post the tx)

Types

type Validatable

type Validatable interface {
	ValidateBasic() error
}

Validatable represents anything that can be Validated

type Wrapper

type Wrapper interface {
	Wrap(sdk.Tx) (sdk.Tx, error)
	Register(*pflag.FlagSet)
}

Wrapper defines the information needed for each middleware package that wraps the data. They should read all configuration out of bounds via viper.

var (
	// Middleware must be set in main.go to defined the wrappers we should apply
	Middleware Wrapper
)

type Wrappers

type Wrappers []Wrapper

Wrappers combines a list of wrapper middlewares. The first one is the inner-most layer, eg. Fee, Nonce, Chain, Auth

func (Wrappers) Register

func (ws Wrappers) Register(fs *pflag.FlagSet)

Register adds any needed flags to the command

func (Wrappers) Wrap

func (ws Wrappers) Wrap(tx sdk.Tx) (sdk.Tx, error)

Wrap applies the wrappers to the passed in tx in order, aborting on the first error

Jump to

Keyboard shortcuts

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