Documentation ¶
Index ¶
- Constants
- Variables
- func AddDecCoinArrays(decCoinsArrayA []sdk.DecCoins, decCoinsArrayB []sdk.DecCoins) ([]sdk.DecCoins, error)
- func ApplyFuncIfNoError(ctx sdk.Context, f func(ctx sdk.Context) error) (err error)
- func CWCoinFromSDKCoin(in sdk.Coin) wasmvmtypes.Coin
- func CWCoinsFromSDKCoins(in sdk.Coins) wasmvmtypes.Coins
- func CanCreateModuleAccountAtAddr(ctx sdk.Context, ak AccountKeeper, addr sdk.AccAddress) error
- func CollapseDecCoinsArray(decCoinsArray []sdk.DecCoins) sdk.DecCoins
- func Contains[T comparable](slice []T, item T) bool
- func ContainsDuplicate[T any](arr []T) bool
- func ContainsDuplicateDeepEqual[T any](multihops []T) bool
- func ConvertCoinArrayToCoins(coinArray []sdk.Coin) sdk.Coins
- func ConvertCoinsToDecCoins(coins sdk.Coins) sdk.DecCoins
- func CreateModuleAccount(ctx sdk.Context, ak AccountKeeper, addr sdk.AccAddress) error
- func CreateRandomAccounts(numAccts int) []sdk.AccAddress
- func DefaultFeeString(cfg network.Config) string
- func DeleteAllKeysFromPrefix(store store.KVStore, prefixKey []byte)
- func DisjointArrays(a, b []uint64) []uint64
- func EmitIBCErrorEvents(ctx sdk.Context, err error, errorContexts []string)
- func Filter[T interface{}](filter func(T) bool, s []T) []T
- func FilterDenoms(coins sdk.Coins, denoms []string) sdk.Coins
- func FormatFixedLengthU64(d uint64) string
- func FormatTimeString(t time.Time) string
- func GatherAllKeysFromStore(storeObj store.KVStore) []string
- func GatherValuesFromStore[T any](storeObj store.KVStore, keyStart []byte, keyEnd []byte, ...) ([]T, error)
- func GatherValuesFromStorePrefix[T any](storeObj store.KVStore, prefix []byte, parseValue func([]byte) (T, error)) ([]T, error)
- func GatherValuesFromStorePrefixWithKeyParser[T any](storeObj store.KVStore, prefix []byte, ...) ([]T, error)
- func Get(store store.KVStore, key []byte, result proto.Message) (found bool, err error)
- func GetCoinArrayFromPrefix(ctx sdk.Context, storeKey storetypes.StoreKey, storePrefix []byte) []sdk.Coin
- func GetCoinByDenomFromPrefix(ctx sdk.Context, storeKey storetypes.StoreKey, storePrefix []byte, ...) (sdk.Coin, error)
- func GetDec(store store.KVStore, key []byte) (osmomath.Dec, error)
- func GetFirstValueAfterPrefixInclusive[T any](storeObj store.KVStore, keyStart []byte, parseValue func([]byte) (T, error)) (T, error)
- func GetFirstValueInRange[T any](storeObj store.KVStore, keyStart []byte, keyEnd []byte, reverseIterate bool, ...) (T, error)
- func GetIterValuesWithStop[T any](storeObj store.KVStore, keyStart []byte, keyEnd []byte, reverse bool, ...) ([]T, error)
- func GetRandomSubset[T any](slice []T) []T
- func GetValuesUntilDerivedStop[T any](storeObj store.KVStore, keyStart []byte, stopFn func([]byte) bool, ...) ([]T, error)
- func HasAnyAtPrefix[T any](storeObj store.KVStore, prefix []byte, parseValue func([]byte) (T, error)) (bool, error)
- func IncreaseCoinByDenomFromPrefix(ctx sdk.Context, storeKey storetypes.StoreKey, storePrefix []byte, ...) error
- func IsAckError(acknowledgement []byte) bool
- func IsOutOfGasError(err any) (bool, string)
- func MakeNew[T any]() T
- func Max(values ...interface{}) interface{}
- func MergeCoinMaps[T comparable](currentEpochExpectedDistributionsOne map[T]sdk.Coins, ...) map[T]sdk.Coins
- func MergeSlices[T any](slice1, slice2 []T, less LessFunc[T]) []T
- func MustExtractDenomFromPacketOnRecv(packet ibcexported.PacketI) string
- func MustGet(store store.KVStore, key []byte, result proto.Message)
- func MustGetDec(store store.KVStore, key []byte) osmomath.Dec
- func MustSet(storeObj store.KVStore, key []byte, value proto.Message)
- func MustSetDec(store store.KVStore, key []byte, value osmomath.Dec)
- func NewEmitErrorAcknowledgement(ctx sdk.Context, err error, errorContexts ...string) channeltypes.Acknowledgement
- func NewModuleAddressWithPrefix(moduleName, prefix string, identifier []byte) sdk.AccAddress
- func NewSuccessAckRepresentingAnError(ctx sdk.Context, err error, errorContent []byte, errorContexts ...string) channeltypes.Acknowledgement
- func ParseBool(opts servertypes.AppOptions, groupOptName, optName string, defaultValue bool) bool
- func ParseInt(opts servertypes.AppOptions, groupOptName, optName string) int
- func ParseSdkDecFromString(s string, separator string) ([]osmomath.Dec, error)
- func ParseSdkIntFromString(s string, separator string) ([]osmomath.Int, error)
- func ParseString(opts servertypes.AppOptions, groupOptName, optName string) string
- func ParseStringToUint64Slice(input string) ([]uint64, error)
- func ParseTimeString(s string) (time.Time, error)
- func ParseUint64Slice(opts servertypes.AppOptions, groupOptName, optName string) []uint64
- func ParseUint64SliceFromString(s string, separator string) ([]uint64, error)
- func PrintPanicRecoveryError(ctx sdk.Context, recoveryError interface{})
- func ReverseSlice[T any](s []T) []T
- func SafeSubDecCoinArrays(decCoinsArrayA []sdk.DecCoins, decCoinsArrayB []sdk.DecCoins) ([]sdk.DecCoins, error)
- func SortSlice[T constraints.Ordered](s []T)
- func SubDecCoinArrays(decCoinsArrayA []sdk.DecCoins, decCoinsArrayB []sdk.DecCoins) ([]sdk.DecCoins, error)
- func Uint64ToBytes(i uint64) []byte
- func Uint64ToString(i uint64) string
- func ValidateAddressList(i interface{}) error
- type AccountKeeper
- type DecNotFoundError
- type LessFunc
- type Proposal
Constants ¶
const IbcAcknowledgementErrorType = "ibc-acknowledgement-error"
Variables ¶
var (
ErrNoValuesInRange = errors.New("No values in range")
)
var OsmoUtilsExtraAccountTypes map[reflect.Type]struct{}
OsmoUtilsExtraAccountTypes is a map of extra account types that can be overridden. This is defined as a global variable so it can be modified in the chain's app.go and used here without having to import the chain. Specifically, this is used for compatibility with Osmosis' Cosmos SDK fork
var ProposalFlags = []string{ cli.FlagTitle, cli.FlagDescription, cli.FlagDeposit, }
Functions ¶
func AddDecCoinArrays ¶ added in v0.0.5
func AddDecCoinArrays(decCoinsArrayA []sdk.DecCoins, decCoinsArrayB []sdk.DecCoins) ([]sdk.DecCoins, error)
AddDecCoinArrays adds the contents of the second param from the first (decCoinsArrayA + decCoinsArrayB) Note that this takes in two _arrays_ of DecCoins, meaning that each term itself is of type DecCoins (i.e. an array of DecCoin).
func ApplyFuncIfNoError ¶
This function lets you run the function f, but if there's 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 CWCoinFromSDKCoin ¶ added in v0.0.8
func CWCoinFromSDKCoin(in sdk.Coin) wasmvmtypes.Coin
Convert sdk.Coin to wasmvmtypes.Coin
func CWCoinsFromSDKCoins ¶ added in v0.0.8
func CWCoinsFromSDKCoins(in sdk.Coins) wasmvmtypes.Coins
Convert sdk.Coins to wasmvmtypes.Coins
func CanCreateModuleAccountAtAddr ¶
func CanCreateModuleAccountAtAddr(ctx sdk.Context, ak AccountKeeper, addr sdk.AccAddress) error
CanCreateModuleAccountAtAddr tells us if we can safely make a module account at a given address. By collision resistance of the address (given API safe construction), the only way for an account to be already be at this address is if its claimed by the same pre-image from the correct module, or some SDK command breaks assumptions and creates an account at designated address. This function checks if there is an account at that address, and runs some safety checks to be extra-sure its not a user account (e.g. non-zero sequence, pubkey, of fore-seen account types). If there is no account, or if we believe its not a user-spendable account, we allow module account creation at the address. else, we do not.
TODO: This is generally from an SDK design flaw code based off wasmd code: https://github.com/CosmWasm/wasmd/pull/996 Its _mandatory_ that the caller do the API safe construction to generate a module account addr, namely, address.Module(ModuleName, {key})
func CollapseDecCoinsArray ¶ added in v0.0.5
CollapseDecCoinsArray takes an array of DecCoins and returns the sum of all the DecCoins in the array.
func Contains ¶ added in v0.0.5
func Contains[T comparable](slice []T, item T) bool
Contains returns true if the slice contains the item, false otherwise.
func ContainsDuplicate ¶
ContainsDuplicate checks if there are any duplicate elements in the slice.
func ContainsDuplicateDeepEqual ¶ added in v0.0.5
ContainsDuplicateDeepEqual returns true if there are duplicates in the slice by performing deep comparison. This is useful for comparing matrices or slices of pointers. Returns false if there are no deep equal duplicates.
func ConvertCoinArrayToCoins ¶ added in v0.0.8
func ConvertCoinsToDecCoins ¶ added in v0.0.5
ConvertCoinsToDecCoins takes sdk.Coins and converts it to sdk.DecCoins
func CreateModuleAccount ¶
func CreateModuleAccount(ctx sdk.Context, ak AccountKeeper, addr sdk.AccAddress) error
CreateModuleAccount creates a module account at the provided address. It overrides an account if it exists at that address, with a non-zero sequence number & pubkey Contract: addr is derived from `address.Module(ModuleName, key)`
func CreateRandomAccounts ¶
func CreateRandomAccounts(numAccts int) []sdk.AccAddress
CreateRandomAccounts is a function return a list of randomly generated AccAddresses
func DefaultFeeString ¶
func DeleteAllKeysFromPrefix ¶ added in v0.0.5
DeleteAllKeysFromPrefix deletes all store records that contains the given prefixKey.
func DisjointArrays ¶ added in v0.0.8
DifferenceBetweenUint64Arrays takes two slices of uint64, 'a' and 'b', as input. It returns a new slice containing the elements that are unique to either 'a' or 'b'. The function uses two maps for efficient lookup of elements.
Example: a := []uint64{1, 2, 3, 4, 5} b := []uint64{4, 5, 6, 7, 8} result := DisjointArrays(a, b) result will be []uint64{1, 2, 3, 6, 7, 8}
Note: This function returns the difference between the two arrays in ascending order, and does not preserve the order of the elements in the original arrays.
func EmitIBCErrorEvents ¶ added in v0.0.6
EmitIBCErrorEvents Emit and Log errors
func FilterDenoms ¶ added in v0.0.8
FilterDenoms returns the coins with only the passed in denoms
func FormatFixedLengthU64 ¶
func FormatTimeString ¶
func GatherAllKeysFromStore ¶
func GatherValuesFromStore ¶
func GatherValuesFromStorePrefix ¶
func GatherValuesFromStorePrefix[T any](storeObj store.KVStore, prefix []byte, parseValue func([]byte) (T, error)) ([]T, error)
GatherValuesFromStorePrefix is a decorator around GatherValuesFromStorePrefixWithKeyParser. It overwrites the parse function to disable parsing keys, only keeping values
func GatherValuesFromStorePrefixWithKeyParser ¶ added in v0.0.4
func GatherValuesFromStorePrefixWithKeyParser[T any](storeObj store.KVStore, prefix []byte, parse func(key []byte, value []byte) (T, error)) ([]T, error)
GatherValuesFromStorePrefixWithKeyParser is a helper function that gathers values from a given store prefix. While iterating through the entries, it parses both key and the value using the provided parse function to return the desired type. Returns error if: - the parse function returns an error. - internal database error
func Get ¶
Get returns a value at key by mutating the result parameter. Returns true if the value was found and the result mutated correctly. If the value is not in the store, returns false. Returns error only when database or serialization errors occur. (And when an error occurs, returns false)
func GetCoinArrayFromPrefix ¶ added in v0.0.8
func GetCoinArrayFromPrefix(ctx sdk.Context, storeKey storetypes.StoreKey, storePrefix []byte) []sdk.Coin
GetCoinArrayFromPrefix returns all coins from the store that has the given prefix.
func GetCoinByDenomFromPrefix ¶ added in v0.0.8
func GetCoinByDenomFromPrefix(ctx sdk.Context, storeKey storetypes.StoreKey, storePrefix []byte, denom string) (sdk.Coin, error)
GetCoinByDenomFromPrefix returns the coin from the store that has the given prefix and denom. If the denom is not found, a zero coin is returned.
func GetDec ¶ added in v0.0.5
GetDec gets dec value from store at key. Returns error if: - database error occurs. - no value at given key is found.
func GetFirstValueInRange ¶
func GetIterValuesWithStop ¶
func GetRandomSubset ¶ added in v0.0.6
func GetRandomSubset[T any](slice []T) []T
GetRandomSubset returns a random subset of the given slice
func HasAnyAtPrefix ¶ added in v0.0.5
func HasAnyAtPrefix[T any](storeObj store.KVStore, prefix []byte, parseValue func([]byte) (T, error)) (bool, error)
HasAnyAtPrefix returns true if there is at least one value in the given prefix.
func IncreaseCoinByDenomFromPrefix ¶ added in v0.0.8
func IncreaseCoinByDenomFromPrefix(ctx sdk.Context, storeKey storetypes.StoreKey, storePrefix []byte, denom string, increasedAmt osmomath.Int) error
IncreaseCoinByDenomFromPrefix increases the coin from the store that has the given prefix and denom by the specified amount.
func IsAckError ¶
IsAckError checks an IBC acknowledgement to see if it's an error. This is a replacement for ack.Success() which is currently not working on some circumstances
func IsOutOfGasError ¶ added in v0.0.4
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 Max ¶ added in v0.0.5
func Max(values ...interface{}) interface{}
Max returns the maximum value among the given values of any type that supports comparison.
func MergeCoinMaps ¶ added in v0.0.8
func MergeCoinMaps[T comparable](currentEpochExpectedDistributionsOne map[T]sdk.Coins, poolIDToExpectedDistributionMapOne map[T]sdk.Coins) map[T]sdk.Coins
MergeCoinMaps takes two maps of type map[T]sdk.Coins and merges them together, adding the values of the second map to the first.
func MergeSlices ¶ added in v0.0.5
MergeSlices efficiently merges two sorted slices into a single sorted slice. The resulting slice contains all elements from slice1 and slice2, sorted according to the less function. The input slices must be sorted in ascending order according to the less function. The less function takes two elements of type T and returns a boolean value indicating whether the first element is less than the second element. The function returns a new slice containing all elements from slice1 and slice2, sorted according to the less function. The function does not modify the input slices.
func MustExtractDenomFromPacketOnRecv ¶
func MustExtractDenomFromPacketOnRecv(packet ibcexported.PacketI) string
MustExtractDenomFromPacketOnRecv takes a packet with a valid ICS20 token data in the Data field and returns the denom as represented in the local chain. If the data cannot be unmarshalled this function will panic
func MustGetDec ¶
MustGetDec gets dec value from store at key. Panics on any error.
func MustSetDec ¶
MustSetDec sets dec value to store at key. Panics on any error.
func NewEmitErrorAcknowledgement ¶ added in v0.0.3
func NewEmitErrorAcknowledgement(ctx sdk.Context, err error, errorContexts ...string) channeltypes.Acknowledgement
NewEmitErrorAcknowledgement creates a new error acknowledgement after having emitted an event with the details of the error.
func NewModuleAddressWithPrefix ¶ added in v0.0.5
func NewModuleAddressWithPrefix(moduleName, prefix string, identifier []byte) sdk.AccAddress
NewModuleAddressWithPrefix returns a new module address with the given prefix and identifier.
func NewSuccessAckRepresentingAnError ¶ added in v0.0.6
func NewSuccessAckRepresentingAnError(ctx sdk.Context, err error, errorContent []byte, errorContexts ...string) channeltypes.Acknowledgement
NewSuccessAckRepresentingAnError creates a new success acknowledgement that represents an error. This is useful for notifying the sender that an error has occurred in a way that does not allow the received tokens to be reverted (which means they shouldn't be released by the sender's ics20 escrow)
func ParseBool ¶ added in v0.0.8
func ParseBool(opts servertypes.AppOptions, groupOptName, optName string, defaultValue bool) bool
ParseBool parses a boolean value from a server type option.
func ParseInt ¶ added in v0.0.8
func ParseInt(opts servertypes.AppOptions, groupOptName, optName string) int
ParseInt parses an integer value from a server type option.
func ParseSdkDecFromString ¶
func ParseSdkIntFromString ¶
func ParseString ¶ added in v0.0.8
func ParseString(opts servertypes.AppOptions, groupOptName, optName string) string
ParseString parses a string value from a server type option.
func ParseStringToUint64Slice ¶ added in v0.0.8
ParseStringToUint64Slice parses a string to a slice of uint64 values.
func ParseTimeString ¶
Parses a string encoded using FormatTimeString back into a time.Time
func ParseUint64Slice ¶ added in v0.0.8
func ParseUint64Slice(opts servertypes.AppOptions, groupOptName, optName string) []uint64
ParseUint64 parses a uint64 value from a server type option.
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 SafeSubDecCoinArrays ¶ added in v0.0.6
func SafeSubDecCoinArrays(decCoinsArrayA []sdk.DecCoins, decCoinsArrayB []sdk.DecCoins) ([]sdk.DecCoins, error)
SafeSubDecCoinArrays subtracts the contents of the second param from the first (decCoinsArrayA - decCoinsArrayB) Note that this takes in two _arrays_ of DecCoins, meaning that each term itself is of type DecCoins (i.e. an array of DecCoin). Contrary to SubDecCoinArrays, this subtractions allows for negative result values.
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
func SubDecCoinArrays ¶ added in v0.0.5
func SubDecCoinArrays(decCoinsArrayA []sdk.DecCoins, decCoinsArrayB []sdk.DecCoins) ([]sdk.DecCoins, error)
SubDecCoinArrays subtracts the contents of the second param from the first (decCoinsArrayA - decCoinsArrayB) Note that this takes in two _arrays_ of DecCoins, meaning that each term itself is of type DecCoins (i.e. an array of DecCoin).
func Uint64ToBytes ¶
func Uint64ToString ¶
func ValidateAddressList ¶ added in v0.0.8
func ValidateAddressList(i interface{}) error
ValidateAddressList validates a slice of addresses.
Parameters: - i: The parameter to validate.
Returns: - An error if any of the strings are not addresses
Types ¶
type AccountKeeper ¶
type DecNotFoundError ¶ added in v0.0.5
type DecNotFoundError struct {
Key string
}
func (DecNotFoundError) Error ¶ added in v0.0.5
func (e DecNotFoundError) Error() string
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
package accumulator allows one to define an accumulator to accommodate constant-rate (linear) distribution mechanisms with constant runtime and linear memory
|
package accumulator allows one to define an accumulator to accommodate constant-rate (linear) distribution mechanisms with constant runtime and linear memory |
package partialord allows one to define partial orderings, and derive a total ordering
|
package partialord allows one to define partial orderings, and derive a total ordering |
internal/dag
Package dag implements a simple Directed Acyclical Graph (DAG) for deterministic topological sorts
|
Package dag implements a simple Directed Acyclical Graph (DAG) for deterministic topological sorts |