console

package
v0.0.0-...-c626c17 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2019 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPrompt = "eosgo > "

DefaultPrompt is the default prompt line prefix to use for user input querying.

View Source
const HistoryFile = "history"

HistoryFile is the file within the data directory to store input scrollback.

Variables

View Source
var BaseUrl string
View Source
var Stdin = newTerminalPrompter()

Stdin holds the stdin line reader (also using stdout for printing prompts). Only this reader may be used for input because it keeps an js buffer.

Functions

func DoHttpCall

func DoHttpCall(result interface{}, path string, body interface{}) error

func NewClient

func NewClient(baseURL string) *client

func PrintAccountResult

func PrintAccountResult(res *chain_plugin.GetAccountResult)

Types

type Approve

type Approve struct {
	Voter        common.Name `json:"voter"`
	ProducerName common.Name `json:"producer_name"`
	StandardTransactionOptions
}

type ApproveAndUnapproveParams

type ApproveAndUnapproveParams struct {
	Proposer     string `json:"proposer"`
	ProposalName string `json:"proposal_name"`
	Perm         string `json:"permissions"`
	StandardTransactionOptions
}

type AssetPair

type AssetPair struct {
	Name       common.AccountName
	SymbolCode common.SymbolCode
}

type BidNameinfoParams

type BidNameinfoParams struct {
	PrintJson bool   `json:"print_json"`
	Newname   string `json:"newname"`
}

type BidnameParams

type BidnameParams struct {
	Bidder    string `json:"bidder"`
	NewName   string `json:"newname"`
	BidAmount string `json:"bid_amount"`
	StandardTransactionOptions
}

type BuyramParams

type BuyramParams struct {
	Payer     string `json:"payer"`
	Receiver  string `json:"receiver"`
	Amount    string `json:"amount"`
	Kbytes    bool   `json:"kbytes"`
	BytesFlag bool   `json:"bytes"`
	StandardTransactionOptions
}

type CancelParams

type CancelParams struct {
	Proposer     string `json:"proposer"`
	ProposalName string `json:"proposal_name"`
	Canceler     string `json:"canceler"`
	StandardTransactionOptions
}

type CanceldelayParams

type CanceldelayParams struct {
	CancelingAccount   string `json:"canceling_account"`
	CanclingPermission string `json:"canceling_permission"`
	TrxID              string `json:"trx_id"`
	StandardTransactionOptions
}

type ClaimrewardsParams

type ClaimrewardsParams struct {
	Owner string `json:"owner"`
	StandardTransactionOptions
}

type Config

type Config struct {
	DataDir  string       // Data directory to store the console history at
	DocRoot  string       // Filesystem path from where to load JavaScript files from
	Client   *client      // RPC client to execute EOSGO requests through
	Prompt   string       // Input prompt prefix string (defaults to DefaultPrompt)
	Prompter UserPrompter // Input prompter to allow interactive user feedback (defaults to TerminalPrompter)
	Printer  io.Writer    // Output writer to serialize any display strings to (defaults to os.Stdout)
	Preload  []string     // Absolute paths to JavaScript files to preload
}

Config is the collection of configurations to fine tune the behavior of the JavaScript console.

type Console

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

Console is a JavaScript interpreted runtime environment. It is a fully fledged JavaScript console attached to a running node via an external or in-process RPC client.

func New

func New(config Config) (*Console, error)

New initializes a JavaScript interpreted runtime environment and sets defaults with the config struct.

func (*Console) AutoCompleteInput

func (c *Console) AutoCompleteInput(line string, pos int) (string, []string, string)

AutoCompleteInput is a pre-assembled word completer to be used by the user input prompter to provide hints to the user about the methods available.

func (*Console) Evaluate

func (c *Console) Evaluate(statement string) error

Evaluate executes code and pretty prints the result to the specified output stream.

func (*Console) Execute

func (c *Console) Execute(path string) error

Execute runs the JavaScript file specified as the argument.

func (*Console) Interactive

func (c *Console) Interactive()

