Documentation ¶
Index ¶
- Constants
- Variables
- func AskNewPassphrase() string
- func BroadcastOrExportTransaction(ctx context.Context, pt *config.ParaTime, conn connection.Connection, ...) bool
- func BroadcastTransaction(ctx context.Context, pt *config.ParaTime, conn connection.Connection, ...)
- func CheckAddressIsConsensusCapable(cfg *config.Config, address string) error
- func CheckAddressNotReserved(cfg *config.Config, address string) error
- func CheckForceErr(err interface{})
- func Confirm(msg, abortMsg string)
- func ExportTransaction(sigTx interface{})
- func GenAccountNames() types.AccountNames
- func GetActualHeight(ctx context.Context, consensusConn consensus.ClientBackend) (int64, error)
- func GetHeight() int64
- func IsForce() 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 ParseTestAccountAddress(name string) string
- func PrettyJSONMarshal(v interface{}) ([]byte, error)
- func PrintTransaction(npa *NPASelection, tx interface{})
- func PrintTransactionBeforeSigning(npa *NPASelection, tx interface{})
- func PrintTransactionRaw(npa *NPASelection, tx interface{})
- 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, wallet 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{}
- type NPASelection
- type NodeLookup
- type TransactionConfig
Constants ¶
const DefaultMarker = " (*)"
Variables ¶
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/wallet. 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 ( // YesFlag corresponds to the yes-to-all flag. YesFlag *flag.FlagSet // TxFlags contains the common consensus transaction flags. TxFlags *flag.FlagSet // RuntimeTxFlags contains the common runtime transaction flags. RuntimeTxFlags *flag.FlagSet )
var ForceFlag *flag.FlagSet
ForceFlag is a force mode switch.
var HeightFlag *flag.FlagSet
HeightFlag is the flag for specifying block height.
Functions ¶
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, pt *config.ParaTime, 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, pt *config.ParaTime, 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 Confirm ¶
func Confirm(msg, abortMsg string)
Confirm asks the user for confirmation and aborts when rejected.
func ExportTransaction ¶ added in v0.4.0
func ExportTransaction(sigTx interface{})
ExportTransaction exports a (signed) transaction based on configuration.
func GenAccountNames ¶ added in v0.2.0
func GenAccountNames() types.AccountNames
GenAccountNames generates a map of all addresses -> account name for pretty printing.
func GetActualHeight ¶
GetActualHeight returns the user-selected block height if explicitly specified, or the current latest height.
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 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 PrettyJSONMarshal ¶
PrettyJSONMarshal returns pretty-printed JSON encoding of v.
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{})
PrintTransactionBeforeSigning prints the transaction and asks the user for confirmation.
func PrintTransactionRaw ¶ added in v0.4.0
func PrintTransactionRaw(npa *NPASelection, tx interface{})
PrintTransaction prints the transaction which can be either signed or unsigned.
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, wallet 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 NPASelection ¶
type NPASelection struct { NetworkName string Network *config.Network ParaTimeName string ParaTime *config.ParaTime AccountName string Account *cliConfig.Account }
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) 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
func NewNodeLookup( ctx context.Context, consensus consensus.ClientBackend, registry registry.Backend, height int64, ) (*NodeLookup, error)
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.