utils

package
v0.4.2-b1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoRestartFlag string = "no-restart"
	MnemonicFlag  string = "mnemonic"
)

Variables

View Source
var (
	YesFlag *cli.BoolFlag = &cli.BoolFlag{
		Name:    "yes",
		Aliases: []string{"y"},
		Usage:   "Automatically confirm all interactive questions",
	}
	PrintTxDataFlag *cli.BoolFlag = &cli.BoolFlag{
		Name:    "print-tx-data",
		Aliases: []string{"pt"},
		Usage:   "Print any TX data for transactions without signing or submitting them. Useful for masquerade mode or offline wallet operations.",
	}
	SignTxOnlyFlag *cli.BoolFlag = &cli.BoolFlag{
		Name:    "sign-tx-only",
		Aliases: []string{"st"},
		Usage:   "Sign any TXs and print the results, but don't submit it to the network. Useful if you want to save a TX for later or bundle it up with a service like Flashbots.",
	}
	RawFlag *cli.BoolFlag = &cli.BoolFlag{
		Name: "raw",
	}
	ComposeFileFlag *cli.StringSliceFlag = &cli.StringSliceFlag{
		Name:    "compose-file",
		Aliases: []string{"f"},
		Usage:   "Supplemental Docker compose files for custom containers to include when performing service commands such as 'start' and 'stop'; this flag may be defined multiple times",
	}
)

Functions

func ClearTerminal added in v1.0.0

func ClearTerminal() error

Clear terminal output

func Confirm

func Confirm(initialPrompt string) bool

Prompt for confirmation

func ConfirmSecureSession

func ConfirmSecureSession(warning string) bool

Prompts the user to verify that there is nobody looking over their shoulder before printing sensitive information.

func ConfirmWithIAgree

func ConfirmWithIAgree(initialPrompt string) bool

Prompt for 'I agree' confirmation (used on important questions to avoid a quick 'y' response from the user)

func GetDateTimeString

func GetDateTimeString(dateTime uint64) string

Convert a Unix datetime to a string, or `---` if it's zero

func GetDateTimeStringOfTime

func GetDateTimeStringOfTime(dateTime time.Time) string

Convert a Unix datetime to a string, or `---` if it's zero

func GetMultiselectIndices

func GetMultiselectIndices[DataType any](c *cli.Context, flagName string, options []SelectionOption[DataType], prompt string) ([]*DataType, error)

Get the list of elements the user wants to use for a multi-select operation

func GetPrettyAddress

func GetPrettyAddress(address common.Address) string

Gets the hex string of an address, or "none" if it was the 0x0 address

func InstantiateFlag

func InstantiateFlag[FlagType cli.Flag](prototype FlagType, description string) cli.Flag

func ParseFloat

func ParseFloat(c *cli.Context, name string, value string, isFraction bool) (*big.Int, error)

Parses a string representing either a floating point value or a raw wei amount into a *big.Int

func PrintDepositMismatchError

func PrintDepositMismatchError(rpNetwork, beaconNetwork uint64, rpDepositAddress, beaconDepositAddress common.Address)

Prints an error message when the Beacon client is not using the deposit contract address that Hyperdrive expects

func PrintMultiTransactionNonceWarning

func PrintMultiTransactionNonceWarning()

Print a warning to the console if the user set a custom nonce, but this operation involves multiple transactions

func PrintNetwork

func PrintNetwork(currentNetwork config.Network, isNew bool) error

Prints what network you're currently on

func PrintTransactionBatchHashes

func PrintTransactionBatchHashes(hd *client.HyperdriveClient, hashes []common.Hash)

Print a batch of transaction hashes to the console.

func PrintTransactionHash

func PrintTransactionHash(hd *client.HyperdriveClient, hash common.Hash)

Print a TX's details to the console.

func PrintTransactionHashNoCancel

func PrintTransactionHashNoCancel(hd *client.HyperdriveClient, hash common.Hash)

Print a TX's details to the console, but inform the user NOT to cancel it.

func Prompt

func Prompt(initialPrompt string, expectedFormat string, incorrectFormatPrompt string) string

Prompt for user input

func PromptPassword

func PromptPassword(initialPrompt string, expectedFormat string, incorrectFormatPrompt string) string

Prompt for password input

func Select

func Select(initialPrompt string, options []string) (int, string)

Prompt for user selection

func ValidateArgCount added in v1.0.0

func ValidateArgCount(c *cli.Context, expectedCount int) error

Validate command argument count

Types

type SelectionOption

type SelectionOption[DataType any] struct {
	// The underlying element this option represents
	Element *DataType

	// The human-readable ID of the option, used for non-interactive selection
	ID string

	// The text to display for this option when listing the available options
	Display string
}

An option that can be selected from a list of choices in the CLI

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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