Interactive starts an interactive user session, where input is propted from the configured user prompter.

func (*Console) Stop

func (c *Console) Stop(graceful bool) error

Stop cleans up the console and terminates the runtime environment.

func (*Console) Welcome

func (c *Console) Welcome()

Welcome show summary of current eosgo instance and some metadata about the console's available modules.

type ConsoleInterface

type ConsoleInterface interface {
	// contains filtered or unexported methods
}

type CreateAccountParams

type CreateAccountParams struct {
	Creator   common.Name `json:"creator"`
	Name      common.Name `json:"name"`
	OwnerKey  string      `json:"owner"`
	ActiveKey string      `json:"active"`
	StandardTransactionOptions
}

type DelegatebwParams

type DelegatebwParams struct {
	From               string `json:"from"`
	Receiver           string `json:"receiver"`
	StakeNetAmount     string `json:"stake_net_amount"`
	StakeCpuAmount     string `json:"stake_cpu_amount"`
	StakeStorageAmount string `json:"stake_storage_amount"`
	BuyRamAmount       string `json:"buy_ram_amount"`
	BuyRamBytes        uint32 `json:"buy_ram_bytes"`
	Transfer           bool   `json:"transfer"`
	StandardTransactionOptions
}

type ExecuteParams

type ExecuteParams struct {
	Proposer     string `json:"proposer"`
	ProposalName string `json:"proposal_name"`
	Executer     string `json:"executer"`
	StandardTransactionOptions
}

type GetCodeParams

type GetCodeParams struct {
	AccountName  string `json:"name"`
	CodeFileName string `json:"code"`
	AbiFileName  string `json:"abi"`
	CodeAsWasm   bool   `json:"wasm"`
}

chain

type GetScopeParams

type GetScopeParams struct {
	Code  string `json:"code"`
	Table string `json:"table"`
	Limit uint32 `json:"limit"` //default =10
	Lower string `json:"lower"`
	Upper string `json:"upper"`
}

type GetTableParams

type GetTableParams struct {
	Code          string `json:"code"`
	Scope         string `json:"scope"`
	Table         string `json:"table"`
	Binary        bool   `json:"binary"`
	Limit         uint32 `json:"limit"` //default =10
	TableKey      string `json:"key"`
	Lower         string `json:"lower"`
	Upper         string `json:"upper"`
	IndexPosition string `json:"index"`
	KeyType       string `json:"key_type"`
	EncodeType    string `json:"encode_type"` //default ='dec'
}

type ListbwParams

type ListbwParams struct {
	Account   common.Name `json:"name"`
	PrintJson bool        `json:"print_json"`
}

type ListproducersParams

type ListproducersParams struct {
	PrintJson bool   `json:"print_json"`
	Limit     uint32 `json:"limit"`
	Lower     string `json:"lower"`
}

type Names

type Names []common.Name

func (Names) Len

func (n Names) Len() int

func (Names) Less

func (n Names) Less(i, j int) bool

func (Names) Swap

func (n Names) Swap(i, j int)

type NetAPI

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

NetAPI interacts with local p2p network connections

func (*NetAPI) Connect

func (n *NetAPI) Connect(call otto.FunctionCall) (response otto.Value)

Connect starts a new connection to a peer

func (*NetAPI) Disconnect

func (n *NetAPI) Disconnect(call otto.FunctionCall) (response otto.Value)

Disconnect closes an existing connection

func (*NetAPI) Peers

func (n *NetAPI) Peers(call otto.FunctionCall) (response otto.Value)

Peers status of exiting connection

func (*NetAPI) Status

func (n *NetAPI) Status(call otto.FunctionCall) (response otto.Value)

Status status of existing connection

type NewAccountParams

