utils

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: May 8, 2025 License: CC0-1.0 Imports: 21 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Copyright (C) 2024, Ava Labs, Inc. All rights reserved. See the file LICENSE for licensing terms.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddressToNodeID added in v0.2.0

func AddressToNodeID(nodeID common.Address) ids.NodeID

Given nodeID in [20]bytes address format, return the [20]byte ids.NodeID format

func Any added in v0.2.0

func Any[T any](input []T, f func(T) bool) bool

func AppendSlices added in v0.2.0

func AppendSlices[T any](slices ...[]T) []T

AppendSlices appends multiple slices into a single slice.

func Belongs added in v0.2.0

func Belongs[T comparable](input []T, elem T) bool

func BytesToHex added in v0.2.0

func BytesToHex(b []byte) string

returns the hexadecimal string representation of the bytes b, prefixed with "0x".

func ConvertAvaxToWei added in v0.2.0

func ConvertAvaxToWei(avax float64) *big.Int

func ConvertNanoAvaxToWei added in v0.2.0

func ConvertNanoAvaxToWei(nanoAvax int64) *big.Int

func DecodeError added in v0.2.0

func DecodeError(abiStr string, err error) error

DecodeError decodes an error from an ABI string and an error. usage: err = DecodeError(abiStr, err)

func FetchRPC

func FetchRPC(url string, method string, params string) (string, error)

func FetchRPCGJSON

func FetchRPCGJSON(url string, method string, params string) (*gjson.Result, error)

func Filter added in v0.2.0

func Filter[T any](input []T, f func(T) bool) []T

func Find added in v0.2.0

func Find[T any](input []T, f func(T) bool) *T

func HexOrCB58ToID added in v0.2.0

func HexOrCB58ToID(s string) (ids.ID, error)

Converts a '0x'-prefixed hex string or cb58-encoded string to an ID.

func HexToBytes added in v0.2.0

func HexToBytes(s string) []byte

returns the bytes represented by the hexadecimal string s, may be prefixed with "0x".

func IsNil added in v0.2.0

func IsNil(v interface{}) bool

Safe nil checking on an interface, that does not panic

func Map added in v0.2.0

func Map[T, U any](input []T, f func(T) U) []U

func MapWithError added in v0.2.0

func MapWithError[T, U any](input []T, f func(T) (U, error)) ([]U, error)

func ParseNodeID added in v0.2.0

func ParseNodeID(nodeID string) (ids.NodeID, error)

Given nodeID in either 0x123 or NodeID-123 format, return the [20]byte ids.NodeID format

func ParsePrivateKey added in v0.2.0

func ParsePrivateKey(pkStr string) (avaKey *secp256k1.PrivateKey, ethKey *ecdsa.PrivateKey, err error)

Support PrivateKey-(cb58) or hex string with optional 0x prefix

func ParsePrivateKeyToAddresses added in v0.2.0

func ParsePrivateKeyToAddresses(privateKeyStr string, network string) (string, string, error)

Parse a private key and return the ava and eth addresses network is the network name (mainnet, fuji, etc)

func RandomBLS added in v0.2.0

func RandomBLS() (*bls.LocalSigner, *signer.ProofOfPossession, error)

func RandomID added in v0.2.0

func RandomID() (ids.ID, error)

func RandomNodeID added in v0.2.0

func RandomNodeID() (ids.NodeID, error)

func RegisterL1ValidatorToJSON added in v0.2.0

func RegisterL1ValidatorToJSON(m *message.RegisterL1Validator) ([]byte, error)

Better JSON output for RegisterL1Validator

func RemoveFromSlice added in v0.2.0

func RemoveFromSlice[T comparable](input []T, toRemove T) []T

func Unique added in v0.2.0

func Unique[T comparable](arr []T) []T

func ValidateBLSKeys added in v0.2.0

func ValidateBLSKeys(blsPubKey string, blsPop string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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