Documentation
¶
Index ¶
- func CompositeKey(parts ...[]byte) []byte
- func ComputeTokensFromShares(shares sdk.DecCoins, delegatedTokens sdk.Coins, delegatorShares sdk.DecCoins) sdk.DecCoins
- func ComputeTokensFromSharesTruncated(shares sdk.DecCoins, delegatedTokens sdk.Coins, delegatorShares sdk.DecCoins) sdk.DecCoins
- func DenomsSubsetOf(coins sdk.DecCoins, coinsB sdk.DecCoins) bool
- func DeserializeFungibleTokenPacketData(packetData []byte) (ics20data transfertypes.FungibleTokenPacketData, isIcs20 bool)
- func Filter[T any](slice []T, f func(T) bool) []T
- func FilterCoinsByDenom(coins, coinsB sdk.Coins) sdk.Coins
- func FilterDecCoinsByDenom(coins, coinsB sdk.DecCoins) sdk.DecCoins
- func Find[T any](slice []T, searchFunction func(T) bool) (*T, bool)
- func FindDuplicate[T comparable](slice []T) *T
- func FindDuplicateFunc[T any](slice []T, compare func(a T, b T) bool) *T
- func GetSharesDenomFromTokenDenom(prefix string, id uint32, tokenDenom string) string
- func GetTokenDenomFromSharesDenom(sharesDenom string) string
- func Intersect[T comparable](a, b []T) []T
- func IsAllGT(coins, coinsB sdk.DecCoins) bool
- func IsAllGTE(coins, coinsB sdk.DecCoins) bool
- func IsAnyGT(coins, coinsB sdk.DecCoins) bool
- func IsAnyLT(coins, coinsB sdk.DecCoins) bool
- func IsInvalidExRate(delegatedTokens sdk.Coins, delegatorsShares sdk.DecCoins) bool
- func IsKeySetEmpty[K any](ctx sdk.Context, collectionMap collections.KeySet[K], ...) (bool, error)
- func IsMapEmpty[K, V any](ctx sdk.Context, collectionMap collections.Map[K, V], ...) (bool, error)
- func IssueShares(amount sdk.Coins, getShareDenom ShareDenomGetter, delegatedTokens sdk.Coins, ...) sdk.DecCoins
- func JSONStringHasKey(data, key string) (found bool, jsonObject map[string]interface{})
- func Map[T, U any](slice []T, f func(T) U) []U
- func MapGetOrDefault[K, V any](ctx sdk.Context, collectionMap collections.Map[K, V], key K, ...) (V, error)
- func MustParseCoin(s string) sdk.Coin
- func MustParseCoins(s string) sdk.Coins
- func MustParseDec(s string) sdkmath.LegacyDec
- func MustParseDecCoins(s string) sdk.DecCoins
- func Remove[T comparable](slice []T, value T) (newSlice []T, removed bool)
- func RemoveDuplicates[T comparable](slice []T) []T
- func SharesFromDecCoins(tokens sdk.DecCoins, getShareDenom ShareDenomGetter, delegatedTokens sdk.Coins, ...) (sdk.DecCoins, error)
- func SharesFromTokens(tokens sdk.Coins, getShareDenom ShareDenomGetter, delegatedTokens sdk.Coins, ...) (sdk.DecCoins, error)
- func SharesFromTokensTruncated(tokens sdk.Coins, getShareDenom ShareDenomGetter, delegatedTokens sdk.Coins, ...) (sdk.DecCoins, error)
- func Uint32ToBigEndian(i uint32) []byte
- type ShareDenomGetter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompositeKey ¶
func ComputeTokensFromShares ¶
func ComputeTokensFromShares(shares sdk.DecCoins, delegatedTokens sdk.Coins, delegatorShares sdk.DecCoins) sdk.DecCoins
ComputeTokensFromShares calculates the token worth of provided shares.
func ComputeTokensFromSharesTruncated ¶
func ComputeTokensFromSharesTruncated(shares sdk.DecCoins, delegatedTokens sdk.Coins, delegatorShares sdk.DecCoins) sdk.DecCoins
ComputeTokensFromSharesTruncated calculates the token worth of provided shares, truncated.
func DenomsSubsetOf ¶
DenomsSubsetOf returns true if receiver's denom set is subset of coinsB's denoms.
func DeserializeFungibleTokenPacketData ¶
func DeserializeFungibleTokenPacketData(packetData []byte) (ics20data transfertypes.FungibleTokenPacketData, isIcs20 bool)
DeserializeFungibleTokenPacketData deserializes the packet data and returns the FungibleTokenPacketData
func FilterCoinsByDenom ¶
FilterCoinsByDenom returns the intersection of two coins. e.g. FilterCoinsByDenom({2A, 3B}, {A}) = {2A} FilterCoinsByDenom({2A, 3B}, {5C}) = {} FilterCoinsByDenom({2A, 3B}, {A, B}) = {2A, 3B}
func FilterDecCoinsByDenom ¶
FilterDecCoinsByDenom returns the intersection of two coins. e.g. FilterDecCoinsByDenom{2A, 3B}, {A}) = {2A} FilterDecCoinsByDenom({2A, 3B}, {5C}) = {} FilterDecCoinsByDenom({2A, 3B}, {A, B}) = {2A, 3B}
func Find ¶
Find returns the first element in the slice that satisfies the given predicate, or false if none is found.
func FindDuplicate ¶
func FindDuplicate[T comparable](slice []T) *T
FindDuplicate returns the first duplicate element in the slice. If no duplicates are found, it returns nil instead.
func FindDuplicateFunc ¶
FindDuplicateFunc returns the first duplicate element in the slice. If no duplicates are found, it returns nil instead.
func GetSharesDenomFromTokenDenom ¶
GetSharesDenomFromTokenDenom returns the shares denom from the token denom. The returned shares denom will be in the format "{prefix}/{id}/{tokenDenom}".
func GetTokenDenomFromSharesDenom ¶
GetTokenDenomFromSharesDenom returns the token denom from the shares denom. It expects the shares denom to be in the format "{xxxxxx}/{xxxxxx}/{tokenDenom}".
func Intersect ¶
func Intersect[T comparable](a, b []T) []T
Intersect returns the intersection of two slices.
func IsAllGT ¶
IsAllGT returns true if for every denom in coinsB, the denom is present at a greater amount in coins.
func IsAllGTE ¶
IsAllGTE returns false if for any denom in coinsB, the denom is present at a smaller amount in coins; else returns true.
func IsAnyGT ¶
IsAnyGT returns true iff for any denom in coins, the denom is present at a greater amount in coinsB.
e.g. IsAnyGT({2A, 3B}, {A}) = true IsAnyGT({2A, 3B}, {5C}) = false IsAnyGT({}, {5C}) = false IsAnyGT({2A, 3B}, {}) = false
func IsAnyLT ¶
IsAnyLT returns true iff for any denom in coins, the denom is present at a smaller amount in coinsB.
func IsInvalidExRate ¶
IsInvalidExRate returns true if the delegated tokens are zero and the delegators shares are positive.
func IsKeySetEmpty ¶
func IsKeySetEmpty[K any](ctx sdk.Context, collectionMap collections.KeySet[K], ranger collections.Ranger[K]) (bool, error)
IsKeySetEmpty checks if the given key set with the given ranger is empty.
func IsMapEmpty ¶
func IsMapEmpty[K, V any](ctx sdk.Context, collectionMap collections.Map[K, V], ranger collections.Ranger[K]) (bool, error)
IsMapEmpty checks if the given map with the given ranger is empty.
func IssueShares ¶
func IssueShares(amount sdk.Coins, getShareDenom ShareDenomGetter, delegatedTokens sdk.Coins, delegatorsShares sdk.DecCoins) sdk.DecCoins
IssueShares calculates the shares to issue for a delegation of the given amount.
func JSONStringHasKey ¶
JSONStringHasKey parses the provided data as a json object and checks if it contains the provided key.
func Map ¶
func Map[T, U any](slice []T, f func(T) U) []U
Map applies the given function to each element in the slice and returns a new slice with the results.
func MapGetOrDefault ¶
func MapGetOrDefault[K, V any]( ctx sdk.Context, collectionMap collections.Map[K, V], key K, defaultValueProvider func() V, ) (V, error)
MapGetOrDefault gets a value from the map with the given key. If the key is not found within the map, the default value is returned.
func MustParseCoin ¶
func MustParseCoins ¶
func MustParseDec ¶
func MustParseDecCoins ¶
func Remove ¶
func Remove[T comparable](slice []T, value T) (newSlice []T, removed bool)
Remove removes the first instance of value from the provided slice.
func RemoveDuplicates ¶
func RemoveDuplicates[T comparable](slice []T) []T
RemoveDuplicates removes all duplicate elements from the slice.
func SharesFromDecCoins ¶
func SharesFromDecCoins(tokens sdk.DecCoins, getShareDenom ShareDenomGetter, delegatedTokens sdk.Coins, delegatorsShares sdk.DecCoins) (sdk.DecCoins, error)
SharesFromDecCoins returns the shares of a delegation given a bond amount.
func SharesFromTokens ¶
func SharesFromTokens(tokens sdk.Coins, getShareDenom ShareDenomGetter, delegatedTokens sdk.Coins, delegatorsShares sdk.DecCoins) (sdk.DecCoins, error)
SharesFromTokens returns the shares of a delegation given a bond amount.
func SharesFromTokensTruncated ¶
func SharesFromTokensTruncated(tokens sdk.Coins, getShareDenom ShareDenomGetter, delegatedTokens sdk.Coins, delegatorsShares sdk.DecCoins) (sdk.DecCoins, error)
SharesFromTokensTruncated returns the truncated shares of a delegation given a bond amount.
func Uint32ToBigEndian ¶
Uint32ToBigEndian marshals uint32 to a bigendian byte slice so it can be sorted
Types ¶
type ShareDenomGetter ¶
ShareDenomGetter represents a function that returns the shares denom given a token denom.