util

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddressToNodeID

func AddressToNodeID(address common.Address) int64

AddressToNodeID converts an Ethereum address into a deterministic node ID. The node ID is derived from the keccak256 hash of the address, matching the on-chain encoding. If n = 1,000,000 (# of operators): probability of collision ≈ 5.4 × 10^-8 (≈ 1 in 1.9 × 10^7)

func DeriveAddress

func DeriveAddress(pk ecdsa.PublicKey) common.Address

func DeriveAddressFromECDSAPrivateKey

func DeriveAddressFromECDSAPrivateKey(pk *ecdsa.PrivateKey) (common.Address, error)

func DeriveAddressFromECDSAPrivateKeyString

func DeriveAddressFromECDSAPrivateKeyString(key string) (common.Address, error)

func EncodeString

func EncodeString(str string) ([]byte, error)

func Filter

func Filter[A any](coll []A, criteria func(i A) bool) []A

Filter creates a new slice containing only the elements from the input slice that satisfy the provided criteria function.

Type Parameters:

  • A: The type of elements in the slice

Parameters:

  • coll: The input slice to filter
  • criteria: Function that determines whether an element should be included

Returns:

  • []A: A new slice containing only the elements that satisfy the criteria

func Find

func Find[A any](coll []*A, criteria func(i *A) bool) *A

Find returns the first element in a slice that satisfies the provided criteria function. If no element satisfies the criteria, nil is returned.

Type Parameters:

  • A: The type of elements in the slice

Parameters:

  • coll: The input slice to search
  • criteria: Function that determines whether an element matches

Returns:

  • *A: Pointer to the first matching element, or nil if no match is found

func Flatten

func Flatten[A any](coll [][]A) []A

Flatten combines multiple slices into a single slice.

Type Parameters:

  • A: The type of elements in the slices

Parameters:

  • coll: A slice of slices to flatten

Returns:

  • []A: A new slice containing all elements from all input slices

func Map

func Map[A any, B any](coll []A, mapper func(i A, index uint64) B) []B

Map applies a transformation function to each element of a slice and returns a new slice with the transformed values. This is a generic implementation of the map higher-order function.

Type Parameters:

  • A: The type of elements in the input slice
  • B: The type of elements in the output slice

Parameters:

  • coll: The input slice to transform
  • mapper: Function that transforms each element and receives the element's index

Returns:

  • []B: A new slice containing the transformed elements

func Reduce

func Reduce[A any, B any](coll []A, processor func(accum B, next A) B, initialState B) B

Reduce applies a function against an accumulator and each element in the slice to reduce it to a single value.

Type Parameters:

  • A: The type of elements in the input slice
  • B: The type of the accumulated result

Parameters:

  • coll: The input slice to reduce
  • processor: Function that combines the accumulator with each element
  • initialState: The initial value of the accumulator

Returns:

  • B: The final accumulated value

func StringToECDSAPrivateKey

func StringToECDSAPrivateKey(pk string) (*ecdsa.PrivateKey, error)

func ValidateAppID

func ValidateAppID(appID string) error

ValidateAppID validates that an application ID meets minimum requirements AppID must be at least 5 characters long

Types

This section is empty.

Jump to

Keyboard shortcuts

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