Lux SDKGoPackages

prompts

Package prompts provides interactive user prompts for CLI applications.

import "github.com/luxfi/sdk/prompts"

Package prompts provides interactive user prompts for CLI applications.

Functions

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

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.

CheckChainAuthKeys

func CheckChainAuthKeys(chainAuthKeys []string, controlKeys []string, threshold uint32) error

CheckChainAuthKeys checks chain authorization criteria:

  • [chainAuthKeys] satisfy chain's [threshold]
  • [chainAuthKeys] is a subset of chain's [controlKeys]

ConvertToAddress

func ConvertToAddress(addr string) (crypto.Address, error)

ConvertToAddress converts a string to a crypto.Address

GetChainAuthKeys

func GetChainAuthKeys(prompt Prompter, controlKeys []string, threshold uint32) ([]string, error)

GetChainAuthKeys gets chain authorization keys from the user, as a subset of the chain's [controlKeys] with a len equal to the chain's [threshold].

GetKeyOrLedger

func GetKeyOrLedger(prompter Prompter, goal string, keyDir string, includeEwoq bool) (bool, string, error)

GetKeyOrLedger prompts user to choose between key or ledger

GetTestnetKeyOrLedger

func GetTestnetKeyOrLedger(prompt Prompter, goal string, keyDir string) (bool, string, error)

PromptAddress

func PromptAddress(prompter Prompter, prompt string) (string, error)

PromptAddress prompts the user for an address

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

PromptPrivateKey

func PromptPrivateKey(prompter Prompter, prompt string) (string, error)

PromptPrivateKey prompts the user for a private key

ValidateAddress

func ValidateAddress(addr string) error

ValidateAddress validates an Ethereum address

ValidateHexa

func ValidateHexa(input string) error

ValidateHexa validates hexadecimal string format

ValidatePositiveInt

func ValidatePositiveInt(val int) error

ValidatePositiveInt validates that an integer is positive

ValidateURLFormat

func ValidateURLFormat(input string) error

Types

Comparator

func (comparator *Comparator) Validate(val uint64) error

Prompter

func NewPrompter() Prompter