type NewAccountParams struct {
	Creator             common.Name `json:"creator"`
	Name                common.Name `json:"name"`
	OwnerKey            string      `json:"owner"`
	ActiveKey           string      `json:"active"`
	StakeNet            string      `json:"stake_net"`
	StakeCpu            string      `json:"stake_cpu"`
	BuyRamBytesInKbytes uint32      `json:"buy_ram_kbytes"`
	BuyRamBytes         uint32      `json:"buy_ram_bytes"`
	BuyRamEos           string      `json:"buy_ram"`
	Transfer            bool        `json:"transfer"`
	StandardTransactionOptions
}

system

type Prods

type Prods struct {
	Voter         string `json:"voter"`
	ProducerNames Names  `json:"producer_names"`
	StandardTransactionOptions
}

type ProduceAPI

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

func (*ProduceAPI) GetWhitelistBlacklist

func (p *ProduceAPI) GetWhitelistBlacklist(call otto.FunctionCall) (response otto.Value)

func (*ProduceAPI) Pause

func (p *ProduceAPI) Pause(call otto.FunctionCall) (response otto.Value)

func (*ProduceAPI) Paused

func (p *ProduceAPI) Paused(call otto.FunctionCall) (response otto.Value)

func (*ProduceAPI) Resume

func (p *ProduceAPI) Resume(call otto.FunctionCall) (response otto.Value)

func (*ProduceAPI) SetWhitelistBlacklist

func (p *ProduceAPI) SetWhitelistBlacklist(call otto.FunctionCall) (response otto.Value)

type ProposeParams

type ProposeParams struct {
	ProposalName            string `json:"proposal_name"`
	RequestedPerm           string `json:"requested_permissions"`
	TransactionPerm         string `json:"trx_permissions"`
	ProposedContract        string `json:"contract"`
	ProposedAction          string `json:"action"`
	ProposedTransaction     string `json:"data"`
	Proposer                string `json:"proposer"`
	ProposalExpirationHours int    `json:"proposal_expiration"` //TODO default 24
	StandardTransactionOptions
}

type ProposeTrxParams

type ProposeTrxParams struct {
	ProposalName  string `json:"proposal_name"`
	RequestedPerm string `json:"requested_permissions"`
	Proposer      string `json:"proposer"`
	TrxToPush     string `json:"transaction"`
	StandardTransactionOptions
}

type Proxy

type Proxy struct {
	Voter string `json:"voter"`
	Proxy string `json:"proxy"`
	StandardTransactionOptions
}

type PushAction

type PushAction struct {
	ContractAccount string `json:"account"`
	Action          string `json:"action"`
	Data            string `json:"data"`
	StandardTransactionOptions
}

type RegisterProducer

type RegisterProducer struct {
	Producer string `json:"producer"`
	Key      string `json:"key"`
	Url      string `json:"url"`
	Loc      uint16 `json:"loc"`
	StandardTransactionOptions
}

type RegproxyParams

type RegproxyParams struct {
	Proxy string `json:"proxy"`
	StandardTransactionOptions
}

type ReviewParams

type ReviewParams struct {
	ProposalName string `json:"proposal_name"`
	Proposer     string `json:"proposer"`
}

type SellRamParams

type SellRamParams struct {
	From     string `json:"from"`
	Receiver string `json:"receiver"`
	Amount   uint64 `json:"amount"`
	StandardTransactionOptions
}

type SetAccountPermissionParams

type SetAccountPermissionParams struct {
	Account             string `json:"account"`
	Permission          string `json:"permission"`
	AuthorityJsonOrFile string `json:"authority"`
	Parent              string `json:"parent"`
	StandardTransactionOptions
}

type SetActionPermissionParams

type SetActionPermissionParams struct {
	Account     string `json:"account"`
	Code        string `json:"code"`
	TypeStr     string `json:"type"`
	Requirement string `json:"requirement"`
	StandardTransactionOptions
}

type SetContractParams

type SetContractParams struct {
	Account                string `json:"account"`
	ContractPath           string `json:"code_file"`
	AbiPath                string `json:"abi_file"`
	ContractClear          bool   `json:"clear"`
	SuppressDuplicateCheck bool   `json:"suppress_duplicate_check"`
	StandardTransactionOptions
}

type SetWhitelistBlacklistParams

