chaincmdrunner

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Overview

Package chaincmdrunner provides a high level access to a blockchain's commands.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAccountAlreadyExists returned when an already exists account attempted to be imported.
	ErrAccountAlreadyExists = errors.New("account already exists")

	// ErrAccountDoesNotExist returned when account does not exit.
	ErrAccountDoesNotExist = errors.New("account does not exit")
)

Functions

This section is empty.

Types

type Account

type Account struct {
	Name     string `json:"name"`
	Address  string `json:"address"`
	Mnemonic string `json:"mnemonic,omitempty"`
}

Account represents a user account.

type Event

type Event struct {
	Type       string
	Attributes []EventAttribute
	Time       time.Time
}

Event represents a TX event.

type EventAttribute

type EventAttribute struct {
	Key   string
	Value string
}

EventAttribute holds event's attributes.

type EventSelector

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

EventSelector is used to query events.

func NewEventSelector

func NewEventSelector(typ, addr, value string) EventSelector

NewEventSelector creates a new event selector.

type KV

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

KV holds a key, value pair.

func NewKV

func NewKV(key, value string) KV

NewKV returns a new key, value pair.

type NodeStatus

type NodeStatus struct {
	ChainID string
}

NodeStatus keeps info about node's status.

type Option

type Option func(r *Runner)

Option configures Runner.

func CLILogPrefix

func CLILogPrefix(prefix string) Option

CLILogPrefix is a prefix added to app's cli logs.

func DaemonLogPrefix

func DaemonLogPrefix(prefix string) Option

DaemonLogPrefix is a prefix added to app's daemon logs.

func Stderr

func Stderr(w io.Writer) Option

Stderr sets stderr for executed commands.

func Stdout

func Stdout(w io.Writer) Option

Stdout sets stdout for executed commands.

type Runner

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

Runner provides a high level access to a blockchain's commands.

func New

func New(ctx context.Context, chainCmd chaincmd.ChainCmd, options ...Option) (Runner, error)

New creates a new Runner with cc and options.

func (Runner) AddAccount

func (r Runner) AddAccount(ctx context.Context, name, mnemonic, coinType string) (Account, error)

AddAccount creates a new account or imports an account when mnemonic is provided. returns with an error if the operation went unsuccessful or an account with the provided name already exists.

func (Runner) AddGenesisAccount

func (r Runner) AddGenesisAccount(ctx context.Context, address, coins string) error

AddGenesisAccount adds account to genesis by its address.

func (Runner) AddVestingAccount

func (r Runner) AddVestingAccount(
	ctx context.Context,
	address,
	originalCoins,
	vestingCoins string,
	vestingEndTime int64,
) error

AddVestingAccount adds vesting account to genesis by its address.

func (Runner) BankSend

func (r Runner) BankSend(ctx context.Context, fromAccount, toAccount, amount string) (string, error)

BankSend sends amount from fromAccount to toAccount.

func (Runner) CheckAccountExist

func (r Runner) CheckAccountExist(ctx context.Context, name string) error

CheckAccountExist returns an error if the account already exists in the chain keyring

func (Runner) Cmd

func (r Runner) Cmd() chaincmd.ChainCmd

Cmd returns underlying chain cmd.

func (Runner) CollectGentxs

func (r Runner) CollectGentxs(ctx context.Context) error

CollectGentxs collects gentxs.

func (Runner) Copy

func (r Runner) Copy(options ...Option) Runner

Copy makes a copy of runner by overwriting its options with given options.

func (Runner) Export

func (r Runner) Export(ctx context.Context, exportedFile string) error

Export exports the state of the chain into the specified file

func (Runner) Gentx

func (r Runner) Gentx(
	ctx context.Context,
	validatorName,
	selfDelegation string,
	options ...chaincmd.GentxOption,
) (gentxPath string, err error)

Gentx generates a genesis tx carrying a self delegation.

func (Runner) ImportAccount

func (r Runner) ImportAccount(ctx context.Context, name, keyFile, passphrase string) (Account, error)

ImportAccount import an account from a key file

func (Runner) Init

func (r Runner) Init(ctx context.Context, moniker string) error

Init inits the blockchain.

func (Runner) LaunchpadSetConfigs

func (r Runner) LaunchpadSetConfigs(ctx context.Context, kvs ...KV) error

LaunchpadSetConfigs updates configurations for a launchpad app.

func (Runner) LaunchpadStartRestServer

func (r Runner) LaunchpadStartRestServer(ctx context.Context, apiAddress, rpcAddress string) error

LaunchpadStartRestServer start launchpad rest server.

func (Runner) QueryTxEvents

func (r Runner) QueryTxEvents(
	ctx context.Context,
	selector EventSelector,
	moreSelectors ...EventSelector,
) ([]Event, error)

QueryTxEvents queries tx events by event selectors.

func (Runner) ShowAccount

func (r Runner) ShowAccount(ctx context.Context, name string) (Account, error)

ShowAccount shows details of an account.

func (Runner) ShowNodeID

func (r Runner) ShowNodeID(ctx context.Context) (nodeID string, err error)

ShowNodeID shows node id.

func (Runner) Simulation

func (r Runner) Simulation(
	ctx context.Context,
	appPath string,
	enabled bool,
	verbose bool,
	config simulation.Config,
	period uint,
	genesisTime int64,
) error

Simulation run the chain simulation.

func (Runner) Start

func (r Runner) Start(ctx context.Context, args ...string) error

Start starts the blockchain.

func (Runner) Status

func (r Runner) Status(ctx context.Context) (NodeStatus, error)

Status returns the node's status.

func (Runner) UnsafeReset

func (r Runner) UnsafeReset(ctx context.Context) error

UnsafeReset resets the blockchain database.

func (Runner) ValidateGenesis

func (r Runner) ValidateGenesis(ctx context.Context) error

ValidateGenesis validates genesis.

func (Runner) WaitTx

func (r Runner) WaitTx(ctx context.Context, txHash string, retryDelay time.Duration, maxRetry int) error

WaitTx waits until a tx is successfully added to a block and can be queried

Jump to

Keyboard shortcuts

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