chaincmdrunner

package
v28.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package chaincmdrunner provides 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 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 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, options ...chaincmd.BankSendOption) (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) ListAccounts

func (r Runner) ListAccounts(ctx context.Context) ([]Account, error)

ListAccounts returns the list of accounts in the keyring.

func (Runner) QueryTx

func (r Runner) QueryTx(
	ctx context.Context,
	option ...step.Option,
) ([]Event, error)

QueryTx queries tx events/query selectors.

func (Runner) QueryTxByEvents

func (r Runner) QueryTxByEvents(
	ctx context.Context,
	selectors ...EventSelector,
) ([]Event, error)

QueryTxByEvents queries tx events by event selectors.

func (Runner) QueryTxByQuery

func (r Runner) QueryTxByQuery(
	ctx context.Context,
	selectors ...EventSelector,
) ([]Event, error)

QueryTxByQuery 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