Documentation ¶
Index ¶
- Variables
- func ApplyFuncIfNoError(ctx sdk.Context, f func(ctx sdk.Context) error) (err error)
- func BinarySearch(f func(input sdk.Int) (sdk.Int, error), lowerbound sdk.Int, upperbound sdk.Int, ...) (sdk.Int, error)
- func CanCreateModuleAccountAtAddr(ctx sdk.Context, ak AccountKeeper, addr sdk.AccAddress) error
- func CoinsDenoms(coins sdk.Coins) []string
- func CreateModuleAccount(ctx sdk.Context, ak AccountKeeper, addr sdk.AccAddress) error
- func DefaultFeeString(cfg network.Config) string
- func Filter[T interface{}](filter func(T) bool, s []T) []T
- 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 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 GetValuesUntilDerivedStop[T any](storeObj store.KVStore, keyStart []byte, stopFn func([]byte) bool, ...) ([]T, error)
- func MinCoins(coinsA sdk.Coins, coinsB sdk.Coins) sdk.Coins
- func MustGet(store store.KVStore, key []byte, result proto.Message)
- func MustGetDec(store store.KVStore, key []byte) sdk.Dec
- func MustSet(storeObj store.KVStore, key []byte, value proto.Message)
- func MustSetDec(store store.KVStore, key []byte, value sdk.Dec)
- func ParseSdkIntFromString(s string, separator string) ([]sdk.Int, error)
- func ParseTimeString(s string) (time.Time, error)
- func ParseUint64SliceFromString(s string, separator string) ([]uint64, error)
- func PrintPanicRecoveryError(ctx sdk.Context, recoveryError interface{})
- func ReverseSlice[T any](s []T) []T
- func SortSlice[T constraints.Ordered](s []T)
- type AccountKeeper
- type ErrTolerance
- type Proposal
Constants ¶
This section is empty.
Variables ¶
var ProposalFlags = []string{ cli.FlagTitle, cli.FlagDescription, cli.FlagDeposit, }
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.
func BinarySearch ¶
func BinarySearch(f func(input sdk.Int) (sdk.Int, error), lowerbound sdk.Int, upperbound sdk.Int, targetOutput sdk.Int, errTolerance ErrTolerance, maxIterations int, ) (sdk.Int, error)
Binary search inputs between [lowerbound, upperbound] to a monotonic increasing function f. We stop once f(found_input) meets the ErrTolerance constraints. If we perform more than maxIterations (or equivalently lowerbound = upperbound), we return an error.
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 CoinsDenoms ¶
TODO: Get this into the SDK https://github.com/cosmos/cosmos-sdk/issues/12538
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 DefaultFeeString ¶
func FormatFixedLengthU64 ¶
func FormatTimeString ¶
func GatherAllKeysFromStore ¶
func GatherValuesFromStore ¶
func GetFirstValueInRange ¶
func GetIterValuesWithStop ¶
func MinCoins ¶
MinCoins returns the minimum of each denom between both coins. For now it assumes they have the same denoms. TODO: Replace with method in SDK once we update our version
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 ParseSdkIntFromString ¶
func ParseTimeString ¶
Parses a string encoded using FormatTimeString back into a time.Time
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 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 ¶
type AccountKeeper ¶
type ErrTolerance ¶
ErrTolerance is used to define a compare function, which checks if two ints are within a certain error tolerance of one another. ErrTolerance.Compare(a, b) returns true iff: |a - b| <= AdditiveTolerance |a - b| / min(a, b) <= MultiplicativeTolerance Each check is respectively ignored if the entry is nil (sdk.Dec{}, sdk.Int{}) Note that if AdditiveTolerance == 0, then this is equivalent to a standard compare.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
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 |