Documentation ¶
Index ¶
- func ApplyFuncIfNoError(ctx sdk.Context, f func(ctx sdk.Context) error) (err error)
- func ContainsDuplicate[T any](arr []T) bool
- func CreateRandomAccounts(numAccts int) []sdk.AccAddress
- func Filter[T interface{}](filter func(T) bool, s []T) []T
- func FilteredPaginateAccountBalances(ctx sdk.Context, bankKeeper types.BankKeeper, address sdk.AccAddress, ...) (*query.PageResponse, error)
- func IsOutOfGasError(err any) (bool, string)
- func MakeNew[T any]() T
- func ParseSdkDecFromString(s, separator string) ([]sdk.Dec, error)
- func ParseSdkIntFromString(s, separator string) ([]math.Int, error)
- func ParseUint64SliceFromString(s, separator string) ([]uint64, error)
- func PrintPanicRecoveryError(ctx sdk.Context, recoveryError interface{})
- func ReverseSlice[T any](s []T) []T
- func SanitizeCoins(coins []sdk.Coin) sdk.Coins
- func SortSlice[T constraints.Ordered](s []T)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyFuncIfNoError ¶
This function lets you run the function f, but if theres an error or panic drop the state machine change and log the error. If there is no error, proceeds as normal (but with some slowdown due to SDK store weirdness) Try to avoid usage of iterators in f.
If its an out of gas panic, this function will also panic like in normal tx execution flow. This is still safe for beginblock / endblock code though, as they do not have out of gas panics.
func ContainsDuplicate ¶
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 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 IsOutOfGasError ¶
Frustratingly, this has to return the error descriptor, not an actual error itself because the SDK errors here are not actually errors. (They don't implement error interface)
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 PrintPanicRecoveryError ¶
PrintPanicRecoveryError error logs the recoveryError, along with the stacktrace, if it can be parsed. If not emits them to stdout.
func ReverseSlice ¶
func ReverseSlice[T any](s []T) []T
ReverseSlice reverses the input slice in place. Does mutate argument.
func SanitizeCoins ¶
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.