Documentation ¶
Index ¶
- Variables
- func ApplyFuncIfNoError(ctx sdk.Context, f func(ctx sdk.Context) error) (err error)
- func ApplyFuncIfNoErrorLogToDebug(ctx sdk.Context, f func(ctx sdk.Context) error) (err error)
- func ChargeMockReadGas(ctx sdk.Context, gasFlat, gasKey, gasVal uint64)
- func DeleteAllKeysFromPrefix(store storetypes.KVStore, prefixKey []byte)
- func GatherAllKeysFromStore(storeObj storetypes.KVStore) []string
- func GatherValuesFromStore[T any](storeObj storetypes.KVStore, keyStart []byte, keyEnd []byte, ...) ([]T, error)
- func GatherValuesFromStorePrefix[T any](storeObj storetypes.KVStore, prefix []byte, parseValue func([]byte) (T, error)) ([]T, error)
- func GatherValuesFromStorePrefixWithKeyParser[T any](storeObj storetypes.KVStore, prefix []byte, ...) ([]T, error)
- func Get(store storetypes.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 storetypes.KVStore, key []byte) (math.LegacyDec, error)
- func GetFirstValueAfterPrefixInclusive[T any](storeObj storetypes.KVStore, keyStart []byte, ...) (T, error)
- func GetFirstValueInRange[T any](storeObj storetypes.KVStore, keyStart []byte, keyEnd []byte, ...) (T, error)
- func GetIterValuesWithStop[T any](storeObj storetypes.KVStore, keyStart []byte, keyEnd []byte, reverse bool, ...) ([]T, error)
- func GetValuesUntilDerivedStop[T any](storeObj storetypes.KVStore, keyStart []byte, stopFn func([]byte) bool, ...) ([]T, error)
- func HasAnyAtPrefix[T any](storeObj storetypes.KVStore, prefix []byte, parseValue func([]byte) (T, error)) (bool, error)
- func IncreaseCoinByDenomFromPrefix(ctx sdk.Context, storeKey storetypes.StoreKey, storePrefix []byte, ...) error
- func IsOutOfGasError(err any) (bool, string)
- func MustGet(store storetypes.KVStore, key []byte, result proto.Message)
- func MustGetDec(store storetypes.KVStore, key []byte) math.LegacyDec
- func MustSet(storeObj storetypes.KVStore, key []byte, value proto.Message)
- func MustSetDec(store storetypes.KVStore, key []byte, value math.LegacyDec)
- func PrintPanicRecoveryError(ctx sdk.Context, recoveryError interface{})
- func TrackGasUsedInGet(store storetypes.KVStore, key []byte, result proto.Message) (found bool, gasFlat, gasKey, gasVal uint64, err error)
- type DecNotFoundError
Constants ¶
This section is empty.
Variables ¶
var (
ErrNoValuesInRange = errors.New("No values in range")
)
Functions ¶
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 ApplyFuncIfNoErrorLogToDebug ¶
ApplyFuncIfNoErrorLogToDebug is the same as ApplyFuncIfNoError, but sends logs to debug instead of error if there is an error.
func ChargeMockReadGas ¶
func DeleteAllKeysFromPrefix ¶
func DeleteAllKeysFromPrefix(store storetypes.KVStore, prefixKey []byte)
DeleteAllKeysFromPrefix deletes all store records that contains the given prefixKey.
func GatherAllKeysFromStore ¶
func GatherAllKeysFromStore(storeObj storetypes.KVStore) []string
func GatherValuesFromStore ¶
func GatherValuesFromStorePrefix ¶
func GatherValuesFromStorePrefix[T any](storeObj storetypes.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 ¶
func GatherValuesFromStorePrefixWithKeyParser[T any](storeObj storetypes.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 ¶
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 ¶
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 ¶
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 HasAnyAtPrefix ¶
func HasAnyAtPrefix[T any](storeObj storetypes.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 ¶
func IncreaseCoinByDenomFromPrefix(ctx sdk.Context, storeKey storetypes.StoreKey, storePrefix []byte, denom string, increasedAmt math.Int) error
IncreaseCoinByDenomFromPrefix increases the coin from the store that has the given prefix and denom by the specified amount.
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 MustGet ¶
func MustGet(store storetypes.KVStore, key []byte, result proto.Message)
MustGet gets key from store by mutating result Panics on any error.
func MustGetDec ¶
func MustGetDec(store storetypes.KVStore, key []byte) math.LegacyDec
MustGetDec gets dec value from store at key. Panics on any error.
func MustSet ¶
func MustSet(storeObj storetypes.KVStore, key []byte, value proto.Message)
MustSet runs store.Set(key, proto.Marshal(value)) but panics on any error.
func MustSetDec ¶
func MustSetDec(store storetypes.KVStore, key []byte, value math.LegacyDec)
MustSetDec sets dec value to store at key. Panics on any error.
func PrintPanicRecoveryError ¶
PrintPanicRecoveryError error logs the recoveryError, along with the stacktrace, if it can be parsed. If not emits them to stdout.
func TrackGasUsedInGet ¶
func TrackGasUsedInGet(store storetypes.KVStore, key []byte, result proto.Message) (found bool, gasFlat, gasKey, gasVal uint64, err error)
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)
This function also returns three gas numbers: Gas flat, gas for key read, gas for value read. You must charge all 3 for the gas accounting to be correct in the current SDK version. nolint
Types ¶
type DecNotFoundError ¶
type DecNotFoundError struct {
Key string
}
func (DecNotFoundError) Error ¶
func (e DecNotFoundError) Error() string