emulator

package
v0.33.2 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package emulator provides helpful wrappers around flow-cli packages and types, providing a high-level interface for common flow development tasks such as running an emulator with non-default configuration settings, creating accounts, deploying contracts, replacing import statements in cadence files, and sending transactions and script executions to the emulator.

Index

Constants

This section is empty.

Variables

View Source
var OptsDefault = Opts{
	Name:                `default`,
	NetName:             `emulator`,
	ConfigPaths:         []string{`flow.json`},
	LogLevel:            logrus.InfoLevel,
	LogLevelClient:      output.InfoLog,
	StorageLimitEnabled: true,
	ClientOnly:          false,
	RESTPort:            38555,
	AdminPort:           38556,
}

Functions

func GetProjectAccount

func GetProjectAccount(proj *flowkit.State, name string) (*flowkit.Account, error)

func NewServer added in v0.1.2

func NewServer(cfg *Config) *server.EmulatorServer

func NewServerWithOpts added in v0.1.2

func NewServerWithOpts(opts *Opts) (*server.EmulatorServer, error)

func ServerConf

func ServerConf(cfg *Config) *server.Config

Types

type Account added in v0.1.2

type Account struct {
	Name    string
	Key     crypto.PrivateKey
	Account *flow.Account
}

type Client added in v0.1.2

type Client struct {
	Net      *config.Network
	Gateway  *gateway.GrpcGateway
	Services *services.Services
	Logger   output.Logger
	Config   *Config
	Flow     *flowClient.Client
}

func NewClient added in v0.1.2

func NewClient(cfg *Config) (*Client, error)

func (*Client) AccountCfg added in v0.1.6

func (client *Client) AccountCfg(name string) (*flowkit.Account, error)

func (*Client) CreateAccount added in v0.1.2

func (client *Client) CreateAccount(name string) (*Account, error)

func (*Client) CreateAccounts added in v0.1.6

func (client *Client) CreateAccounts(names ...string) (map[string]*Account, error)

func (*Client) DeployProject added in v0.1.6

func (client *Client) DeployProject(update bool) ([]*contracts.Contract, error)

func (*Client) EventsWatch added in v0.1.7

func (client *Client) EventsWatch(ctx context.Context, req EventsWatchReq) <-chan []TxResult

func (*Client) FetchEvents added in v0.1.7

func (client *Client) FetchEvents(ctx context.Context, req flowClient.EventRangeQuery) ([]TxResult, error)

func (*Client) GetAccount added in v0.1.7

func (client *Client) GetAccount(name string) (*Account, error)

func (*Client) ResolveCode added in v0.1.2

func (client *Client) ResolveCode(code string, codepath string) ([]byte, error)

func (*Client) ResolveImports added in v0.1.2

func (client *Client) ResolveImports(code []byte, codepath string) ([]byte, error)

func (*Client) ScriptExec added in v0.1.2

func (client *Client) ScriptExec(req ScriptExecReq) (cadence.Value, error)

func (*Client) TxBuild added in v0.1.2

func (client *Client) TxBuild(req TxBuildReq) (*flowkit.Transaction, error)

func (*Client) TxSend added in v0.1.2

func (client *Client) TxSend(req TxSendReq) (*flow.Transaction, *flow.TransactionResult, error)

func (*Client) TxSetCode added in v0.1.6

func (client *Client) TxSetCode(req TxSetCodeReq, tx *flowkit.Transaction) error

func (*Client) TxSign added in v0.1.6

func (client *Client) TxSign(tx *flowkit.Transaction, req TxSignReq) error

type Config added in v0.1.2

type Config struct {
	Opts           *Opts
	Proj           *flowkit.State
	Emulator       *config.Emulator
	ServiceAccount *flowkit.Account
	PrivateKey     crypto.PrivateKey
	SigAlgo        crypto.SignatureAlgorithm
	HashAlgo       crypto.HashAlgorithm
}

func LoadConfig added in v0.1.2

func LoadConfig(opts *Opts) (*Config, error)

type Emu

type Emu struct {
	Config *Config
	Server *server.EmulatorServer
	Client *Client
}

func NewEmu

func NewEmu(opts *Opts) (*Emu, error)

type EventsFetchReq added in v0.1.7

type EventsFetchReq struct {
	Type        string
	StartHeight uint64
	EndHeight   uint64
}

type EventsWatchReq added in v0.1.7

type EventsWatchReq struct {
	Type        string
	StartHeight uint64
}

type Opts added in v0.1.2

type Opts struct {
	Name                string
	NetName             string
	ConfigPaths         []string
	LogLevel            logrus.Level
	LogLevelClient      int
	StorageLimitEnabled bool
	ClientOnly          bool
	RESTPort            int
	AdminPort           int
}

type ScriptExecReq added in v0.1.1

type ScriptExecReq struct {
	Code     string
	Codepath string
	Args     []string
	ArgsJSON string
}

type TxBuildReq added in v0.1.6

type TxBuildReq struct {
	Account  string // Config account name, overridden by Payer, Proposer, and Authorizers
	GasLimit uint64
	Payer    string // Config account name, overrides Account
	Proposer string // Config account name, overrides Account

}

type TxResult added in v0.1.7

type TxResult struct {
	BlockID flow.Identifier
	Height  uint64
	TxID    flow.Identifier
	Events  []flow.Event
	Err     error
}

type TxSendReq

type TxSendReq struct {
	Account     string // Config account name, overridden by Payer, Proposer, and Authorizers
	GasLimit    uint64
	Code        string
	Codepath    string
	Args        []string
	ArgsJSON    string
	Payer       string   // Config account name, overrides Account
	Proposer    string   // Config account name, overrides Account
	Authorizers []string // Config account names, overrides Account
	Signer      string   // Config account name, overrides Account
}

type TxSetCodeReq added in v0.1.6

type TxSetCodeReq struct {
	Code     string
	Codepath string
	Args     []string
	ArgsJSON string
}

type TxSignReq added in v0.33.1

type TxSignReq struct {
	Account     string   // Config account name, overridden by Payer, Proposer, and Authorizers
	Authorizers []string // Config account names, overrides Account
	Signer      string   // Config account name, overrides Account
}

Jump to

Keyboard shortcuts

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