Documentation
¶
Overview ¶
Copyright (C) 2025, Lux Industries, Inc. All rights reserved. See the file LICENSE for licensing terms.
Copyright (C) 2023, Lux Industries Inc. All rights reserved. See the file LICENSE for licensing terms.
Copyright (C) 2025, Lux Industries, Inc. All rights reserved. See the file LICENSE for licensing terms.
Copyright (C) 2022, Lux Industries Inc. All rights reserved. See the file LICENSE for licensing terms.
Copyright (C) 2020-2025, Lux Industries Inc. All rights reserved. See the file LICENSE for licensing terms.
Copyright (C) 2025, Lux Industries, Inc. All rights reserved. See the file LICENSE for licensing terms.
Copyright (C) 2025, Lux Industries Inc. All rights reserved. See the file LICENSE for licensing terms.
Copyright (C) 2022, Lux Industries Inc. All rights reserved. See the file LICENSE for licensing terms.
Copyright (C) 2025, Lux Industries, Inc. All rights reserved. See the file LICENSE for licensing terms.
Copyright (C) 2025, Lux Industries, Inc. All rights reserved. See the file LICENSE for licensing terms.
Copyright (C) 2025, Lux Industries, Inc. All rights reserved. See the file LICENSE for licensing terms.
Index ¶
- func AddSingleQuotes(s []string) []string
- func Any[T any](input []T, f func(T) bool) bool
- func AppendSlices[T any](slices ...[]T) []T
- func ArchSupported(arch string) bool
- func ByteSliceIsSubnetEvmGenesis(bs []byte) bool
- func ByteSliceToSubnetEvmGenesis(bs []byte) (core.Genesis, error)
- func CleanupString(s string) string
- func CleanupStrings(s []string) []string
- func CombineSCPPath(host, path string) string
- func Command(cmdLine string, params ...string) *exec.Cmd
- func ContainsIgnoreCase(s, substr string) bool
- func ConvertInterfaceToMap(value interface{}) (map[string]interface{}, error)
- func E2EConvertIP(ip string) string
- func E2EDocker() bool
- func E2ESuffix(ip string) string
- func ErrWrongArgCount(expected, got int) error
- func ExpandHome(path string) string
- func ExtractPlaceholderValue(pattern, text string) (string, error)
- func FileCopy(src string, dst string) error
- func FileExists(filename string) bool
- func FileIsSubnetEVMGenesis(genesisPath string) (bool, error)
- func Filter[T any](input []T, f func(T) bool) []T
- func Find[T any](input []T, f func(T) bool) *T
- func FindErrorLogs(rootDirs ...string)
- func FormatAmount(amount *big.Int, decimals uint8) string
- func GetANRContext() (context.Context, context.CancelFunc)
- func GetAPIContext() (context.Context, context.CancelFunc)
- func GetAPILargeContext() (context.Context, context.CancelFunc)
- func GetBlockchainTx(endpoint string, blockchainID ids.ID) (*txs.CreateChainTx, error)
- func GetCLIVersion() string
- func GetChainID(endpoint string, chainName string) (ids.ID, error)
- func GetChainIDs(endpoint string, chainName string) (string, string, error)
- func GetCodespaceURL(url string) (string, error)
- func GetDefaultBlockchainAirdropKeyName(blockchainName string) string
- func GetGitCommit(gitRepoURL string) string
- func GetIPPort(uri string) (netip.AddrPort, error)
- func GetIndexInSlice[T comparable](list []T, element T) (int, error)
- func GetJSONKey[T any](m map[string]interface{}, key string) (T, error)
- func GetKeyNames(keyDir string, includeEwoq bool) ([]string, error)
- func GetL1ValidatorUptimeSeconds(rpcURL string, nodeID ids.NodeID) (uint64, error)
- func GetNetworkBalance(address ids.ShortID, network models.Network) (uint64, error)
- func GetNodeID(endpoint string) (string, string, string, error)
- func GetNodeParams(nodeDir string) (ids.NodeID, []byte, []byte, error)
- func GetProcess(pid int) (*os.Process, error)
- func GetRealFilePath(path string) string
- func GetRemainingValidationTime(networkEndpoint string, nodeID ids.NodeID, subnetID ids.ID, ...) (time.Duration, error)
- func GetRemoteComposeFile() string
- func GetRemoteComposeServicePath(serviceName string, dirs ...string) string
- func GetRepoFromCommitURL(gitRepoURL string) (string, string)
- func GetSCPCommandString(certFilePath string, sourceIP, sourcePath string, destIP, destPath string, ...) (string, error)
- func GetSCPTargetPath(ip, path string) string
- func GetSHA256FromDisk(binPath string) (string, error)
- func GetSSHConnectionString(publicIP, certFilePath string) string
- func GetTimedContext(timeout time.Duration) (context.Context, context.CancelFunc)
- func GetURIHostPortAndPath(uri string) (string, uint32, string, error)
- func GetUserIPAddress() (string, error)
- func HandleTracking(cmd *cobra.Command, app interface{}, flags map[string]string)
- func HandleUserMetricsPreference(app interface{}) error
- func InsideCodespace() bool
- func IsE2E() bool
- func IsExecutable(filename string) bool
- func IsSSHAgentAvailable() bool
- func IsSSHAgentIdentityValid(identity string) (bool, error)
- func IsSSHPubKey(pubkey string) bool
- func IsUnsignedSlice(n []int) bool
- func IsValidIP(ipStr string) bool
- func IsValidIPPort(ipPortPair string) bool
- func IsValidSemanticVersion(version string, component string) bool
- func IsValidURL(urlString string) bool
- func ListSSHAgentIdentities() ([]string, error)
- func LogLevelToEmoji(logLevel string) (string, error)
- func MapWithError[T, U any](input []T, f func(T) (U, error)) ([]U, error)
- func MkDirWithTimestamp(dirPrefix string) (string, error)
- func NetworkIDFromGenesis(genesis []byte) (uint32, error)
- func NewBlsSecretKeyBytes() ([]byte, error)
- func NewLogger(logName string, logLevelStr string, defaultLogLevelStr string, logDir string, ...) (logging.Logger, error)
- func NonEmptyDirectory(dirName string) (bool, error)
- func PointersSlice[T any](input []T) []*T
- func PrintMetricsOptOutPrompt()
- func PrintUnreportedErrors(errors []error, returnedError error, print func(string, ...interface{}))
- func RandomString(length int) string
- func ReadFile(filePath string) (string, error)
- func ReadGoVersion(filePath string) (string, error)
- func ReadJSON(path string, v interface{}) error
- func ReadLongString(msg string, args ...interface{}) (string, error)
- func ReadSSHAgentIdentityPublicKey(identityName string) (string, error)
- func RemoveFromSlice[T comparable](input []T, toRemove T) []T
- func ReplaceUserHomeWithTilde(path string) string
- func ScriptLog(nodeID string, msg string, args ...interface{}) string
- func SearchSHA256File(file []byte, toSearch string) (string, error)
- func SetupExecFile(log logging.Logger, src string, dst string) error
- func SetupRealtimeCLIOutput(cmd *exec.Cmd, redirectStdout bool, redirectStderr bool) (*bytes.Buffer, *bytes.Buffer)
- func SizeInKB(path string) (int64, error)
- func SplitComaSeparatedInt(s string) []int
- func SplitComaSeparatedString(s string) []string
- func SplitKeyValueStringToMap(str string, delimiter string) (map[string]string, error)
- func SplitLuxgoRPCURI(requestURI string) (string, string, error)
- func SplitSCPPath(path string) (string, string)
- func SplitSliceAt[T any](slice []T, index int) ([]T, []T)
- func SplitStringWithQuotes(str string, r rune) []string
- func StringValue(data map[string]interface{}, key string) (string, error)
- func Sum(s []int) int
- func SupportedLuxdArch() []string
- func TimedFunction[T any](f func() (T, error), name string, timeout time.Duration) (T, error)
- func TimedFunctionWithRetry[T any](f func() (T, error), name string, timeout time.Duration, maxAttempts int, ...) (T, error)
- func ToBLSPoP(keyBytes []byte) ([]byte, []byte, error)
- func ToNodeID(certBytes []byte) (ids.NodeID, error)
- func TrackMetrics(command *cobra.Command, flags map[string]string)
- func TrimHexa(s string) string
- func Unique(slice []string) []string
- func UserHomePath(filePath ...string) string
- func VMID(vmName string) (ids.ID, error)
- func ValidateJSON(path string) ([]byte, error)
- func WriteJSON(path string, v interface{}) error
- func WriteStringToFile(filePath string, data string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddSingleQuotes ¶
AddSingleQuotes adds single quotes to each string in the given slice.
func AppendSlices ¶
func AppendSlices[T any](slices ...[]T) []T
AppendSlices appends multiple slices into a single slice.
func ArchSupported ¶
func CleanupString ¶
Cleans up a string by trimming \r and \n characters.
func CleanupStrings ¶
CleanupStrings cleans up a slice of strings by trimming \r and \n characters.
func CombineSCPPath ¶
CombineSCPPath combines the given host and path into a single item for scp.
func ContainsIgnoreCase ¶
ContainsIgnoreCase checks if the given string contains the specified substring, ignoring case.
func ConvertInterfaceToMap ¶
ConvertInterfaceToMap converts a given value to a map[string]interface{}.
func E2EConvertIP ¶
E2EConvertIP maps an IP address to an E2E IP address.
func ErrWrongArgCount ¶
func ExtractPlaceholderValue ¶
ExtractValueFromBytes extracts a value from a byte array using a regular expression.
func FileIsSubnetEVMGenesis ¶
func FindErrorLogs ¶
func FindErrorLogs(rootDirs ...string)
FindErrorLogs is a utility function, we will NOT do error handling, as this is supposed to be called during error handling itself we don't want to make it even more complex
func FormatAmount ¶
Formats an amount of base units as a string representing the amount in the given denomination. (i.e. An amount of 54321 with a decimals value of 3 results in the stirng "54.321")
func GetANRContext ¶
func GetANRContext() (context.Context, context.CancelFunc)
Context for ANR network operations
func GetAPIContext ¶
func GetAPIContext() (context.Context, context.CancelFunc)
Context for API requests
func GetAPILargeContext ¶
func GetAPILargeContext() (context.Context, context.CancelFunc)
Context for API requests with large timeout
func GetBlockchainTx ¶
func GetCLIVersion ¶
func GetCLIVersion() string
func GetCodespaceURL ¶
func GetGitCommit ¶
GetGitCommit takes a Git repository URL that contains commit ID and returns the commit ID Example: https://github.com/luxfi/hypersdk/pull/772/commits/b88acfb370f5aeb83a000aece2d72f28154410a5 Should return b88acfb370f5aeb83a000aece2d72f28154410a5
func GetIndexInSlice ¶
func GetIndexInSlice[T comparable](list []T, element T) (int, error)
func GetJSONKey ¶
GetJSONKey retrieves a value from a map by key and returns it as the specified type
func GetKeyNames ¶
GetKeyNames returns all key names in the key directory
func GetL1ValidatorUptimeSeconds ¶
GetL1ValidatorUptimeSeconds returns the uptime of the L1 validator
func GetNetworkBalance ¶
GetNetworkBalance returns the balance of an address on the P-chain
func GetNodeParams ¶
GetNodeParams returns node id, bls public key and bls proof of possession
func GetRealFilePath ¶
func GetRemoteComposeFile ¶
func GetRemoteComposeFile() string
RemoteComposeFile returns the path to the remote docker-compose file
func GetRemoteComposeServicePath ¶
GetRemoteComposeServicePath returns the path to the remote service directory
func GetRepoFromCommitURL ¶
GetRepoFromCommitURL takes a Git repository URL that contains commit ID and returns the cloneable Git Repo URL (ends in .git) and the repo directory name Example: https://github.com/luxfi/hypersdk/pull/772/commits/b88acfb370f5aeb83a000aece2d72f28154410a5 Should return https://github.com/luxfi/hypersdk
func GetSCPCommandString ¶
func GetSCPCommandString(certFilePath string, sourceIP, sourcePath string, destIP, destPath string, recursive, withCompression bool) (string, error)
GetSCPCommandString returns the SCP command string for the given source and destination paths.
func GetSCPTargetPath ¶
GetSCPTargetPath returns the target path for the given source path and target directory.
func GetSHA256FromDisk ¶
func GetSSHConnectionString ¶
GetSSHConnectionString returns the SSH connection string for the given public IP and certificate file path.
func GetTimedContext ¶
Timed Context
func GetURIHostPortAndPath ¶
Get the host, port and path from a URL.
func GetUserIPAddress ¶
GetUserIPAddress retrieves the IP address of the user.
func HandleTracking ¶
func HandleUserMetricsPreference ¶
func HandleUserMetricsPreference(app interface{}) error
func InsideCodespace ¶
func InsideCodespace() bool
func IsExecutable ¶
IsExecutable checks if a file is executable.
func IsSSHAgentAvailable ¶
func IsSSHAgentAvailable() bool
IsSSHAgentAvailable checks if the SSH agent is available.
func IsSSHAgentIdentityValid ¶
func IsSSHPubKey ¶
IsSSHPubKey checks if the given string is a valid SSH public key.
func IsUnsignedSlice ¶
IsUnsignedSlice returns true if all elements in the slice are unsigned integers.
func IsValidIPPort ¶
IsValidIPPort checks if an string IP:port pair is valid.
func IsValidSemanticVersion ¶
func ListSSHAgentIdentities ¶
ListSSHAgentIdentities returns a list of SSH identities from ssh-agent.
func LogLevelToEmoji ¶
func MapWithError ¶
func MkDirWithTimestamp ¶
func NetworkIDFromGenesis ¶
NetworkIDFromGenesis returns the network ID in the given genesis
func NewBlsSecretKeyBytes ¶
func NonEmptyDirectory ¶
func PointersSlice ¶
func PointersSlice[T any](input []T) []*T
func PrintMetricsOptOutPrompt ¶
func PrintMetricsOptOutPrompt()
func PrintUnreportedErrors ¶
func PrintUnreportedErrors( errors []error, returnedError error, print func(string, ...interface{}), )
PrintUnreportedErrors takes a list of errors obtained by a routine, and the main error it is going to report, and prints to the user the unreported errors only, avoiding duplications
func RandomString ¶
RandomString generates a random string of the specified length.
func ReadGoVersion ¶
ReadGoVersion reads the Go version from the go.mod file
func ReadLongString ¶
ReadLongString reads a long string from the user input.
func RemoveFromSlice ¶
func RemoveFromSlice[T comparable](input []T, toRemove T) []T
func ReplaceUserHomeWithTilde ¶
ReplaceUserHomeWithTilde replaces user home directory with ~
func SetupExecFile ¶
SetupExecFile copies a file into destination and set it to have exec perms, if destination either does not exists, or is not executable
func SetupRealtimeCLIOutput ¶
func SplitComaSeparatedInt ¶
SplitComaSeparatedInt splits a comma-separated string into a slice of integers.
func SplitComaSeparatedString ¶
SplitComaSeparatedString splits and trims a comma-separated string into a slice of strings.
func SplitKeyValueStringToMap ¶
SplitKeyValueStringToMap splits a string with multiple key-value pairs separated by delimiter. Delimiter must be a single character
func SplitLuxgoRPCURI ¶
SplitRPCURI splits the RPC URI into `endpoint` and `chain`. Reverse operation of `fmt.Sprintf("%s/ext/bc/%s", endpoint, chain)`. returns the `uri` and `chain` as strings, or an error if the request URI is invalid.
func SplitSCPPath ¶
SplitSCPPath splits the given path into host and path.
func SplitSliceAt ¶
SplitSliceAt splits a slice at the given index and returns two new slices.func SplitSliceAt[T any](slice []T, index int) ([]T, []T) {
func SplitStringWithQuotes ¶
SplitStringWithQuotes split string with a rune comma ignore quoted
func StringValue ¶
StringValue returns the value of a key in a map as a string.
func SupportedLuxdArch ¶
func SupportedLuxdArch() []string
func TimedFunction ¶
TimedFunction is a function that executes the given function `f` within a specified timeout duration.
func TimedFunctionWithRetry ¶
func TimedFunctionWithRetry[T any]( f func() (T, error), name string, timeout time.Duration, maxAttempts int, retryInterval time.Duration, ) (T, error)
TimedFunctionWithRetry is a function that executes the given function `f` within a specified timeout duration.
func UserHomePath ¶
UserHomePath returns the absolute path of a file located in the user's home directory.
func ValidateJSON ¶
ValidateJSON takes a json string and returns it's byte representation if it contains valid JSON
func WriteStringToFile ¶
WriteStringToFile writes a string to a file
Types ¶
This section is empty.