Documentation
¶
Overview ¶
Copyright (C) 2022-2025, Lux Industries Inc. All rights reserved. See the file LICENSE for licensing terms.
Copyright (C) 2022-2025, Lux Industries Inc. All rights reserved. See the file LICENSE for licensing terms.
Index ¶
- Constants
- func CaptureKeyAddress(prompt Prompter, goal string, keyDir string, ...) (string, error)
- func CaptureListDecision[T comparable](prompter Prompter, prompt string, capture func(prompt string) (T, error), ...) ([]T, bool, error)
- func CheckSubnetAuthKeys(subnetAuthKeys []string, controlKeys []string, threshold uint32) error
- func ConvertToAddress(addr string) (crypto.Address, error)
- func GetKeyOrLedger(prompter Prompter, goal string, keyDir string, includeEwoq bool) (bool, string, error)
- func GetSubnetAuthKeys(prompt Prompter, controlKeys []string, threshold uint32) ([]string, error)
- func GetTestnetKeyOrLedger(prompt Prompter, goal string, keyDir string) (bool, string, error)
- func PromptAddress(prompter Prompter, prompt string) (string, error)
- func PromptChain(prompt Prompter, message string, blockchainNames []string, pChainEnabled bool, ...) (bool, bool, bool, bool, string, string, error)
- func PromptPrivateKey(prompter Prompter, prompt string) (string, error)
- func RequestURL(url string) error
- func ValidateAddress(addr string) error
- func ValidateHexa(s string) error
- func ValidateNodeID(input string) error
- func ValidatePositiveInt(input string) error
- func ValidateRepoBranch(branch string) error
- func ValidateRepoFile(filepath string) error
- func ValidateURL(input string, checkConnection bool) error
- func ValidateURLFormat(input string) error
- type Comparator
- type Prompter
Constants ¶
const ( Yes = "Yes" No = "No" Add = "Add" Del = "Delete" Preview = "Preview" MoreInfo = "More Info" Done = "Done" Cancel = "Cancel" LessThanEq = "Less Than Or Eq" MoreThanEq = "More Than Or Eq" MoreThan = "More Than" // Address formats PChainFormat = "P-Chain" CChainFormat = "C-Chain" )
const EVMFormat = "evm"
EVMFormat represents the EVM address format
Variables ¶
This section is empty.
Functions ¶
func CaptureKeyAddress ¶
func CaptureKeyAddress( prompt Prompter, goal string, keyDir string, getKey func(string) (string, error), network models.Network, addressFormat string, ) (string, error)
CaptureKeyAddress prompts the user to select a key address
func CaptureListDecision ¶
func CaptureListDecision[T comparable]( prompter Prompter, prompt string, capture func(prompt string) (T, error), capturePrompt string, label string, info string, ) ([]T, bool, error)
CaptureListDecision runs a for loop and continuously asks the user for a specific input (currently only `CapturePChainAddress` and `CaptureAddress` is supported) until the user cancels or chooses `Done`. It does also offer an optional `info` to print (if provided) and a preview. Items can also be removed.
func CheckSubnetAuthKeys ¶
check subnet authorization criteria: - [subnetAuthKeys] satisfy subnet's [threshold] - [subnetAuthKeys] is a subset of subnet's [controlKeys]
func ConvertToAddress ¶
ConvertToAddress converts a string to a crypto.Address
func GetKeyOrLedger ¶
func GetKeyOrLedger(prompter Prompter, goal string, keyDir string, includeEwoq bool) (bool, string, error)
GetKeyOrLedger prompts user to choose between key or ledger
func GetSubnetAuthKeys ¶
get subnet authorization keys from the user, as a subset of the subnet's [controlKeys] with a len equal to the subnet's [threshold]
func GetTestnetKeyOrLedger ¶
func PromptAddress ¶
PromptAddress prompts the user for an address
func PromptChain ¶
func PromptChain( prompt Prompter, message string, blockchainNames []string, pChainEnabled bool, xChainEnabled bool, cChainEnabled bool, blockchainNameToAvoid string, blockchainIDEnabled bool, ) (bool, bool, bool, bool, string, string, error)
PromptChain prompts the user to select a chain
func PromptPrivateKey ¶
PromptPrivateKey prompts the user for a private key
func RequestURL ¶
RequestURL makes a GET request to validate URL connectivity
func ValidateAddress ¶
ValidateAddress validates an Ethereum address Accepts addresses with or without 0x prefix
func ValidateNodeID ¶
ValidateNodeID validates a node ID string (exported for external use)
func ValidatePositiveInt ¶
ValidatePositiveInt validates that a string can be parsed as a positive integer
func ValidateRepoBranch ¶
ValidateRepoBranch validates a git branch name
func ValidateRepoFile ¶
ValidateRepoFile validates a repository file path
func ValidateURL ¶
ValidateURL validates URL format and optionally checks connectivity
func ValidateURLFormat ¶
Types ¶
type Comparator ¶
type Comparator struct {
Label string // Label that identifies reference value
Type string // Less Than Eq or More than Eq
Value uint64 // Value to Compare To
}
func (*Comparator) Validate ¶
func (comparator *Comparator) Validate(val uint64) error
type Prompter ¶
type Prompter interface {
CapturePositiveBigInt(promptStr string) (*big.Int, error)
CaptureAddress(promptStr string) (crypto.Address, error)
CaptureNewFilepath(promptStr string) (string, error)
CaptureExistingFilepath(promptStr string) (string, error)
CaptureYesNo(promptStr string) (bool, error)
CaptureNoYes(promptStr string) (bool, error)
CaptureList(promptStr string, options []string) (string, error)
CaptureString(promptStr string) (string, error)
CaptureGitURL(promptStr string) (*url.URL, error)
CaptureURL(promptStr string, validateConnection bool) (string, error)
CaptureStringAllowEmpty(promptStr string) (string, error)
CaptureEmail(promptStr string) (string, error)
CaptureIndex(promptStr string, options []any) (int, error)
CaptureVersion(promptStr string) (string, error)
CaptureDuration(promptStr string) (time.Duration, error)
CaptureDate(promptStr string) (time.Time, error)
CaptureNodeID(promptStr string) (ids.NodeID, error)
CaptureID(promptStr string) (ids.ID, error)
CaptureWeight(promptStr string, validator func(uint64) error) (uint64, error)
CapturePositiveInt(promptStr string, comparators []Comparator) (int, error)
CaptureUint64(promptStr string) (uint64, error)
CaptureUint64Compare(promptStr string, comparators []Comparator) (uint64, error)
CapturePChainAddress(promptStr string, network models.Network) (string, error)
CaptureFutureDate(promptStr string, minDate time.Time) (time.Time, error)
ChooseKeyOrLedger(goal string) (bool, error)
CaptureValidatorBalance(promptStr string, availableBalance float64, minBalance float64) (float64, error)
CaptureListWithSize(prompt string, options []string, size int) ([]string, error)
CaptureFloat(promptStr string, validator func(float64) error) (float64, error)
CaptureAddresses(promptStr string) ([]crypto.Address, error)
CaptureXChainAddress(promptStr string, network models.Network) (string, error)
CaptureValidatedString(promptStr string, validator func(string) error) (string, error)
CaptureRepoBranch(promptStr string, repo string) (string, error)
CaptureRepoFile(promptStr string, repo string, branch string) (string, error)
CaptureInt(promptStr string, validator func(int) error) (int, error)
CaptureUint8(promptStr string) (uint8, error)
CaptureFujiDuration(promptStr string) (time.Duration, error)
CaptureMainnetDuration(promptStr string) (time.Duration, error)
CaptureMainnetL1StakingDuration(promptStr string) (time.Duration, error)
}
func NewPrompter ¶
func NewPrompter() Prompter
NewProcessChecker creates a new process checker which can respond if the server is running