type SetWhitelistBlacklistParams struct {
	ActorWhitelist    []common.AccountName `json:"actorWhitelist"`
	ActorBlacklist    []common.AccountName `json:"actorBlacklist"`
	ContractWhitelist []common.AccountName `json:"contractWhitelist"`
	ContractBlacklist []common.AccountName `json:"contractBlacklist"`
	ActionBlacklist   []common.NamePair    `json:"actionBlacklist"`
	KeyBlacklist      []string             `json:"keyBlacklist"`
}

type StandardTransactionOptions

type StandardTransactionOptions struct {
	Expiration        uint64   `json:"expiration"`
	TxForceUnique     bool     `json:"force_unique"`
	TxSkipSign        bool     `json:"skip_sign"`
	TxPrintJson       bool     `json:"json"`
	TxDontBroadcast   bool     `json:"dont_broadcast"`
	TxReturnPacked    bool     `json:"return_packed"`
	TxRefBlockNumOrId string   `json:"ref_block"`
	TxPermission      []string `json:"p"`
	TxMaxCpuUsage     uint8    `json:"max_cpu_usage_ms"`
	TxMaxNetUsage     uint32   `json:"max_net_usage"`
	DelaySec          uint32   `json:"delay_sec"`
}

type TransferParams

type TransferParams struct {
	Sender    string `json:"sender"`
	Recipient string `json:"recipient"`
	Amount    string `json:"amount"`
	Memo      string `json:"memo"`
	PayRam    bool   `json:"pay_ram"`
	StandardTransactionOptions
}

type UnapproveProducer

type UnapproveProducer struct {
	Voter        common.Name `json:"voter"`
	ProducerName common.Name `json:"producer_name"`
	StandardTransactionOptions
}

type UndelegatebwParams

type UndelegatebwParams struct {
	From             string `json:"from"`
	Receive          string `json:"receive"`
	UnstakeNetAmount string `json:"unstake_net_amount"`
	UnstakeCpuAmount string `json:"unstake_cpu_amount"`
	StandardTransactionOptions
}

type UnregrodParams

type UnregrodParams struct {
	Producer string `json:"producer"`
	StandardTransactionOptions
}

type UserPrompter

type UserPrompter interface {
	// PromptInput displays the given prompt to the user and requests some textual
	// data to be entered, returning the input of the user.
	PromptInput(prompt string) (string, error)

	// PromptPassword displays the given prompt to the user and requests some textual
	// data to be entered, but one which must not be echoed out into the terminal.
	// The method returns the input provided by the user.
	PromptPassword(prompt string) (string, error)

	// PromptConfirm displays the given prompt to the user and requests a boolean
	// choice to be made, returning that choice.
	PromptConfirm(prompt string) (bool, error)

	// SetHistory sets the the input scrollback history that the prompter will allow
	// the user to scroll back to.
	SetHistory(history []string)

	// AppendHistory appends an entry to the scrollback history. It should be called
	// if and only if the prompt to append was a valid command.
	AppendHistory(command string)

	// ClearHistory clears the entire history
	ClearHistory()

	// SetWordCompleter sets the completion function that the prompter will call to
	// fetch completion candidates when the user presses tab.
	SetWordCompleter(completer WordCompleter)
}

UserPrompter defines the methods needed by the console to promt the user for various types of inputs.

type WordCompleter

type WordCompleter func(line string, pos int) (string, []string, string)

WordCompleter takes the currently edited line with the cursor position and returns the completion candidates for the partial word to be completed. If the line is "Hello, wo!!!" and the cursor is before the first '!', ("Hello, wo!!!", 9) is passed to the completer which may returns ("Hello, ", {"world", "Word"}, "!!!") to have "Hello, world!!!".

Directories

Path Synopsis
Package jsre provides execution environment for JavaScript.
Package jsre provides execution environment for JavaScript.
deps
Package deps contains the console JavaScript dependencies Go embedded.
Package deps contains the console JavaScript dependencies Go embedded.

Jump to

Keyboard shortcuts

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