utils

package
v3.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsDuplicate

func ContainsDuplicate[T any](arr []T) bool

ContainsDuplicate checks if there are any duplicate elements in the slice.

func CreateRandomAccounts

func CreateRandomAccounts(numAccts int) []sdk.AccAddress

CreateRandomAccounts is a function return a list of randomly generated AccAddresses

func Filter

func Filter[T interface{}](filter func(T) bool, s []T) []T

func FilteredPaginateAccountBalances

func FilteredPaginateAccountBalances(
	ctx sdk.Context,
	bankKeeper types.BankKeeper,
	address sdk.AccAddress,
	pageRequest *query.PageRequest,
	onResult func(coin sdk.Coin, accumulate bool) bool,
) (*query.PageResponse, error)

func MakeNew

func MakeNew[T any]() T

MakeNew makes a new instance of generic T. if T is a pointer, makes a new instance of the underlying struct via reflection, and then a pointer to it.

func ParseSdkDecFromString

func ParseSdkDecFromString(s, separator string) ([]sdk.Dec, error)

func ParseSdkIntFromString

func ParseSdkIntFromString(s, separator string) ([]math.Int, error)

func ParseUint64SliceFromString

func ParseUint64SliceFromString(s, separator string) ([]uint64, error)

func ReverseSlice

func ReverseSlice[T any](s []T) []T

ReverseSlice reverses the input slice in place. Does mutate argument.

func SanitizeCoins

func SanitizeCoins(coins []sdk.Coin) sdk.Coins

SanitizeCoins takes an unsorted list of coins and sorts them, removes coins with amount zero and combines duplicate coins

func SortSlice

func SortSlice[T constraints.Ordered](s []T)

SortSlice sorts a slice of type T elements that implement constraints.Ordered. Mutates input slice s

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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