Documentation
¶
Index ¶
- Constants
- Variables
- func AddAccountFlag(cmd *cobra.Command)
- func AddSelectorFlags(cmd *cobra.Command)
- func AddSelectorNAFlags(cmd *cobra.Command)
- func AddSelectorNFlags(cmd *cobra.Command)
- func AddSelectorNPFlags(cmd *cobra.Command)
- func Ask(p survey.Prompt, response interface{}, opts ...survey.AskOpt) error
- func AskMulti(qs []*survey.Question, response interface{}, opts ...survey.AskOpt) error
- func AskNewPassphrase() string
- func BroadcastOrExportTransaction(ctx context.Context, npa *NPASelection, conn connection.Connection, ...) bool
- func BroadcastTransaction(ctx context.Context, npa *NPASelection, conn connection.Connection, ...)
- func CheckAddressIsConsensusCapable(cfg *config.Config, address string) error
- func CheckAddressNotReserved(cfg *config.Config, address string) error
- func CheckForceErr(err interface{})
- func CompleteNetworkThenParaTime(_ *cobra.Command, args []string, _ string) ([]string, cobra.ShellCompDirective)
- func CompleteParaTimeNames(cmd *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective)
- func Confirm(msg, abortMsg string)
- func DecodeSafe(raw []byte) (*types.Transaction, error)
- func ExportTransaction(pt *config.ParaTime, sigTx interface{})
- func FindAccountName(address string) string
- func GenAccountEthMap() map[string]string
- func GenAccountNames() types.AccountNames
- func GetActualHeight(ctx context.Context, consensusConn consensus.Backend) (int64, error)
- func GetAnswerYes() bool
- func GetHeight() int64
- func IsForce() bool
- func IsVerbose() bool
- func JSONMarshalKey(k interface{}) (keyJSON []byte, err error)
- func JSONMarshalUniversalValue(v interface{}) []byte
- func JSONPrintKeyValueTuple(items []contracts.InstanceStorageKeyValue)
- func LoadAccount(cfg *config.Config, name string) wallet.Account
- func LoadAccountConfig(cfg *config.Config, name string) (*config.Account, error)
- func LoadTestAccount(name string) (wallet.Account, error)
- func LoadTestAccountConfig(name string) (*config.Account, error)
- func ParaTimeAddresses(cfg *config.Config) []string
- func ParseTestAccountAddress(name string) string
- func PrepareConsensusTransaction(ctx context.Context, npa *NPASelection, signer coreSignature.Signer, ...) (consensusTx.Gas, *quantity.Quantity, error)
- func PrepareParatimeTransaction(ctx context.Context, npa *NPASelection, account wallet.Account, ...) (uint64, *quantity.Quantity, types.Denomination, error)
- func PrettyAddress(addr string) string
- func PrettyAddressWith(ctx AddressFormatContext, addr string) string
- func PrettyErrorHints(_ context.Context, npa *NPASelection, _ connection.Connection, _ interface{}, ...) string
- func PrettyJSONMarshal(v interface{}) ([]byte, error)
- func PrettyJSONMarshalIndent(v interface{}, prefix, indent string) ([]byte, error)
- func PrettyPrint(npa *NPASelection, prefix string, blob interface{}) string
- func PrettyPrintWithTxDetails(npa *NPASelection, prefix string, blob interface{}, ...) string
- func PrintTransaction(npa *NPASelection, tx interface{})
- func PrintTransactionBeforeSigning(npa *NPASelection, tx interface{}, txDetails *signature.TxDetails)
- func PrintTransactionRaw(npa *NPASelection, tx interface{})
- func PrintTransactionRawWithTxDetails(npa *NPASelection, tx interface{}, txDetails *signature.TxDetails)
- func PrintTransactionWithTxDetails(npa *NPASelection, tx interface{}, txDetails *signature.TxDetails)
- func ResolveAddress(net *configSdk.Network, address string) (*types.Address, *ethCommon.Address, error)
- func ResolveLocalAccountOrAddress(net *configSdk.Network, address string) (*types.Address, *ethCommon.Address, error)
- func SignConsensusTransaction(ctx context.Context, npa *NPASelection, account wallet.Account, ...) (interface{}, error)
- func SignParaTimeTransaction(ctx context.Context, npa *NPASelection, account wallet.Account, ...) (interface{}, interface{}, error)
- func WaitForEvent(ctx context.Context, pt *config.ParaTime, conn connection.Connection, ...) <-chan interface{}
- func Warn(msg string)
- func Warnf(format string, args ...interface{})
- type AddressFormatContext
- type CobraCompletionFunc
- type FormatType
- type JSONPrettyPrintRoflAppConfig
- type JSONPrettyPrintRoflRegistration
- type NPASelection
- type NodeLookup
- type TransactionConfig
Constants ¶
const DefaultMarker = " (*)"
Variables ¶
var ( // HeightFlag is the flag for specifying block height. HeightFlag *flag.FlagSet // ForceFlag is a force mode switch. ForceFlag *flag.FlagSet // AnswerYesFlag answers yes to all questions. AnswerYesFlag *flag.FlagSet // FormatFlag specifies the command's output format (text/json). FormatFlag *flag.FlagSet // VerboseFlag specifies the command's verbosity. VerboseFlag *flag.FlagSet )
var ( // PromptPassphrase is the standard passphrase prompt. PromptPassphrase = &survey.Password{ Message: "Passphrase:", } // PromptCreatePassphrase is the standard create a new passphrase prompt. PromptCreatePassphrase = &survey.Password{ Message: "Choose a new passphrase:", } // PromptRepeatPassphrase is the standard repeat a new passphrase prompt. PromptRepeatPassphrase = &survey.Password{ Message: "Repeat passphrase:", } )
var ( // AccountFlag corresponds to the --account selector flag. AccountFlag *flag.FlagSet // SelectorFlags contains the common selector flags for network/ParaTime/account. SelectorFlags *flag.FlagSet // SelectorNPFlags contains the common selector flags for network/ParaTime. SelectorNPFlags *flag.FlagSet // SelectorNFlags contains the common selector flags for network. SelectorNFlags *flag.FlagSet // SelectorNAFlags contains the common selector flags for network/account. SelectorNAFlags *flag.FlagSet )
var ( // TxFlags contains the common consensus transaction flags. TxFlags *flag.FlagSet // RuntimeTxFlags contains the common runtime transaction flags. RuntimeTxFlags *flag.FlagSet )
var CompleteAccountAndAddressBookNames = simpleComplete(addressNames)
CompleteAccountAndAddressBookNames provides completion for both wallet accounts and address book entries. Useful for commands that accept either as an address.
var CompleteAccountNames = simpleComplete(accountNames)
CompleteAccountNames provides completion for wallet account names.
var CompleteAddressBookNames = simpleComplete(addressBookNames)
CompleteAddressBookNames provides completion for address book entry names.
var CompleteNetworkNames = simpleComplete(networkNames)
CompleteNetworkNames provides completion for network names.
SurveyStdio is the standard survey option to direct prompts to stderr.
var (
TxUnsigned bool
)
Functions ¶
func AddAccountFlag ¶ added in v0.18.2
AddAccountFlag adds account selector flag with completion.
func AddSelectorFlags ¶ added in v0.18.2
AddSelectorFlags adds network/paratime/account selector flags with completions.
func AddSelectorNAFlags ¶ added in v0.18.2
AddSelectorNAFlags adds network/account selector flags with completions.
func AddSelectorNFlags ¶ added in v0.18.2
AddSelectorNFlags adds network selector flags with completions.
func AddSelectorNPFlags ¶ added in v0.18.2
AddSelectorNPFlags adds network/paratime selector flags with completions.
func AskNewPassphrase ¶
func AskNewPassphrase() string
AskNewPassphrase asks the user to create a new passphrase.
func BroadcastOrExportTransaction ¶ added in v0.4.0
func BroadcastOrExportTransaction( ctx context.Context, npa *NPASelection, conn connection.Connection, tx interface{}, meta interface{}, result interface{}, ) bool
BroadcastOrExportTransaction broadcasts or exports a transaction based on configuration.
When in offline or unsigned mode, it exports the transaction and returns false. Otherwise it broadcasts the transaction and returns true.
func BroadcastTransaction ¶
func BroadcastTransaction( ctx context.Context, npa *NPASelection, conn connection.Connection, tx interface{}, meta interface{}, result interface{}, )
BroadcastTransaction broadcasts a transaction.
When in offline mode, it outputs the transaction instead.
func CheckAddressIsConsensusCapable ¶ added in v0.2.0
CheckAddressIsConsensusCapable checks whether the given address is derived from any known Ethereum address and is thus unspendable on consensus layer.
func CheckAddressNotReserved ¶
CheckAddressNotReserved checks whether the given native address is potentially unspendable like the reserved addresses for the staking reward and common pool, fee accumulator or the native ParaTime addresses.
func CheckForceErr ¶
func CheckForceErr(err interface{})
CheckForceErr treats error as warning, if --force is provided.
func CompleteNetworkThenParaTime ¶ added in v0.18.2
func CompleteNetworkThenParaTime(_ *cobra.Command, args []string, _ string) ([]string, cobra.ShellCompDirective)
CompleteNetworkThenParaTime provides completion for commands that take <network> <paratime> as positional arguments.
func CompleteParaTimeNames ¶ added in v0.18.2
func CompleteParaTimeNames(cmd *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective)
CompleteParaTimeNames provides completion for ParaTime names. It uses the default network if --network flag is not set.
func Confirm ¶
func Confirm(msg, abortMsg string)
Confirm asks the user for confirmation and aborts when rejected.
func DecodeSafe ¶ added in v0.20.0
func DecodeSafe(raw []byte) (*types.Transaction, error)
DecodeSafe attempts to decode raw bytes as a Safe Transaction Builder batch and unwraps Subcall precompile calldata back into an unsigned ParaTime transaction.
The resulting transaction only has Call.Method and Call.Body populated, since the Safe batch does not carry sender, nonce, or fee information.
func ExportTransaction ¶ added in v0.4.0
ExportTransaction exports a (signed) transaction based on configuration.
func FindAccountName ¶ added in v0.14.2
FindAccountName finds account's name (if exists).
func GenAccountEthMap ¶ added in v0.18.3
GenAccountEthMap generates a map of native address string -> eth hex address (if known). Priority order matches GenAccountNames: test accounts < addressbook < wallet.
func GenAccountNames ¶ added in v0.2.0
func GenAccountNames() types.AccountNames
GenAccountNames generates a map of all known native addresses -> account name for pretty printing. It includes test accounts, configured networks (paratimes/ROFL defaults), addressbook and wallet.
Priority order (later entries overwrite earlier): test accounts < network entries < addressbook < wallet.
func GetActualHeight ¶
GetActualHeight returns the user-selected block height if explicitly specified, or the current latest height.
func GetAnswerYes ¶ added in v0.9.0
func GetAnswerYes() bool
GetAnswerYes returns whether all interactive questions should be answered with yes.
func JSONMarshalKey ¶
JSONMarshalKey encodes k as UTF-8 string if valid, or Base64 otherwise.
func JSONMarshalUniversalValue ¶
func JSONMarshalUniversalValue(v interface{}) []byte
JSONMarshalUniversalValue is a wrapper for the built-in JSON encoder which adds support for marshalling map[interface{}]interface{}.
Each key is encoded as string if it contains valid UTF-8 value. Otherwise, Base64 is used.
func JSONPrintKeyValueTuple ¶
func JSONPrintKeyValueTuple(items []contracts.InstanceStorageKeyValue)
JSONPrintKeyValueTuple traverses potentially large number of items and prints JSON representation of them.
Marshalling is done externally without holding resulting JSON string in-memory. Cbor decoding of each value is tried first. If it fails, the binary content is preserved. Universal marshalling of map[interface{}]interface{} types is also supported. Each key is encoded as string if it contains valid UTF-8 value. Otherwise, Base64 is used.
func LoadAccount ¶
LoadAccount loads the given named account.
func LoadAccountConfig ¶ added in v0.8.0
LoadAccountConfig loads the config instance of the given named account.
func LoadTestAccount ¶
LoadTestAccount loads the given named test account.
func LoadTestAccountConfig ¶
LoadTestAccountConfig loads config for the given named test account.
func ParaTimeAddresses ¶ added in v0.18.2
ParaTimeAddresses returns all paratime addresses in "paratime:<name>" format for the given config.
func ParseTestAccountAddress ¶ added in v0.8.0
ParseTestAccountAddress extracts test account name from "test:some_test_account" format or returns an empty string, if the format doesn't match.
func PrepareConsensusTransaction ¶ added in v0.10.3
func PrepareConsensusTransaction(ctx context.Context, npa *NPASelection, signer coreSignature.Signer, conn connection.Connection, tx *consensusTx.Transaction) (consensusTx.Gas, *quantity.Quantity, error)
PrepareConsensusTransaction initialized nonce and gas fields of the consensus transaction and estimates gas.
Returns the estimated gas limit and total fee amount.
func PrepareParatimeTransaction ¶ added in v0.10.3
func PrepareParatimeTransaction(ctx context.Context, npa *NPASelection, account wallet.Account, conn connection.Connection, tx *types.Transaction) (uint64, *quantity.Quantity, types.Denomination, error)
PrepareParatimeTransaction initializes nonce and gas fields of the ParaTime transaction and estimates gas.
Returns the estimated gas limit, total fee amount and fee denominator.
func PrettyAddress ¶ added in v0.18.3
PrettyAddress is like PrettyAddressWith but builds a fresh context on each call.
func PrettyAddressWith ¶ added in v0.18.3
func PrettyAddressWith(ctx AddressFormatContext, addr string) string
PrettyAddressWith formats the address in native or eth string for display using a precomputed context. Known addresses return "name (preferred_addr)", unknown addresses return the input unchanged.
func PrettyErrorHints ¶ added in v0.12.1
func PrettyErrorHints( _ context.Context, npa *NPASelection, _ connection.Connection, _ interface{}, _ interface{}, failedRes *types.FailedCallResult, ) string
PrettyErrorHints adds any hints based on the error and the transaction context.
func PrettyJSONMarshal ¶
PrettyJSONMarshal returns pretty-printed JSON encoding of v.
func PrettyJSONMarshalIndent ¶ added in v0.13.0
PrettyJSONMarshal returns pretty-printed JSON encoding of v.
func PrettyPrint ¶ added in v0.10.4
func PrettyPrint(npa *NPASelection, prefix string, blob interface{}) string
PrettyPrint transforms generic JSON-formatted data into a pretty-printed string. For types implementing consensusPretty.PrettyPrinter, it uses the custom pretty printer. For other types, it does basic JSON indentation and cleanup of common delimiters.
func PrettyPrintWithTxDetails ¶ added in v0.18.3
func PrettyPrintWithTxDetails(npa *NPASelection, prefix string, blob interface{}, txDetails *signature.TxDetails) string
PrettyPrintWithTxDetails is like PrettyPrint but passes txDetails to the signature context.
func PrintTransaction ¶ added in v0.2.0
func PrintTransaction(npa *NPASelection, tx interface{})
PrintTransaction prints the transaction which can be either signed or unsigned together with information about the selected network/ParaTime.
func PrintTransactionBeforeSigning ¶
func PrintTransactionBeforeSigning(npa *NPASelection, tx interface{}, txDetails *signature.TxDetails)
PrintTransactionBeforeSigning prints the transaction and asks the user for confirmation.
func PrintTransactionRaw ¶ added in v0.4.0
func PrintTransactionRaw(npa *NPASelection, tx interface{})
PrintTransactionRaw prints the transaction which can be either signed or unsigned.
func PrintTransactionRawWithTxDetails ¶ added in v0.18.3
func PrintTransactionRawWithTxDetails(npa *NPASelection, tx interface{}, txDetails *signature.TxDetails)
PrintTransactionRawWithTxDetails is like PrintTransactionRaw but passes txDetails to the pretty-printer.
func PrintTransactionWithTxDetails ¶ added in v0.18.3
func PrintTransactionWithTxDetails(npa *NPASelection, tx interface{}, txDetails *signature.TxDetails)
PrintTransactionWithTxDetails is like PrintTransaction but passes txDetails to the pretty-printer.
func ResolveAddress ¶ added in v0.8.0
func ResolveAddress(net *configSdk.Network, address string) (*types.Address, *ethCommon.Address, error)
ResolveAddress resolves a string address into the corresponding account address.
func ResolveLocalAccountOrAddress ¶
func ResolveLocalAccountOrAddress(net *configSdk.Network, address string) (*types.Address, *ethCommon.Address, error)
ResolveLocalAccountOrAddress resolves a string address into the corresponding account address.
func SignConsensusTransaction ¶
func SignConsensusTransaction( ctx context.Context, npa *NPASelection, account wallet.Account, conn connection.Connection, tx *consensusTx.Transaction, ) (interface{}, error)
SignConsensusTransaction signs a consensus transaction.
func SignParaTimeTransaction ¶
func SignParaTimeTransaction( ctx context.Context, npa *NPASelection, account wallet.Account, conn connection.Connection, tx *types.Transaction, txDetails *signature.TxDetails, ) (interface{}, interface{}, error)
SignParaTimeTransaction signs a ParaTime transaction.
Returns the signed transaction and call format-specific metadata for result decoding.
func WaitForEvent ¶
func WaitForEvent( ctx context.Context, pt *config.ParaTime, conn connection.Connection, decoder client.EventDecoder, mapFn func(client.DecodedEvent) interface{}, ) <-chan interface{}
WaitForEvent waits for a specific ParaTime event.
If no mapFn is specified, the returned channel will contain DecodedEvents, otherwise it will contain whatever mapFn returns.
If mapFn is specified it should return a non-nil value when encountering a matching event.
Types ¶
type AddressFormatContext ¶ added in v0.18.3
type AddressFormatContext struct {
// Names maps native address string to account name.
Names types.AccountNames
// Eth maps native address string to Ethereum hex address string, if known.
Eth map[string]string
}
AddressFormatContext contains precomputed maps for address formatting.
func GenAddressFormatContext ¶ added in v0.18.3
func GenAddressFormatContext() AddressFormatContext
GenAddressFormatContext builds both name and eth address maps for formatting.
type CobraCompletionFunc ¶ added in v0.18.2
type CobraCompletionFunc = func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective)
CobraCompletionFunc is the function signature for cobra completions.
func AccountNamesAt ¶ added in v0.18.2
func AccountNamesAt(positions ...int) CobraCompletionFunc
AccountNamesAt returns a completion function for wallet account names at specified positions.
func AddressBookNamesAt ¶ added in v0.18.2
func AddressBookNamesAt(positions ...int) CobraCompletionFunc
AddressBookNamesAt returns a completion function for address book names at specified positions.
func AddressesAt ¶ added in v0.18.2
func AddressesAt(positions ...int) CobraCompletionFunc
AddressesAt returns a completion function for wallet + address book names at specified positions.
func NetworksAt ¶ added in v0.18.2
func NetworksAt(positions ...int) CobraCompletionFunc
NetworksAt returns a completion function for network names at specified positions.
func StaticAt ¶ added in v0.18.2
func StaticAt(values []string, positions ...int) CobraCompletionFunc
StaticAt returns a completion function for static values at specified positions.
type FormatType ¶ added in v0.10.4
type FormatType string
FormatType specifies the type of format for output of commands.
const ( // Output plain text. FormatText FormatType = "text" // Output JSON. FormatJSON FormatType = "json" )
Supported output formats for the format flag.
func OutputFormat ¶ added in v0.10.4
func OutputFormat() FormatType
OutputFormat returns the format of the command's output.
func (*FormatType) Set ¶ added in v0.10.4
func (f *FormatType) Set(v string) error
Set sets the value of the type to the argument given.
func (*FormatType) String ¶ added in v0.10.4
func (f *FormatType) String() string
String returns a string representation of the output format type.
func (*FormatType) Type ¶ added in v0.10.4
func (f *FormatType) Type() string
Type returns the type of the flag.
type JSONPrettyPrintRoflAppConfig ¶ added in v0.16.1
JSONPrettyPrintRoflAppConfig is a wrapper around rofl.AppConfig that implements custom JSON marshaling.
func (JSONPrettyPrintRoflAppConfig) MarshalJSON ¶ added in v0.16.1
func (a JSONPrettyPrintRoflAppConfig) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling.
type JSONPrettyPrintRoflRegistration ¶ added in v0.16.1
type JSONPrettyPrintRoflRegistration rofl.Registration
JSONPrettyPrintRoflRegistration is a wrapper around rofl.Registration that implements custom JSON marshaling.
func (JSONPrettyPrintRoflRegistration) MarshalJSON ¶ added in v0.16.1
func (r JSONPrettyPrintRoflRegistration) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling.
type NPASelection ¶
type NPASelection struct {
NetworkName string
Network *config.Network
ParaTimeName string
ParaTime *config.ParaTime
AccountName string
Account *cliConfig.Account
AccountSetExplicitly bool
}
NPASelection contains the network/ParaTime/account selection.
func GetNPASelection ¶
func GetNPASelection(cfg *cliConfig.Config) *NPASelection
GetNPASelection returns the user-selected network/ParaTime/account combination.
func (*NPASelection) ConsensusDenomination ¶ added in v0.8.0
func (npa *NPASelection) ConsensusDenomination() (denom types.Denomination)
ConsensusDenomination returns the denomination used to represent the consensus layer token.
func (*NPASelection) MustHaveAccount ¶ added in v0.12.1
func (npa *NPASelection) MustHaveAccount()
MustHaveAccount checks whether Account is populated and fails if it is not.
func (*NPASelection) MustHaveParaTime ¶ added in v0.12.1
func (npa *NPASelection) MustHaveParaTime()
MustHaveParaTime checks whether ParaTime is populated and fails if it is not.
func (*NPASelection) PrettyPrintNetwork ¶ added in v0.4.0
func (npa *NPASelection) PrettyPrintNetwork() (out string)
PrettyPrintNetwork formats the network name and description, if one exists.
type NodeLookup ¶ added in v0.4.0
type NodeLookup struct {
// contains filtered or unexported fields
}
func NewNodeLookup ¶ added in v0.4.0
type TransactionConfig ¶
type TransactionConfig struct {
// Offline is a flag indicating that no online queries are allowed.
Offline bool
// Export is a flag indicating that the transaction should be exported instead of broadcast.
Export bool
}
TransactionConfig contains the transaction-related configuration from flags.
func GetTransactionConfig ¶
func GetTransactionConfig() *TransactionConfig
GetTransactionConfig returns the transaction-related configuration from flags.